4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2012, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * lustre/ptlrpc/pack_generic.c
34 * (Un)packing of OST requests
36 * Author: Peter J. Braam <braam@clusterfs.com>
37 * Author: Phil Schwan <phil@clusterfs.com>
38 * Author: Eric Barton <eeb@clusterfs.com>
41 #define DEBUG_SUBSYSTEM S_RPC
43 #include "../../include/linux/libcfs/libcfs.h"
45 #include "../include/obd_support.h"
46 #include "../include/obd_class.h"
47 #include "../include/lustre_net.h"
48 #include "../include/obd_cksum.h"
49 #include "../include/lustre/ll_fiemap.h"
51 #include "ptlrpc_internal.h"
53 static inline u32 lustre_msg_hdr_size_v2(u32 count)
55 return cfs_size_round(offsetof(struct lustre_msg_v2,
59 u32 lustre_msg_hdr_size(__u32 magic, u32 count)
62 case LUSTRE_MSG_MAGIC_V2:
63 return lustre_msg_hdr_size_v2(count);
65 LASSERTF(0, "incorrect message magic: %08x\n", magic);
70 void ptlrpc_buf_set_swabbed(struct ptlrpc_request *req, const int inout,
74 lustre_set_req_swabbed(req, index);
76 lustre_set_rep_swabbed(req, index);
79 int ptlrpc_buf_need_swab(struct ptlrpc_request *req, const int inout,
83 return (ptlrpc_req_need_swab(req) &&
84 !lustre_req_swabbed(req, index));
86 return (ptlrpc_rep_need_swab(req) &&
87 !lustre_rep_swabbed(req, index));
90 /* early reply size */
91 u32 lustre_msg_early_size(void)
96 /* Always reply old ptlrpc_body_v2 to keep interoperability
97 * with the old client (< 2.3) which doesn't have pb_jobid
100 * XXX Remove this whenever we drop interoperability with such
103 __u32 pblen = sizeof(struct ptlrpc_body_v2);
105 size = lustre_msg_size(LUSTRE_MSG_MAGIC_V2, 1, &pblen);
109 EXPORT_SYMBOL(lustre_msg_early_size);
111 u32 lustre_msg_size_v2(int count, __u32 *lengths)
116 size = lustre_msg_hdr_size_v2(count);
117 for (i = 0; i < count; i++)
118 size += cfs_size_round(lengths[i]);
122 EXPORT_SYMBOL(lustre_msg_size_v2);
124 /* This returns the size of the buffer that is required to hold a lustre_msg
125 * with the given sub-buffer lengths.
126 * NOTE: this should only be used for NEW requests, and should always be
127 * in the form of a v2 request. If this is a connection to a v1
128 * target then the first buffer will be stripped because the ptlrpc
129 * data is part of the lustre_msg_v1 header. b=14043
131 u32 lustre_msg_size(__u32 magic, int count, __u32 *lens)
133 __u32 size[] = { sizeof(struct ptlrpc_body) };
141 LASSERT(lens[MSG_PTLRPC_BODY_OFF] >= sizeof(struct ptlrpc_body_v2));
144 case LUSTRE_MSG_MAGIC_V2:
145 return lustre_msg_size_v2(count, lens);
147 LASSERTF(0, "incorrect message magic: %08x\n", magic);
152 /* This is used to determine the size of a buffer that was already packed
153 * and will correctly handle the different message formats.
155 u32 lustre_packed_msg_size(struct lustre_msg *msg)
157 switch (msg->lm_magic) {
158 case LUSTRE_MSG_MAGIC_V2:
159 return lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens);
161 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
166 void lustre_init_msg_v2(struct lustre_msg_v2 *msg, int count, __u32 *lens,
172 msg->lm_bufcount = count;
173 /* XXX: lm_secflvr uninitialized here */
174 msg->lm_magic = LUSTRE_MSG_MAGIC_V2;
176 for (i = 0; i < count; i++)
177 msg->lm_buflens[i] = lens[i];
182 ptr = (char *)msg + lustre_msg_hdr_size_v2(count);
183 for (i = 0; i < count; i++) {
186 LOGL(tmp, lens[i], ptr);
189 EXPORT_SYMBOL(lustre_init_msg_v2);
191 static int lustre_pack_request_v2(struct ptlrpc_request *req,
192 int count, __u32 *lens, char **bufs)
196 reqlen = lustre_msg_size_v2(count, lens);
198 rc = sptlrpc_cli_alloc_reqbuf(req, reqlen);
202 req->rq_reqlen = reqlen;
204 lustre_init_msg_v2(req->rq_reqmsg, count, lens, bufs);
205 lustre_msg_add_version(req->rq_reqmsg, PTLRPC_MSG_VERSION);
209 int lustre_pack_request(struct ptlrpc_request *req, __u32 magic, int count,
210 __u32 *lens, char **bufs)
212 __u32 size[] = { sizeof(struct ptlrpc_body) };
220 LASSERT(lens[MSG_PTLRPC_BODY_OFF] == sizeof(struct ptlrpc_body));
222 /* only use new format, we don't need to be compatible with 1.4 */
223 return lustre_pack_request_v2(req, count, lens, bufs);
227 LIST_HEAD(ptlrpc_rs_debug_lru);
228 spinlock_t ptlrpc_rs_debug_lock;
230 #define PTLRPC_RS_DEBUG_LRU_ADD(rs) \
232 spin_lock(&ptlrpc_rs_debug_lock); \
233 list_add_tail(&(rs)->rs_debug_list, &ptlrpc_rs_debug_lru); \
234 spin_unlock(&ptlrpc_rs_debug_lock); \
237 #define PTLRPC_RS_DEBUG_LRU_DEL(rs) \
239 spin_lock(&ptlrpc_rs_debug_lock); \
240 list_del(&(rs)->rs_debug_list); \
241 spin_unlock(&ptlrpc_rs_debug_lock); \
244 # define PTLRPC_RS_DEBUG_LRU_ADD(rs) do {} while (0)
245 # define PTLRPC_RS_DEBUG_LRU_DEL(rs) do {} while (0)
248 struct ptlrpc_reply_state *
249 lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt)
251 struct ptlrpc_reply_state *rs = NULL;
253 spin_lock(&svcpt->scp_rep_lock);
255 /* See if we have anything in a pool, and wait if nothing */
256 while (list_empty(&svcpt->scp_rep_idle)) {
257 struct l_wait_info lwi;
260 spin_unlock(&svcpt->scp_rep_lock);
261 /* If we cannot get anything for some long time, we better
262 * bail out instead of waiting infinitely
264 lwi = LWI_TIMEOUT(cfs_time_seconds(10), NULL, NULL);
265 rc = l_wait_event(svcpt->scp_rep_waitq,
266 !list_empty(&svcpt->scp_rep_idle), &lwi);
269 spin_lock(&svcpt->scp_rep_lock);
272 rs = list_entry(svcpt->scp_rep_idle.next,
273 struct ptlrpc_reply_state, rs_list);
274 list_del(&rs->rs_list);
276 spin_unlock(&svcpt->scp_rep_lock);
278 memset(rs, 0, svcpt->scp_service->srv_max_reply_size);
279 rs->rs_size = svcpt->scp_service->srv_max_reply_size;
280 rs->rs_svcpt = svcpt;
286 void lustre_put_emerg_rs(struct ptlrpc_reply_state *rs)
288 struct ptlrpc_service_part *svcpt = rs->rs_svcpt;
290 spin_lock(&svcpt->scp_rep_lock);
291 list_add(&rs->rs_list, &svcpt->scp_rep_idle);
292 spin_unlock(&svcpt->scp_rep_lock);
293 wake_up(&svcpt->scp_rep_waitq);
296 int lustre_pack_reply_v2(struct ptlrpc_request *req, int count,
297 __u32 *lens, char **bufs, int flags)
299 struct ptlrpc_reply_state *rs;
302 LASSERT(!req->rq_reply_state);
304 if ((flags & LPRFL_EARLY_REPLY) == 0) {
305 spin_lock(&req->rq_lock);
306 req->rq_packed_final = 1;
307 spin_unlock(&req->rq_lock);
310 msg_len = lustre_msg_size_v2(count, lens);
311 rc = sptlrpc_svc_alloc_rs(req, msg_len);
315 rs = req->rq_reply_state;
316 atomic_set(&rs->rs_refcount, 1); /* 1 ref for rq_reply_state */
317 rs->rs_cb_id.cbid_fn = reply_out_callback;
318 rs->rs_cb_id.cbid_arg = rs;
319 rs->rs_svcpt = req->rq_rqbd->rqbd_svcpt;
320 INIT_LIST_HEAD(&rs->rs_exp_list);
321 INIT_LIST_HEAD(&rs->rs_obd_list);
322 INIT_LIST_HEAD(&rs->rs_list);
323 spin_lock_init(&rs->rs_lock);
325 req->rq_replen = msg_len;
326 req->rq_reply_state = rs;
327 req->rq_repmsg = rs->rs_msg;
329 lustre_init_msg_v2(rs->rs_msg, count, lens, bufs);
330 lustre_msg_add_version(rs->rs_msg, PTLRPC_MSG_VERSION);
332 PTLRPC_RS_DEBUG_LRU_ADD(rs);
336 EXPORT_SYMBOL(lustre_pack_reply_v2);
338 int lustre_pack_reply_flags(struct ptlrpc_request *req, int count, __u32 *lens,
339 char **bufs, int flags)
342 __u32 size[] = { sizeof(struct ptlrpc_body) };
350 LASSERT(lens[MSG_PTLRPC_BODY_OFF] == sizeof(struct ptlrpc_body));
352 switch (req->rq_reqmsg->lm_magic) {
353 case LUSTRE_MSG_MAGIC_V2:
354 rc = lustre_pack_reply_v2(req, count, lens, bufs, flags);
357 LASSERTF(0, "incorrect message magic: %08x\n",
358 req->rq_reqmsg->lm_magic);
362 CERROR("lustre_pack_reply failed: rc=%d size=%d\n", rc,
363 lustre_msg_size(req->rq_reqmsg->lm_magic, count, lens));
367 int lustre_pack_reply(struct ptlrpc_request *req, int count, __u32 *lens,
370 return lustre_pack_reply_flags(req, count, lens, bufs, 0);
372 EXPORT_SYMBOL(lustre_pack_reply);
374 void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, u32 n, u32 min_size)
376 u32 i, offset, buflen, bufcount;
378 bufcount = m->lm_bufcount;
379 if (unlikely(n >= bufcount)) {
380 CDEBUG(D_INFO, "msg %p buffer[%d] not present (count %d)\n",
385 buflen = m->lm_buflens[n];
386 if (unlikely(buflen < min_size)) {
387 CERROR("msg %p buffer[%d] size %d too small (required %d, opc=%d)\n",
388 m, n, buflen, min_size,
389 n == MSG_PTLRPC_BODY_OFF ? -1 : lustre_msg_get_opc(m));
393 offset = lustre_msg_hdr_size_v2(bufcount);
394 for (i = 0; i < n; i++)
395 offset += cfs_size_round(m->lm_buflens[i]);
397 return (char *)m + offset;
400 void *lustre_msg_buf(struct lustre_msg *m, u32 n, u32 min_size)
402 switch (m->lm_magic) {
403 case LUSTRE_MSG_MAGIC_V2:
404 return lustre_msg_buf_v2(m, n, min_size);
406 LASSERTF(0, "incorrect message magic: %08x (msg:%p)\n",
411 EXPORT_SYMBOL(lustre_msg_buf);
413 static int lustre_shrink_msg_v2(struct lustre_msg_v2 *msg, u32 segment,
414 unsigned int newlen, int move_data)
416 char *tail = NULL, *newpos;
420 LASSERT(msg->lm_bufcount > segment);
421 LASSERT(msg->lm_buflens[segment] >= newlen);
423 if (msg->lm_buflens[segment] == newlen)
426 if (move_data && msg->lm_bufcount > segment + 1) {
427 tail = lustre_msg_buf_v2(msg, segment + 1, 0);
428 for (n = segment + 1; n < msg->lm_bufcount; n++)
429 tail_len += cfs_size_round(msg->lm_buflens[n]);
432 msg->lm_buflens[segment] = newlen;
434 if (tail && tail_len) {
435 newpos = lustre_msg_buf_v2(msg, segment + 1, 0);
436 LASSERT(newpos <= tail);
438 memmove(newpos, tail, tail_len);
441 return lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens);
445 * for @msg, shrink @segment to size @newlen. if @move_data is non-zero,
446 * we also move data forward from @segment + 1.
448 * if @newlen == 0, we remove the segment completely, but we still keep the
449 * totally bufcount the same to save possible data moving. this will leave a
450 * unused segment with size 0 at the tail, but that's ok.
452 * return new msg size after shrinking.
455 * + if any buffers higher than @segment has been filled in, must call shrink
456 * with non-zero @move_data.
457 * + caller should NOT keep pointers to msg buffers which higher than @segment
460 int lustre_shrink_msg(struct lustre_msg *msg, int segment,
461 unsigned int newlen, int move_data)
463 switch (msg->lm_magic) {
464 case LUSTRE_MSG_MAGIC_V2:
465 return lustre_shrink_msg_v2(msg, segment, newlen, move_data);
467 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
470 EXPORT_SYMBOL(lustre_shrink_msg);
472 void lustre_free_reply_state(struct ptlrpc_reply_state *rs)
474 PTLRPC_RS_DEBUG_LRU_DEL(rs);
476 LASSERT(atomic_read(&rs->rs_refcount) == 0);
477 LASSERT(!rs->rs_difficult || rs->rs_handled);
478 LASSERT(!rs->rs_on_net);
479 LASSERT(!rs->rs_scheduled);
480 LASSERT(!rs->rs_export);
481 LASSERT(rs->rs_nlocks == 0);
482 LASSERT(list_empty(&rs->rs_exp_list));
483 LASSERT(list_empty(&rs->rs_obd_list));
485 sptlrpc_svc_free_rs(rs);
488 static int lustre_unpack_msg_v2(struct lustre_msg_v2 *m, int len)
490 int swabbed, required_len, i;
492 /* Now we know the sender speaks my language. */
493 required_len = lustre_msg_hdr_size_v2(0);
494 if (len < required_len) {
495 /* can't even look inside the message */
496 CERROR("message length %d too small for lustre_msg\n", len);
500 swabbed = (m->lm_magic == LUSTRE_MSG_MAGIC_V2_SWABBED);
503 __swab32s(&m->lm_magic);
504 __swab32s(&m->lm_bufcount);
505 __swab32s(&m->lm_secflvr);
506 __swab32s(&m->lm_repsize);
507 __swab32s(&m->lm_cksum);
508 __swab32s(&m->lm_flags);
509 CLASSERT(offsetof(typeof(*m), lm_padding_2) != 0);
510 CLASSERT(offsetof(typeof(*m), lm_padding_3) != 0);
513 required_len = lustre_msg_hdr_size_v2(m->lm_bufcount);
514 if (len < required_len) {
515 /* didn't receive all the buffer lengths */
516 CERROR("message length %d too small for %d buflens\n",
517 len, m->lm_bufcount);
521 for (i = 0; i < m->lm_bufcount; i++) {
523 __swab32s(&m->lm_buflens[i]);
524 required_len += cfs_size_round(m->lm_buflens[i]);
527 if (len < required_len) {
528 CERROR("len: %d, required_len %d\n", len, required_len);
529 CERROR("bufcount: %d\n", m->lm_bufcount);
530 for (i = 0; i < m->lm_bufcount; i++)
531 CERROR("buffer %d length %d\n", i, m->lm_buflens[i]);
538 int __lustre_unpack_msg(struct lustre_msg *m, int len)
540 int required_len, rc;
542 /* We can provide a slightly better error log, if we check the
543 * message magic and version first. In the future, struct
544 * lustre_msg may grow, and we'd like to log a version mismatch,
545 * rather than a short message.
548 required_len = offsetof(struct lustre_msg, lm_magic) +
550 if (len < required_len) {
551 /* can't even look inside the message */
552 CERROR("message length %d too small for magic/version check\n",
557 rc = lustre_unpack_msg_v2(m, len);
561 EXPORT_SYMBOL(__lustre_unpack_msg);
563 int ptlrpc_unpack_req_msg(struct ptlrpc_request *req, int len)
567 rc = __lustre_unpack_msg(req->rq_reqmsg, len);
569 lustre_set_req_swabbed(req, MSG_PTLRPC_HEADER_OFF);
575 int ptlrpc_unpack_rep_msg(struct ptlrpc_request *req, int len)
579 rc = __lustre_unpack_msg(req->rq_repmsg, len);
581 lustre_set_rep_swabbed(req, MSG_PTLRPC_HEADER_OFF);
587 static inline int lustre_unpack_ptlrpc_body_v2(struct ptlrpc_request *req,
588 const int inout, int offset)
590 struct ptlrpc_body *pb;
591 struct lustre_msg_v2 *m = inout ? req->rq_reqmsg : req->rq_repmsg;
593 pb = lustre_msg_buf_v2(m, offset, sizeof(struct ptlrpc_body_v2));
595 CERROR("error unpacking ptlrpc body\n");
598 if (ptlrpc_buf_need_swab(req, inout, offset)) {
599 lustre_swab_ptlrpc_body(pb);
600 ptlrpc_buf_set_swabbed(req, inout, offset);
603 if ((pb->pb_version & ~LUSTRE_VERSION_MASK) != PTLRPC_MSG_VERSION) {
604 CERROR("wrong lustre_msg version %08x\n", pb->pb_version);
609 pb->pb_status = ptlrpc_status_ntoh(pb->pb_status);
614 int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset)
616 switch (req->rq_reqmsg->lm_magic) {
617 case LUSTRE_MSG_MAGIC_V2:
618 return lustre_unpack_ptlrpc_body_v2(req, 1, offset);
620 CERROR("bad lustre msg magic: %08x\n",
621 req->rq_reqmsg->lm_magic);
626 int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset)
628 switch (req->rq_repmsg->lm_magic) {
629 case LUSTRE_MSG_MAGIC_V2:
630 return lustre_unpack_ptlrpc_body_v2(req, 0, offset);
632 CERROR("bad lustre msg magic: %08x\n",
633 req->rq_repmsg->lm_magic);
638 static inline u32 lustre_msg_buflen_v2(struct lustre_msg_v2 *m, u32 n)
640 if (n >= m->lm_bufcount)
643 return m->lm_buflens[n];
647 * lustre_msg_buflen - return the length of buffer \a n in message \a m
648 * \param m lustre_msg (request or reply) to look at
649 * \param n message index (base 0)
651 * returns zero for non-existent message indices
653 u32 lustre_msg_buflen(struct lustre_msg *m, u32 n)
655 switch (m->lm_magic) {
656 case LUSTRE_MSG_MAGIC_V2:
657 return lustre_msg_buflen_v2(m, n);
659 CERROR("incorrect message magic: %08x\n", m->lm_magic);
663 EXPORT_SYMBOL(lustre_msg_buflen);
665 /* NB return the bufcount for lustre_msg_v2 format, so if message is packed
666 * in V1 format, the result is one bigger. (add struct ptlrpc_body).
668 u32 lustre_msg_bufcount(struct lustre_msg *m)
670 switch (m->lm_magic) {
671 case LUSTRE_MSG_MAGIC_V2:
672 return m->lm_bufcount;
674 CERROR("incorrect message magic: %08x\n", m->lm_magic);
679 char *lustre_msg_string(struct lustre_msg *m, u32 index, u32 max_len)
681 /* max_len == 0 means the string should fill the buffer */
685 switch (m->lm_magic) {
686 case LUSTRE_MSG_MAGIC_V2:
687 str = lustre_msg_buf_v2(m, index, 0);
688 blen = lustre_msg_buflen_v2(m, index);
691 LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic);
695 CERROR("can't unpack string in msg %p buffer[%d]\n", m, index);
699 slen = strnlen(str, blen);
701 if (slen == blen) { /* not NULL terminated */
702 CERROR("can't unpack non-NULL terminated string in msg %p buffer[%d] len %d\n",
708 if (slen != blen - 1) {
709 CERROR("can't unpack short string in msg %p buffer[%d] len %d: strlen %d\n",
710 m, index, blen, slen);
713 } else if (slen > max_len) {
714 CERROR("can't unpack oversized string in msg %p buffer[%d] len %d strlen %d: max %d expected\n",
715 m, index, blen, slen, max_len);
722 /* Wrap up the normal fixed length cases */
723 static inline void *__lustre_swab_buf(struct lustre_msg *msg, u32 index,
724 u32 min_size, void *swabber)
728 switch (msg->lm_magic) {
729 case LUSTRE_MSG_MAGIC_V2:
730 ptr = lustre_msg_buf_v2(msg, index, min_size);
733 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
737 ((void (*)(void *))swabber)(ptr);
742 static inline struct ptlrpc_body *lustre_msg_ptlrpc_body(struct lustre_msg *msg)
744 return lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF,
745 sizeof(struct ptlrpc_body_v2));
748 __u32 lustre_msghdr_get_flags(struct lustre_msg *msg)
750 switch (msg->lm_magic) {
751 case LUSTRE_MSG_MAGIC_V2:
752 /* already in host endian */
753 return msg->lm_flags;
755 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
759 EXPORT_SYMBOL(lustre_msghdr_get_flags);
761 void lustre_msghdr_set_flags(struct lustre_msg *msg, __u32 flags)
763 switch (msg->lm_magic) {
764 case LUSTRE_MSG_MAGIC_V2:
765 msg->lm_flags = flags;
768 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
772 __u32 lustre_msg_get_flags(struct lustre_msg *msg)
774 switch (msg->lm_magic) {
775 case LUSTRE_MSG_MAGIC_V2: {
776 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
781 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
785 /* flags might be printed in debug code while message
791 EXPORT_SYMBOL(lustre_msg_get_flags);
793 void lustre_msg_add_flags(struct lustre_msg *msg, u32 flags)
795 switch (msg->lm_magic) {
796 case LUSTRE_MSG_MAGIC_V2: {
797 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
799 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
800 pb->pb_flags |= flags;
804 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
807 EXPORT_SYMBOL(lustre_msg_add_flags);
809 void lustre_msg_set_flags(struct lustre_msg *msg, u32 flags)
811 switch (msg->lm_magic) {
812 case LUSTRE_MSG_MAGIC_V2: {
813 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
815 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
816 pb->pb_flags = flags;
820 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
824 void lustre_msg_clear_flags(struct lustre_msg *msg, u32 flags)
826 switch (msg->lm_magic) {
827 case LUSTRE_MSG_MAGIC_V2: {
828 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
830 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
831 pb->pb_flags &= ~(flags & MSG_GEN_FLAG_MASK);
835 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
838 EXPORT_SYMBOL(lustre_msg_clear_flags);
840 __u32 lustre_msg_get_op_flags(struct lustre_msg *msg)
842 switch (msg->lm_magic) {
843 case LUSTRE_MSG_MAGIC_V2: {
844 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
847 return pb->pb_op_flags;
849 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
857 void lustre_msg_add_op_flags(struct lustre_msg *msg, u32 flags)
859 switch (msg->lm_magic) {
860 case LUSTRE_MSG_MAGIC_V2: {
861 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
863 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
864 pb->pb_op_flags |= flags;
868 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
871 EXPORT_SYMBOL(lustre_msg_add_op_flags);
873 struct lustre_handle *lustre_msg_get_handle(struct lustre_msg *msg)
875 switch (msg->lm_magic) {
876 case LUSTRE_MSG_MAGIC_V2: {
877 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
880 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
883 return &pb->pb_handle;
886 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
891 __u32 lustre_msg_get_type(struct lustre_msg *msg)
893 switch (msg->lm_magic) {
894 case LUSTRE_MSG_MAGIC_V2: {
895 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
898 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
899 return PTL_RPC_MSG_ERR;
904 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
905 return PTL_RPC_MSG_ERR;
908 EXPORT_SYMBOL(lustre_msg_get_type);
910 void lustre_msg_add_version(struct lustre_msg *msg, u32 version)
912 switch (msg->lm_magic) {
913 case LUSTRE_MSG_MAGIC_V2: {
914 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
916 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
917 pb->pb_version |= version;
921 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
925 __u32 lustre_msg_get_opc(struct lustre_msg *msg)
927 switch (msg->lm_magic) {
928 case LUSTRE_MSG_MAGIC_V2: {
929 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
932 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
938 CERROR("incorrect message magic: %08x (msg:%p)\n",
943 EXPORT_SYMBOL(lustre_msg_get_opc);
945 __u64 lustre_msg_get_last_committed(struct lustre_msg *msg)
947 switch (msg->lm_magic) {
948 case LUSTRE_MSG_MAGIC_V2: {
949 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
952 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
955 return pb->pb_last_committed;
958 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
962 EXPORT_SYMBOL(lustre_msg_get_last_committed);
964 __u64 *lustre_msg_get_versions(struct lustre_msg *msg)
966 switch (msg->lm_magic) {
967 case LUSTRE_MSG_MAGIC_V2: {
968 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
971 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
974 return pb->pb_pre_versions;
977 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
981 EXPORT_SYMBOL(lustre_msg_get_versions);
983 __u64 lustre_msg_get_transno(struct lustre_msg *msg)
985 switch (msg->lm_magic) {
986 case LUSTRE_MSG_MAGIC_V2: {
987 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
990 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
993 return pb->pb_transno;
996 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1000 EXPORT_SYMBOL(lustre_msg_get_transno);
1002 int lustre_msg_get_status(struct lustre_msg *msg)
1004 switch (msg->lm_magic) {
1005 case LUSTRE_MSG_MAGIC_V2: {
1006 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1009 return pb->pb_status;
1011 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1015 /* status might be printed in debug code while message
1021 EXPORT_SYMBOL(lustre_msg_get_status);
1023 __u64 lustre_msg_get_slv(struct lustre_msg *msg)
1025 switch (msg->lm_magic) {
1026 case LUSTRE_MSG_MAGIC_V2: {
1027 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1030 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1036 CERROR("invalid msg magic %08x\n", msg->lm_magic);
1041 void lustre_msg_set_slv(struct lustre_msg *msg, __u64 slv)
1043 switch (msg->lm_magic) {
1044 case LUSTRE_MSG_MAGIC_V2: {
1045 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1048 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1055 CERROR("invalid msg magic %x\n", msg->lm_magic);
1060 __u32 lustre_msg_get_limit(struct lustre_msg *msg)
1062 switch (msg->lm_magic) {
1063 case LUSTRE_MSG_MAGIC_V2: {
1064 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1067 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1070 return pb->pb_limit;
1073 CERROR("invalid msg magic %x\n", msg->lm_magic);
1078 void lustre_msg_set_limit(struct lustre_msg *msg, __u64 limit)
1080 switch (msg->lm_magic) {
1081 case LUSTRE_MSG_MAGIC_V2: {
1082 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1085 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1088 pb->pb_limit = limit;
1092 CERROR("invalid msg magic %08x\n", msg->lm_magic);
1097 __u32 lustre_msg_get_conn_cnt(struct lustre_msg *msg)
1099 switch (msg->lm_magic) {
1100 case LUSTRE_MSG_MAGIC_V2: {
1101 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1104 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1107 return pb->pb_conn_cnt;
1110 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1114 EXPORT_SYMBOL(lustre_msg_get_conn_cnt);
1116 __u32 lustre_msg_get_magic(struct lustre_msg *msg)
1118 switch (msg->lm_magic) {
1119 case LUSTRE_MSG_MAGIC_V2:
1120 return msg->lm_magic;
1122 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1127 __u32 lustre_msg_get_timeout(struct lustre_msg *msg)
1129 switch (msg->lm_magic) {
1130 case LUSTRE_MSG_MAGIC_V2: {
1131 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1134 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1137 return pb->pb_timeout;
1140 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1145 __u32 lustre_msg_get_service_time(struct lustre_msg *msg)
1147 switch (msg->lm_magic) {
1148 case LUSTRE_MSG_MAGIC_V2: {
1149 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1152 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1155 return pb->pb_service_time;
1158 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1163 __u32 lustre_msg_get_cksum(struct lustre_msg *msg)
1165 switch (msg->lm_magic) {
1166 case LUSTRE_MSG_MAGIC_V2:
1167 return msg->lm_cksum;
1169 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1174 __u32 lustre_msg_calc_cksum(struct lustre_msg *msg)
1176 switch (msg->lm_magic) {
1177 case LUSTRE_MSG_MAGIC_V2: {
1178 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1180 unsigned int hsize = 4;
1182 cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32, (unsigned char *)pb,
1183 lustre_msg_buflen(msg,
1184 MSG_PTLRPC_BODY_OFF),
1185 NULL, 0, (unsigned char *)&crc, &hsize);
1189 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1194 void lustre_msg_set_handle(struct lustre_msg *msg, struct lustre_handle *handle)
1196 switch (msg->lm_magic) {
1197 case LUSTRE_MSG_MAGIC_V2: {
1198 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1200 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1201 pb->pb_handle = *handle;
1205 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1209 void lustre_msg_set_type(struct lustre_msg *msg, __u32 type)
1211 switch (msg->lm_magic) {
1212 case LUSTRE_MSG_MAGIC_V2: {
1213 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1215 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1220 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1224 void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc)
1226 switch (msg->lm_magic) {
1227 case LUSTRE_MSG_MAGIC_V2: {
1228 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1230 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1235 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1239 void lustre_msg_set_versions(struct lustre_msg *msg, __u64 *versions)
1241 switch (msg->lm_magic) {
1242 case LUSTRE_MSG_MAGIC_V2: {
1243 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1245 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1246 pb->pb_pre_versions[0] = versions[0];
1247 pb->pb_pre_versions[1] = versions[1];
1248 pb->pb_pre_versions[2] = versions[2];
1249 pb->pb_pre_versions[3] = versions[3];
1253 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1256 EXPORT_SYMBOL(lustre_msg_set_versions);
1258 void lustre_msg_set_transno(struct lustre_msg *msg, __u64 transno)
1260 switch (msg->lm_magic) {
1261 case LUSTRE_MSG_MAGIC_V2: {
1262 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1264 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1265 pb->pb_transno = transno;
1269 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1272 EXPORT_SYMBOL(lustre_msg_set_transno);
1274 void lustre_msg_set_status(struct lustre_msg *msg, __u32 status)
1276 switch (msg->lm_magic) {
1277 case LUSTRE_MSG_MAGIC_V2: {
1278 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1280 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1281 pb->pb_status = status;
1285 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1288 EXPORT_SYMBOL(lustre_msg_set_status);
1290 void lustre_msg_set_conn_cnt(struct lustre_msg *msg, __u32 conn_cnt)
1292 switch (msg->lm_magic) {
1293 case LUSTRE_MSG_MAGIC_V2: {
1294 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1296 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1297 pb->pb_conn_cnt = conn_cnt;
1301 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1305 void lustre_msg_set_timeout(struct lustre_msg *msg, __u32 timeout)
1307 switch (msg->lm_magic) {
1308 case LUSTRE_MSG_MAGIC_V2: {
1309 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1311 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1312 pb->pb_timeout = timeout;
1316 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1320 void lustre_msg_set_service_time(struct lustre_msg *msg, __u32 service_time)
1322 switch (msg->lm_magic) {
1323 case LUSTRE_MSG_MAGIC_V2: {
1324 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1326 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1327 pb->pb_service_time = service_time;
1331 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1335 void lustre_msg_set_jobid(struct lustre_msg *msg, char *jobid)
1337 switch (msg->lm_magic) {
1338 case LUSTRE_MSG_MAGIC_V2: {
1339 __u32 opc = lustre_msg_get_opc(msg);
1340 struct ptlrpc_body *pb;
1342 /* Don't set jobid for ldlm ast RPCs, they've been shrunk.
1343 * See the comment in ptlrpc_request_pack().
1345 if (!opc || opc == LDLM_BL_CALLBACK ||
1346 opc == LDLM_CP_CALLBACK || opc == LDLM_GL_CALLBACK)
1349 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF,
1350 sizeof(struct ptlrpc_body));
1351 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1354 memcpy(pb->pb_jobid, jobid, LUSTRE_JOBID_SIZE);
1355 else if (pb->pb_jobid[0] == '\0')
1356 lustre_get_jobid(pb->pb_jobid);
1360 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1363 EXPORT_SYMBOL(lustre_msg_set_jobid);
1365 void lustre_msg_set_cksum(struct lustre_msg *msg, __u32 cksum)
1367 switch (msg->lm_magic) {
1368 case LUSTRE_MSG_MAGIC_V2:
1369 msg->lm_cksum = cksum;
1372 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1376 void ptlrpc_request_set_replen(struct ptlrpc_request *req)
1378 int count = req_capsule_filled_sizes(&req->rq_pill, RCL_SERVER);
1380 req->rq_replen = lustre_msg_size(req->rq_reqmsg->lm_magic, count,
1381 req->rq_pill.rc_area[RCL_SERVER]);
1382 if (req->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V2)
1383 req->rq_reqmsg->lm_repsize = req->rq_replen;
1385 EXPORT_SYMBOL(ptlrpc_request_set_replen);
1388 * Send a remote set_info_async.
1390 * This may go from client to server or server to client.
1392 int do_set_info_async(struct obd_import *imp,
1393 int opcode, int version,
1394 u32 keylen, void *key,
1395 u32 vallen, void *val,
1396 struct ptlrpc_request_set *set)
1398 struct ptlrpc_request *req;
1402 req = ptlrpc_request_alloc(imp, &RQF_OBD_SET_INFO);
1406 req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY,
1407 RCL_CLIENT, keylen);
1408 req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_VAL,
1409 RCL_CLIENT, vallen);
1410 rc = ptlrpc_request_pack(req, version, opcode);
1412 ptlrpc_request_free(req);
1416 tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY);
1417 memcpy(tmp, key, keylen);
1418 tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_VAL);
1419 memcpy(tmp, val, vallen);
1421 ptlrpc_request_set_replen(req);
1424 ptlrpc_set_add_req(set, req);
1425 ptlrpc_check_set(NULL, set);
1427 rc = ptlrpc_queue_wait(req);
1428 ptlrpc_req_finished(req);
1433 EXPORT_SYMBOL(do_set_info_async);
1435 /* byte flipping routines for all wire types declared in
1436 * lustre_idl.h implemented here.
1438 void lustre_swab_ptlrpc_body(struct ptlrpc_body *b)
1440 __swab32s(&b->pb_type);
1441 __swab32s(&b->pb_version);
1442 __swab32s(&b->pb_opc);
1443 __swab32s(&b->pb_status);
1444 __swab64s(&b->pb_last_xid);
1445 __swab64s(&b->pb_last_seen);
1446 __swab64s(&b->pb_last_committed);
1447 __swab64s(&b->pb_transno);
1448 __swab32s(&b->pb_flags);
1449 __swab32s(&b->pb_op_flags);
1450 __swab32s(&b->pb_conn_cnt);
1451 __swab32s(&b->pb_timeout);
1452 __swab32s(&b->pb_service_time);
1453 __swab32s(&b->pb_limit);
1454 __swab64s(&b->pb_slv);
1455 __swab64s(&b->pb_pre_versions[0]);
1456 __swab64s(&b->pb_pre_versions[1]);
1457 __swab64s(&b->pb_pre_versions[2]);
1458 __swab64s(&b->pb_pre_versions[3]);
1459 CLASSERT(offsetof(typeof(*b), pb_padding) != 0);
1460 /* While we need to maintain compatibility between
1461 * clients and servers without ptlrpc_body_v2 (< 2.3)
1462 * do not swab any fields beyond pb_jobid, as we are
1463 * using this swab function for both ptlrpc_body
1464 * and ptlrpc_body_v2.
1466 CLASSERT(offsetof(typeof(*b), pb_jobid) != 0);
1469 void lustre_swab_connect(struct obd_connect_data *ocd)
1471 __swab64s(&ocd->ocd_connect_flags);
1472 __swab32s(&ocd->ocd_version);
1473 __swab32s(&ocd->ocd_grant);
1474 __swab64s(&ocd->ocd_ibits_known);
1475 __swab32s(&ocd->ocd_index);
1476 __swab32s(&ocd->ocd_brw_size);
1477 /* ocd_blocksize and ocd_inodespace don't need to be swabbed because
1478 * they are 8-byte values
1480 __swab16s(&ocd->ocd_grant_extent);
1481 __swab32s(&ocd->ocd_unused);
1482 __swab64s(&ocd->ocd_transno);
1483 __swab32s(&ocd->ocd_group);
1484 __swab32s(&ocd->ocd_cksum_types);
1485 __swab32s(&ocd->ocd_instance);
1486 /* Fields after ocd_cksum_types are only accessible by the receiver
1487 * if the corresponding flag in ocd_connect_flags is set. Accessing
1488 * any field after ocd_maxbytes on the receiver without a valid flag
1489 * may result in out-of-bound memory access and kernel oops.
1491 if (ocd->ocd_connect_flags & OBD_CONNECT_MAX_EASIZE)
1492 __swab32s(&ocd->ocd_max_easize);
1493 if (ocd->ocd_connect_flags & OBD_CONNECT_MAXBYTES)
1494 __swab64s(&ocd->ocd_maxbytes);
1495 CLASSERT(offsetof(typeof(*ocd), padding1) != 0);
1496 CLASSERT(offsetof(typeof(*ocd), padding2) != 0);
1497 CLASSERT(offsetof(typeof(*ocd), padding3) != 0);
1498 CLASSERT(offsetof(typeof(*ocd), padding4) != 0);
1499 CLASSERT(offsetof(typeof(*ocd), padding5) != 0);
1500 CLASSERT(offsetof(typeof(*ocd), padding6) != 0);
1501 CLASSERT(offsetof(typeof(*ocd), padding7) != 0);
1502 CLASSERT(offsetof(typeof(*ocd), padding8) != 0);
1503 CLASSERT(offsetof(typeof(*ocd), padding9) != 0);
1504 CLASSERT(offsetof(typeof(*ocd), paddingA) != 0);
1505 CLASSERT(offsetof(typeof(*ocd), paddingB) != 0);
1506 CLASSERT(offsetof(typeof(*ocd), paddingC) != 0);
1507 CLASSERT(offsetof(typeof(*ocd), paddingD) != 0);
1508 CLASSERT(offsetof(typeof(*ocd), paddingE) != 0);
1509 CLASSERT(offsetof(typeof(*ocd), paddingF) != 0);
1512 static void lustre_swab_obdo(struct obdo *o)
1514 __swab64s(&o->o_valid);
1515 lustre_swab_ost_id(&o->o_oi);
1516 __swab64s(&o->o_parent_seq);
1517 __swab64s(&o->o_size);
1518 __swab64s(&o->o_mtime);
1519 __swab64s(&o->o_atime);
1520 __swab64s(&o->o_ctime);
1521 __swab64s(&o->o_blocks);
1522 __swab64s(&o->o_grant);
1523 __swab32s(&o->o_blksize);
1524 __swab32s(&o->o_mode);
1525 __swab32s(&o->o_uid);
1526 __swab32s(&o->o_gid);
1527 __swab32s(&o->o_flags);
1528 __swab32s(&o->o_nlink);
1529 __swab32s(&o->o_parent_oid);
1530 __swab32s(&o->o_misc);
1531 __swab64s(&o->o_ioepoch);
1532 __swab32s(&o->o_stripe_idx);
1533 __swab32s(&o->o_parent_ver);
1534 /* o_handle is opaque */
1535 /* o_lcookie is swabbed elsewhere */
1536 __swab32s(&o->o_uid_h);
1537 __swab32s(&o->o_gid_h);
1538 __swab64s(&o->o_data_version);
1539 CLASSERT(offsetof(typeof(*o), o_padding_4) != 0);
1540 CLASSERT(offsetof(typeof(*o), o_padding_5) != 0);
1541 CLASSERT(offsetof(typeof(*o), o_padding_6) != 0);
1544 void lustre_swab_obd_statfs(struct obd_statfs *os)
1546 __swab64s(&os->os_type);
1547 __swab64s(&os->os_blocks);
1548 __swab64s(&os->os_bfree);
1549 __swab64s(&os->os_bavail);
1550 __swab64s(&os->os_files);
1551 __swab64s(&os->os_ffree);
1552 /* no need to swab os_fsid */
1553 __swab32s(&os->os_bsize);
1554 __swab32s(&os->os_namelen);
1555 __swab64s(&os->os_maxbytes);
1556 __swab32s(&os->os_state);
1557 CLASSERT(offsetof(typeof(*os), os_fprecreated) != 0);
1558 CLASSERT(offsetof(typeof(*os), os_spare2) != 0);
1559 CLASSERT(offsetof(typeof(*os), os_spare3) != 0);
1560 CLASSERT(offsetof(typeof(*os), os_spare4) != 0);
1561 CLASSERT(offsetof(typeof(*os), os_spare5) != 0);
1562 CLASSERT(offsetof(typeof(*os), os_spare6) != 0);
1563 CLASSERT(offsetof(typeof(*os), os_spare7) != 0);
1564 CLASSERT(offsetof(typeof(*os), os_spare8) != 0);
1565 CLASSERT(offsetof(typeof(*os), os_spare9) != 0);
1568 void lustre_swab_obd_ioobj(struct obd_ioobj *ioo)
1570 lustre_swab_ost_id(&ioo->ioo_oid);
1571 __swab32s(&ioo->ioo_max_brw);
1572 __swab32s(&ioo->ioo_bufcnt);
1575 void lustre_swab_niobuf_remote(struct niobuf_remote *nbr)
1577 __swab64s(&nbr->rnb_offset);
1578 __swab32s(&nbr->rnb_len);
1579 __swab32s(&nbr->rnb_flags);
1582 void lustre_swab_ost_body(struct ost_body *b)
1584 lustre_swab_obdo(&b->oa);
1587 void lustre_swab_ost_last_id(u64 *id)
1592 void lustre_swab_generic_32s(__u32 *val)
1597 void lustre_swab_gl_desc(union ldlm_gl_desc *desc)
1599 lustre_swab_lu_fid(&desc->lquota_desc.gl_id.qid_fid);
1600 __swab64s(&desc->lquota_desc.gl_flags);
1601 __swab64s(&desc->lquota_desc.gl_ver);
1602 __swab64s(&desc->lquota_desc.gl_hardlimit);
1603 __swab64s(&desc->lquota_desc.gl_softlimit);
1604 __swab64s(&desc->lquota_desc.gl_time);
1605 CLASSERT(offsetof(typeof(desc->lquota_desc), gl_pad2) != 0);
1608 void lustre_swab_ost_lvb_v1(struct ost_lvb_v1 *lvb)
1610 __swab64s(&lvb->lvb_size);
1611 __swab64s(&lvb->lvb_mtime);
1612 __swab64s(&lvb->lvb_atime);
1613 __swab64s(&lvb->lvb_ctime);
1614 __swab64s(&lvb->lvb_blocks);
1616 EXPORT_SYMBOL(lustre_swab_ost_lvb_v1);
1618 void lustre_swab_ost_lvb(struct ost_lvb *lvb)
1620 __swab64s(&lvb->lvb_size);
1621 __swab64s(&lvb->lvb_mtime);
1622 __swab64s(&lvb->lvb_atime);
1623 __swab64s(&lvb->lvb_ctime);
1624 __swab64s(&lvb->lvb_blocks);
1625 __swab32s(&lvb->lvb_mtime_ns);
1626 __swab32s(&lvb->lvb_atime_ns);
1627 __swab32s(&lvb->lvb_ctime_ns);
1628 __swab32s(&lvb->lvb_padding);
1630 EXPORT_SYMBOL(lustre_swab_ost_lvb);
1632 void lustre_swab_lquota_lvb(struct lquota_lvb *lvb)
1634 __swab64s(&lvb->lvb_flags);
1635 __swab64s(&lvb->lvb_id_may_rel);
1636 __swab64s(&lvb->lvb_id_rel);
1637 __swab64s(&lvb->lvb_id_qunit);
1638 __swab64s(&lvb->lvb_pad1);
1640 EXPORT_SYMBOL(lustre_swab_lquota_lvb);
1642 void lustre_swab_mdt_body(struct mdt_body *b)
1644 lustre_swab_lu_fid(&b->mbo_fid1);
1645 lustre_swab_lu_fid(&b->mbo_fid2);
1646 /* handle is opaque */
1647 __swab64s(&b->mbo_valid);
1648 __swab64s(&b->mbo_size);
1649 __swab64s(&b->mbo_mtime);
1650 __swab64s(&b->mbo_atime);
1651 __swab64s(&b->mbo_ctime);
1652 __swab64s(&b->mbo_blocks);
1653 __swab64s(&b->mbo_ioepoch);
1654 __swab64s(&b->mbo_t_state);
1655 __swab32s(&b->mbo_fsuid);
1656 __swab32s(&b->mbo_fsgid);
1657 __swab32s(&b->mbo_capability);
1658 __swab32s(&b->mbo_mode);
1659 __swab32s(&b->mbo_uid);
1660 __swab32s(&b->mbo_gid);
1661 __swab32s(&b->mbo_flags);
1662 __swab32s(&b->mbo_rdev);
1663 __swab32s(&b->mbo_nlink);
1664 CLASSERT(offsetof(typeof(*b), mbo_unused2) != 0);
1665 __swab32s(&b->mbo_suppgid);
1666 __swab32s(&b->mbo_eadatasize);
1667 __swab32s(&b->mbo_aclsize);
1668 __swab32s(&b->mbo_max_mdsize);
1669 __swab32s(&b->mbo_max_cookiesize);
1670 __swab32s(&b->mbo_uid_h);
1671 __swab32s(&b->mbo_gid_h);
1672 CLASSERT(offsetof(typeof(*b), mbo_padding_5) != 0);
1675 void lustre_swab_mdt_ioepoch(struct mdt_ioepoch *b)
1677 /* handle is opaque */
1678 __swab64s(&b->ioepoch);
1679 __swab32s(&b->flags);
1680 CLASSERT(offsetof(typeof(*b), padding) != 0);
1683 void lustre_swab_mgs_target_info(struct mgs_target_info *mti)
1687 __swab32s(&mti->mti_lustre_ver);
1688 __swab32s(&mti->mti_stripe_index);
1689 __swab32s(&mti->mti_config_ver);
1690 __swab32s(&mti->mti_flags);
1691 __swab32s(&mti->mti_instance);
1692 __swab32s(&mti->mti_nid_count);
1693 CLASSERT(sizeof(lnet_nid_t) == sizeof(__u64));
1694 for (i = 0; i < MTI_NIDS_MAX; i++)
1695 __swab64s(&mti->mti_nids[i]);
1698 void lustre_swab_mgs_nidtbl_entry(struct mgs_nidtbl_entry *entry)
1702 __swab64s(&entry->mne_version);
1703 __swab32s(&entry->mne_instance);
1704 __swab32s(&entry->mne_index);
1705 __swab32s(&entry->mne_length);
1707 /* mne_nid_(count|type) must be one byte size because we're gonna
1708 * access it w/o swapping. */
1709 CLASSERT(sizeof(entry->mne_nid_count) == sizeof(__u8));
1710 CLASSERT(sizeof(entry->mne_nid_type) == sizeof(__u8));
1712 /* remove this assertion if ipv6 is supported. */
1713 LASSERT(entry->mne_nid_type == 0);
1714 for (i = 0; i < entry->mne_nid_count; i++) {
1715 CLASSERT(sizeof(lnet_nid_t) == sizeof(__u64));
1716 __swab64s(&entry->u.nids[i]);
1719 EXPORT_SYMBOL(lustre_swab_mgs_nidtbl_entry);
1721 void lustre_swab_mgs_config_body(struct mgs_config_body *body)
1723 __swab64s(&body->mcb_offset);
1724 __swab32s(&body->mcb_units);
1725 __swab16s(&body->mcb_type);
1728 void lustre_swab_mgs_config_res(struct mgs_config_res *body)
1730 __swab64s(&body->mcr_offset);
1731 __swab64s(&body->mcr_size);
1734 static void lustre_swab_obd_dqinfo(struct obd_dqinfo *i)
1736 __swab64s(&i->dqi_bgrace);
1737 __swab64s(&i->dqi_igrace);
1738 __swab32s(&i->dqi_flags);
1739 __swab32s(&i->dqi_valid);
1742 static void lustre_swab_obd_dqblk(struct obd_dqblk *b)
1744 __swab64s(&b->dqb_ihardlimit);
1745 __swab64s(&b->dqb_isoftlimit);
1746 __swab64s(&b->dqb_curinodes);
1747 __swab64s(&b->dqb_bhardlimit);
1748 __swab64s(&b->dqb_bsoftlimit);
1749 __swab64s(&b->dqb_curspace);
1750 __swab64s(&b->dqb_btime);
1751 __swab64s(&b->dqb_itime);
1752 __swab32s(&b->dqb_valid);
1753 CLASSERT(offsetof(typeof(*b), dqb_padding) != 0);
1756 void lustre_swab_obd_quotactl(struct obd_quotactl *q)
1758 __swab32s(&q->qc_cmd);
1759 __swab32s(&q->qc_type);
1760 __swab32s(&q->qc_id);
1761 __swab32s(&q->qc_stat);
1762 lustre_swab_obd_dqinfo(&q->qc_dqinfo);
1763 lustre_swab_obd_dqblk(&q->qc_dqblk);
1766 void lustre_swab_fid2path(struct getinfo_fid2path *gf)
1768 lustre_swab_lu_fid(&gf->gf_fid);
1769 __swab64s(&gf->gf_recno);
1770 __swab32s(&gf->gf_linkno);
1771 __swab32s(&gf->gf_pathlen);
1773 EXPORT_SYMBOL(lustre_swab_fid2path);
1775 static void lustre_swab_fiemap_extent(struct ll_fiemap_extent *fm_extent)
1777 __swab64s(&fm_extent->fe_logical);
1778 __swab64s(&fm_extent->fe_physical);
1779 __swab64s(&fm_extent->fe_length);
1780 __swab32s(&fm_extent->fe_flags);
1781 __swab32s(&fm_extent->fe_device);
1784 void lustre_swab_fiemap(struct ll_user_fiemap *fiemap)
1788 __swab64s(&fiemap->fm_start);
1789 __swab64s(&fiemap->fm_length);
1790 __swab32s(&fiemap->fm_flags);
1791 __swab32s(&fiemap->fm_mapped_extents);
1792 __swab32s(&fiemap->fm_extent_count);
1793 __swab32s(&fiemap->fm_reserved);
1795 for (i = 0; i < fiemap->fm_mapped_extents; i++)
1796 lustre_swab_fiemap_extent(&fiemap->fm_extents[i]);
1799 void lustre_swab_mdt_rec_reint (struct mdt_rec_reint *rr)
1801 __swab32s(&rr->rr_opcode);
1802 __swab32s(&rr->rr_cap);
1803 __swab32s(&rr->rr_fsuid);
1804 /* rr_fsuid_h is unused */
1805 __swab32s(&rr->rr_fsgid);
1806 /* rr_fsgid_h is unused */
1807 __swab32s(&rr->rr_suppgid1);
1808 /* rr_suppgid1_h is unused */
1809 __swab32s(&rr->rr_suppgid2);
1810 /* rr_suppgid2_h is unused */
1811 lustre_swab_lu_fid(&rr->rr_fid1);
1812 lustre_swab_lu_fid(&rr->rr_fid2);
1813 __swab64s(&rr->rr_mtime);
1814 __swab64s(&rr->rr_atime);
1815 __swab64s(&rr->rr_ctime);
1816 __swab64s(&rr->rr_size);
1817 __swab64s(&rr->rr_blocks);
1818 __swab32s(&rr->rr_bias);
1819 __swab32s(&rr->rr_mode);
1820 __swab32s(&rr->rr_flags);
1821 __swab32s(&rr->rr_flags_h);
1822 __swab32s(&rr->rr_umask);
1824 CLASSERT(offsetof(typeof(*rr), rr_padding_4) != 0);
1827 void lustre_swab_lov_desc(struct lov_desc *ld)
1829 __swab32s(&ld->ld_tgt_count);
1830 __swab32s(&ld->ld_active_tgt_count);
1831 __swab32s(&ld->ld_default_stripe_count);
1832 __swab32s(&ld->ld_pattern);
1833 __swab64s(&ld->ld_default_stripe_size);
1834 __swab64s(&ld->ld_default_stripe_offset);
1835 __swab32s(&ld->ld_qos_maxage);
1836 /* uuid endian insensitive */
1838 EXPORT_SYMBOL(lustre_swab_lov_desc);
1840 /* This structure is always in little-endian */
1841 static void lustre_swab_lmv_mds_md_v1(struct lmv_mds_md_v1 *lmm1)
1845 __swab32s(&lmm1->lmv_magic);
1846 __swab32s(&lmm1->lmv_stripe_count);
1847 __swab32s(&lmm1->lmv_master_mdt_index);
1848 __swab32s(&lmm1->lmv_hash_type);
1849 __swab32s(&lmm1->lmv_layout_version);
1850 for (i = 0; i < lmm1->lmv_stripe_count; i++)
1851 lustre_swab_lu_fid(&lmm1->lmv_stripe_fids[i]);
1854 void lustre_swab_lmv_mds_md(union lmv_mds_md *lmm)
1856 switch (lmm->lmv_magic) {
1858 lustre_swab_lmv_mds_md_v1(&lmm->lmv_md_v1);
1864 EXPORT_SYMBOL(lustre_swab_lmv_mds_md);
1866 void lustre_swab_lmv_user_md(struct lmv_user_md *lum)
1868 __swab32s(&lum->lum_magic);
1869 __swab32s(&lum->lum_stripe_count);
1870 __swab32s(&lum->lum_stripe_offset);
1871 __swab32s(&lum->lum_hash_type);
1872 __swab32s(&lum->lum_type);
1873 CLASSERT(offsetof(typeof(*lum), lum_padding1));
1875 EXPORT_SYMBOL(lustre_swab_lmv_user_md);
1877 static void lustre_swab_lmm_oi(struct ost_id *oi)
1879 __swab64s(&oi->oi.oi_id);
1880 __swab64s(&oi->oi.oi_seq);
1883 static void lustre_swab_lov_user_md_common(struct lov_user_md_v1 *lum)
1885 __swab32s(&lum->lmm_magic);
1886 __swab32s(&lum->lmm_pattern);
1887 lustre_swab_lmm_oi(&lum->lmm_oi);
1888 __swab32s(&lum->lmm_stripe_size);
1889 __swab16s(&lum->lmm_stripe_count);
1890 __swab16s(&lum->lmm_stripe_offset);
1893 void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum)
1895 CDEBUG(D_IOCTL, "swabbing lov_user_md v1\n");
1896 lustre_swab_lov_user_md_common(lum);
1898 EXPORT_SYMBOL(lustre_swab_lov_user_md_v1);
1900 void lustre_swab_lov_user_md_v3(struct lov_user_md_v3 *lum)
1902 CDEBUG(D_IOCTL, "swabbing lov_user_md v3\n");
1903 lustre_swab_lov_user_md_common((struct lov_user_md_v1 *)lum);
1904 /* lmm_pool_name nothing to do with char */
1906 EXPORT_SYMBOL(lustre_swab_lov_user_md_v3);
1908 void lustre_swab_lov_mds_md(struct lov_mds_md *lmm)
1910 CDEBUG(D_IOCTL, "swabbing lov_mds_md\n");
1911 __swab32s(&lmm->lmm_magic);
1912 __swab32s(&lmm->lmm_pattern);
1913 lustre_swab_lmm_oi(&lmm->lmm_oi);
1914 __swab32s(&lmm->lmm_stripe_size);
1915 __swab16s(&lmm->lmm_stripe_count);
1916 __swab16s(&lmm->lmm_layout_gen);
1918 EXPORT_SYMBOL(lustre_swab_lov_mds_md);
1920 void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod,
1925 for (i = 0; i < stripe_count; i++) {
1926 lustre_swab_ost_id(&lod[i].l_ost_oi);
1927 __swab32s(&lod[i].l_ost_gen);
1928 __swab32s(&lod[i].l_ost_idx);
1931 EXPORT_SYMBOL(lustre_swab_lov_user_md_objects);
1933 static void lustre_swab_ldlm_res_id(struct ldlm_res_id *id)
1937 for (i = 0; i < RES_NAME_SIZE; i++)
1938 __swab64s(&id->name[i]);
1941 static void lustre_swab_ldlm_policy_data(ldlm_wire_policy_data_t *d)
1943 /* the lock data is a union and the first two fields are always an
1944 * extent so it's ok to process an LDLM_EXTENT and LDLM_FLOCK lock
1945 * data the same way.
1947 __swab64s(&d->l_extent.start);
1948 __swab64s(&d->l_extent.end);
1949 __swab64s(&d->l_extent.gid);
1950 __swab64s(&d->l_flock.lfw_owner);
1951 __swab32s(&d->l_flock.lfw_pid);
1954 void lustre_swab_ldlm_intent(struct ldlm_intent *i)
1959 static void lustre_swab_ldlm_resource_desc(struct ldlm_resource_desc *r)
1961 __swab32s(&r->lr_type);
1962 CLASSERT(offsetof(typeof(*r), lr_padding) != 0);
1963 lustre_swab_ldlm_res_id(&r->lr_name);
1966 static void lustre_swab_ldlm_lock_desc(struct ldlm_lock_desc *l)
1968 lustre_swab_ldlm_resource_desc(&l->l_resource);
1969 __swab32s(&l->l_req_mode);
1970 __swab32s(&l->l_granted_mode);
1971 lustre_swab_ldlm_policy_data(&l->l_policy_data);
1974 void lustre_swab_ldlm_request(struct ldlm_request *rq)
1976 __swab32s(&rq->lock_flags);
1977 lustre_swab_ldlm_lock_desc(&rq->lock_desc);
1978 __swab32s(&rq->lock_count);
1979 /* lock_handle[] opaque */
1982 void lustre_swab_ldlm_reply(struct ldlm_reply *r)
1984 __swab32s(&r->lock_flags);
1985 CLASSERT(offsetof(typeof(*r), lock_padding) != 0);
1986 lustre_swab_ldlm_lock_desc(&r->lock_desc);
1987 /* lock_handle opaque */
1988 __swab64s(&r->lock_policy_res1);
1989 __swab64s(&r->lock_policy_res2);
1992 /* Dump functions */
1993 void dump_ioo(struct obd_ioobj *ioo)
1996 "obd_ioobj: ioo_oid=" DOSTID ", ioo_max_brw=%#x, ioo_bufct=%d\n",
1997 POSTID(&ioo->ioo_oid), ioo->ioo_max_brw,
2001 void dump_rniobuf(struct niobuf_remote *nb)
2003 CDEBUG(D_RPCTRACE, "niobuf_remote: offset=%llu, len=%d, flags=%x\n",
2004 nb->rnb_offset, nb->rnb_len, nb->rnb_flags);
2007 static void dump_obdo(struct obdo *oa)
2009 __u32 valid = oa->o_valid;
2011 CDEBUG(D_RPCTRACE, "obdo: o_valid = %08x\n", valid);
2012 if (valid & OBD_MD_FLID)
2013 CDEBUG(D_RPCTRACE, "obdo: id = "DOSTID"\n", POSTID(&oa->o_oi));
2014 if (valid & OBD_MD_FLFID)
2015 CDEBUG(D_RPCTRACE, "obdo: o_parent_seq = %#llx\n",
2017 if (valid & OBD_MD_FLSIZE)
2018 CDEBUG(D_RPCTRACE, "obdo: o_size = %lld\n", oa->o_size);
2019 if (valid & OBD_MD_FLMTIME)
2020 CDEBUG(D_RPCTRACE, "obdo: o_mtime = %lld\n", oa->o_mtime);
2021 if (valid & OBD_MD_FLATIME)
2022 CDEBUG(D_RPCTRACE, "obdo: o_atime = %lld\n", oa->o_atime);
2023 if (valid & OBD_MD_FLCTIME)
2024 CDEBUG(D_RPCTRACE, "obdo: o_ctime = %lld\n", oa->o_ctime);
2025 if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
2026 CDEBUG(D_RPCTRACE, "obdo: o_blocks = %lld\n", oa->o_blocks);
2027 if (valid & OBD_MD_FLGRANT)
2028 CDEBUG(D_RPCTRACE, "obdo: o_grant = %lld\n", oa->o_grant);
2029 if (valid & OBD_MD_FLBLKSZ)
2030 CDEBUG(D_RPCTRACE, "obdo: o_blksize = %d\n", oa->o_blksize);
2031 if (valid & (OBD_MD_FLTYPE | OBD_MD_FLMODE))
2032 CDEBUG(D_RPCTRACE, "obdo: o_mode = %o\n",
2033 oa->o_mode & ((valid & OBD_MD_FLTYPE ? S_IFMT : 0) |
2034 (valid & OBD_MD_FLMODE ? ~S_IFMT : 0)));
2035 if (valid & OBD_MD_FLUID)
2036 CDEBUG(D_RPCTRACE, "obdo: o_uid = %u\n", oa->o_uid);
2037 if (valid & OBD_MD_FLUID)
2038 CDEBUG(D_RPCTRACE, "obdo: o_uid_h = %u\n", oa->o_uid_h);
2039 if (valid & OBD_MD_FLGID)
2040 CDEBUG(D_RPCTRACE, "obdo: o_gid = %u\n", oa->o_gid);
2041 if (valid & OBD_MD_FLGID)
2042 CDEBUG(D_RPCTRACE, "obdo: o_gid_h = %u\n", oa->o_gid_h);
2043 if (valid & OBD_MD_FLFLAGS)
2044 CDEBUG(D_RPCTRACE, "obdo: o_flags = %x\n", oa->o_flags);
2045 if (valid & OBD_MD_FLNLINK)
2046 CDEBUG(D_RPCTRACE, "obdo: o_nlink = %u\n", oa->o_nlink);
2047 else if (valid & OBD_MD_FLCKSUM)
2048 CDEBUG(D_RPCTRACE, "obdo: o_checksum (o_nlink) = %u\n",
2050 if (valid & OBD_MD_FLGENER)
2051 CDEBUG(D_RPCTRACE, "obdo: o_parent_oid = %x\n",
2053 if (valid & OBD_MD_FLEPOCH)
2054 CDEBUG(D_RPCTRACE, "obdo: o_ioepoch = %lld\n",
2056 if (valid & OBD_MD_FLFID) {
2057 CDEBUG(D_RPCTRACE, "obdo: o_stripe_idx = %u\n",
2059 CDEBUG(D_RPCTRACE, "obdo: o_parent_ver = %x\n",
2062 if (valid & OBD_MD_FLHANDLE)
2063 CDEBUG(D_RPCTRACE, "obdo: o_handle = %lld\n",
2064 oa->o_handle.cookie);
2065 if (valid & OBD_MD_FLCOOKIE)
2066 CDEBUG(D_RPCTRACE, "obdo: o_lcookie = (llog_cookie dumping not yet implemented)\n");
2069 void dump_ost_body(struct ost_body *ob)
2074 void dump_rcs(__u32 *rc)
2076 CDEBUG(D_RPCTRACE, "rmf_rcs: %d\n", *rc);
2079 static inline int req_ptlrpc_body_swabbed(struct ptlrpc_request *req)
2081 LASSERT(req->rq_reqmsg);
2083 switch (req->rq_reqmsg->lm_magic) {
2084 case LUSTRE_MSG_MAGIC_V2:
2085 return lustre_req_swabbed(req, MSG_PTLRPC_BODY_OFF);
2087 CERROR("bad lustre msg magic: %#08X\n",
2088 req->rq_reqmsg->lm_magic);
2093 static inline int rep_ptlrpc_body_swabbed(struct ptlrpc_request *req)
2095 LASSERT(req->rq_repmsg);
2097 switch (req->rq_repmsg->lm_magic) {
2098 case LUSTRE_MSG_MAGIC_V2:
2099 return lustre_rep_swabbed(req, MSG_PTLRPC_BODY_OFF);
2101 /* uninitialized yet */
2106 void _debug_req(struct ptlrpc_request *req,
2107 struct libcfs_debug_msg_data *msgdata,
2108 const char *fmt, ...)
2110 int req_ok = req->rq_reqmsg != NULL;
2111 int rep_ok = req->rq_repmsg != NULL;
2112 lnet_nid_t nid = LNET_NID_ANY;
2115 if (ptlrpc_req_need_swab(req)) {
2116 req_ok = req_ok && req_ptlrpc_body_swabbed(req);
2117 rep_ok = rep_ok && rep_ptlrpc_body_swabbed(req);
2120 if (req->rq_import && req->rq_import->imp_connection)
2121 nid = req->rq_import->imp_connection->c_peer.nid;
2122 else if (req->rq_export && req->rq_export->exp_connection)
2123 nid = req->rq_export->exp_connection->c_peer.nid;
2125 va_start(args, fmt);
2126 libcfs_debug_vmsg2(msgdata, fmt, args,
2127 " req@%p x%llu/t%lld(%lld) o%d->%s@%s:%d/%d lens %d/%d e %d to %lld dl %lld ref %d fl " REQ_FLAGS_FMT "/%x/%x rc %d/%d\n",
2128 req, req->rq_xid, req->rq_transno,
2129 req_ok ? lustre_msg_get_transno(req->rq_reqmsg) : 0,
2130 req_ok ? lustre_msg_get_opc(req->rq_reqmsg) : -1,
2132 req->rq_import->imp_obd->obd_name :
2134 req->rq_export->exp_client_uuid.uuid :
2136 libcfs_nid2str(nid),
2137 req->rq_request_portal, req->rq_reply_portal,
2138 req->rq_reqlen, req->rq_replen,
2139 req->rq_early_count, (s64)req->rq_timedout,
2140 (s64)req->rq_deadline,
2141 atomic_read(&req->rq_refcount),
2142 DEBUG_REQ_FLAGS(req),
2143 req_ok ? lustre_msg_get_flags(req->rq_reqmsg) : -1,
2144 rep_ok ? lustre_msg_get_flags(req->rq_repmsg) : -1,
2146 rep_ok ? lustre_msg_get_status(req->rq_repmsg) : -1);
2149 EXPORT_SYMBOL(_debug_req);
2151 void lustre_swab_lustre_capa(struct lustre_capa *c)
2153 lustre_swab_lu_fid(&c->lc_fid);
2154 __swab64s(&c->lc_opc);
2155 __swab64s(&c->lc_uid);
2156 __swab64s(&c->lc_gid);
2157 __swab32s(&c->lc_flags);
2158 __swab32s(&c->lc_keyid);
2159 __swab32s(&c->lc_timeout);
2160 __swab32s(&c->lc_expiry);
2163 void lustre_swab_hsm_user_state(struct hsm_user_state *state)
2165 __swab32s(&state->hus_states);
2166 __swab32s(&state->hus_archive_id);
2169 void lustre_swab_hsm_state_set(struct hsm_state_set *hss)
2171 __swab32s(&hss->hss_valid);
2172 __swab64s(&hss->hss_setmask);
2173 __swab64s(&hss->hss_clearmask);
2174 __swab32s(&hss->hss_archive_id);
2176 EXPORT_SYMBOL(lustre_swab_hsm_state_set);
2178 static void lustre_swab_hsm_extent(struct hsm_extent *extent)
2180 __swab64s(&extent->offset);
2181 __swab64s(&extent->length);
2184 void lustre_swab_hsm_current_action(struct hsm_current_action *action)
2186 __swab32s(&action->hca_state);
2187 __swab32s(&action->hca_action);
2188 lustre_swab_hsm_extent(&action->hca_location);
2191 void lustre_swab_hsm_user_item(struct hsm_user_item *hui)
2193 lustre_swab_lu_fid(&hui->hui_fid);
2194 lustre_swab_hsm_extent(&hui->hui_extent);
2197 void lustre_swab_layout_intent(struct layout_intent *li)
2199 __swab32s(&li->li_opc);
2200 __swab32s(&li->li_flags);
2201 __swab64s(&li->li_start);
2202 __swab64s(&li->li_end);
2205 void lustre_swab_hsm_progress_kernel(struct hsm_progress_kernel *hpk)
2207 lustre_swab_lu_fid(&hpk->hpk_fid);
2208 __swab64s(&hpk->hpk_cookie);
2209 __swab64s(&hpk->hpk_extent.offset);
2210 __swab64s(&hpk->hpk_extent.length);
2211 __swab16s(&hpk->hpk_flags);
2212 __swab16s(&hpk->hpk_errval);
2215 void lustre_swab_hsm_request(struct hsm_request *hr)
2217 __swab32s(&hr->hr_action);
2218 __swab32s(&hr->hr_archive_id);
2219 __swab64s(&hr->hr_flags);
2220 __swab32s(&hr->hr_itemcount);
2221 __swab32s(&hr->hr_data_len);
2224 void lustre_swab_swap_layouts(struct mdc_swap_layouts *msl)
2226 __swab64s(&msl->msl_flags);
2228 EXPORT_SYMBOL(lustre_swab_swap_layouts);
2230 void lustre_swab_close_data(struct close_data *cd)
2232 lustre_swab_lu_fid(&cd->cd_fid);
2233 __swab64s(&cd->cd_data_version);