1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/ptlrpc/pack_generic.c
38 * (Un)packing of OST requests
40 * Author: Peter J. Braam <braam@clusterfs.com>
41 * Author: Phil Schwan <phil@clusterfs.com>
42 * Author: Eric Barton <eeb@clusterfs.com>
45 #define DEBUG_SUBSYSTEM S_RPC
47 # include <liblustre.h>
50 #include <libcfs/libcfs.h>
52 #include <obd_support.h>
53 #include <obd_class.h>
54 #include <lustre_net.h>
55 #include <obd_cksum.h>
56 #include <lustre/ll_fiemap.h>
58 static inline int lustre_msg_hdr_size_v2(int count)
60 return cfs_size_round(offsetof(struct lustre_msg_v2,
64 int lustre_msg_hdr_size(__u32 magic, int count)
67 case LUSTRE_MSG_MAGIC_V2:
68 return lustre_msg_hdr_size_v2(count);
70 LASSERTF(0, "incorrect message magic: %08x\n", magic);
74 EXPORT_SYMBOL(lustre_msg_hdr_size);
76 void ptlrpc_buf_set_swabbed(struct ptlrpc_request *req, const int inout,
80 lustre_set_req_swabbed(req, index);
82 lustre_set_rep_swabbed(req, index);
85 int ptlrpc_buf_need_swab(struct ptlrpc_request *req, const int inout,
89 return (ptlrpc_req_need_swab(req) &&
90 !lustre_req_swabbed(req, index));
92 return (ptlrpc_rep_need_swab(req) &&
93 !lustre_rep_swabbed(req, index));
96 static inline int lustre_msg_check_version_v2(struct lustre_msg_v2 *msg,
99 __u32 ver = lustre_msg_get_version(msg);
100 return (ver & LUSTRE_VERSION_MASK) != version;
103 int lustre_msg_check_version(struct lustre_msg *msg, __u32 version)
105 switch (msg->lm_magic) {
106 case LUSTRE_MSG_MAGIC_V1:
107 CERROR("msg v1 not supported - please upgrade you system\n");
109 case LUSTRE_MSG_MAGIC_V2:
110 return lustre_msg_check_version_v2(msg, version);
112 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
117 /* early reply size */
118 int lustre_msg_early_size()
122 size = lustre_msg_size(LUSTRE_MSG_MAGIC_V2, 1, NULL);
125 EXPORT_SYMBOL(lustre_msg_early_size);
127 int lustre_msg_size_v2(int count, __u32 *lengths)
132 size = lustre_msg_hdr_size_v2(count);
133 for (i = 0; i < count; i++)
134 size += cfs_size_round(lengths[i]);
138 EXPORT_SYMBOL(lustre_msg_size_v2);
140 /* This returns the size of the buffer that is required to hold a lustre_msg
141 * with the given sub-buffer lengths.
142 * NOTE: this should only be used for NEW requests, and should always be
143 * in the form of a v2 request. If this is a connection to a v1
144 * target then the first buffer will be stripped because the ptlrpc
145 * data is part of the lustre_msg_v1 header. b=14043 */
146 int lustre_msg_size(__u32 magic, int count, __u32 *lens)
148 __u32 size[] = { sizeof(struct ptlrpc_body) };
156 LASSERT(lens[MSG_PTLRPC_BODY_OFF] == sizeof(struct ptlrpc_body));
159 case LUSTRE_MSG_MAGIC_V2:
160 return lustre_msg_size_v2(count, lens);
162 LASSERTF(0, "incorrect message magic: %08x\n", magic);
167 /* This is used to determine the size of a buffer that was already packed
168 * and will correctly handle the different message formats. */
169 int lustre_packed_msg_size(struct lustre_msg *msg)
171 switch (msg->lm_magic) {
172 case LUSTRE_MSG_MAGIC_V2:
173 return lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens);
175 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
180 void lustre_init_msg_v2(struct lustre_msg_v2 *msg, int count, __u32 *lens,
186 msg->lm_bufcount = count;
187 /* XXX: lm_secflvr uninitialized here */
188 msg->lm_magic = LUSTRE_MSG_MAGIC_V2;
190 for (i = 0; i < count; i++)
191 msg->lm_buflens[i] = lens[i];
196 ptr = (char *)msg + lustre_msg_hdr_size_v2(count);
197 for (i = 0; i < count; i++) {
199 LOGL(tmp, lens[i], ptr);
202 EXPORT_SYMBOL(lustre_init_msg_v2);
204 static int lustre_pack_request_v2(struct ptlrpc_request *req,
205 int count, __u32 *lens, char **bufs)
209 reqlen = lustre_msg_size_v2(count, lens);
211 rc = sptlrpc_cli_alloc_reqbuf(req, reqlen);
215 req->rq_reqlen = reqlen;
217 lustre_init_msg_v2(req->rq_reqmsg, count, lens, bufs);
218 lustre_msg_add_version(req->rq_reqmsg, PTLRPC_MSG_VERSION);
222 int lustre_pack_request(struct ptlrpc_request *req, __u32 magic, int count,
223 __u32 *lens, char **bufs)
225 __u32 size[] = { sizeof(struct ptlrpc_body) };
233 LASSERT(lens[MSG_PTLRPC_BODY_OFF] == sizeof(struct ptlrpc_body));
235 /* only use new format, we don't need to be compatible with 1.4 */
236 magic = LUSTRE_MSG_MAGIC_V2;
239 case LUSTRE_MSG_MAGIC_V2:
240 return lustre_pack_request_v2(req, count, lens, bufs);
242 LASSERTF(0, "incorrect message magic: %08x\n", magic);
248 CFS_LIST_HEAD(ptlrpc_rs_debug_lru);
249 cfs_spinlock_t ptlrpc_rs_debug_lock;
251 #define PTLRPC_RS_DEBUG_LRU_ADD(rs) \
253 cfs_spin_lock(&ptlrpc_rs_debug_lock); \
254 cfs_list_add_tail(&(rs)->rs_debug_list, &ptlrpc_rs_debug_lru); \
255 cfs_spin_unlock(&ptlrpc_rs_debug_lock); \
258 #define PTLRPC_RS_DEBUG_LRU_DEL(rs) \
260 cfs_spin_lock(&ptlrpc_rs_debug_lock); \
261 cfs_list_del(&(rs)->rs_debug_list); \
262 cfs_spin_unlock(&ptlrpc_rs_debug_lock); \
265 # define PTLRPC_RS_DEBUG_LRU_ADD(rs) do {} while(0)
266 # define PTLRPC_RS_DEBUG_LRU_DEL(rs) do {} while(0)
269 struct ptlrpc_reply_state *lustre_get_emerg_rs(struct ptlrpc_service *svc)
271 struct ptlrpc_reply_state *rs = NULL;
273 cfs_spin_lock(&svc->srv_lock);
274 /* See if we have anything in a pool, and wait if nothing */
275 while (cfs_list_empty(&svc->srv_free_rs_list)) {
276 struct l_wait_info lwi;
278 cfs_spin_unlock(&svc->srv_lock);
279 /* If we cannot get anything for some long time, we better
280 bail out instead of waiting infinitely */
281 lwi = LWI_TIMEOUT(cfs_time_seconds(10), NULL, NULL);
282 rc = l_wait_event(svc->srv_free_rs_waitq,
283 !cfs_list_empty(&svc->srv_free_rs_list),
287 cfs_spin_lock(&svc->srv_lock);
290 rs = cfs_list_entry(svc->srv_free_rs_list.next,
291 struct ptlrpc_reply_state, rs_list);
292 cfs_list_del(&rs->rs_list);
293 cfs_spin_unlock(&svc->srv_lock);
295 memset(rs, 0, svc->srv_max_reply_size);
296 rs->rs_service = svc;
302 void lustre_put_emerg_rs(struct ptlrpc_reply_state *rs)
304 struct ptlrpc_service *svc = rs->rs_service;
308 cfs_spin_lock(&svc->srv_lock);
309 cfs_list_add(&rs->rs_list, &svc->srv_free_rs_list);
310 cfs_spin_unlock(&svc->srv_lock);
311 cfs_waitq_signal(&svc->srv_free_rs_waitq);
314 int lustre_pack_reply_v2(struct ptlrpc_request *req, int count,
315 __u32 *lens, char **bufs, int flags)
317 struct ptlrpc_reply_state *rs;
321 LASSERT(req->rq_reply_state == NULL);
323 if ((flags & LPRFL_EARLY_REPLY) == 0)
324 req->rq_packed_final = 1;
326 msg_len = lustre_msg_size_v2(count, lens);
327 rc = sptlrpc_svc_alloc_rs(req, msg_len);
331 rs = req->rq_reply_state;
332 cfs_atomic_set(&rs->rs_refcount, 1); /* 1 ref for rq_reply_state */
333 rs->rs_cb_id.cbid_fn = reply_out_callback;
334 rs->rs_cb_id.cbid_arg = rs;
335 rs->rs_service = req->rq_rqbd->rqbd_service;
336 CFS_INIT_LIST_HEAD(&rs->rs_exp_list);
337 CFS_INIT_LIST_HEAD(&rs->rs_obd_list);
338 CFS_INIT_LIST_HEAD(&rs->rs_list);
339 cfs_spin_lock_init(&rs->rs_lock);
341 req->rq_replen = msg_len;
342 req->rq_reply_state = rs;
343 req->rq_repmsg = rs->rs_msg;
345 lustre_init_msg_v2(rs->rs_msg, count, lens, bufs);
346 lustre_msg_add_version(rs->rs_msg, PTLRPC_MSG_VERSION);
348 PTLRPC_RS_DEBUG_LRU_ADD(rs);
352 EXPORT_SYMBOL(lustre_pack_reply_v2);
354 int lustre_pack_reply_flags(struct ptlrpc_request *req, int count, __u32 *lens,
355 char **bufs, int flags)
358 __u32 size[] = { sizeof(struct ptlrpc_body) };
366 LASSERT(lens[MSG_PTLRPC_BODY_OFF] == sizeof(struct ptlrpc_body));
368 switch (req->rq_reqmsg->lm_magic) {
369 case LUSTRE_MSG_MAGIC_V2:
370 rc = lustre_pack_reply_v2(req, count, lens, bufs, flags);
373 LASSERTF(0, "incorrect message magic: %08x\n",
374 req->rq_reqmsg->lm_magic);
378 CERROR("lustre_pack_reply failed: rc=%d size=%d\n", rc,
379 lustre_msg_size(req->rq_reqmsg->lm_magic, count, lens));
383 int lustre_pack_reply(struct ptlrpc_request *req, int count, __u32 *lens,
386 return lustre_pack_reply_flags(req, count, lens, bufs, 0);
389 void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, int n, int min_size)
391 int i, offset, buflen, bufcount;
396 bufcount = m->lm_bufcount;
397 if (unlikely(n >= bufcount)) {
398 CDEBUG(D_INFO, "msg %p buffer[%d] not present (count %d)\n",
403 buflen = m->lm_buflens[n];
404 if (unlikely(buflen < min_size)) {
405 CERROR("msg %p buffer[%d] size %d too small "
406 "(required %d, opc=%d)\n", m, n, buflen, min_size,
407 n == MSG_PTLRPC_BODY_OFF ? -1 : lustre_msg_get_opc(m));
411 offset = lustre_msg_hdr_size_v2(bufcount);
412 for (i = 0; i < n; i++)
413 offset += cfs_size_round(m->lm_buflens[i]);
415 return (char *)m + offset;
418 void *lustre_msg_buf(struct lustre_msg *m, int n, int min_size)
420 switch (m->lm_magic) {
421 case LUSTRE_MSG_MAGIC_V2:
422 return lustre_msg_buf_v2(m, n, min_size);
424 LASSERTF(0, "incorrect message magic: %08x(msg:%p)\n", m->lm_magic, m);
429 int lustre_shrink_msg_v2(struct lustre_msg_v2 *msg, int segment,
430 unsigned int newlen, int move_data)
432 char *tail = NULL, *newpos;
436 LASSERT(msg->lm_bufcount > segment);
437 LASSERT(msg->lm_buflens[segment] >= newlen);
439 if (msg->lm_buflens[segment] == newlen)
442 if (move_data && msg->lm_bufcount > segment + 1) {
443 tail = lustre_msg_buf_v2(msg, segment + 1, 0);
444 for (n = segment + 1; n < msg->lm_bufcount; n++)
445 tail_len += cfs_size_round(msg->lm_buflens[n]);
448 msg->lm_buflens[segment] = newlen;
450 if (tail && tail_len) {
451 newpos = lustre_msg_buf_v2(msg, segment + 1, 0);
452 LASSERT(newpos <= tail);
454 memmove(newpos, tail, tail_len);
457 return lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens);
461 * for @msg, shrink @segment to size @newlen. if @move_data is non-zero,
462 * we also move data forward from @segment + 1.
464 * if @newlen == 0, we remove the segment completely, but we still keep the
465 * totally bufcount the same to save possible data moving. this will leave a
466 * unused segment with size 0 at the tail, but that's ok.
468 * return new msg size after shrinking.
471 * + if any buffers higher than @segment has been filled in, must call shrink
472 * with non-zero @move_data.
473 * + caller should NOT keep pointers to msg buffers which higher than @segment
476 int lustre_shrink_msg(struct lustre_msg *msg, int segment,
477 unsigned int newlen, int move_data)
479 switch (msg->lm_magic) {
480 case LUSTRE_MSG_MAGIC_V2:
481 return lustre_shrink_msg_v2(msg, segment, newlen, move_data);
483 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
487 void lustre_free_reply_state(struct ptlrpc_reply_state *rs)
489 PTLRPC_RS_DEBUG_LRU_DEL(rs);
491 LASSERT (cfs_atomic_read(&rs->rs_refcount) == 0);
492 LASSERT (!rs->rs_difficult || rs->rs_handled);
493 LASSERT (!rs->rs_on_net);
494 LASSERT (!rs->rs_scheduled);
495 LASSERT (rs->rs_export == NULL);
496 LASSERT (rs->rs_nlocks == 0);
497 LASSERT (cfs_list_empty(&rs->rs_exp_list));
498 LASSERT (cfs_list_empty(&rs->rs_obd_list));
500 sptlrpc_svc_free_rs(rs);
503 static int lustre_unpack_msg_v2(struct lustre_msg_v2 *m, int len)
505 int swabbed, required_len, i;
507 /* Now we know the sender speaks my language. */
508 required_len = lustre_msg_hdr_size_v2(0);
509 if (len < required_len) {
510 /* can't even look inside the message */
511 CERROR("message length %d too small for lustre_msg\n", len);
515 swabbed = (m->lm_magic == LUSTRE_MSG_MAGIC_V2_SWABBED);
518 __swab32s(&m->lm_magic);
519 __swab32s(&m->lm_bufcount);
520 __swab32s(&m->lm_secflvr);
521 __swab32s(&m->lm_repsize);
522 __swab32s(&m->lm_cksum);
523 __swab32s(&m->lm_flags);
524 CLASSERT(offsetof(typeof(*m), lm_padding_2) != 0);
525 CLASSERT(offsetof(typeof(*m), lm_padding_3) != 0);
528 required_len = lustre_msg_hdr_size_v2(m->lm_bufcount);
529 if (len < required_len) {
530 /* didn't receive all the buffer lengths */
531 CERROR ("message length %d too small for %d buflens\n",
532 len, m->lm_bufcount);
536 for (i = 0; i < m->lm_bufcount; i++) {
538 __swab32s(&m->lm_buflens[i]);
539 required_len += cfs_size_round(m->lm_buflens[i]);
542 if (len < required_len) {
543 CERROR("len: %d, required_len %d\n", len, required_len);
544 CERROR("bufcount: %d\n", m->lm_bufcount);
545 for (i = 0; i < m->lm_bufcount; i++)
546 CERROR("buffer %d length %d\n", i, m->lm_buflens[i]);
553 int __lustre_unpack_msg(struct lustre_msg *m, int len)
555 int required_len, rc;
558 /* We can provide a slightly better error log, if we check the
559 * message magic and version first. In the future, struct
560 * lustre_msg may grow, and we'd like to log a version mismatch,
561 * rather than a short message.
564 required_len = offsetof(struct lustre_msg, lm_magic) +
566 if (len < required_len) {
567 /* can't even look inside the message */
568 CERROR("message length %d too small for magic/version check\n",
573 rc = lustre_unpack_msg_v2(m, len);
577 EXPORT_SYMBOL(__lustre_unpack_msg);
579 int ptlrpc_unpack_req_msg(struct ptlrpc_request *req, int len)
582 rc = __lustre_unpack_msg(req->rq_reqmsg, len);
584 lustre_set_req_swabbed(req, MSG_PTLRPC_HEADER_OFF);
590 int ptlrpc_unpack_rep_msg(struct ptlrpc_request *req, int len)
593 rc = __lustre_unpack_msg(req->rq_repmsg, len);
595 lustre_set_rep_swabbed(req, MSG_PTLRPC_HEADER_OFF);
601 static inline int lustre_unpack_ptlrpc_body_v2(struct ptlrpc_request *req,
602 const int inout, int offset)
604 struct ptlrpc_body *pb;
605 struct lustre_msg_v2 *m = inout ? req->rq_reqmsg : req->rq_repmsg;
607 pb = lustre_msg_buf_v2(m, offset, sizeof(*pb));
609 CERROR("error unpacking ptlrpc body\n");
612 if (ptlrpc_buf_need_swab(req, inout, offset)) {
613 lustre_swab_ptlrpc_body(pb);
614 ptlrpc_buf_set_swabbed(req, inout, offset);
617 if ((pb->pb_version & ~LUSTRE_VERSION_MASK) != PTLRPC_MSG_VERSION) {
618 CERROR("wrong lustre_msg version %08x\n", pb->pb_version);
625 int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset)
627 switch (req->rq_reqmsg->lm_magic) {
628 case LUSTRE_MSG_MAGIC_V2:
629 return lustre_unpack_ptlrpc_body_v2(req, 1, offset);
631 CERROR("bad lustre msg magic: %08x\n",
632 req->rq_reqmsg->lm_magic);
637 int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset)
639 switch (req->rq_repmsg->lm_magic) {
640 case LUSTRE_MSG_MAGIC_V2:
641 return lustre_unpack_ptlrpc_body_v2(req, 0, offset);
643 CERROR("bad lustre msg magic: %08x\n",
644 req->rq_repmsg->lm_magic);
649 static inline int lustre_msg_buflen_v2(struct lustre_msg_v2 *m, int n)
651 if (n >= m->lm_bufcount)
654 return m->lm_buflens[n];
658 * lustre_msg_buflen - return the length of buffer \a n in message \a m
659 * \param m lustre_msg (request or reply) to look at
660 * \param n message index (base 0)
662 * returns zero for non-existent message indices
664 int lustre_msg_buflen(struct lustre_msg *m, int n)
666 switch (m->lm_magic) {
667 case LUSTRE_MSG_MAGIC_V2:
668 return lustre_msg_buflen_v2(m, n);
670 CERROR("incorrect message magic: %08x\n", m->lm_magic);
674 EXPORT_SYMBOL(lustre_msg_buflen);
677 lustre_msg_set_buflen_v2(struct lustre_msg_v2 *m, int n, int len)
679 if (n >= m->lm_bufcount)
682 m->lm_buflens[n] = len;
685 void lustre_msg_set_buflen(struct lustre_msg *m, int n, int len)
687 switch (m->lm_magic) {
688 case LUSTRE_MSG_MAGIC_V2:
689 lustre_msg_set_buflen_v2(m, n, len);
692 LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic);
696 EXPORT_SYMBOL(lustre_msg_set_buflen);
698 /* NB return the bufcount for lustre_msg_v2 format, so if message is packed
699 * in V1 format, the result is one bigger. (add struct ptlrpc_body). */
700 int lustre_msg_bufcount(struct lustre_msg *m)
702 switch (m->lm_magic) {
703 case LUSTRE_MSG_MAGIC_V2:
704 return m->lm_bufcount;
706 CERROR("incorrect message magic: %08x\n", m->lm_magic);
710 EXPORT_SYMBOL(lustre_msg_bufcount);
712 char *lustre_msg_string(struct lustre_msg *m, int index, int max_len)
714 /* max_len == 0 means the string should fill the buffer */
718 switch (m->lm_magic) {
719 case LUSTRE_MSG_MAGIC_V2:
720 str = lustre_msg_buf_v2(m, index, 0);
721 blen = lustre_msg_buflen_v2(m, index);
724 LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic);
728 CERROR ("can't unpack string in msg %p buffer[%d]\n", m, index);
732 slen = strnlen(str, blen);
734 if (slen == blen) { /* not NULL terminated */
735 CERROR("can't unpack non-NULL terminated string in "
736 "msg %p buffer[%d] len %d\n", m, index, blen);
741 if (slen != blen - 1) {
742 CERROR("can't unpack short string in msg %p "
743 "buffer[%d] len %d: strlen %d\n",
744 m, index, blen, slen);
747 } else if (slen > max_len) {
748 CERROR("can't unpack oversized string in msg %p "
749 "buffer[%d] len %d strlen %d: max %d expected\n",
750 m, index, blen, slen, max_len);
757 /* Wrap up the normal fixed length cases */
758 static inline void *__lustre_swab_buf(struct lustre_msg *msg, int index,
759 int min_size, void *swabber)
763 LASSERT(msg != NULL);
764 switch (msg->lm_magic) {
765 case LUSTRE_MSG_MAGIC_V2:
766 ptr = lustre_msg_buf_v2(msg, index, min_size);
769 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
773 ((void (*)(void *))swabber)(ptr);
778 static inline struct ptlrpc_body *lustre_msg_ptlrpc_body(struct lustre_msg *msg)
780 return lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF,
781 sizeof(struct ptlrpc_body));
784 __u32 lustre_msghdr_get_flags(struct lustre_msg *msg)
786 switch (msg->lm_magic) {
787 case LUSTRE_MSG_MAGIC_V1:
788 case LUSTRE_MSG_MAGIC_V1_SWABBED:
790 case LUSTRE_MSG_MAGIC_V2:
791 /* already in host endian */
792 return msg->lm_flags;
794 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
798 EXPORT_SYMBOL(lustre_msghdr_get_flags);
800 void lustre_msghdr_set_flags(struct lustre_msg *msg, __u32 flags)
802 switch (msg->lm_magic) {
803 case LUSTRE_MSG_MAGIC_V1:
805 case LUSTRE_MSG_MAGIC_V2:
806 msg->lm_flags = flags;
809 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
813 __u32 lustre_msg_get_flags(struct lustre_msg *msg)
815 switch (msg->lm_magic) {
816 case LUSTRE_MSG_MAGIC_V2: {
817 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
819 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
825 /* flags might be printed in debug code while message
831 void lustre_msg_add_flags(struct lustre_msg *msg, int flags)
833 switch (msg->lm_magic) {
834 case LUSTRE_MSG_MAGIC_V2: {
835 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
836 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
837 pb->pb_flags |= flags;
841 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
845 void lustre_msg_set_flags(struct lustre_msg *msg, int flags)
847 switch (msg->lm_magic) {
848 case LUSTRE_MSG_MAGIC_V2: {
849 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
850 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
851 pb->pb_flags = flags;
855 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
859 void lustre_msg_clear_flags(struct lustre_msg *msg, int flags)
861 switch (msg->lm_magic) {
862 case LUSTRE_MSG_MAGIC_V2: {
863 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
864 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
865 pb->pb_flags &= ~(MSG_GEN_FLAG_MASK & flags);
869 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
873 __u32 lustre_msg_get_op_flags(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);
879 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
882 return pb->pb_op_flags;
889 void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags)
891 switch (msg->lm_magic) {
892 case LUSTRE_MSG_MAGIC_V2: {
893 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
894 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
895 pb->pb_op_flags |= flags;
899 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
903 void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
905 switch (msg->lm_magic) {
906 case LUSTRE_MSG_MAGIC_V2: {
907 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
908 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
909 pb->pb_op_flags |= flags;
913 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
917 struct lustre_handle *lustre_msg_get_handle(struct lustre_msg *msg)
919 switch (msg->lm_magic) {
920 case LUSTRE_MSG_MAGIC_V2: {
921 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
923 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
926 return &pb->pb_handle;
929 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
934 __u32 lustre_msg_get_type(struct lustre_msg *msg)
936 switch (msg->lm_magic) {
937 case LUSTRE_MSG_MAGIC_V2: {
938 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
940 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
941 return PTL_RPC_MSG_ERR;
946 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
947 return PTL_RPC_MSG_ERR;
951 __u32 lustre_msg_get_version(struct lustre_msg *msg)
953 switch (msg->lm_magic) {
954 case LUSTRE_MSG_MAGIC_V2: {
955 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
957 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
960 return pb->pb_version;
963 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
968 void lustre_msg_add_version(struct lustre_msg *msg, int version)
970 switch (msg->lm_magic) {
971 case LUSTRE_MSG_MAGIC_V2: {
972 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
973 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
974 pb->pb_version |= version;
978 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
982 __u32 lustre_msg_get_opc(struct lustre_msg *msg)
984 switch (msg->lm_magic) {
985 case LUSTRE_MSG_MAGIC_V2: {
986 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
988 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
994 CERROR("incorrect message magic: %08x(msg:%p)\n", msg->lm_magic, msg);
1000 __u64 lustre_msg_get_last_xid(struct lustre_msg *msg)
1002 switch (msg->lm_magic) {
1003 case LUSTRE_MSG_MAGIC_V2: {
1004 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1006 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1009 return pb->pb_last_xid;
1012 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1017 __u64 lustre_msg_get_last_committed(struct lustre_msg *msg)
1019 switch (msg->lm_magic) {
1020 case LUSTRE_MSG_MAGIC_V2: {
1021 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1023 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1026 return pb->pb_last_committed;
1029 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1034 __u64 *lustre_msg_get_versions(struct lustre_msg *msg)
1036 switch (msg->lm_magic) {
1037 case LUSTRE_MSG_MAGIC_V1:
1039 case LUSTRE_MSG_MAGIC_V2: {
1040 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1042 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1045 return pb->pb_pre_versions;
1048 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1053 __u64 lustre_msg_get_transno(struct lustre_msg *msg)
1055 switch (msg->lm_magic) {
1056 case LUSTRE_MSG_MAGIC_V2: {
1057 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1059 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1062 return pb->pb_transno;
1065 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1070 int lustre_msg_get_status(struct lustre_msg *msg)
1072 switch (msg->lm_magic) {
1073 case LUSTRE_MSG_MAGIC_V2: {
1074 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1076 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1079 return pb->pb_status;
1082 /* status might be printed in debug code while message
1088 __u64 lustre_msg_get_slv(struct lustre_msg *msg)
1090 switch (msg->lm_magic) {
1091 case LUSTRE_MSG_MAGIC_V2: {
1092 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1094 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1100 CERROR("invalid msg magic %08x\n", msg->lm_magic);
1106 void lustre_msg_set_slv(struct lustre_msg *msg, __u64 slv)
1108 switch (msg->lm_magic) {
1109 case LUSTRE_MSG_MAGIC_V2: {
1110 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1112 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1119 CERROR("invalid msg magic %x\n", msg->lm_magic);
1124 __u32 lustre_msg_get_limit(struct lustre_msg *msg)
1126 switch (msg->lm_magic) {
1127 case LUSTRE_MSG_MAGIC_V2: {
1128 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1130 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1133 return pb->pb_limit;
1136 CERROR("invalid msg magic %x\n", msg->lm_magic);
1142 void lustre_msg_set_limit(struct lustre_msg *msg, __u64 limit)
1144 switch (msg->lm_magic) {
1145 case LUSTRE_MSG_MAGIC_V2: {
1146 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1148 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1151 pb->pb_limit = limit;
1155 CERROR("invalid msg magic %08x\n", msg->lm_magic);
1160 __u32 lustre_msg_get_conn_cnt(struct lustre_msg *msg)
1162 switch (msg->lm_magic) {
1163 case LUSTRE_MSG_MAGIC_V2: {
1164 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1166 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1169 return pb->pb_conn_cnt;
1172 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1177 int lustre_msg_is_v1(struct lustre_msg *msg)
1179 switch (msg->lm_magic) {
1180 case LUSTRE_MSG_MAGIC_V1:
1181 case LUSTRE_MSG_MAGIC_V1_SWABBED:
1188 __u32 lustre_msg_get_magic(struct lustre_msg *msg)
1190 switch (msg->lm_magic) {
1191 case LUSTRE_MSG_MAGIC_V2:
1192 return msg->lm_magic;
1194 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1199 __u32 lustre_msg_get_timeout(struct lustre_msg *msg)
1201 switch (msg->lm_magic) {
1202 case LUSTRE_MSG_MAGIC_V1:
1203 case LUSTRE_MSG_MAGIC_V1_SWABBED:
1205 case LUSTRE_MSG_MAGIC_V2: {
1206 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1208 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1212 return pb->pb_timeout;
1215 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1220 __u32 lustre_msg_get_service_time(struct lustre_msg *msg)
1222 switch (msg->lm_magic) {
1223 case LUSTRE_MSG_MAGIC_V1:
1224 case LUSTRE_MSG_MAGIC_V1_SWABBED:
1226 case LUSTRE_MSG_MAGIC_V2: {
1227 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1229 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1233 return pb->pb_service_time;
1236 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1241 __u32 lustre_msg_get_cksum(struct lustre_msg *msg)
1243 switch (msg->lm_magic) {
1244 case LUSTRE_MSG_MAGIC_V2:
1245 return msg->lm_cksum;
1247 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1252 __u32 lustre_msg_calc_cksum(struct lustre_msg *msg)
1254 switch (msg->lm_magic) {
1255 case LUSTRE_MSG_MAGIC_V2: {
1256 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1257 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1258 return crc32_le(~(__u32)0, (unsigned char *)pb, sizeof(*pb));
1261 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1266 void lustre_msg_set_handle(struct lustre_msg *msg, struct lustre_handle *handle)
1268 switch (msg->lm_magic) {
1269 case LUSTRE_MSG_MAGIC_V2: {
1270 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1271 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1272 pb->pb_handle = *handle;
1276 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1280 void lustre_msg_set_type(struct lustre_msg *msg, __u32 type)
1282 switch (msg->lm_magic) {
1283 case LUSTRE_MSG_MAGIC_V2: {
1284 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1285 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1290 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1294 void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc)
1296 switch (msg->lm_magic) {
1297 case LUSTRE_MSG_MAGIC_V2: {
1298 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1299 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1304 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1308 void lustre_msg_set_last_xid(struct lustre_msg *msg, __u64 last_xid)
1310 switch (msg->lm_magic) {
1311 case LUSTRE_MSG_MAGIC_V2: {
1312 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1313 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1314 pb->pb_last_xid = last_xid;
1318 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1322 void lustre_msg_set_last_committed(struct lustre_msg *msg, __u64 last_committed)
1324 switch (msg->lm_magic) {
1325 case LUSTRE_MSG_MAGIC_V2: {
1326 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1327 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1328 pb->pb_last_committed = last_committed;
1332 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1336 void lustre_msg_set_versions(struct lustre_msg *msg, __u64 *versions)
1338 switch (msg->lm_magic) {
1339 case LUSTRE_MSG_MAGIC_V1:
1341 case LUSTRE_MSG_MAGIC_V2: {
1342 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1343 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1344 pb->pb_pre_versions[0] = versions[0];
1345 pb->pb_pre_versions[1] = versions[1];
1346 pb->pb_pre_versions[2] = versions[2];
1347 pb->pb_pre_versions[3] = versions[3];
1351 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1355 void lustre_msg_set_transno(struct lustre_msg *msg, __u64 transno)
1357 switch (msg->lm_magic) {
1358 case LUSTRE_MSG_MAGIC_V2: {
1359 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1360 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1361 pb->pb_transno = transno;
1365 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1369 void lustre_msg_set_status(struct lustre_msg *msg, __u32 status)
1371 switch (msg->lm_magic) {
1372 case LUSTRE_MSG_MAGIC_V2: {
1373 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1374 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1375 pb->pb_status = status;
1379 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1383 void lustre_msg_set_conn_cnt(struct lustre_msg *msg, __u32 conn_cnt)
1385 switch (msg->lm_magic) {
1386 case LUSTRE_MSG_MAGIC_V2: {
1387 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1388 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1389 pb->pb_conn_cnt = conn_cnt;
1393 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1397 void lustre_msg_set_timeout(struct lustre_msg *msg, __u32 timeout)
1399 switch (msg->lm_magic) {
1400 case LUSTRE_MSG_MAGIC_V1:
1402 case LUSTRE_MSG_MAGIC_V2: {
1403 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1404 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1405 pb->pb_timeout = timeout;
1409 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1413 void lustre_msg_set_service_time(struct lustre_msg *msg, __u32 service_time)
1415 switch (msg->lm_magic) {
1416 case LUSTRE_MSG_MAGIC_V1:
1418 case LUSTRE_MSG_MAGIC_V2: {
1419 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1420 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1421 pb->pb_service_time = service_time;
1425 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1429 void lustre_msg_set_cksum(struct lustre_msg *msg, __u32 cksum)
1431 switch (msg->lm_magic) {
1432 case LUSTRE_MSG_MAGIC_V1:
1434 case LUSTRE_MSG_MAGIC_V2:
1435 msg->lm_cksum = cksum;
1438 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1443 void ptlrpc_request_set_replen(struct ptlrpc_request *req)
1445 int count = req_capsule_filled_sizes(&req->rq_pill, RCL_SERVER);
1447 req->rq_replen = lustre_msg_size(req->rq_reqmsg->lm_magic, count,
1448 req->rq_pill.rc_area[RCL_SERVER]);
1449 if (req->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V2)
1450 req->rq_reqmsg->lm_repsize = req->rq_replen;
1453 void ptlrpc_req_set_repsize(struct ptlrpc_request *req, int count, __u32 *lens)
1455 req->rq_replen = lustre_msg_size(req->rq_reqmsg->lm_magic, count, lens);
1456 if (req->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V2)
1457 req->rq_reqmsg->lm_repsize = req->rq_replen;
1460 /* byte flipping routines for all wire types declared in
1461 * lustre_idl.h implemented here.
1463 void lustre_swab_ptlrpc_body(struct ptlrpc_body *b)
1465 __swab32s (&b->pb_type);
1466 __swab32s (&b->pb_version);
1467 __swab32s (&b->pb_opc);
1468 __swab32s (&b->pb_status);
1469 __swab64s (&b->pb_last_xid);
1470 __swab64s (&b->pb_last_seen);
1471 __swab64s (&b->pb_last_committed);
1472 __swab64s (&b->pb_transno);
1473 __swab32s (&b->pb_flags);
1474 __swab32s (&b->pb_op_flags);
1475 __swab32s (&b->pb_conn_cnt);
1476 __swab32s (&b->pb_timeout);
1477 __swab32s (&b->pb_service_time);
1478 __swab32s (&b->pb_limit);
1479 __swab64s (&b->pb_slv);
1480 __swab64s (&b->pb_pre_versions[0]);
1481 __swab64s (&b->pb_pre_versions[1]);
1482 __swab64s (&b->pb_pre_versions[2]);
1483 __swab64s (&b->pb_pre_versions[3]);
1484 CLASSERT(offsetof(typeof(*b), pb_padding) != 0);
1487 void lustre_swab_connect(struct obd_connect_data *ocd)
1489 __swab64s(&ocd->ocd_connect_flags);
1490 __swab32s(&ocd->ocd_version);
1491 __swab32s(&ocd->ocd_grant);
1492 __swab64s(&ocd->ocd_ibits_known);
1493 __swab32s(&ocd->ocd_index);
1494 __swab32s(&ocd->ocd_brw_size);
1495 __swab32s(&ocd->ocd_nllu);
1496 __swab32s(&ocd->ocd_nllg);
1497 __swab64s(&ocd->ocd_transno);
1498 __swab32s(&ocd->ocd_group);
1499 __swab32s(&ocd->ocd_cksum_types);
1500 CLASSERT(offsetof(typeof(*ocd), padding1) != 0);
1501 CLASSERT(offsetof(typeof(*ocd), padding2) != 0);
1504 void lustre_swab_obdo (struct obdo *o)
1506 __swab64s (&o->o_valid);
1507 __swab64s (&o->o_id);
1508 __swab64s (&o->o_gr);
1509 __swab64s (&o->o_fid);
1510 __swab64s (&o->o_size);
1511 __swab64s (&o->o_mtime);
1512 __swab64s (&o->o_atime);
1513 __swab64s (&o->o_ctime);
1514 __swab64s (&o->o_blocks);
1515 __swab64s (&o->o_grant);
1516 __swab32s (&o->o_blksize);
1517 __swab32s (&o->o_mode);
1518 __swab32s (&o->o_uid);
1519 __swab32s (&o->o_gid);
1520 __swab32s (&o->o_flags);
1521 __swab32s (&o->o_nlink);
1522 __swab32s (&o->o_generation);
1523 __swab32s (&o->o_misc);
1524 __swab64s (&o->o_ioepoch);
1525 __swab32s (&o->o_stripe_idx);
1526 __swab32s (&o->o_padding_1);
1527 /* o_inline is opaque */
1530 void lustre_swab_obd_statfs (struct obd_statfs *os)
1532 __swab64s (&os->os_type);
1533 __swab64s (&os->os_blocks);
1534 __swab64s (&os->os_bfree);
1535 __swab64s (&os->os_bavail);
1536 __swab64s (&os->os_files);
1537 __swab64s (&os->os_ffree);
1538 /* no need to swab os_fsid */
1539 __swab32s (&os->os_bsize);
1540 __swab32s (&os->os_namelen);
1541 __swab64s (&os->os_maxbytes);
1542 __swab32s (&os->os_state);
1543 /* no need to swap os_spare */
1546 void lustre_swab_obd_ioobj (struct obd_ioobj *ioo)
1548 __swab64s (&ioo->ioo_id);
1549 __swab64s (&ioo->ioo_gr);
1550 __swab32s (&ioo->ioo_type);
1551 __swab32s (&ioo->ioo_bufcnt);
1554 void lustre_swab_niobuf_remote (struct niobuf_remote *nbr)
1556 __swab64s (&nbr->offset);
1557 __swab32s (&nbr->len);
1558 __swab32s (&nbr->flags);
1561 void lustre_swab_ost_body (struct ost_body *b)
1563 lustre_swab_obdo (&b->oa);
1566 void lustre_swab_ost_last_id(obd_id *id)
1571 void lustre_swab_generic_32s(__u32 *val)
1576 void lustre_swab_ost_lvb(struct ost_lvb *lvb)
1578 __swab64s(&lvb->lvb_size);
1579 __swab64s(&lvb->lvb_mtime);
1580 __swab64s(&lvb->lvb_atime);
1581 __swab64s(&lvb->lvb_ctime);
1582 __swab64s(&lvb->lvb_blocks);
1585 void lustre_swab_mds_status_req (struct mds_status_req *r)
1587 __swab32s (&r->flags);
1588 __swab32s (&r->repbuf);
1591 void lustre_swab_mds_body (struct mds_body *b)
1593 lustre_swab_ll_fid (&b->fid1);
1594 lustre_swab_ll_fid (&b->fid2);
1595 /* handle is opaque */
1596 __swab64s (&b->valid);
1597 __swab64s (&b->size);
1598 __swab64s (&b->mtime);
1599 __swab64s (&b->atime);
1600 __swab64s (&b->ctime);
1601 __swab64s (&b->blocks);
1602 __swab64s (&b->io_epoch);
1603 __swab64s (&b->ino);
1604 __swab32s (&b->fsuid);
1605 __swab32s (&b->fsgid);
1606 __swab32s (&b->capability);
1607 __swab32s (&b->mode);
1608 __swab32s (&b->uid);
1609 __swab32s (&b->gid);
1610 __swab32s (&b->flags);
1611 __swab32s (&b->rdev);
1612 __swab32s (&b->nlink);
1613 __swab32s (&b->generation);
1614 __swab32s (&b->suppgid);
1615 __swab32s (&b->eadatasize);
1616 __swab32s (&b->aclsize);
1617 __swab32s (&b->max_mdsize);
1618 __swab32s (&b->max_cookiesize);
1619 __swab32s (&b->padding_4);
1622 void lustre_swab_mdt_body (struct mdt_body *b)
1624 lustre_swab_lu_fid (&b->fid1);
1625 lustre_swab_lu_fid (&b->fid2);
1626 /* handle is opaque */
1627 __swab64s (&b->valid);
1628 __swab64s (&b->size);
1629 __swab64s (&b->mtime);
1630 __swab64s (&b->atime);
1631 __swab64s (&b->ctime);
1632 __swab64s (&b->blocks);
1633 __swab64s (&b->ioepoch);
1634 __swab64s (&b->ino);
1635 __swab32s (&b->fsuid);
1636 __swab32s (&b->fsgid);
1637 __swab32s (&b->capability);
1638 __swab32s (&b->mode);
1639 __swab32s (&b->uid);
1640 __swab32s (&b->gid);
1641 __swab32s (&b->flags);
1642 __swab32s (&b->rdev);
1643 __swab32s (&b->nlink);
1644 __swab32s (&b->generation);
1645 __swab32s (&b->suppgid);
1646 __swab32s (&b->eadatasize);
1647 __swab32s (&b->aclsize);
1648 __swab32s (&b->max_mdsize);
1649 __swab32s (&b->max_cookiesize);
1650 __swab32s (&b->padding_4);
1653 void lustre_swab_mdt_ioepoch (struct mdt_ioepoch *b)
1655 /* handle is opaque */
1656 __swab64s (&b->ioepoch);
1657 __swab32s (&b->flags);
1658 CLASSERT(offsetof(typeof(*b), padding) != 0);
1661 void lustre_swab_mgs_target_info(struct mgs_target_info *mti)
1664 __swab32s(&mti->mti_lustre_ver);
1665 __swab32s(&mti->mti_stripe_index);
1666 __swab32s(&mti->mti_config_ver);
1667 __swab32s(&mti->mti_flags);
1668 __swab32s(&mti->mti_nid_count);
1669 CLASSERT(sizeof(lnet_nid_t) == sizeof(__u64));
1670 for (i = 0; i < MTI_NIDS_MAX; i++)
1671 __swab64s(&mti->mti_nids[i]);
1674 static void lustre_swab_obd_dqinfo (struct obd_dqinfo *i)
1676 __swab64s (&i->dqi_bgrace);
1677 __swab64s (&i->dqi_igrace);
1678 __swab32s (&i->dqi_flags);
1679 __swab32s (&i->dqi_valid);
1682 static void lustre_swab_obd_dqblk (struct obd_dqblk *b)
1684 __swab64s (&b->dqb_ihardlimit);
1685 __swab64s (&b->dqb_isoftlimit);
1686 __swab64s (&b->dqb_curinodes);
1687 __swab64s (&b->dqb_bhardlimit);
1688 __swab64s (&b->dqb_bsoftlimit);
1689 __swab64s (&b->dqb_curspace);
1690 __swab64s (&b->dqb_btime);
1691 __swab64s (&b->dqb_itime);
1692 __swab32s (&b->dqb_valid);
1693 CLASSERT(offsetof(typeof(*b), padding) != 0);
1696 void lustre_swab_obd_quotactl (struct obd_quotactl *q)
1698 __swab32s (&q->qc_cmd);
1699 __swab32s (&q->qc_type);
1700 __swab32s (&q->qc_id);
1701 __swab32s (&q->qc_stat);
1702 lustre_swab_obd_dqinfo (&q->qc_dqinfo);
1703 lustre_swab_obd_dqblk (&q->qc_dqblk);
1706 void lustre_swab_quota_adjust_qunit (struct quota_adjust_qunit *q)
1708 __swab32s (&q->qaq_flags);
1709 __swab32s (&q->qaq_id);
1710 __swab64s (&q->qaq_bunit_sz);
1711 __swab64s (&q->qaq_iunit_sz);
1712 __swab64s (&q->padding1);
1715 void lustre_swab_mds_remote_perm (struct mds_remote_perm *p)
1717 __swab32s (&p->rp_uid);
1718 __swab32s (&p->rp_gid);
1719 __swab32s (&p->rp_fsuid);
1720 __swab32s (&p->rp_fsgid);
1721 __swab32s (&p->rp_access_perm);
1724 void lustre_swab_mdt_remote_perm (struct mdt_remote_perm *p)
1726 __swab32s (&p->rp_uid);
1727 __swab32s (&p->rp_gid);
1728 __swab32s (&p->rp_fsuid);
1729 __swab32s (&p->rp_fsgid);
1730 __swab32s (&p->rp_access_perm);
1733 void lustre_swab_fid2path(struct getinfo_fid2path *gf)
1735 lustre_swab_lu_fid(&gf->gf_fid);
1736 __swab64s(&gf->gf_recno);
1737 __swab32s(&gf->gf_linkno);
1738 __swab32s(&gf->gf_pathlen);
1740 EXPORT_SYMBOL(lustre_swab_fid2path);
1742 void lustre_swab_fiemap_extent(struct ll_fiemap_extent *fm_extent)
1744 __swab64s(&fm_extent->fe_logical);
1745 __swab64s(&fm_extent->fe_physical);
1746 __swab64s(&fm_extent->fe_length);
1747 __swab32s(&fm_extent->fe_flags);
1748 __swab32s(&fm_extent->fe_device);
1751 void lustre_swab_fiemap(struct ll_user_fiemap *fiemap)
1755 __swab64s(&fiemap->fm_start);
1756 __swab64s(&fiemap->fm_length);
1757 __swab32s(&fiemap->fm_flags);
1758 __swab32s(&fiemap->fm_mapped_extents);
1759 __swab32s(&fiemap->fm_extent_count);
1760 __swab32s(&fiemap->fm_reserved);
1762 for (i = 0; i < fiemap->fm_mapped_extents; i++)
1763 lustre_swab_fiemap_extent(&fiemap->fm_extents[i]);
1766 void lustre_swab_mdt_rec_reint (struct mdt_rec_reint *rr)
1768 __swab32s (&rr->rr_opcode);
1769 __swab32s (&rr->rr_cap);
1770 __swab32s (&rr->rr_fsuid);
1771 /* rr_fsuid_h is unused */
1772 __swab32s (&rr->rr_fsgid);
1773 /* rr_fsgid_h is unused */
1774 __swab32s (&rr->rr_suppgid1);
1775 /* rr_suppgid1_h is unused */
1776 __swab32s (&rr->rr_suppgid2);
1777 /* rr_suppgid2_h is unused */
1778 lustre_swab_lu_fid (&rr->rr_fid1);
1779 lustre_swab_lu_fid (&rr->rr_fid2);
1780 __swab64s (&rr->rr_mtime);
1781 __swab64s (&rr->rr_atime);
1782 __swab64s (&rr->rr_ctime);
1783 __swab64s (&rr->rr_size);
1784 __swab64s (&rr->rr_blocks);
1785 __swab32s (&rr->rr_bias);
1786 __swab32s (&rr->rr_mode);
1787 __swab32s (&rr->rr_padding_1);
1788 __swab32s (&rr->rr_padding_2);
1789 __swab32s (&rr->rr_padding_3);
1790 __swab32s (&rr->rr_padding_4);
1792 CLASSERT(offsetof(typeof(*rr), rr_padding_1) != 0);
1793 CLASSERT(offsetof(typeof(*rr), rr_padding_2) != 0);
1794 CLASSERT(offsetof(typeof(*rr), rr_padding_3) != 0);
1795 CLASSERT(offsetof(typeof(*rr), rr_padding_4) != 0);
1798 void lustre_swab_lov_desc (struct lov_desc *ld)
1800 __swab32s (&ld->ld_tgt_count);
1801 __swab32s (&ld->ld_active_tgt_count);
1802 __swab32s (&ld->ld_default_stripe_count);
1803 __swab32s (&ld->ld_pattern);
1804 __swab64s (&ld->ld_default_stripe_size);
1805 __swab64s (&ld->ld_default_stripe_offset);
1806 __swab32s (&ld->ld_qos_maxage);
1807 /* uuid endian insensitive */
1810 void lustre_swab_lmv_desc (struct lmv_desc *ld)
1812 __swab32s (&ld->ld_tgt_count);
1813 __swab32s (&ld->ld_active_tgt_count);
1814 __swab32s (&ld->ld_default_stripe_count);
1815 __swab32s (&ld->ld_pattern);
1816 __swab64s (&ld->ld_default_hash_size);
1817 __swab32s (&ld->ld_qos_maxage);
1818 /* uuid endian insensitive */
1821 void lustre_swab_lmv_stripe_md (struct lmv_stripe_md *mea)
1823 __swab32s(&mea->mea_magic);
1824 __swab32s(&mea->mea_count);
1825 __swab32s(&mea->mea_master);
1826 CLASSERT(offsetof(typeof(*mea), mea_padding) != 0);
1830 static void print_lum (struct lov_user_md *lum)
1832 CDEBUG(D_OTHER, "lov_user_md %p:\n", lum);
1833 CDEBUG(D_OTHER, "\tlmm_magic: %#x\n", lum->lmm_magic);
1834 CDEBUG(D_OTHER, "\tlmm_pattern: %#x\n", lum->lmm_pattern);
1835 CDEBUG(D_OTHER, "\tlmm_object_id: "LPU64"\n", lum->lmm_object_id);
1836 CDEBUG(D_OTHER, "\tlmm_object_gr: "LPU64"\n", lum->lmm_object_gr);
1837 CDEBUG(D_OTHER, "\tlmm_stripe_size: %#x\n", lum->lmm_stripe_size);
1838 CDEBUG(D_OTHER, "\tlmm_stripe_count: %#x\n", lum->lmm_stripe_count);
1839 CDEBUG(D_OTHER, "\tlmm_stripe_offset: %#x\n", lum->lmm_stripe_offset);
1842 static void lustre_swab_lov_user_md_common(struct lov_user_md_v1 *lum)
1845 __swab32s(&lum->lmm_magic);
1846 __swab32s(&lum->lmm_pattern);
1847 __swab64s(&lum->lmm_object_id);
1848 __swab64s(&lum->lmm_object_gr);
1849 __swab32s(&lum->lmm_stripe_size);
1850 __swab16s(&lum->lmm_stripe_count);
1851 __swab16s(&lum->lmm_stripe_offset);
1856 void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum)
1859 CDEBUG(D_IOCTL, "swabbing lov_user_md v1\n");
1860 lustre_swab_lov_user_md_common(lum);
1864 void lustre_swab_lov_user_md_v3(struct lov_user_md_v3 *lum)
1867 CDEBUG(D_IOCTL, "swabbing lov_user_md v3\n");
1868 lustre_swab_lov_user_md_common((struct lov_user_md_v1 *)lum);
1869 /* lmm_pool_name nothing to do with char */
1873 void lustre_swab_lov_mds_md(struct lov_mds_md *lmm)
1876 CDEBUG(D_IOCTL, "swabbing lov_mds_md\n");
1877 __swab32s(&lmm->lmm_magic);
1878 __swab32s(&lmm->lmm_pattern);
1879 __swab64s(&lmm->lmm_object_id);
1880 __swab64s(&lmm->lmm_object_gr);
1881 __swab32s(&lmm->lmm_stripe_size);
1882 __swab32s(&lmm->lmm_stripe_count);
1886 void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod,
1891 for (i = 0; i < stripe_count; i++) {
1892 __swab64s(&(lod[i].l_object_id));
1893 __swab64s(&(lod[i].l_object_gr));
1894 __swab32s(&(lod[i].l_ost_gen));
1895 __swab32s(&(lod[i].l_ost_idx));
1901 void lustre_swab_ldlm_res_id (struct ldlm_res_id *id)
1905 for (i = 0; i < RES_NAME_SIZE; i++)
1906 __swab64s (&id->name[i]);
1909 void lustre_swab_ldlm_policy_data (ldlm_policy_data_t *d)
1911 /* the lock data is a union and the first two fields are always an
1912 * extent so it's ok to process an LDLM_EXTENT and LDLM_FLOCK lock
1913 * data the same way. */
1914 __swab64s(&d->l_extent.start);
1915 __swab64s(&d->l_extent.end);
1916 __swab64s(&d->l_extent.gid);
1917 __swab32s(&d->l_flock.pid);
1920 void lustre_swab_ldlm_intent (struct ldlm_intent *i)
1922 __swab64s (&i->opc);
1925 void lustre_swab_ldlm_resource_desc (struct ldlm_resource_desc *r)
1927 __swab32s (&r->lr_type);
1928 CLASSERT(offsetof(typeof(*r), lr_padding) != 0);
1929 lustre_swab_ldlm_res_id (&r->lr_name);
1932 void lustre_swab_ldlm_lock_desc (struct ldlm_lock_desc *l)
1934 lustre_swab_ldlm_resource_desc (&l->l_resource);
1935 __swab32s (&l->l_req_mode);
1936 __swab32s (&l->l_granted_mode);
1937 lustre_swab_ldlm_policy_data (&l->l_policy_data);
1940 void lustre_swab_ldlm_request (struct ldlm_request *rq)
1942 __swab32s (&rq->lock_flags);
1943 lustre_swab_ldlm_lock_desc (&rq->lock_desc);
1944 __swab32s (&rq->lock_count);
1945 /* lock_handle[] opaque */
1948 void lustre_swab_ldlm_reply (struct ldlm_reply *r)
1950 __swab32s (&r->lock_flags);
1951 CLASSERT(offsetof(typeof(*r), lock_padding) != 0);
1952 lustre_swab_ldlm_lock_desc (&r->lock_desc);
1953 /* lock_handle opaque */
1954 __swab64s (&r->lock_policy_res1);
1955 __swab64s (&r->lock_policy_res2);
1958 /* no one calls this */
1959 int llog_log_swabbed(struct llog_log_hdr *hdr)
1961 if (hdr->llh_hdr.lrh_type == __swab32(LLOG_HDR_MAGIC))
1963 if (hdr->llh_hdr.lrh_type == LLOG_HDR_MAGIC)
1968 void lustre_swab_qdata(struct qunit_data *d)
1970 __swab32s (&d->qd_id);
1971 __swab32s (&d->qd_flags);
1972 __swab64s (&d->qd_count);
1973 __swab64s (&d->qd_qunit);
1974 __swab64s (&d->padding);
1977 /* Dump functions */
1978 void dump_ioo(struct obd_ioobj *ioo)
1981 "obd_ioobj: ioo_id="LPD64", ioo_gr="LPD64", ioo_type=%d, "
1982 "ioo_bufct=%d\n", ioo->ioo_id, ioo->ioo_gr, ioo->ioo_type,
1986 void dump_rniobuf(struct niobuf_remote *nb)
1988 CDEBUG(D_RPCTRACE, "niobuf_remote: offset="LPU64", len=%d, flags=%x\n",
1989 nb->offset, nb->len, nb->flags);
1992 void dump_obdo(struct obdo *oa)
1994 __u32 valid = oa->o_valid;
1996 CDEBUG(D_RPCTRACE, "obdo: o_valid = %08x\n", valid);
1997 if (valid & OBD_MD_FLID)
1998 CDEBUG(D_RPCTRACE, "obdo: o_id = "LPD64"\n", oa->o_id);
1999 if (valid & OBD_MD_FLGROUP)
2000 CDEBUG(D_RPCTRACE, "obdo: o_gr = "LPD64"\n", oa->o_gr);
2001 if (valid & OBD_MD_FLFID)
2002 CDEBUG(D_RPCTRACE, "obdo: o_fid = "LPD64"\n", oa->o_fid);
2003 if (valid & OBD_MD_FLSIZE)
2004 CDEBUG(D_RPCTRACE, "obdo: o_size = "LPD64"\n", oa->o_size);
2005 if (valid & OBD_MD_FLMTIME)
2006 CDEBUG(D_RPCTRACE, "obdo: o_mtime = "LPD64"\n", oa->o_mtime);
2007 if (valid & OBD_MD_FLATIME)
2008 CDEBUG(D_RPCTRACE, "obdo: o_atime = "LPD64"\n", oa->o_atime);
2009 if (valid & OBD_MD_FLCTIME)
2010 CDEBUG(D_RPCTRACE, "obdo: o_ctime = "LPD64"\n", oa->o_ctime);
2011 if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
2012 CDEBUG(D_RPCTRACE, "obdo: o_blocks = "LPD64"\n", oa->o_blocks);
2013 if (valid & OBD_MD_FLGRANT)
2014 CDEBUG(D_RPCTRACE, "obdo: o_grant = "LPD64"\n", oa->o_grant);
2015 if (valid & OBD_MD_FLBLKSZ)
2016 CDEBUG(D_RPCTRACE, "obdo: o_blksize = %d\n", oa->o_blksize);
2017 if (valid & (OBD_MD_FLTYPE | OBD_MD_FLMODE))
2018 CDEBUG(D_RPCTRACE, "obdo: o_mode = %o\n",
2019 oa->o_mode & ((valid & OBD_MD_FLTYPE ? S_IFMT : 0) |
2020 (valid & OBD_MD_FLMODE ? ~S_IFMT : 0)));
2021 if (valid & OBD_MD_FLUID)
2022 CDEBUG(D_RPCTRACE, "obdo: o_uid = %u\n", oa->o_uid);
2023 if (valid & OBD_MD_FLGID)
2024 CDEBUG(D_RPCTRACE, "obdo: o_gid = %u\n", oa->o_gid);
2025 if (valid & OBD_MD_FLFLAGS)
2026 CDEBUG(D_RPCTRACE, "obdo: o_flags = %x\n", oa->o_flags);
2027 if (valid & OBD_MD_FLNLINK)
2028 CDEBUG(D_RPCTRACE, "obdo: o_nlink = %u\n", oa->o_nlink);
2029 else if (valid & OBD_MD_FLCKSUM)
2030 CDEBUG(D_RPCTRACE, "obdo: o_checksum (o_nlink) = %u\n", oa->o_nlink);
2031 if (valid & OBD_MD_FLGENER)
2032 CDEBUG(D_RPCTRACE, "obdo: o_generation = %u\n",
2034 else if (valid & OBD_MD_FLEPOCH)
2035 CDEBUG(D_RPCTRACE, "obdo: o_ioepoch = "LPD64"\n", oa->o_ioepoch);
2036 if (valid & OBD_MD_FLID)
2037 CDEBUG(D_RPCTRACE, "obdo: o_stripe_idx = %u\n", oa->o_stripe_idx);
2038 if (valid & OBD_MD_FLHANDLE)
2039 CDEBUG(D_RPCTRACE, "obdo: o_handle = "LPD64"\n", oa->o_handle.cookie);
2040 if (valid & OBD_MD_FLCOOKIE)
2041 CDEBUG(D_RPCTRACE, "obdo: o_lcookie = "
2042 "(llog_cookie dumping not yet implemented)\n");
2045 void dump_ost_body(struct ost_body *ob)
2050 void dump_rcs(__u32 *rc)
2052 CDEBUG(D_RPCTRACE, "rmf_rcs: %d\n", *rc);
2058 * got qdata from request(req/rep)
2060 struct qunit_data *quota_get_qdata(void *r, int is_req, int is_exp)
2062 struct ptlrpc_request *req = (struct ptlrpc_request *)r;
2063 struct qunit_data *qdata;
2064 __u64 flags = is_exp ? req->rq_export->exp_connect_flags :
2065 req->rq_import->imp_connect_data.ocd_connect_flags;
2068 /* support for quota64 */
2069 LASSERT(flags & OBD_CONNECT_QUOTA64);
2070 /* support for change_qs */
2071 LASSERT(flags & OBD_CONNECT_CHANGE_QS);
2073 if (is_req == QUOTA_REQUEST)
2074 qdata = req_capsule_client_get(&req->rq_pill, &RMF_QUNIT_DATA);
2076 qdata = req_capsule_server_get(&req->rq_pill, &RMF_QUNIT_DATA);
2078 return ERR_PTR(-EPROTO);
2080 QDATA_SET_CHANGE_QS(qdata);
2083 EXPORT_SYMBOL(quota_get_qdata);
2086 * copy qdata to request(req/rep)
2088 int quota_copy_qdata(void *r, struct qunit_data *qdata, int is_req,
2091 struct ptlrpc_request *req = (struct ptlrpc_request *)r;
2093 __u64 flags = is_exp ? req->rq_export->exp_connect_flags :
2094 req->rq_import->imp_connect_data.ocd_connect_flags;
2098 /* support for quota64 */
2099 LASSERT(flags & OBD_CONNECT_QUOTA64);
2100 /* support for change_qs */
2101 LASSERT(flags & OBD_CONNECT_CHANGE_QS);
2103 if (is_req == QUOTA_REQUEST)
2104 target = req_capsule_client_get(&req->rq_pill, &RMF_QUNIT_DATA);
2106 target = req_capsule_server_get(&req->rq_pill, &RMF_QUNIT_DATA);
2110 LASSERT(target != qdata);
2111 memcpy(target, qdata, sizeof(*qdata));
2114 EXPORT_SYMBOL(quota_copy_qdata);
2115 #endif /* __KERNEL__ */
2117 static inline int req_ptlrpc_body_swabbed(struct ptlrpc_request *req)
2119 LASSERT(req->rq_reqmsg);
2121 switch (req->rq_reqmsg->lm_magic) {
2122 case LUSTRE_MSG_MAGIC_V2:
2123 return lustre_req_swabbed(req, MSG_PTLRPC_BODY_OFF);
2125 CERROR("bad lustre msg magic: %#08X\n",
2126 req->rq_reqmsg->lm_magic);
2131 static inline int rep_ptlrpc_body_swabbed(struct ptlrpc_request *req)
2133 LASSERT(req->rq_repmsg);
2135 switch (req->rq_repmsg->lm_magic) {
2136 case LUSTRE_MSG_MAGIC_V2:
2137 return lustre_rep_swabbed(req, MSG_PTLRPC_BODY_OFF);
2139 /* uninitialized yet */
2144 void _debug_req(struct ptlrpc_request *req, __u32 mask,
2145 struct libcfs_debug_msg_data *data, const char *fmt, ... )
2148 va_start(args, fmt);
2149 libcfs_debug_vmsg2(data->msg_cdls, data->msg_subsys, mask, data->msg_file,
2150 data->msg_fn, data->msg_line, fmt, args,
2151 " req@%p x"LPU64"/t"LPD64"("LPD64") o%d->%s@%s:%d/%d"
2152 " lens %d/%d e %d to %d dl "CFS_TIME_T" ref %d "
2153 "fl "REQ_FLAGS_FMT"/%x/%x rc %d/%d\n",
2154 req, req->rq_xid, req->rq_transno,
2155 req->rq_reqmsg ? lustre_msg_get_transno(req->rq_reqmsg) : 0,
2156 req->rq_reqmsg ? lustre_msg_get_opc(req->rq_reqmsg) : -1,
2157 req->rq_import ? obd2cli_tgt(req->rq_import->imp_obd) :
2159 (char*)req->rq_export->exp_client_uuid.uuid : "<?>",
2161 (char *)req->rq_import->imp_connection->c_remote_uuid.uuid :
2163 (char *)req->rq_export->exp_connection->c_remote_uuid.uuid : "<?>",
2164 req->rq_request_portal, req->rq_reply_portal,
2165 req->rq_reqlen, req->rq_replen,
2166 req->rq_early_count, req->rq_timedout,
2168 cfs_atomic_read(&req->rq_refcount),
2169 DEBUG_REQ_FLAGS(req),
2170 req->rq_reqmsg && req_ptlrpc_body_swabbed(req) ?
2171 lustre_msg_get_flags(req->rq_reqmsg) : -1,
2172 req->rq_repmsg && rep_ptlrpc_body_swabbed(req) ?
2173 lustre_msg_get_flags(req->rq_repmsg) : -1,
2175 req->rq_repmsg && rep_ptlrpc_body_swabbed(req) ?
2176 lustre_msg_get_status(req->rq_repmsg) : -1);
2178 EXPORT_SYMBOL(_debug_req);
2180 void lustre_swab_lustre_capa(struct lustre_capa *c)
2182 lustre_swab_lu_fid(&c->lc_fid);
2183 __swab64s (&c->lc_opc);
2184 __swab64s (&c->lc_uid);
2185 __swab64s (&c->lc_gid);
2186 __swab32s (&c->lc_flags);
2187 __swab32s (&c->lc_keyid);
2188 __swab32s (&c->lc_timeout);
2189 __swab32s (&c->lc_expiry);
2192 void lustre_swab_lustre_capa_key(struct lustre_capa_key *k)
2194 __swab64s (&k->lk_mdsid);
2195 __swab32s (&k->lk_keyid);
2196 __swab32s (&k->lk_padding);
2199 void lustre_swab_lnlh(struct lnl_hdr *l)
2201 __swab16s(&l->lnl_magic);
2202 /* __u8 l->lnl_transport */
2203 __swab16s(&l->lnl_msgtype);
2204 __swab16s(&l->lnl_msglen);
2206 EXPORT_SYMBOL(lustre_swab_lnlh);