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;
1461 * Send a remote set_info_async.
1463 * This may go from client to server or server to client.
1465 int do_set_info_async(struct obd_import *imp,
1466 int opcode, int version,
1467 obd_count keylen, void *key,
1468 obd_count vallen, void *val,
1469 struct ptlrpc_request_set *set)
1471 struct ptlrpc_request *req;
1476 req = ptlrpc_request_alloc(imp, &RQF_OBD_SET_INFO);
1480 req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY,
1481 RCL_CLIENT, keylen);
1482 req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_VAL,
1483 RCL_CLIENT, vallen);
1484 rc = ptlrpc_request_pack(req, version, opcode);
1486 ptlrpc_request_free(req);
1490 tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY);
1491 memcpy(tmp, key, keylen);
1492 tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_VAL);
1493 memcpy(tmp, val, vallen);
1495 ptlrpc_request_set_replen(req);
1498 ptlrpc_set_add_req(set, req);
1499 ptlrpc_check_set(NULL, set);
1501 rc = ptlrpc_queue_wait(req);
1502 ptlrpc_req_finished(req);
1507 EXPORT_SYMBOL(do_set_info_async);
1509 /* byte flipping routines for all wire types declared in
1510 * lustre_idl.h implemented here.
1512 void lustre_swab_ptlrpc_body(struct ptlrpc_body *b)
1514 __swab32s (&b->pb_type);
1515 __swab32s (&b->pb_version);
1516 __swab32s (&b->pb_opc);
1517 __swab32s (&b->pb_status);
1518 __swab64s (&b->pb_last_xid);
1519 __swab64s (&b->pb_last_seen);
1520 __swab64s (&b->pb_last_committed);
1521 __swab64s (&b->pb_transno);
1522 __swab32s (&b->pb_flags);
1523 __swab32s (&b->pb_op_flags);
1524 __swab32s (&b->pb_conn_cnt);
1525 __swab32s (&b->pb_timeout);
1526 __swab32s (&b->pb_service_time);
1527 __swab32s (&b->pb_limit);
1528 __swab64s (&b->pb_slv);
1529 __swab64s (&b->pb_pre_versions[0]);
1530 __swab64s (&b->pb_pre_versions[1]);
1531 __swab64s (&b->pb_pre_versions[2]);
1532 __swab64s (&b->pb_pre_versions[3]);
1533 CLASSERT(offsetof(typeof(*b), pb_padding) != 0);
1536 void lustre_swab_connect(struct obd_connect_data *ocd)
1538 __swab64s(&ocd->ocd_connect_flags);
1539 __swab32s(&ocd->ocd_version);
1540 __swab32s(&ocd->ocd_grant);
1541 __swab64s(&ocd->ocd_ibits_known);
1542 __swab32s(&ocd->ocd_index);
1543 __swab32s(&ocd->ocd_brw_size);
1544 __swab32s(&ocd->ocd_nllu);
1545 __swab32s(&ocd->ocd_nllg);
1546 __swab64s(&ocd->ocd_transno);
1547 __swab32s(&ocd->ocd_group);
1548 __swab32s(&ocd->ocd_cksum_types);
1549 CLASSERT(offsetof(typeof(*ocd), padding1) != 0);
1550 CLASSERT(offsetof(typeof(*ocd), padding2) != 0);
1553 void lustre_swab_obdo (struct obdo *o)
1555 __swab64s (&o->o_valid);
1556 __swab64s (&o->o_id);
1557 __swab64s (&o->o_gr);
1558 __swab64s (&o->o_fid);
1559 __swab64s (&o->o_size);
1560 __swab64s (&o->o_mtime);
1561 __swab64s (&o->o_atime);
1562 __swab64s (&o->o_ctime);
1563 __swab64s (&o->o_blocks);
1564 __swab64s (&o->o_grant);
1565 __swab32s (&o->o_blksize);
1566 __swab32s (&o->o_mode);
1567 __swab32s (&o->o_uid);
1568 __swab32s (&o->o_gid);
1569 __swab32s (&o->o_flags);
1570 __swab32s (&o->o_nlink);
1571 __swab32s (&o->o_generation);
1572 __swab32s (&o->o_misc);
1573 __swab64s (&o->o_ioepoch);
1574 __swab32s (&o->o_stripe_idx);
1575 __swab32s (&o->o_padding_1);
1576 /* o_inline is opaque */
1579 void lustre_swab_obd_statfs (struct obd_statfs *os)
1581 __swab64s (&os->os_type);
1582 __swab64s (&os->os_blocks);
1583 __swab64s (&os->os_bfree);
1584 __swab64s (&os->os_bavail);
1585 __swab64s (&os->os_files);
1586 __swab64s (&os->os_ffree);
1587 /* no need to swab os_fsid */
1588 __swab32s (&os->os_bsize);
1589 __swab32s (&os->os_namelen);
1590 __swab64s (&os->os_maxbytes);
1591 __swab32s (&os->os_state);
1592 /* no need to swap os_spare */
1595 void lustre_swab_obd_ioobj (struct obd_ioobj *ioo)
1597 __swab64s (&ioo->ioo_id);
1598 __swab64s (&ioo->ioo_gr);
1599 __swab32s (&ioo->ioo_type);
1600 __swab32s (&ioo->ioo_bufcnt);
1603 void lustre_swab_niobuf_remote (struct niobuf_remote *nbr)
1605 __swab64s (&nbr->offset);
1606 __swab32s (&nbr->len);
1607 __swab32s (&nbr->flags);
1610 void lustre_swab_ost_body (struct ost_body *b)
1612 lustre_swab_obdo (&b->oa);
1615 void lustre_swab_ost_last_id(obd_id *id)
1620 void lustre_swab_generic_32s(__u32 *val)
1625 void lustre_swab_ost_lvb(struct ost_lvb *lvb)
1627 __swab64s(&lvb->lvb_size);
1628 __swab64s(&lvb->lvb_mtime);
1629 __swab64s(&lvb->lvb_atime);
1630 __swab64s(&lvb->lvb_ctime);
1631 __swab64s(&lvb->lvb_blocks);
1634 void lustre_swab_mds_status_req (struct mds_status_req *r)
1636 __swab32s (&r->flags);
1637 __swab32s (&r->repbuf);
1640 void lustre_swab_mds_body (struct mds_body *b)
1642 lustre_swab_ll_fid (&b->fid1);
1643 lustre_swab_ll_fid (&b->fid2);
1644 /* handle is opaque */
1645 __swab64s (&b->valid);
1646 __swab64s (&b->size);
1647 __swab64s (&b->mtime);
1648 __swab64s (&b->atime);
1649 __swab64s (&b->ctime);
1650 __swab64s (&b->blocks);
1651 __swab64s (&b->io_epoch);
1652 __swab64s (&b->ino);
1653 __swab32s (&b->fsuid);
1654 __swab32s (&b->fsgid);
1655 __swab32s (&b->capability);
1656 __swab32s (&b->mode);
1657 __swab32s (&b->uid);
1658 __swab32s (&b->gid);
1659 __swab32s (&b->flags);
1660 __swab32s (&b->rdev);
1661 __swab32s (&b->nlink);
1662 __swab32s (&b->generation);
1663 __swab32s (&b->suppgid);
1664 __swab32s (&b->eadatasize);
1665 __swab32s (&b->aclsize);
1666 __swab32s (&b->max_mdsize);
1667 __swab32s (&b->max_cookiesize);
1668 __swab32s (&b->padding_4);
1671 void lustre_swab_mdt_body (struct mdt_body *b)
1673 lustre_swab_lu_fid (&b->fid1);
1674 lustre_swab_lu_fid (&b->fid2);
1675 /* handle is opaque */
1676 __swab64s (&b->valid);
1677 __swab64s (&b->size);
1678 __swab64s (&b->mtime);
1679 __swab64s (&b->atime);
1680 __swab64s (&b->ctime);
1681 __swab64s (&b->blocks);
1682 __swab64s (&b->ioepoch);
1683 __swab64s (&b->ino);
1684 __swab32s (&b->fsuid);
1685 __swab32s (&b->fsgid);
1686 __swab32s (&b->capability);
1687 __swab32s (&b->mode);
1688 __swab32s (&b->uid);
1689 __swab32s (&b->gid);
1690 __swab32s (&b->flags);
1691 __swab32s (&b->rdev);
1692 __swab32s (&b->nlink);
1693 __swab32s (&b->generation);
1694 __swab32s (&b->suppgid);
1695 __swab32s (&b->eadatasize);
1696 __swab32s (&b->aclsize);
1697 __swab32s (&b->max_mdsize);
1698 __swab32s (&b->max_cookiesize);
1699 __swab32s (&b->padding_4);
1702 void lustre_swab_mdt_ioepoch (struct mdt_ioepoch *b)
1704 /* handle is opaque */
1705 __swab64s (&b->ioepoch);
1706 __swab32s (&b->flags);
1707 CLASSERT(offsetof(typeof(*b), padding) != 0);
1710 void lustre_swab_mgs_target_info(struct mgs_target_info *mti)
1713 __swab32s(&mti->mti_lustre_ver);
1714 __swab32s(&mti->mti_stripe_index);
1715 __swab32s(&mti->mti_config_ver);
1716 __swab32s(&mti->mti_flags);
1717 __swab32s(&mti->mti_nid_count);
1718 CLASSERT(sizeof(lnet_nid_t) == sizeof(__u64));
1719 for (i = 0; i < MTI_NIDS_MAX; i++)
1720 __swab64s(&mti->mti_nids[i]);
1723 static void lustre_swab_obd_dqinfo (struct obd_dqinfo *i)
1725 __swab64s (&i->dqi_bgrace);
1726 __swab64s (&i->dqi_igrace);
1727 __swab32s (&i->dqi_flags);
1728 __swab32s (&i->dqi_valid);
1731 static void lustre_swab_obd_dqblk (struct obd_dqblk *b)
1733 __swab64s (&b->dqb_ihardlimit);
1734 __swab64s (&b->dqb_isoftlimit);
1735 __swab64s (&b->dqb_curinodes);
1736 __swab64s (&b->dqb_bhardlimit);
1737 __swab64s (&b->dqb_bsoftlimit);
1738 __swab64s (&b->dqb_curspace);
1739 __swab64s (&b->dqb_btime);
1740 __swab64s (&b->dqb_itime);
1741 __swab32s (&b->dqb_valid);
1742 CLASSERT(offsetof(typeof(*b), padding) != 0);
1745 void lustre_swab_obd_quotactl (struct obd_quotactl *q)
1747 __swab32s (&q->qc_cmd);
1748 __swab32s (&q->qc_type);
1749 __swab32s (&q->qc_id);
1750 __swab32s (&q->qc_stat);
1751 lustre_swab_obd_dqinfo (&q->qc_dqinfo);
1752 lustre_swab_obd_dqblk (&q->qc_dqblk);
1755 void lustre_swab_quota_adjust_qunit (struct quota_adjust_qunit *q)
1757 __swab32s (&q->qaq_flags);
1758 __swab32s (&q->qaq_id);
1759 __swab64s (&q->qaq_bunit_sz);
1760 __swab64s (&q->qaq_iunit_sz);
1761 __swab64s (&q->padding1);
1764 void lustre_swab_mds_remote_perm (struct mds_remote_perm *p)
1766 __swab32s (&p->rp_uid);
1767 __swab32s (&p->rp_gid);
1768 __swab32s (&p->rp_fsuid);
1769 __swab32s (&p->rp_fsgid);
1770 __swab32s (&p->rp_access_perm);
1773 void lustre_swab_mdt_remote_perm (struct mdt_remote_perm *p)
1775 __swab32s (&p->rp_uid);
1776 __swab32s (&p->rp_gid);
1777 __swab32s (&p->rp_fsuid);
1778 __swab32s (&p->rp_fsgid);
1779 __swab32s (&p->rp_access_perm);
1782 void lustre_swab_fid2path(struct getinfo_fid2path *gf)
1784 lustre_swab_lu_fid(&gf->gf_fid);
1785 __swab64s(&gf->gf_recno);
1786 __swab32s(&gf->gf_linkno);
1787 __swab32s(&gf->gf_pathlen);
1789 EXPORT_SYMBOL(lustre_swab_fid2path);
1791 void lustre_swab_fiemap_extent(struct ll_fiemap_extent *fm_extent)
1793 __swab64s(&fm_extent->fe_logical);
1794 __swab64s(&fm_extent->fe_physical);
1795 __swab64s(&fm_extent->fe_length);
1796 __swab32s(&fm_extent->fe_flags);
1797 __swab32s(&fm_extent->fe_device);
1800 void lustre_swab_fiemap(struct ll_user_fiemap *fiemap)
1804 __swab64s(&fiemap->fm_start);
1805 __swab64s(&fiemap->fm_length);
1806 __swab32s(&fiemap->fm_flags);
1807 __swab32s(&fiemap->fm_mapped_extents);
1808 __swab32s(&fiemap->fm_extent_count);
1809 __swab32s(&fiemap->fm_reserved);
1811 for (i = 0; i < fiemap->fm_mapped_extents; i++)
1812 lustre_swab_fiemap_extent(&fiemap->fm_extents[i]);
1815 void lustre_swab_mdt_rec_reint (struct mdt_rec_reint *rr)
1817 __swab32s (&rr->rr_opcode);
1818 __swab32s (&rr->rr_cap);
1819 __swab32s (&rr->rr_fsuid);
1820 /* rr_fsuid_h is unused */
1821 __swab32s (&rr->rr_fsgid);
1822 /* rr_fsgid_h is unused */
1823 __swab32s (&rr->rr_suppgid1);
1824 /* rr_suppgid1_h is unused */
1825 __swab32s (&rr->rr_suppgid2);
1826 /* rr_suppgid2_h is unused */
1827 lustre_swab_lu_fid (&rr->rr_fid1);
1828 lustre_swab_lu_fid (&rr->rr_fid2);
1829 __swab64s (&rr->rr_mtime);
1830 __swab64s (&rr->rr_atime);
1831 __swab64s (&rr->rr_ctime);
1832 __swab64s (&rr->rr_size);
1833 __swab64s (&rr->rr_blocks);
1834 __swab32s (&rr->rr_bias);
1835 __swab32s (&rr->rr_mode);
1836 __swab32s (&rr->rr_padding_1);
1837 __swab32s (&rr->rr_padding_2);
1838 __swab32s (&rr->rr_padding_3);
1839 __swab32s (&rr->rr_padding_4);
1841 CLASSERT(offsetof(typeof(*rr), rr_padding_1) != 0);
1842 CLASSERT(offsetof(typeof(*rr), rr_padding_2) != 0);
1843 CLASSERT(offsetof(typeof(*rr), rr_padding_3) != 0);
1844 CLASSERT(offsetof(typeof(*rr), rr_padding_4) != 0);
1847 void lustre_swab_lov_desc (struct lov_desc *ld)
1849 __swab32s (&ld->ld_tgt_count);
1850 __swab32s (&ld->ld_active_tgt_count);
1851 __swab32s (&ld->ld_default_stripe_count);
1852 __swab32s (&ld->ld_pattern);
1853 __swab64s (&ld->ld_default_stripe_size);
1854 __swab64s (&ld->ld_default_stripe_offset);
1855 __swab32s (&ld->ld_qos_maxage);
1856 /* uuid endian insensitive */
1859 void lustre_swab_lmv_desc (struct lmv_desc *ld)
1861 __swab32s (&ld->ld_tgt_count);
1862 __swab32s (&ld->ld_active_tgt_count);
1863 __swab32s (&ld->ld_default_stripe_count);
1864 __swab32s (&ld->ld_pattern);
1865 __swab64s (&ld->ld_default_hash_size);
1866 __swab32s (&ld->ld_qos_maxage);
1867 /* uuid endian insensitive */
1870 void lustre_swab_lmv_stripe_md (struct lmv_stripe_md *mea)
1872 __swab32s(&mea->mea_magic);
1873 __swab32s(&mea->mea_count);
1874 __swab32s(&mea->mea_master);
1875 CLASSERT(offsetof(typeof(*mea), mea_padding) != 0);
1879 static void print_lum (struct lov_user_md *lum)
1881 CDEBUG(D_OTHER, "lov_user_md %p:\n", lum);
1882 CDEBUG(D_OTHER, "\tlmm_magic: %#x\n", lum->lmm_magic);
1883 CDEBUG(D_OTHER, "\tlmm_pattern: %#x\n", lum->lmm_pattern);
1884 CDEBUG(D_OTHER, "\tlmm_object_id: "LPU64"\n", lum->lmm_object_id);
1885 CDEBUG(D_OTHER, "\tlmm_object_gr: "LPU64"\n", lum->lmm_object_gr);
1886 CDEBUG(D_OTHER, "\tlmm_stripe_size: %#x\n", lum->lmm_stripe_size);
1887 CDEBUG(D_OTHER, "\tlmm_stripe_count: %#x\n", lum->lmm_stripe_count);
1888 CDEBUG(D_OTHER, "\tlmm_stripe_offset: %#x\n", lum->lmm_stripe_offset);
1891 static void lustre_swab_lov_user_md_common(struct lov_user_md_v1 *lum)
1894 __swab32s(&lum->lmm_magic);
1895 __swab32s(&lum->lmm_pattern);
1896 __swab64s(&lum->lmm_object_id);
1897 __swab64s(&lum->lmm_object_gr);
1898 __swab32s(&lum->lmm_stripe_size);
1899 __swab16s(&lum->lmm_stripe_count);
1900 __swab16s(&lum->lmm_stripe_offset);
1905 void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum)
1908 CDEBUG(D_IOCTL, "swabbing lov_user_md v1\n");
1909 lustre_swab_lov_user_md_common(lum);
1913 void lustre_swab_lov_user_md_v3(struct lov_user_md_v3 *lum)
1916 CDEBUG(D_IOCTL, "swabbing lov_user_md v3\n");
1917 lustre_swab_lov_user_md_common((struct lov_user_md_v1 *)lum);
1918 /* lmm_pool_name nothing to do with char */
1922 void lustre_swab_lov_mds_md(struct lov_mds_md *lmm)
1925 CDEBUG(D_IOCTL, "swabbing lov_mds_md\n");
1926 __swab32s(&lmm->lmm_magic);
1927 __swab32s(&lmm->lmm_pattern);
1928 __swab64s(&lmm->lmm_object_id);
1929 __swab64s(&lmm->lmm_object_gr);
1930 __swab32s(&lmm->lmm_stripe_size);
1931 __swab32s(&lmm->lmm_stripe_count);
1935 void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod,
1940 for (i = 0; i < stripe_count; i++) {
1941 __swab64s(&(lod[i].l_object_id));
1942 __swab64s(&(lod[i].l_object_gr));
1943 __swab32s(&(lod[i].l_ost_gen));
1944 __swab32s(&(lod[i].l_ost_idx));
1950 void lustre_swab_ldlm_res_id (struct ldlm_res_id *id)
1954 for (i = 0; i < RES_NAME_SIZE; i++)
1955 __swab64s (&id->name[i]);
1958 void lustre_swab_ldlm_policy_data (ldlm_policy_data_t *d)
1960 /* the lock data is a union and the first two fields are always an
1961 * extent so it's ok to process an LDLM_EXTENT and LDLM_FLOCK lock
1962 * data the same way. */
1963 __swab64s(&d->l_extent.start);
1964 __swab64s(&d->l_extent.end);
1965 __swab64s(&d->l_extent.gid);
1966 __swab32s(&d->l_flock.pid);
1969 void lustre_swab_ldlm_intent (struct ldlm_intent *i)
1971 __swab64s (&i->opc);
1974 void lustre_swab_ldlm_resource_desc (struct ldlm_resource_desc *r)
1976 __swab32s (&r->lr_type);
1977 CLASSERT(offsetof(typeof(*r), lr_padding) != 0);
1978 lustre_swab_ldlm_res_id (&r->lr_name);
1981 void lustre_swab_ldlm_lock_desc (struct ldlm_lock_desc *l)
1983 lustre_swab_ldlm_resource_desc (&l->l_resource);
1984 __swab32s (&l->l_req_mode);
1985 __swab32s (&l->l_granted_mode);
1986 lustre_swab_ldlm_policy_data (&l->l_policy_data);
1989 void lustre_swab_ldlm_request (struct ldlm_request *rq)
1991 __swab32s (&rq->lock_flags);
1992 lustre_swab_ldlm_lock_desc (&rq->lock_desc);
1993 __swab32s (&rq->lock_count);
1994 /* lock_handle[] opaque */
1997 void lustre_swab_ldlm_reply (struct ldlm_reply *r)
1999 __swab32s (&r->lock_flags);
2000 CLASSERT(offsetof(typeof(*r), lock_padding) != 0);
2001 lustre_swab_ldlm_lock_desc (&r->lock_desc);
2002 /* lock_handle opaque */
2003 __swab64s (&r->lock_policy_res1);
2004 __swab64s (&r->lock_policy_res2);
2007 /* no one calls this */
2008 int llog_log_swabbed(struct llog_log_hdr *hdr)
2010 if (hdr->llh_hdr.lrh_type == __swab32(LLOG_HDR_MAGIC))
2012 if (hdr->llh_hdr.lrh_type == LLOG_HDR_MAGIC)
2017 void lustre_swab_qdata(struct qunit_data *d)
2019 __swab32s (&d->qd_id);
2020 __swab32s (&d->qd_flags);
2021 __swab64s (&d->qd_count);
2022 __swab64s (&d->qd_qunit);
2023 __swab64s (&d->padding);
2026 /* Dump functions */
2027 void dump_ioo(struct obd_ioobj *ioo)
2030 "obd_ioobj: ioo_id="LPD64", ioo_gr="LPD64", ioo_type=%d, "
2031 "ioo_bufct=%d\n", ioo->ioo_id, ioo->ioo_gr, ioo->ioo_type,
2035 void dump_rniobuf(struct niobuf_remote *nb)
2037 CDEBUG(D_RPCTRACE, "niobuf_remote: offset="LPU64", len=%d, flags=%x\n",
2038 nb->offset, nb->len, nb->flags);
2041 void dump_obdo(struct obdo *oa)
2043 __u32 valid = oa->o_valid;
2045 CDEBUG(D_RPCTRACE, "obdo: o_valid = %08x\n", valid);
2046 if (valid & OBD_MD_FLID)
2047 CDEBUG(D_RPCTRACE, "obdo: o_id = "LPD64"\n", oa->o_id);
2048 if (valid & OBD_MD_FLGROUP)
2049 CDEBUG(D_RPCTRACE, "obdo: o_gr = "LPD64"\n", oa->o_gr);
2050 if (valid & OBD_MD_FLFID)
2051 CDEBUG(D_RPCTRACE, "obdo: o_fid = "LPD64"\n", oa->o_fid);
2052 if (valid & OBD_MD_FLSIZE)
2053 CDEBUG(D_RPCTRACE, "obdo: o_size = "LPD64"\n", oa->o_size);
2054 if (valid & OBD_MD_FLMTIME)
2055 CDEBUG(D_RPCTRACE, "obdo: o_mtime = "LPD64"\n", oa->o_mtime);
2056 if (valid & OBD_MD_FLATIME)
2057 CDEBUG(D_RPCTRACE, "obdo: o_atime = "LPD64"\n", oa->o_atime);
2058 if (valid & OBD_MD_FLCTIME)
2059 CDEBUG(D_RPCTRACE, "obdo: o_ctime = "LPD64"\n", oa->o_ctime);
2060 if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
2061 CDEBUG(D_RPCTRACE, "obdo: o_blocks = "LPD64"\n", oa->o_blocks);
2062 if (valid & OBD_MD_FLGRANT)
2063 CDEBUG(D_RPCTRACE, "obdo: o_grant = "LPD64"\n", oa->o_grant);
2064 if (valid & OBD_MD_FLBLKSZ)
2065 CDEBUG(D_RPCTRACE, "obdo: o_blksize = %d\n", oa->o_blksize);
2066 if (valid & (OBD_MD_FLTYPE | OBD_MD_FLMODE))
2067 CDEBUG(D_RPCTRACE, "obdo: o_mode = %o\n",
2068 oa->o_mode & ((valid & OBD_MD_FLTYPE ? S_IFMT : 0) |
2069 (valid & OBD_MD_FLMODE ? ~S_IFMT : 0)));
2070 if (valid & OBD_MD_FLUID)
2071 CDEBUG(D_RPCTRACE, "obdo: o_uid = %u\n", oa->o_uid);
2072 if (valid & OBD_MD_FLGID)
2073 CDEBUG(D_RPCTRACE, "obdo: o_gid = %u\n", oa->o_gid);
2074 if (valid & OBD_MD_FLFLAGS)
2075 CDEBUG(D_RPCTRACE, "obdo: o_flags = %x\n", oa->o_flags);
2076 if (valid & OBD_MD_FLNLINK)
2077 CDEBUG(D_RPCTRACE, "obdo: o_nlink = %u\n", oa->o_nlink);
2078 else if (valid & OBD_MD_FLCKSUM)
2079 CDEBUG(D_RPCTRACE, "obdo: o_checksum (o_nlink) = %u\n", oa->o_nlink);
2080 if (valid & OBD_MD_FLGENER)
2081 CDEBUG(D_RPCTRACE, "obdo: o_generation = %u\n",
2083 else if (valid & OBD_MD_FLEPOCH)
2084 CDEBUG(D_RPCTRACE, "obdo: o_ioepoch = "LPD64"\n", oa->o_ioepoch);
2085 if (valid & OBD_MD_FLID)
2086 CDEBUG(D_RPCTRACE, "obdo: o_stripe_idx = %u\n", oa->o_stripe_idx);
2087 if (valid & OBD_MD_FLHANDLE)
2088 CDEBUG(D_RPCTRACE, "obdo: o_handle = "LPD64"\n", oa->o_handle.cookie);
2089 if (valid & OBD_MD_FLCOOKIE)
2090 CDEBUG(D_RPCTRACE, "obdo: o_lcookie = "
2091 "(llog_cookie dumping not yet implemented)\n");
2094 void dump_ost_body(struct ost_body *ob)
2099 void dump_rcs(__u32 *rc)
2101 CDEBUG(D_RPCTRACE, "rmf_rcs: %d\n", *rc);
2107 * got qdata from request(req/rep)
2109 struct qunit_data *quota_get_qdata(void *r, int is_req, int is_exp)
2111 struct ptlrpc_request *req = (struct ptlrpc_request *)r;
2112 struct qunit_data *qdata;
2113 __u64 flags = is_exp ? req->rq_export->exp_connect_flags :
2114 req->rq_import->imp_connect_data.ocd_connect_flags;
2117 /* support for quota64 */
2118 LASSERT(flags & OBD_CONNECT_QUOTA64);
2119 /* support for change_qs */
2120 LASSERT(flags & OBD_CONNECT_CHANGE_QS);
2122 if (is_req == QUOTA_REQUEST)
2123 qdata = req_capsule_client_get(&req->rq_pill, &RMF_QUNIT_DATA);
2125 qdata = req_capsule_server_get(&req->rq_pill, &RMF_QUNIT_DATA);
2127 return ERR_PTR(-EPROTO);
2129 QDATA_SET_CHANGE_QS(qdata);
2132 EXPORT_SYMBOL(quota_get_qdata);
2135 * copy qdata to request(req/rep)
2137 int quota_copy_qdata(void *r, struct qunit_data *qdata, int is_req,
2140 struct ptlrpc_request *req = (struct ptlrpc_request *)r;
2142 __u64 flags = is_exp ? req->rq_export->exp_connect_flags :
2143 req->rq_import->imp_connect_data.ocd_connect_flags;
2147 /* support for quota64 */
2148 LASSERT(flags & OBD_CONNECT_QUOTA64);
2149 /* support for change_qs */
2150 LASSERT(flags & OBD_CONNECT_CHANGE_QS);
2152 if (is_req == QUOTA_REQUEST)
2153 target = req_capsule_client_get(&req->rq_pill, &RMF_QUNIT_DATA);
2155 target = req_capsule_server_get(&req->rq_pill, &RMF_QUNIT_DATA);
2159 LASSERT(target != qdata);
2160 memcpy(target, qdata, sizeof(*qdata));
2163 EXPORT_SYMBOL(quota_copy_qdata);
2164 #endif /* __KERNEL__ */
2166 static inline int req_ptlrpc_body_swabbed(struct ptlrpc_request *req)
2168 LASSERT(req->rq_reqmsg);
2170 switch (req->rq_reqmsg->lm_magic) {
2171 case LUSTRE_MSG_MAGIC_V2:
2172 return lustre_req_swabbed(req, MSG_PTLRPC_BODY_OFF);
2174 CERROR("bad lustre msg magic: %#08X\n",
2175 req->rq_reqmsg->lm_magic);
2180 static inline int rep_ptlrpc_body_swabbed(struct ptlrpc_request *req)
2182 LASSERT(req->rq_repmsg);
2184 switch (req->rq_repmsg->lm_magic) {
2185 case LUSTRE_MSG_MAGIC_V2:
2186 return lustre_rep_swabbed(req, MSG_PTLRPC_BODY_OFF);
2188 /* uninitialized yet */
2193 void _debug_req(struct ptlrpc_request *req, __u32 mask,
2194 struct libcfs_debug_msg_data *data, const char *fmt, ... )
2197 va_start(args, fmt);
2198 libcfs_debug_vmsg2(data->msg_cdls, data->msg_subsys, mask, data->msg_file,
2199 data->msg_fn, data->msg_line, fmt, args,
2200 " req@%p x"LPU64"/t"LPD64"("LPD64") o%d->%s@%s:%d/%d"
2201 " lens %d/%d e %d to %d dl "CFS_TIME_T" ref %d "
2202 "fl "REQ_FLAGS_FMT"/%x/%x rc %d/%d\n",
2203 req, req->rq_xid, req->rq_transno,
2204 req->rq_reqmsg ? lustre_msg_get_transno(req->rq_reqmsg) : 0,
2205 req->rq_reqmsg ? lustre_msg_get_opc(req->rq_reqmsg) : -1,
2206 req->rq_import ? obd2cli_tgt(req->rq_import->imp_obd) :
2208 (char*)req->rq_export->exp_client_uuid.uuid : "<?>",
2210 (char *)req->rq_import->imp_connection->c_remote_uuid.uuid :
2212 (char *)req->rq_export->exp_connection->c_remote_uuid.uuid : "<?>",
2213 req->rq_request_portal, req->rq_reply_portal,
2214 req->rq_reqlen, req->rq_replen,
2215 req->rq_early_count, req->rq_timedout,
2217 cfs_atomic_read(&req->rq_refcount),
2218 DEBUG_REQ_FLAGS(req),
2219 req->rq_reqmsg && req_ptlrpc_body_swabbed(req) ?
2220 lustre_msg_get_flags(req->rq_reqmsg) : -1,
2221 req->rq_repmsg && rep_ptlrpc_body_swabbed(req) ?
2222 lustre_msg_get_flags(req->rq_repmsg) : -1,
2224 req->rq_repmsg && rep_ptlrpc_body_swabbed(req) ?
2225 lustre_msg_get_status(req->rq_repmsg) : -1);
2227 EXPORT_SYMBOL(_debug_req);
2229 void lustre_swab_lustre_capa(struct lustre_capa *c)
2231 lustre_swab_lu_fid(&c->lc_fid);
2232 __swab64s (&c->lc_opc);
2233 __swab64s (&c->lc_uid);
2234 __swab64s (&c->lc_gid);
2235 __swab32s (&c->lc_flags);
2236 __swab32s (&c->lc_keyid);
2237 __swab32s (&c->lc_timeout);
2238 __swab32s (&c->lc_expiry);
2241 void lustre_swab_lustre_capa_key(struct lustre_capa_key *k)
2243 __swab64s (&k->lk_mdsid);
2244 __swab32s (&k->lk_keyid);
2245 __swab32s (&k->lk_padding);
2248 void lustre_swab_kuch(struct kuc_hdr *l)
2250 __swab16s(&l->kuc_magic);
2251 /* __u8 l->kuc_transport */
2252 __swab16s(&l->kuc_msgtype);
2253 __swab16s(&l->kuc_msglen);
2255 EXPORT_SYMBOL(lustre_swab_kuch);