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 cfs_spin_lock(&req->rq_lock);
325 req->rq_packed_final = 1;
326 cfs_spin_unlock(&req->rq_lock);
329 msg_len = lustre_msg_size_v2(count, lens);
330 rc = sptlrpc_svc_alloc_rs(req, msg_len);
334 rs = req->rq_reply_state;
335 cfs_atomic_set(&rs->rs_refcount, 1); /* 1 ref for rq_reply_state */
336 rs->rs_cb_id.cbid_fn = reply_out_callback;
337 rs->rs_cb_id.cbid_arg = rs;
338 rs->rs_service = req->rq_rqbd->rqbd_service;
339 CFS_INIT_LIST_HEAD(&rs->rs_exp_list);
340 CFS_INIT_LIST_HEAD(&rs->rs_obd_list);
341 CFS_INIT_LIST_HEAD(&rs->rs_list);
342 cfs_spin_lock_init(&rs->rs_lock);
344 req->rq_replen = msg_len;
345 req->rq_reply_state = rs;
346 req->rq_repmsg = rs->rs_msg;
348 lustre_init_msg_v2(rs->rs_msg, count, lens, bufs);
349 lustre_msg_add_version(rs->rs_msg, PTLRPC_MSG_VERSION);
351 PTLRPC_RS_DEBUG_LRU_ADD(rs);
355 EXPORT_SYMBOL(lustre_pack_reply_v2);
357 int lustre_pack_reply_flags(struct ptlrpc_request *req, int count, __u32 *lens,
358 char **bufs, int flags)
361 __u32 size[] = { sizeof(struct ptlrpc_body) };
369 LASSERT(lens[MSG_PTLRPC_BODY_OFF] == sizeof(struct ptlrpc_body));
371 switch (req->rq_reqmsg->lm_magic) {
372 case LUSTRE_MSG_MAGIC_V2:
373 rc = lustre_pack_reply_v2(req, count, lens, bufs, flags);
376 LASSERTF(0, "incorrect message magic: %08x\n",
377 req->rq_reqmsg->lm_magic);
381 CERROR("lustre_pack_reply failed: rc=%d size=%d\n", rc,
382 lustre_msg_size(req->rq_reqmsg->lm_magic, count, lens));
386 int lustre_pack_reply(struct ptlrpc_request *req, int count, __u32 *lens,
389 return lustre_pack_reply_flags(req, count, lens, bufs, 0);
392 void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, int n, int min_size)
394 int i, offset, buflen, bufcount;
399 bufcount = m->lm_bufcount;
400 if (unlikely(n >= bufcount)) {
401 CDEBUG(D_INFO, "msg %p buffer[%d] not present (count %d)\n",
406 buflen = m->lm_buflens[n];
407 if (unlikely(buflen < min_size)) {
408 CERROR("msg %p buffer[%d] size %d too small "
409 "(required %d, opc=%d)\n", m, n, buflen, min_size,
410 n == MSG_PTLRPC_BODY_OFF ? -1 : lustre_msg_get_opc(m));
414 offset = lustre_msg_hdr_size_v2(bufcount);
415 for (i = 0; i < n; i++)
416 offset += cfs_size_round(m->lm_buflens[i]);
418 return (char *)m + offset;
421 void *lustre_msg_buf(struct lustre_msg *m, int n, int min_size)
423 switch (m->lm_magic) {
424 case LUSTRE_MSG_MAGIC_V2:
425 return lustre_msg_buf_v2(m, n, min_size);
427 LASSERTF(0, "incorrect message magic: %08x(msg:%p)\n", m->lm_magic, m);
432 int lustre_shrink_msg_v2(struct lustre_msg_v2 *msg, int segment,
433 unsigned int newlen, int move_data)
435 char *tail = NULL, *newpos;
439 LASSERT(msg->lm_bufcount > segment);
440 LASSERT(msg->lm_buflens[segment] >= newlen);
442 if (msg->lm_buflens[segment] == newlen)
445 if (move_data && msg->lm_bufcount > segment + 1) {
446 tail = lustre_msg_buf_v2(msg, segment + 1, 0);
447 for (n = segment + 1; n < msg->lm_bufcount; n++)
448 tail_len += cfs_size_round(msg->lm_buflens[n]);
451 msg->lm_buflens[segment] = newlen;
453 if (tail && tail_len) {
454 newpos = lustre_msg_buf_v2(msg, segment + 1, 0);
455 LASSERT(newpos <= tail);
457 memmove(newpos, tail, tail_len);
460 return lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens);
464 * for @msg, shrink @segment to size @newlen. if @move_data is non-zero,
465 * we also move data forward from @segment + 1.
467 * if @newlen == 0, we remove the segment completely, but we still keep the
468 * totally bufcount the same to save possible data moving. this will leave a
469 * unused segment with size 0 at the tail, but that's ok.
471 * return new msg size after shrinking.
474 * + if any buffers higher than @segment has been filled in, must call shrink
475 * with non-zero @move_data.
476 * + caller should NOT keep pointers to msg buffers which higher than @segment
479 int lustre_shrink_msg(struct lustre_msg *msg, int segment,
480 unsigned int newlen, int move_data)
482 switch (msg->lm_magic) {
483 case LUSTRE_MSG_MAGIC_V2:
484 return lustre_shrink_msg_v2(msg, segment, newlen, move_data);
486 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
490 void lustre_free_reply_state(struct ptlrpc_reply_state *rs)
492 PTLRPC_RS_DEBUG_LRU_DEL(rs);
494 LASSERT (cfs_atomic_read(&rs->rs_refcount) == 0);
495 LASSERT (!rs->rs_difficult || rs->rs_handled);
496 LASSERT (!rs->rs_on_net);
497 LASSERT (!rs->rs_scheduled);
498 LASSERT (rs->rs_export == NULL);
499 LASSERT (rs->rs_nlocks == 0);
500 LASSERT (cfs_list_empty(&rs->rs_exp_list));
501 LASSERT (cfs_list_empty(&rs->rs_obd_list));
503 sptlrpc_svc_free_rs(rs);
506 static int lustre_unpack_msg_v2(struct lustre_msg_v2 *m, int len)
508 int swabbed, required_len, i;
510 /* Now we know the sender speaks my language. */
511 required_len = lustre_msg_hdr_size_v2(0);
512 if (len < required_len) {
513 /* can't even look inside the message */
514 CERROR("message length %d too small for lustre_msg\n", len);
518 swabbed = (m->lm_magic == LUSTRE_MSG_MAGIC_V2_SWABBED);
521 __swab32s(&m->lm_magic);
522 __swab32s(&m->lm_bufcount);
523 __swab32s(&m->lm_secflvr);
524 __swab32s(&m->lm_repsize);
525 __swab32s(&m->lm_cksum);
526 __swab32s(&m->lm_flags);
527 CLASSERT(offsetof(typeof(*m), lm_padding_2) != 0);
528 CLASSERT(offsetof(typeof(*m), lm_padding_3) != 0);
531 required_len = lustre_msg_hdr_size_v2(m->lm_bufcount);
532 if (len < required_len) {
533 /* didn't receive all the buffer lengths */
534 CERROR ("message length %d too small for %d buflens\n",
535 len, m->lm_bufcount);
539 for (i = 0; i < m->lm_bufcount; i++) {
541 __swab32s(&m->lm_buflens[i]);
542 required_len += cfs_size_round(m->lm_buflens[i]);
545 if (len < required_len) {
546 CERROR("len: %d, required_len %d\n", len, required_len);
547 CERROR("bufcount: %d\n", m->lm_bufcount);
548 for (i = 0; i < m->lm_bufcount; i++)
549 CERROR("buffer %d length %d\n", i, m->lm_buflens[i]);
556 int __lustre_unpack_msg(struct lustre_msg *m, int len)
558 int required_len, rc;
561 /* We can provide a slightly better error log, if we check the
562 * message magic and version first. In the future, struct
563 * lustre_msg may grow, and we'd like to log a version mismatch,
564 * rather than a short message.
567 required_len = offsetof(struct lustre_msg, lm_magic) +
569 if (len < required_len) {
570 /* can't even look inside the message */
571 CERROR("message length %d too small for magic/version check\n",
576 rc = lustre_unpack_msg_v2(m, len);
580 EXPORT_SYMBOL(__lustre_unpack_msg);
582 int ptlrpc_unpack_req_msg(struct ptlrpc_request *req, int len)
585 rc = __lustre_unpack_msg(req->rq_reqmsg, len);
587 lustre_set_req_swabbed(req, MSG_PTLRPC_HEADER_OFF);
593 int ptlrpc_unpack_rep_msg(struct ptlrpc_request *req, int len)
596 rc = __lustre_unpack_msg(req->rq_repmsg, len);
598 lustre_set_rep_swabbed(req, MSG_PTLRPC_HEADER_OFF);
604 static inline int lustre_unpack_ptlrpc_body_v2(struct ptlrpc_request *req,
605 const int inout, int offset)
607 struct ptlrpc_body *pb;
608 struct lustre_msg_v2 *m = inout ? req->rq_reqmsg : req->rq_repmsg;
610 pb = lustre_msg_buf_v2(m, offset, sizeof(*pb));
612 CERROR("error unpacking ptlrpc body\n");
615 if (ptlrpc_buf_need_swab(req, inout, offset)) {
616 lustre_swab_ptlrpc_body(pb);
617 ptlrpc_buf_set_swabbed(req, inout, offset);
620 if ((pb->pb_version & ~LUSTRE_VERSION_MASK) != PTLRPC_MSG_VERSION) {
621 CERROR("wrong lustre_msg version %08x\n", pb->pb_version);
628 int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset)
630 switch (req->rq_reqmsg->lm_magic) {
631 case LUSTRE_MSG_MAGIC_V2:
632 return lustre_unpack_ptlrpc_body_v2(req, 1, offset);
634 CERROR("bad lustre msg magic: %08x\n",
635 req->rq_reqmsg->lm_magic);
640 int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset)
642 switch (req->rq_repmsg->lm_magic) {
643 case LUSTRE_MSG_MAGIC_V2:
644 return lustre_unpack_ptlrpc_body_v2(req, 0, offset);
646 CERROR("bad lustre msg magic: %08x\n",
647 req->rq_repmsg->lm_magic);
652 static inline int lustre_msg_buflen_v2(struct lustre_msg_v2 *m, int n)
654 if (n >= m->lm_bufcount)
657 return m->lm_buflens[n];
661 * lustre_msg_buflen - return the length of buffer \a n in message \a m
662 * \param m lustre_msg (request or reply) to look at
663 * \param n message index (base 0)
665 * returns zero for non-existent message indices
667 int lustre_msg_buflen(struct lustre_msg *m, int n)
669 switch (m->lm_magic) {
670 case LUSTRE_MSG_MAGIC_V2:
671 return lustre_msg_buflen_v2(m, n);
673 CERROR("incorrect message magic: %08x\n", m->lm_magic);
677 EXPORT_SYMBOL(lustre_msg_buflen);
680 lustre_msg_set_buflen_v2(struct lustre_msg_v2 *m, int n, int len)
682 if (n >= m->lm_bufcount)
685 m->lm_buflens[n] = len;
688 void lustre_msg_set_buflen(struct lustre_msg *m, int n, int len)
690 switch (m->lm_magic) {
691 case LUSTRE_MSG_MAGIC_V2:
692 lustre_msg_set_buflen_v2(m, n, len);
695 LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic);
699 EXPORT_SYMBOL(lustre_msg_set_buflen);
701 /* NB return the bufcount for lustre_msg_v2 format, so if message is packed
702 * in V1 format, the result is one bigger. (add struct ptlrpc_body). */
703 int lustre_msg_bufcount(struct lustre_msg *m)
705 switch (m->lm_magic) {
706 case LUSTRE_MSG_MAGIC_V2:
707 return m->lm_bufcount;
709 CERROR("incorrect message magic: %08x\n", m->lm_magic);
713 EXPORT_SYMBOL(lustre_msg_bufcount);
715 char *lustre_msg_string(struct lustre_msg *m, int index, int max_len)
717 /* max_len == 0 means the string should fill the buffer */
721 switch (m->lm_magic) {
722 case LUSTRE_MSG_MAGIC_V2:
723 str = lustre_msg_buf_v2(m, index, 0);
724 blen = lustre_msg_buflen_v2(m, index);
727 LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic);
731 CERROR ("can't unpack string in msg %p buffer[%d]\n", m, index);
735 slen = strnlen(str, blen);
737 if (slen == blen) { /* not NULL terminated */
738 CERROR("can't unpack non-NULL terminated string in "
739 "msg %p buffer[%d] len %d\n", m, index, blen);
744 if (slen != blen - 1) {
745 CERROR("can't unpack short string in msg %p "
746 "buffer[%d] len %d: strlen %d\n",
747 m, index, blen, slen);
750 } else if (slen > max_len) {
751 CERROR("can't unpack oversized string in msg %p "
752 "buffer[%d] len %d strlen %d: max %d expected\n",
753 m, index, blen, slen, max_len);
760 /* Wrap up the normal fixed length cases */
761 static inline void *__lustre_swab_buf(struct lustre_msg *msg, int index,
762 int min_size, void *swabber)
766 LASSERT(msg != NULL);
767 switch (msg->lm_magic) {
768 case LUSTRE_MSG_MAGIC_V2:
769 ptr = lustre_msg_buf_v2(msg, index, min_size);
772 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
776 ((void (*)(void *))swabber)(ptr);
781 static inline struct ptlrpc_body *lustre_msg_ptlrpc_body(struct lustre_msg *msg)
783 return lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF,
784 sizeof(struct ptlrpc_body));
787 __u32 lustre_msghdr_get_flags(struct lustre_msg *msg)
789 switch (msg->lm_magic) {
790 case LUSTRE_MSG_MAGIC_V1:
791 case LUSTRE_MSG_MAGIC_V1_SWABBED:
793 case LUSTRE_MSG_MAGIC_V2:
794 /* already in host endian */
795 return msg->lm_flags;
797 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
801 EXPORT_SYMBOL(lustre_msghdr_get_flags);
803 void lustre_msghdr_set_flags(struct lustre_msg *msg, __u32 flags)
805 switch (msg->lm_magic) {
806 case LUSTRE_MSG_MAGIC_V1:
808 case LUSTRE_MSG_MAGIC_V2:
809 msg->lm_flags = flags;
812 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
816 __u32 lustre_msg_get_flags(struct lustre_msg *msg)
818 switch (msg->lm_magic) {
819 case LUSTRE_MSG_MAGIC_V2: {
820 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
822 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
828 /* flags might be printed in debug code while message
834 void lustre_msg_add_flags(struct lustre_msg *msg, int flags)
836 switch (msg->lm_magic) {
837 case LUSTRE_MSG_MAGIC_V2: {
838 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
839 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
840 pb->pb_flags |= flags;
844 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
848 void lustre_msg_set_flags(struct lustre_msg *msg, int flags)
850 switch (msg->lm_magic) {
851 case LUSTRE_MSG_MAGIC_V2: {
852 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
853 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
854 pb->pb_flags = flags;
858 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
862 void lustre_msg_clear_flags(struct lustre_msg *msg, int flags)
864 switch (msg->lm_magic) {
865 case LUSTRE_MSG_MAGIC_V2: {
866 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
867 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
868 pb->pb_flags &= ~(MSG_GEN_FLAG_MASK & flags);
872 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
876 __u32 lustre_msg_get_op_flags(struct lustre_msg *msg)
878 switch (msg->lm_magic) {
879 case LUSTRE_MSG_MAGIC_V2: {
880 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
882 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
885 return pb->pb_op_flags;
892 void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags)
894 switch (msg->lm_magic) {
895 case LUSTRE_MSG_MAGIC_V2: {
896 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
897 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
898 pb->pb_op_flags |= flags;
902 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
906 void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
908 switch (msg->lm_magic) {
909 case LUSTRE_MSG_MAGIC_V2: {
910 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
911 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
912 pb->pb_op_flags |= flags;
916 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
920 struct lustre_handle *lustre_msg_get_handle(struct lustre_msg *msg)
922 switch (msg->lm_magic) {
923 case LUSTRE_MSG_MAGIC_V2: {
924 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
926 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
929 return &pb->pb_handle;
932 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
937 __u32 lustre_msg_get_type(struct lustre_msg *msg)
939 switch (msg->lm_magic) {
940 case LUSTRE_MSG_MAGIC_V2: {
941 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
943 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
944 return PTL_RPC_MSG_ERR;
949 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
950 return PTL_RPC_MSG_ERR;
954 __u32 lustre_msg_get_version(struct lustre_msg *msg)
956 switch (msg->lm_magic) {
957 case LUSTRE_MSG_MAGIC_V2: {
958 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
960 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
963 return pb->pb_version;
966 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
971 void lustre_msg_add_version(struct lustre_msg *msg, int version)
973 switch (msg->lm_magic) {
974 case LUSTRE_MSG_MAGIC_V2: {
975 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
976 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
977 pb->pb_version |= version;
981 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
985 __u32 lustre_msg_get_opc(struct lustre_msg *msg)
987 switch (msg->lm_magic) {
988 case LUSTRE_MSG_MAGIC_V2: {
989 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
991 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
997 CERROR("incorrect message magic: %08x(msg:%p)\n", msg->lm_magic, msg);
1003 __u64 lustre_msg_get_last_xid(struct lustre_msg *msg)
1005 switch (msg->lm_magic) {
1006 case LUSTRE_MSG_MAGIC_V2: {
1007 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1009 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1012 return pb->pb_last_xid;
1015 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1020 __u64 lustre_msg_get_last_committed(struct lustre_msg *msg)
1022 switch (msg->lm_magic) {
1023 case LUSTRE_MSG_MAGIC_V2: {
1024 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1026 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1029 return pb->pb_last_committed;
1032 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1037 __u64 *lustre_msg_get_versions(struct lustre_msg *msg)
1039 switch (msg->lm_magic) {
1040 case LUSTRE_MSG_MAGIC_V1:
1042 case LUSTRE_MSG_MAGIC_V2: {
1043 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1045 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1048 return pb->pb_pre_versions;
1051 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1056 __u64 lustre_msg_get_transno(struct lustre_msg *msg)
1058 switch (msg->lm_magic) {
1059 case LUSTRE_MSG_MAGIC_V2: {
1060 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1062 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1065 return pb->pb_transno;
1068 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1073 int lustre_msg_get_status(struct lustre_msg *msg)
1075 switch (msg->lm_magic) {
1076 case LUSTRE_MSG_MAGIC_V2: {
1077 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1079 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1082 return pb->pb_status;
1085 /* status might be printed in debug code while message
1091 __u64 lustre_msg_get_slv(struct lustre_msg *msg)
1093 switch (msg->lm_magic) {
1094 case LUSTRE_MSG_MAGIC_V2: {
1095 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1097 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1103 CERROR("invalid msg magic %08x\n", msg->lm_magic);
1109 void lustre_msg_set_slv(struct lustre_msg *msg, __u64 slv)
1111 switch (msg->lm_magic) {
1112 case LUSTRE_MSG_MAGIC_V2: {
1113 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1115 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1122 CERROR("invalid msg magic %x\n", msg->lm_magic);
1127 __u32 lustre_msg_get_limit(struct lustre_msg *msg)
1129 switch (msg->lm_magic) {
1130 case LUSTRE_MSG_MAGIC_V2: {
1131 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1133 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1136 return pb->pb_limit;
1139 CERROR("invalid msg magic %x\n", msg->lm_magic);
1145 void lustre_msg_set_limit(struct lustre_msg *msg, __u64 limit)
1147 switch (msg->lm_magic) {
1148 case LUSTRE_MSG_MAGIC_V2: {
1149 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1151 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1154 pb->pb_limit = limit;
1158 CERROR("invalid msg magic %08x\n", msg->lm_magic);
1163 __u32 lustre_msg_get_conn_cnt(struct lustre_msg *msg)
1165 switch (msg->lm_magic) {
1166 case LUSTRE_MSG_MAGIC_V2: {
1167 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1169 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1172 return pb->pb_conn_cnt;
1175 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1180 int lustre_msg_is_v1(struct lustre_msg *msg)
1182 switch (msg->lm_magic) {
1183 case LUSTRE_MSG_MAGIC_V1:
1184 case LUSTRE_MSG_MAGIC_V1_SWABBED:
1191 __u32 lustre_msg_get_magic(struct lustre_msg *msg)
1193 switch (msg->lm_magic) {
1194 case LUSTRE_MSG_MAGIC_V2:
1195 return msg->lm_magic;
1197 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1202 __u32 lustre_msg_get_timeout(struct lustre_msg *msg)
1204 switch (msg->lm_magic) {
1205 case LUSTRE_MSG_MAGIC_V1:
1206 case LUSTRE_MSG_MAGIC_V1_SWABBED:
1208 case LUSTRE_MSG_MAGIC_V2: {
1209 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1211 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1215 return pb->pb_timeout;
1218 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1223 __u32 lustre_msg_get_service_time(struct lustre_msg *msg)
1225 switch (msg->lm_magic) {
1226 case LUSTRE_MSG_MAGIC_V1:
1227 case LUSTRE_MSG_MAGIC_V1_SWABBED:
1229 case LUSTRE_MSG_MAGIC_V2: {
1230 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1232 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1236 return pb->pb_service_time;
1239 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1244 __u32 lustre_msg_get_cksum(struct lustre_msg *msg)
1246 switch (msg->lm_magic) {
1247 case LUSTRE_MSG_MAGIC_V2:
1248 return msg->lm_cksum;
1250 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1255 __u32 lustre_msg_calc_cksum(struct lustre_msg *msg)
1257 switch (msg->lm_magic) {
1258 case LUSTRE_MSG_MAGIC_V2: {
1259 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1260 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1261 return crc32_le(~(__u32)0, (unsigned char *)pb, sizeof(*pb));
1264 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1269 void lustre_msg_set_handle(struct lustre_msg *msg, struct lustre_handle *handle)
1271 switch (msg->lm_magic) {
1272 case LUSTRE_MSG_MAGIC_V2: {
1273 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1274 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1275 pb->pb_handle = *handle;
1279 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1283 void lustre_msg_set_type(struct lustre_msg *msg, __u32 type)
1285 switch (msg->lm_magic) {
1286 case LUSTRE_MSG_MAGIC_V2: {
1287 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1288 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1293 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1297 void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc)
1299 switch (msg->lm_magic) {
1300 case LUSTRE_MSG_MAGIC_V2: {
1301 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1302 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1307 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1311 void lustre_msg_set_last_xid(struct lustre_msg *msg, __u64 last_xid)
1313 switch (msg->lm_magic) {
1314 case LUSTRE_MSG_MAGIC_V2: {
1315 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1316 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1317 pb->pb_last_xid = last_xid;
1321 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1325 void lustre_msg_set_last_committed(struct lustre_msg *msg, __u64 last_committed)
1327 switch (msg->lm_magic) {
1328 case LUSTRE_MSG_MAGIC_V2: {
1329 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1330 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1331 pb->pb_last_committed = last_committed;
1335 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1339 void lustre_msg_set_versions(struct lustre_msg *msg, __u64 *versions)
1341 switch (msg->lm_magic) {
1342 case LUSTRE_MSG_MAGIC_V1:
1344 case LUSTRE_MSG_MAGIC_V2: {
1345 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1346 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1347 pb->pb_pre_versions[0] = versions[0];
1348 pb->pb_pre_versions[1] = versions[1];
1349 pb->pb_pre_versions[2] = versions[2];
1350 pb->pb_pre_versions[3] = versions[3];
1354 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1358 void lustre_msg_set_transno(struct lustre_msg *msg, __u64 transno)
1360 switch (msg->lm_magic) {
1361 case LUSTRE_MSG_MAGIC_V2: {
1362 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1363 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1364 pb->pb_transno = transno;
1368 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1372 void lustre_msg_set_status(struct lustre_msg *msg, __u32 status)
1374 switch (msg->lm_magic) {
1375 case LUSTRE_MSG_MAGIC_V2: {
1376 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1377 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1378 pb->pb_status = status;
1382 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1386 void lustre_msg_set_conn_cnt(struct lustre_msg *msg, __u32 conn_cnt)
1388 switch (msg->lm_magic) {
1389 case LUSTRE_MSG_MAGIC_V2: {
1390 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1391 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1392 pb->pb_conn_cnt = conn_cnt;
1396 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1400 void lustre_msg_set_timeout(struct lustre_msg *msg, __u32 timeout)
1402 switch (msg->lm_magic) {
1403 case LUSTRE_MSG_MAGIC_V1:
1405 case LUSTRE_MSG_MAGIC_V2: {
1406 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1407 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1408 pb->pb_timeout = timeout;
1412 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1416 void lustre_msg_set_service_time(struct lustre_msg *msg, __u32 service_time)
1418 switch (msg->lm_magic) {
1419 case LUSTRE_MSG_MAGIC_V1:
1421 case LUSTRE_MSG_MAGIC_V2: {
1422 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1423 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1424 pb->pb_service_time = service_time;
1428 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1432 void lustre_msg_set_cksum(struct lustre_msg *msg, __u32 cksum)
1434 switch (msg->lm_magic) {
1435 case LUSTRE_MSG_MAGIC_V1:
1437 case LUSTRE_MSG_MAGIC_V2:
1438 msg->lm_cksum = cksum;
1441 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1446 void ptlrpc_request_set_replen(struct ptlrpc_request *req)
1448 int count = req_capsule_filled_sizes(&req->rq_pill, RCL_SERVER);
1450 req->rq_replen = lustre_msg_size(req->rq_reqmsg->lm_magic, count,
1451 req->rq_pill.rc_area[RCL_SERVER]);
1452 if (req->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V2)
1453 req->rq_reqmsg->lm_repsize = req->rq_replen;
1456 void ptlrpc_req_set_repsize(struct ptlrpc_request *req, int count, __u32 *lens)
1458 req->rq_replen = lustre_msg_size(req->rq_reqmsg->lm_magic, count, lens);
1459 if (req->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V2)
1460 req->rq_reqmsg->lm_repsize = req->rq_replen;
1464 * Send a remote set_info_async.
1466 * This may go from client to server or server to client.
1468 int do_set_info_async(struct obd_import *imp,
1469 int opcode, int version,
1470 obd_count keylen, void *key,
1471 obd_count vallen, void *val,
1472 struct ptlrpc_request_set *set)
1474 struct ptlrpc_request *req;
1479 req = ptlrpc_request_alloc(imp, &RQF_OBD_SET_INFO);
1483 req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY,
1484 RCL_CLIENT, keylen);
1485 req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_VAL,
1486 RCL_CLIENT, vallen);
1487 rc = ptlrpc_request_pack(req, version, opcode);
1489 ptlrpc_request_free(req);
1493 tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY);
1494 memcpy(tmp, key, keylen);
1495 tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_VAL);
1496 memcpy(tmp, val, vallen);
1498 ptlrpc_request_set_replen(req);
1501 ptlrpc_set_add_req(set, req);
1502 ptlrpc_check_set(NULL, set);
1504 rc = ptlrpc_queue_wait(req);
1505 ptlrpc_req_finished(req);
1510 EXPORT_SYMBOL(do_set_info_async);
1512 /* byte flipping routines for all wire types declared in
1513 * lustre_idl.h implemented here.
1515 void lustre_swab_ptlrpc_body(struct ptlrpc_body *b)
1517 __swab32s (&b->pb_type);
1518 __swab32s (&b->pb_version);
1519 __swab32s (&b->pb_opc);
1520 __swab32s (&b->pb_status);
1521 __swab64s (&b->pb_last_xid);
1522 __swab64s (&b->pb_last_seen);
1523 __swab64s (&b->pb_last_committed);
1524 __swab64s (&b->pb_transno);
1525 __swab32s (&b->pb_flags);
1526 __swab32s (&b->pb_op_flags);
1527 __swab32s (&b->pb_conn_cnt);
1528 __swab32s (&b->pb_timeout);
1529 __swab32s (&b->pb_service_time);
1530 __swab32s (&b->pb_limit);
1531 __swab64s (&b->pb_slv);
1532 __swab64s (&b->pb_pre_versions[0]);
1533 __swab64s (&b->pb_pre_versions[1]);
1534 __swab64s (&b->pb_pre_versions[2]);
1535 __swab64s (&b->pb_pre_versions[3]);
1536 CLASSERT(offsetof(typeof(*b), pb_padding) != 0);
1539 void lustre_swab_connect(struct obd_connect_data *ocd)
1541 __swab64s(&ocd->ocd_connect_flags);
1542 __swab32s(&ocd->ocd_version);
1543 __swab32s(&ocd->ocd_grant);
1544 __swab64s(&ocd->ocd_ibits_known);
1545 __swab32s(&ocd->ocd_index);
1546 __swab32s(&ocd->ocd_brw_size);
1547 __swab32s(&ocd->ocd_nllu);
1548 __swab32s(&ocd->ocd_nllg);
1549 __swab64s(&ocd->ocd_transno);
1550 __swab32s(&ocd->ocd_group);
1551 __swab32s(&ocd->ocd_cksum_types);
1552 CLASSERT(offsetof(typeof(*ocd), padding1) != 0);
1553 CLASSERT(offsetof(typeof(*ocd), padding2) != 0);
1556 void lustre_swab_obdo (struct obdo *o)
1558 __swab64s (&o->o_valid);
1559 __swab64s (&o->o_id);
1560 __swab64s (&o->o_gr);
1561 __swab64s (&o->o_fid);
1562 __swab64s (&o->o_size);
1563 __swab64s (&o->o_mtime);
1564 __swab64s (&o->o_atime);
1565 __swab64s (&o->o_ctime);
1566 __swab64s (&o->o_blocks);
1567 __swab64s (&o->o_grant);
1568 __swab32s (&o->o_blksize);
1569 __swab32s (&o->o_mode);
1570 __swab32s (&o->o_uid);
1571 __swab32s (&o->o_gid);
1572 __swab32s (&o->o_flags);
1573 __swab32s (&o->o_nlink);
1574 __swab32s (&o->o_generation);
1575 __swab32s (&o->o_misc);
1576 __swab64s (&o->o_ioepoch);
1577 __swab32s (&o->o_stripe_idx);
1578 __swab32s (&o->o_padding_1);
1579 /* o_inline is opaque */
1582 void lustre_swab_obd_statfs (struct obd_statfs *os)
1584 __swab64s (&os->os_type);
1585 __swab64s (&os->os_blocks);
1586 __swab64s (&os->os_bfree);
1587 __swab64s (&os->os_bavail);
1588 __swab64s (&os->os_files);
1589 __swab64s (&os->os_ffree);
1590 /* no need to swab os_fsid */
1591 __swab32s (&os->os_bsize);
1592 __swab32s (&os->os_namelen);
1593 __swab64s (&os->os_maxbytes);
1594 __swab32s (&os->os_state);
1595 /* no need to swap os_spare */
1598 void lustre_swab_obd_ioobj (struct obd_ioobj *ioo)
1600 __swab64s (&ioo->ioo_id);
1601 __swab64s (&ioo->ioo_gr);
1602 __swab32s (&ioo->ioo_type);
1603 __swab32s (&ioo->ioo_bufcnt);
1606 void lustre_swab_niobuf_remote (struct niobuf_remote *nbr)
1608 __swab64s (&nbr->offset);
1609 __swab32s (&nbr->len);
1610 __swab32s (&nbr->flags);
1613 void lustre_swab_ost_body (struct ost_body *b)
1615 lustre_swab_obdo (&b->oa);
1618 void lustre_swab_ost_last_id(obd_id *id)
1623 void lustre_swab_generic_32s(__u32 *val)
1628 void lustre_swab_ost_lvb(struct ost_lvb *lvb)
1630 __swab64s(&lvb->lvb_size);
1631 __swab64s(&lvb->lvb_mtime);
1632 __swab64s(&lvb->lvb_atime);
1633 __swab64s(&lvb->lvb_ctime);
1634 __swab64s(&lvb->lvb_blocks);
1637 void lustre_swab_mds_status_req (struct mds_status_req *r)
1639 __swab32s (&r->flags);
1640 __swab32s (&r->repbuf);
1643 void lustre_swab_mds_body (struct mds_body *b)
1645 lustre_swab_ll_fid (&b->fid1);
1646 lustre_swab_ll_fid (&b->fid2);
1647 /* handle is opaque */
1648 __swab64s (&b->valid);
1649 __swab64s (&b->size);
1650 __swab64s (&b->mtime);
1651 __swab64s (&b->atime);
1652 __swab64s (&b->ctime);
1653 __swab64s (&b->blocks);
1654 __swab64s (&b->io_epoch);
1655 __swab64s (&b->ino);
1656 __swab32s (&b->fsuid);
1657 __swab32s (&b->fsgid);
1658 __swab32s (&b->capability);
1659 __swab32s (&b->mode);
1660 __swab32s (&b->uid);
1661 __swab32s (&b->gid);
1662 __swab32s (&b->flags);
1663 __swab32s (&b->rdev);
1664 __swab32s (&b->nlink);
1665 __swab32s (&b->generation);
1666 __swab32s (&b->suppgid);
1667 __swab32s (&b->eadatasize);
1668 __swab32s (&b->aclsize);
1669 __swab32s (&b->max_mdsize);
1670 __swab32s (&b->max_cookiesize);
1671 __swab32s (&b->padding_4);
1674 void lustre_swab_mdt_body (struct mdt_body *b)
1676 lustre_swab_lu_fid (&b->fid1);
1677 lustre_swab_lu_fid (&b->fid2);
1678 /* handle is opaque */
1679 __swab64s (&b->valid);
1680 __swab64s (&b->size);
1681 __swab64s (&b->mtime);
1682 __swab64s (&b->atime);
1683 __swab64s (&b->ctime);
1684 __swab64s (&b->blocks);
1685 __swab64s (&b->ioepoch);
1686 __swab64s (&b->ino);
1687 __swab32s (&b->fsuid);
1688 __swab32s (&b->fsgid);
1689 __swab32s (&b->capability);
1690 __swab32s (&b->mode);
1691 __swab32s (&b->uid);
1692 __swab32s (&b->gid);
1693 __swab32s (&b->flags);
1694 __swab32s (&b->rdev);
1695 __swab32s (&b->nlink);
1696 __swab32s (&b->generation);
1697 __swab32s (&b->suppgid);
1698 __swab32s (&b->eadatasize);
1699 __swab32s (&b->aclsize);
1700 __swab32s (&b->max_mdsize);
1701 __swab32s (&b->max_cookiesize);
1702 __swab32s (&b->padding_4);
1705 void lustre_swab_mdt_ioepoch (struct mdt_ioepoch *b)
1707 /* handle is opaque */
1708 __swab64s (&b->ioepoch);
1709 __swab32s (&b->flags);
1710 CLASSERT(offsetof(typeof(*b), padding) != 0);
1713 void lustre_swab_mgs_target_info(struct mgs_target_info *mti)
1716 __swab32s(&mti->mti_lustre_ver);
1717 __swab32s(&mti->mti_stripe_index);
1718 __swab32s(&mti->mti_config_ver);
1719 __swab32s(&mti->mti_flags);
1720 __swab32s(&mti->mti_nid_count);
1721 CLASSERT(sizeof(lnet_nid_t) == sizeof(__u64));
1722 for (i = 0; i < MTI_NIDS_MAX; i++)
1723 __swab64s(&mti->mti_nids[i]);
1726 static void lustre_swab_obd_dqinfo (struct obd_dqinfo *i)
1728 __swab64s (&i->dqi_bgrace);
1729 __swab64s (&i->dqi_igrace);
1730 __swab32s (&i->dqi_flags);
1731 __swab32s (&i->dqi_valid);
1734 static void lustre_swab_obd_dqblk (struct obd_dqblk *b)
1736 __swab64s (&b->dqb_ihardlimit);
1737 __swab64s (&b->dqb_isoftlimit);
1738 __swab64s (&b->dqb_curinodes);
1739 __swab64s (&b->dqb_bhardlimit);
1740 __swab64s (&b->dqb_bsoftlimit);
1741 __swab64s (&b->dqb_curspace);
1742 __swab64s (&b->dqb_btime);
1743 __swab64s (&b->dqb_itime);
1744 __swab32s (&b->dqb_valid);
1745 CLASSERT(offsetof(typeof(*b), padding) != 0);
1748 void lustre_swab_obd_quotactl (struct obd_quotactl *q)
1750 __swab32s (&q->qc_cmd);
1751 __swab32s (&q->qc_type);
1752 __swab32s (&q->qc_id);
1753 __swab32s (&q->qc_stat);
1754 lustre_swab_obd_dqinfo (&q->qc_dqinfo);
1755 lustre_swab_obd_dqblk (&q->qc_dqblk);
1758 void lustre_swab_quota_adjust_qunit (struct quota_adjust_qunit *q)
1760 __swab32s (&q->qaq_flags);
1761 __swab32s (&q->qaq_id);
1762 __swab64s (&q->qaq_bunit_sz);
1763 __swab64s (&q->qaq_iunit_sz);
1764 __swab64s (&q->padding1);
1767 void lustre_swab_mds_remote_perm (struct mds_remote_perm *p)
1769 __swab32s (&p->rp_uid);
1770 __swab32s (&p->rp_gid);
1771 __swab32s (&p->rp_fsuid);
1772 __swab32s (&p->rp_fsgid);
1773 __swab32s (&p->rp_access_perm);
1776 void lustre_swab_mdt_remote_perm (struct mdt_remote_perm *p)
1778 __swab32s (&p->rp_uid);
1779 __swab32s (&p->rp_gid);
1780 __swab32s (&p->rp_fsuid);
1781 __swab32s (&p->rp_fsgid);
1782 __swab32s (&p->rp_access_perm);
1785 void lustre_swab_fid2path(struct getinfo_fid2path *gf)
1787 lustre_swab_lu_fid(&gf->gf_fid);
1788 __swab64s(&gf->gf_recno);
1789 __swab32s(&gf->gf_linkno);
1790 __swab32s(&gf->gf_pathlen);
1792 EXPORT_SYMBOL(lustre_swab_fid2path);
1794 void lustre_swab_fiemap_extent(struct ll_fiemap_extent *fm_extent)
1796 __swab64s(&fm_extent->fe_logical);
1797 __swab64s(&fm_extent->fe_physical);
1798 __swab64s(&fm_extent->fe_length);
1799 __swab32s(&fm_extent->fe_flags);
1800 __swab32s(&fm_extent->fe_device);
1803 void lustre_swab_fiemap(struct ll_user_fiemap *fiemap)
1807 __swab64s(&fiemap->fm_start);
1808 __swab64s(&fiemap->fm_length);
1809 __swab32s(&fiemap->fm_flags);
1810 __swab32s(&fiemap->fm_mapped_extents);
1811 __swab32s(&fiemap->fm_extent_count);
1812 __swab32s(&fiemap->fm_reserved);
1814 for (i = 0; i < fiemap->fm_mapped_extents; i++)
1815 lustre_swab_fiemap_extent(&fiemap->fm_extents[i]);
1818 void lustre_swab_mdt_rec_reint (struct mdt_rec_reint *rr)
1820 __swab32s (&rr->rr_opcode);
1821 __swab32s (&rr->rr_cap);
1822 __swab32s (&rr->rr_fsuid);
1823 /* rr_fsuid_h is unused */
1824 __swab32s (&rr->rr_fsgid);
1825 /* rr_fsgid_h is unused */
1826 __swab32s (&rr->rr_suppgid1);
1827 /* rr_suppgid1_h is unused */
1828 __swab32s (&rr->rr_suppgid2);
1829 /* rr_suppgid2_h is unused */
1830 lustre_swab_lu_fid (&rr->rr_fid1);
1831 lustre_swab_lu_fid (&rr->rr_fid2);
1832 __swab64s (&rr->rr_mtime);
1833 __swab64s (&rr->rr_atime);
1834 __swab64s (&rr->rr_ctime);
1835 __swab64s (&rr->rr_size);
1836 __swab64s (&rr->rr_blocks);
1837 __swab32s (&rr->rr_bias);
1838 __swab32s (&rr->rr_mode);
1839 __swab32s (&rr->rr_padding_1);
1840 __swab32s (&rr->rr_padding_2);
1841 __swab32s (&rr->rr_padding_3);
1842 __swab32s (&rr->rr_padding_4);
1844 CLASSERT(offsetof(typeof(*rr), rr_padding_1) != 0);
1845 CLASSERT(offsetof(typeof(*rr), rr_padding_2) != 0);
1846 CLASSERT(offsetof(typeof(*rr), rr_padding_3) != 0);
1847 CLASSERT(offsetof(typeof(*rr), rr_padding_4) != 0);
1850 void lustre_swab_lov_desc (struct lov_desc *ld)
1852 __swab32s (&ld->ld_tgt_count);
1853 __swab32s (&ld->ld_active_tgt_count);
1854 __swab32s (&ld->ld_default_stripe_count);
1855 __swab32s (&ld->ld_pattern);
1856 __swab64s (&ld->ld_default_stripe_size);
1857 __swab64s (&ld->ld_default_stripe_offset);
1858 __swab32s (&ld->ld_qos_maxage);
1859 /* uuid endian insensitive */
1862 void lustre_swab_lmv_desc (struct lmv_desc *ld)
1864 __swab32s (&ld->ld_tgt_count);
1865 __swab32s (&ld->ld_active_tgt_count);
1866 __swab32s (&ld->ld_default_stripe_count);
1867 __swab32s (&ld->ld_pattern);
1868 __swab64s (&ld->ld_default_hash_size);
1869 __swab32s (&ld->ld_qos_maxage);
1870 /* uuid endian insensitive */
1873 void lustre_swab_lmv_stripe_md (struct lmv_stripe_md *mea)
1875 __swab32s(&mea->mea_magic);
1876 __swab32s(&mea->mea_count);
1877 __swab32s(&mea->mea_master);
1878 CLASSERT(offsetof(typeof(*mea), mea_padding) != 0);
1882 static void print_lum (struct lov_user_md *lum)
1884 CDEBUG(D_OTHER, "lov_user_md %p:\n", lum);
1885 CDEBUG(D_OTHER, "\tlmm_magic: %#x\n", lum->lmm_magic);
1886 CDEBUG(D_OTHER, "\tlmm_pattern: %#x\n", lum->lmm_pattern);
1887 CDEBUG(D_OTHER, "\tlmm_object_id: "LPU64"\n", lum->lmm_object_id);
1888 CDEBUG(D_OTHER, "\tlmm_object_gr: "LPU64"\n", lum->lmm_object_gr);
1889 CDEBUG(D_OTHER, "\tlmm_stripe_size: %#x\n", lum->lmm_stripe_size);
1890 CDEBUG(D_OTHER, "\tlmm_stripe_count: %#x\n", lum->lmm_stripe_count);
1891 CDEBUG(D_OTHER, "\tlmm_stripe_offset: %#x\n", lum->lmm_stripe_offset);
1894 static void lustre_swab_lov_user_md_common(struct lov_user_md_v1 *lum)
1897 __swab32s(&lum->lmm_magic);
1898 __swab32s(&lum->lmm_pattern);
1899 __swab64s(&lum->lmm_object_id);
1900 __swab64s(&lum->lmm_object_gr);
1901 __swab32s(&lum->lmm_stripe_size);
1902 __swab16s(&lum->lmm_stripe_count);
1903 __swab16s(&lum->lmm_stripe_offset);
1908 void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum)
1911 CDEBUG(D_IOCTL, "swabbing lov_user_md v1\n");
1912 lustre_swab_lov_user_md_common(lum);
1916 void lustre_swab_lov_user_md_v3(struct lov_user_md_v3 *lum)
1919 CDEBUG(D_IOCTL, "swabbing lov_user_md v3\n");
1920 lustre_swab_lov_user_md_common((struct lov_user_md_v1 *)lum);
1921 /* lmm_pool_name nothing to do with char */
1925 void lustre_swab_lov_mds_md(struct lov_mds_md *lmm)
1928 CDEBUG(D_IOCTL, "swabbing lov_mds_md\n");
1929 __swab32s(&lmm->lmm_magic);
1930 __swab32s(&lmm->lmm_pattern);
1931 __swab64s(&lmm->lmm_object_id);
1932 __swab64s(&lmm->lmm_object_gr);
1933 __swab32s(&lmm->lmm_stripe_size);
1934 __swab32s(&lmm->lmm_stripe_count);
1938 void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod,
1943 for (i = 0; i < stripe_count; i++) {
1944 __swab64s(&(lod[i].l_object_id));
1945 __swab64s(&(lod[i].l_object_gr));
1946 __swab32s(&(lod[i].l_ost_gen));
1947 __swab32s(&(lod[i].l_ost_idx));
1953 void lustre_swab_ldlm_res_id (struct ldlm_res_id *id)
1957 for (i = 0; i < RES_NAME_SIZE; i++)
1958 __swab64s (&id->name[i]);
1961 void lustre_swab_ldlm_policy_data (ldlm_policy_data_t *d)
1963 /* the lock data is a union and the first two fields are always an
1964 * extent so it's ok to process an LDLM_EXTENT and LDLM_FLOCK lock
1965 * data the same way. */
1966 __swab64s(&d->l_extent.start);
1967 __swab64s(&d->l_extent.end);
1968 __swab64s(&d->l_extent.gid);
1969 __swab32s(&d->l_flock.pid);
1972 void lustre_swab_ldlm_intent (struct ldlm_intent *i)
1974 __swab64s (&i->opc);
1977 void lustre_swab_ldlm_resource_desc (struct ldlm_resource_desc *r)
1979 __swab32s (&r->lr_type);
1980 CLASSERT(offsetof(typeof(*r), lr_padding) != 0);
1981 lustre_swab_ldlm_res_id (&r->lr_name);
1984 void lustre_swab_ldlm_lock_desc (struct ldlm_lock_desc *l)
1986 lustre_swab_ldlm_resource_desc (&l->l_resource);
1987 __swab32s (&l->l_req_mode);
1988 __swab32s (&l->l_granted_mode);
1989 lustre_swab_ldlm_policy_data (&l->l_policy_data);
1992 void lustre_swab_ldlm_request (struct ldlm_request *rq)
1994 __swab32s (&rq->lock_flags);
1995 lustre_swab_ldlm_lock_desc (&rq->lock_desc);
1996 __swab32s (&rq->lock_count);
1997 /* lock_handle[] opaque */
2000 void lustre_swab_ldlm_reply (struct ldlm_reply *r)
2002 __swab32s (&r->lock_flags);
2003 CLASSERT(offsetof(typeof(*r), lock_padding) != 0);
2004 lustre_swab_ldlm_lock_desc (&r->lock_desc);
2005 /* lock_handle opaque */
2006 __swab64s (&r->lock_policy_res1);
2007 __swab64s (&r->lock_policy_res2);
2010 /* no one calls this */
2011 int llog_log_swabbed(struct llog_log_hdr *hdr)
2013 if (hdr->llh_hdr.lrh_type == __swab32(LLOG_HDR_MAGIC))
2015 if (hdr->llh_hdr.lrh_type == LLOG_HDR_MAGIC)
2020 void lustre_swab_qdata(struct qunit_data *d)
2022 __swab32s (&d->qd_id);
2023 __swab32s (&d->qd_flags);
2024 __swab64s (&d->qd_count);
2025 __swab64s (&d->qd_qunit);
2026 __swab64s (&d->padding);
2029 /* Dump functions */
2030 void dump_ioo(struct obd_ioobj *ioo)
2033 "obd_ioobj: ioo_id="LPD64", ioo_gr="LPD64", ioo_type=%d, "
2034 "ioo_bufct=%d\n", ioo->ioo_id, ioo->ioo_gr, ioo->ioo_type,
2038 void dump_rniobuf(struct niobuf_remote *nb)
2040 CDEBUG(D_RPCTRACE, "niobuf_remote: offset="LPU64", len=%d, flags=%x\n",
2041 nb->offset, nb->len, nb->flags);
2044 void dump_obdo(struct obdo *oa)
2046 __u32 valid = oa->o_valid;
2048 CDEBUG(D_RPCTRACE, "obdo: o_valid = %08x\n", valid);
2049 if (valid & OBD_MD_FLID)
2050 CDEBUG(D_RPCTRACE, "obdo: o_id = "LPD64"\n", oa->o_id);
2051 if (valid & OBD_MD_FLGROUP)
2052 CDEBUG(D_RPCTRACE, "obdo: o_gr = "LPD64"\n", oa->o_gr);
2053 if (valid & OBD_MD_FLFID)
2054 CDEBUG(D_RPCTRACE, "obdo: o_fid = "LPD64"\n", oa->o_fid);
2055 if (valid & OBD_MD_FLSIZE)
2056 CDEBUG(D_RPCTRACE, "obdo: o_size = "LPD64"\n", oa->o_size);
2057 if (valid & OBD_MD_FLMTIME)
2058 CDEBUG(D_RPCTRACE, "obdo: o_mtime = "LPD64"\n", oa->o_mtime);
2059 if (valid & OBD_MD_FLATIME)
2060 CDEBUG(D_RPCTRACE, "obdo: o_atime = "LPD64"\n", oa->o_atime);
2061 if (valid & OBD_MD_FLCTIME)
2062 CDEBUG(D_RPCTRACE, "obdo: o_ctime = "LPD64"\n", oa->o_ctime);
2063 if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
2064 CDEBUG(D_RPCTRACE, "obdo: o_blocks = "LPD64"\n", oa->o_blocks);
2065 if (valid & OBD_MD_FLGRANT)
2066 CDEBUG(D_RPCTRACE, "obdo: o_grant = "LPD64"\n", oa->o_grant);
2067 if (valid & OBD_MD_FLBLKSZ)
2068 CDEBUG(D_RPCTRACE, "obdo: o_blksize = %d\n", oa->o_blksize);
2069 if (valid & (OBD_MD_FLTYPE | OBD_MD_FLMODE))
2070 CDEBUG(D_RPCTRACE, "obdo: o_mode = %o\n",
2071 oa->o_mode & ((valid & OBD_MD_FLTYPE ? S_IFMT : 0) |
2072 (valid & OBD_MD_FLMODE ? ~S_IFMT : 0)));
2073 if (valid & OBD_MD_FLUID)
2074 CDEBUG(D_RPCTRACE, "obdo: o_uid = %u\n", oa->o_uid);
2075 if (valid & OBD_MD_FLGID)
2076 CDEBUG(D_RPCTRACE, "obdo: o_gid = %u\n", oa->o_gid);
2077 if (valid & OBD_MD_FLFLAGS)
2078 CDEBUG(D_RPCTRACE, "obdo: o_flags = %x\n", oa->o_flags);
2079 if (valid & OBD_MD_FLNLINK)
2080 CDEBUG(D_RPCTRACE, "obdo: o_nlink = %u\n", oa->o_nlink);
2081 else if (valid & OBD_MD_FLCKSUM)
2082 CDEBUG(D_RPCTRACE, "obdo: o_checksum (o_nlink) = %u\n", oa->o_nlink);
2083 if (valid & OBD_MD_FLGENER)
2084 CDEBUG(D_RPCTRACE, "obdo: o_generation = %u\n",
2086 else if (valid & OBD_MD_FLEPOCH)
2087 CDEBUG(D_RPCTRACE, "obdo: o_ioepoch = "LPD64"\n", oa->o_ioepoch);
2088 if (valid & OBD_MD_FLID)
2089 CDEBUG(D_RPCTRACE, "obdo: o_stripe_idx = %u\n", oa->o_stripe_idx);
2090 if (valid & OBD_MD_FLHANDLE)
2091 CDEBUG(D_RPCTRACE, "obdo: o_handle = "LPD64"\n", oa->o_handle.cookie);
2092 if (valid & OBD_MD_FLCOOKIE)
2093 CDEBUG(D_RPCTRACE, "obdo: o_lcookie = "
2094 "(llog_cookie dumping not yet implemented)\n");
2097 void dump_ost_body(struct ost_body *ob)
2102 void dump_rcs(__u32 *rc)
2104 CDEBUG(D_RPCTRACE, "rmf_rcs: %d\n", *rc);
2110 * got qdata from request(req/rep)
2112 struct qunit_data *quota_get_qdata(void *r, int is_req, int is_exp)
2114 struct ptlrpc_request *req = (struct ptlrpc_request *)r;
2115 struct qunit_data *qdata;
2116 __u64 flags = is_exp ? req->rq_export->exp_connect_flags :
2117 req->rq_import->imp_connect_data.ocd_connect_flags;
2120 /* support for quota64 */
2121 LASSERT(flags & OBD_CONNECT_QUOTA64);
2122 /* support for change_qs */
2123 LASSERT(flags & OBD_CONNECT_CHANGE_QS);
2125 if (is_req == QUOTA_REQUEST)
2126 qdata = req_capsule_client_get(&req->rq_pill, &RMF_QUNIT_DATA);
2128 qdata = req_capsule_server_get(&req->rq_pill, &RMF_QUNIT_DATA);
2130 return ERR_PTR(-EPROTO);
2132 QDATA_SET_CHANGE_QS(qdata);
2135 EXPORT_SYMBOL(quota_get_qdata);
2138 * copy qdata to request(req/rep)
2140 int quota_copy_qdata(void *r, struct qunit_data *qdata, int is_req,
2143 struct ptlrpc_request *req = (struct ptlrpc_request *)r;
2145 __u64 flags = is_exp ? req->rq_export->exp_connect_flags :
2146 req->rq_import->imp_connect_data.ocd_connect_flags;
2150 /* support for quota64 */
2151 LASSERT(flags & OBD_CONNECT_QUOTA64);
2152 /* support for change_qs */
2153 LASSERT(flags & OBD_CONNECT_CHANGE_QS);
2155 if (is_req == QUOTA_REQUEST)
2156 target = req_capsule_client_get(&req->rq_pill, &RMF_QUNIT_DATA);
2158 target = req_capsule_server_get(&req->rq_pill, &RMF_QUNIT_DATA);
2162 LASSERT(target != qdata);
2163 memcpy(target, qdata, sizeof(*qdata));
2166 EXPORT_SYMBOL(quota_copy_qdata);
2167 #endif /* __KERNEL__ */
2169 static inline int req_ptlrpc_body_swabbed(struct ptlrpc_request *req)
2171 LASSERT(req->rq_reqmsg);
2173 switch (req->rq_reqmsg->lm_magic) {
2174 case LUSTRE_MSG_MAGIC_V2:
2175 return lustre_req_swabbed(req, MSG_PTLRPC_BODY_OFF);
2177 CERROR("bad lustre msg magic: %#08X\n",
2178 req->rq_reqmsg->lm_magic);
2183 static inline int rep_ptlrpc_body_swabbed(struct ptlrpc_request *req)
2185 LASSERT(req->rq_repmsg);
2187 switch (req->rq_repmsg->lm_magic) {
2188 case LUSTRE_MSG_MAGIC_V2:
2189 return lustre_rep_swabbed(req, MSG_PTLRPC_BODY_OFF);
2191 /* uninitialized yet */
2196 void _debug_req(struct ptlrpc_request *req, __u32 mask,
2197 struct libcfs_debug_msg_data *data, const char *fmt, ... )
2200 va_start(args, fmt);
2201 libcfs_debug_vmsg2(data->msg_cdls, data->msg_subsys, mask, data->msg_file,
2202 data->msg_fn, data->msg_line, fmt, args,
2203 " req@%p x"LPU64"/t"LPD64"("LPD64") o%d->%s@%s:%d/%d"
2204 " lens %d/%d e %d to %d dl "CFS_TIME_T" ref %d "
2205 "fl "REQ_FLAGS_FMT"/%x/%x rc %d/%d\n",
2206 req, req->rq_xid, req->rq_transno,
2207 req->rq_reqmsg ? lustre_msg_get_transno(req->rq_reqmsg) : 0,
2208 req->rq_reqmsg ? lustre_msg_get_opc(req->rq_reqmsg) : -1,
2209 req->rq_import ? obd2cli_tgt(req->rq_import->imp_obd) :
2211 (char*)req->rq_export->exp_client_uuid.uuid : "<?>",
2213 (char *)req->rq_import->imp_connection->c_remote_uuid.uuid :
2215 (char *)req->rq_export->exp_connection->c_remote_uuid.uuid : "<?>",
2216 req->rq_request_portal, req->rq_reply_portal,
2217 req->rq_reqlen, req->rq_replen,
2218 req->rq_early_count, req->rq_timedout,
2220 cfs_atomic_read(&req->rq_refcount),
2221 DEBUG_REQ_FLAGS(req),
2222 req->rq_reqmsg && req_ptlrpc_body_swabbed(req) ?
2223 lustre_msg_get_flags(req->rq_reqmsg) : -1,
2224 req->rq_repmsg && rep_ptlrpc_body_swabbed(req) ?
2225 lustre_msg_get_flags(req->rq_repmsg) : -1,
2227 req->rq_repmsg && rep_ptlrpc_body_swabbed(req) ?
2228 lustre_msg_get_status(req->rq_repmsg) : -1);
2230 EXPORT_SYMBOL(_debug_req);
2232 void lustre_swab_lustre_capa(struct lustre_capa *c)
2234 lustre_swab_lu_fid(&c->lc_fid);
2235 __swab64s (&c->lc_opc);
2236 __swab64s (&c->lc_uid);
2237 __swab64s (&c->lc_gid);
2238 __swab32s (&c->lc_flags);
2239 __swab32s (&c->lc_keyid);
2240 __swab32s (&c->lc_timeout);
2241 __swab32s (&c->lc_expiry);
2244 void lustre_swab_lustre_capa_key(struct lustre_capa_key *k)
2246 __swab64s (&k->lk_mdsid);
2247 __swab32s (&k->lk_keyid);
2248 __swab32s (&k->lk_padding);
2251 void lustre_swab_kuch(struct kuc_hdr *l)
2253 __swab16s(&l->kuc_magic);
2254 /* __u8 l->kuc_transport */
2255 __swab16s(&l->kuc_msgtype);
2256 __swab16s(&l->kuc_msglen);
2258 EXPORT_SYMBOL(lustre_swab_kuch);