4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2013, Intel Corporation.
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>
57 #include <lustre_update.h>
59 static inline int lustre_msg_hdr_size_v2(int count)
61 return cfs_size_round(offsetof(struct lustre_msg_v2,
65 int lustre_msg_hdr_size(__u32 magic, int count)
68 case LUSTRE_MSG_MAGIC_V2:
69 return lustre_msg_hdr_size_v2(count);
71 LASSERTF(0, "incorrect message magic: %08x\n", magic);
75 EXPORT_SYMBOL(lustre_msg_hdr_size);
77 void ptlrpc_buf_set_swabbed(struct ptlrpc_request *req, const int inout,
81 lustre_set_req_swabbed(req, index);
83 lustre_set_rep_swabbed(req, index);
85 EXPORT_SYMBOL(ptlrpc_buf_set_swabbed);
87 int ptlrpc_buf_need_swab(struct ptlrpc_request *req, const int inout,
91 return (ptlrpc_req_need_swab(req) &&
92 !lustre_req_swabbed(req, index));
94 return (ptlrpc_rep_need_swab(req) &&
95 !lustre_rep_swabbed(req, index));
97 EXPORT_SYMBOL(ptlrpc_buf_need_swab);
99 /* This enlarges the req buffer of request \a req to the next power of 2
100 * multiple of \a newbuf_size.
101 * Returns zero on success or ENOMEM if it failed to allocate the new buffer.
103 * This is used in the reply path on the client if the server responded
104 * with a bigger message than we expected so we can save the new state for
105 * a possible future replay where we'll need to present this new info
106 * (usually striping that's not available at create time) */
107 int ptlrpc_enlarge_req_buffer(struct ptlrpc_request *req, int newbuf_size)
109 struct lustre_msg *newbuf;
111 newbuf_size = size_roundup_power2(newbuf_size);
113 OBD_ALLOC_LARGE(newbuf, newbuf_size);
117 /* Must lock this, so that otherwise unprotected change of
118 * rq_reqmsg is not racing with parallel processing of
119 * imp_replay_list traversing threads. See LU-3333
120 * This is a bandaid at best, we really need to deal with this
121 * in request enlarging code before unpacking what's already
124 spin_lock(&req->rq_import->imp_lock);
126 memcpy(newbuf, req->rq_reqbuf, req->rq_reqbuf_len);
128 OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
129 req->rq_reqbuf = newbuf;
130 req->rq_reqbuf_len = newbuf_size;
131 req->rq_reqmsg = lustre_msg_buf(req->rq_reqbuf, 1, 0);
134 spin_unlock(&req->rq_import->imp_lock);
139 static inline int lustre_msg_check_version_v2(struct lustre_msg_v2 *msg,
142 __u32 ver = lustre_msg_get_version(msg);
143 return (ver & LUSTRE_VERSION_MASK) != version;
146 int lustre_msg_check_version(struct lustre_msg *msg, __u32 version)
148 switch (msg->lm_magic) {
149 case LUSTRE_MSG_MAGIC_V1:
150 CERROR("msg v1 not supported - please upgrade you system\n");
152 case LUSTRE_MSG_MAGIC_V2:
153 return lustre_msg_check_version_v2(msg, version);
155 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
159 EXPORT_SYMBOL(lustre_msg_check_version);
161 /* early reply size */
162 int lustre_msg_early_size()
166 /* Always reply old ptlrpc_body_v2 to keep interoprability
167 * with the old client (< 2.3) which doesn't have pb_jobid
168 * in the ptlrpc_body.
170 * XXX Remove this whenever we dorp interoprability with such
173 __u32 pblen = sizeof(struct ptlrpc_body_v2);
174 size = lustre_msg_size(LUSTRE_MSG_MAGIC_V2, 1, &pblen);
178 EXPORT_SYMBOL(lustre_msg_early_size);
180 int lustre_msg_size_v2(int count, __u32 *lengths)
185 size = lustre_msg_hdr_size_v2(count);
186 for (i = 0; i < count; i++)
187 size += cfs_size_round(lengths[i]);
191 EXPORT_SYMBOL(lustre_msg_size_v2);
193 /* This returns the size of the buffer that is required to hold a lustre_msg
194 * with the given sub-buffer lengths.
195 * NOTE: this should only be used for NEW requests, and should always be
196 * in the form of a v2 request. If this is a connection to a v1
197 * target then the first buffer will be stripped because the ptlrpc
198 * data is part of the lustre_msg_v1 header. b=14043 */
199 int lustre_msg_size(__u32 magic, int count, __u32 *lens)
201 __u32 size[] = { sizeof(struct ptlrpc_body) };
209 LASSERT(lens[MSG_PTLRPC_BODY_OFF] >= sizeof(struct ptlrpc_body_v2));
212 case LUSTRE_MSG_MAGIC_V2:
213 return lustre_msg_size_v2(count, lens);
215 LASSERTF(0, "incorrect message magic: %08x\n", magic);
219 EXPORT_SYMBOL(lustre_msg_size);
221 /* This is used to determine the size of a buffer that was already packed
222 * and will correctly handle the different message formats. */
223 int lustre_packed_msg_size(struct lustre_msg *msg)
225 switch (msg->lm_magic) {
226 case LUSTRE_MSG_MAGIC_V2:
227 return lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens);
229 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
233 EXPORT_SYMBOL(lustre_packed_msg_size);
235 void lustre_init_msg_v2(struct lustre_msg_v2 *msg, int count, __u32 *lens,
241 msg->lm_bufcount = count;
242 /* XXX: lm_secflvr uninitialized here */
243 msg->lm_magic = LUSTRE_MSG_MAGIC_V2;
245 for (i = 0; i < count; i++)
246 msg->lm_buflens[i] = lens[i];
251 ptr = (char *)msg + lustre_msg_hdr_size_v2(count);
252 for (i = 0; i < count; i++) {
254 LOGL(tmp, lens[i], ptr);
257 EXPORT_SYMBOL(lustre_init_msg_v2);
259 static int lustre_pack_request_v2(struct ptlrpc_request *req,
260 int count, __u32 *lens, char **bufs)
264 reqlen = lustre_msg_size_v2(count, lens);
266 rc = sptlrpc_cli_alloc_reqbuf(req, reqlen);
270 req->rq_reqlen = reqlen;
272 lustre_init_msg_v2(req->rq_reqmsg, count, lens, bufs);
273 lustre_msg_add_version(req->rq_reqmsg, PTLRPC_MSG_VERSION);
277 int lustre_pack_request(struct ptlrpc_request *req, __u32 magic, int count,
278 __u32 *lens, char **bufs)
280 __u32 size[] = { sizeof(struct ptlrpc_body) };
288 LASSERT(lens[MSG_PTLRPC_BODY_OFF] == sizeof(struct ptlrpc_body));
290 /* only use new format, we don't need to be compatible with 1.4 */
291 magic = LUSTRE_MSG_MAGIC_V2;
294 case LUSTRE_MSG_MAGIC_V2:
295 return lustre_pack_request_v2(req, count, lens, bufs);
297 LASSERTF(0, "incorrect message magic: %08x\n", magic);
301 EXPORT_SYMBOL(lustre_pack_request);
304 CFS_LIST_HEAD(ptlrpc_rs_debug_lru);
305 spinlock_t ptlrpc_rs_debug_lock;
307 #define PTLRPC_RS_DEBUG_LRU_ADD(rs) \
309 spin_lock(&ptlrpc_rs_debug_lock); \
310 cfs_list_add_tail(&(rs)->rs_debug_list, &ptlrpc_rs_debug_lru); \
311 spin_unlock(&ptlrpc_rs_debug_lock); \
314 #define PTLRPC_RS_DEBUG_LRU_DEL(rs) \
316 spin_lock(&ptlrpc_rs_debug_lock); \
317 cfs_list_del(&(rs)->rs_debug_list); \
318 spin_unlock(&ptlrpc_rs_debug_lock); \
321 # define PTLRPC_RS_DEBUG_LRU_ADD(rs) do {} while(0)
322 # define PTLRPC_RS_DEBUG_LRU_DEL(rs) do {} while(0)
325 struct ptlrpc_reply_state *
326 lustre_get_emerg_rs(struct ptlrpc_service_part *svcpt)
328 struct ptlrpc_reply_state *rs = NULL;
330 spin_lock(&svcpt->scp_rep_lock);
332 /* See if we have anything in a pool, and wait if nothing */
333 while (cfs_list_empty(&svcpt->scp_rep_idle)) {
334 struct l_wait_info lwi;
337 spin_unlock(&svcpt->scp_rep_lock);
338 /* If we cannot get anything for some long time, we better
339 * bail out instead of waiting infinitely */
340 lwi = LWI_TIMEOUT(cfs_time_seconds(10), NULL, NULL);
341 rc = l_wait_event(svcpt->scp_rep_waitq,
342 !cfs_list_empty(&svcpt->scp_rep_idle), &lwi);
345 spin_lock(&svcpt->scp_rep_lock);
348 rs = cfs_list_entry(svcpt->scp_rep_idle.next,
349 struct ptlrpc_reply_state, rs_list);
350 cfs_list_del(&rs->rs_list);
352 spin_unlock(&svcpt->scp_rep_lock);
354 memset(rs, 0, svcpt->scp_service->srv_max_reply_size);
355 rs->rs_size = svcpt->scp_service->srv_max_reply_size;
356 rs->rs_svcpt = svcpt;
362 void lustre_put_emerg_rs(struct ptlrpc_reply_state *rs)
364 struct ptlrpc_service_part *svcpt = rs->rs_svcpt;
366 spin_lock(&svcpt->scp_rep_lock);
367 cfs_list_add(&rs->rs_list, &svcpt->scp_rep_idle);
368 spin_unlock(&svcpt->scp_rep_lock);
369 wake_up(&svcpt->scp_rep_waitq);
372 int lustre_pack_reply_v2(struct ptlrpc_request *req, int count,
373 __u32 *lens, char **bufs, int flags)
375 struct ptlrpc_reply_state *rs;
379 LASSERT(req->rq_reply_state == NULL);
381 if ((flags & LPRFL_EARLY_REPLY) == 0) {
382 spin_lock(&req->rq_lock);
383 req->rq_packed_final = 1;
384 spin_unlock(&req->rq_lock);
387 msg_len = lustre_msg_size_v2(count, lens);
388 rc = sptlrpc_svc_alloc_rs(req, msg_len);
392 rs = req->rq_reply_state;
393 atomic_set(&rs->rs_refcount, 1); /* 1 ref for rq_reply_state */
394 rs->rs_cb_id.cbid_fn = reply_out_callback;
395 rs->rs_cb_id.cbid_arg = rs;
396 rs->rs_svcpt = req->rq_rqbd->rqbd_svcpt;
397 CFS_INIT_LIST_HEAD(&rs->rs_exp_list);
398 CFS_INIT_LIST_HEAD(&rs->rs_obd_list);
399 CFS_INIT_LIST_HEAD(&rs->rs_list);
400 spin_lock_init(&rs->rs_lock);
402 req->rq_replen = msg_len;
403 req->rq_reply_state = rs;
404 req->rq_repmsg = rs->rs_msg;
406 lustre_init_msg_v2(rs->rs_msg, count, lens, bufs);
407 lustre_msg_add_version(rs->rs_msg, PTLRPC_MSG_VERSION);
409 PTLRPC_RS_DEBUG_LRU_ADD(rs);
413 EXPORT_SYMBOL(lustre_pack_reply_v2);
415 int lustre_pack_reply_flags(struct ptlrpc_request *req, int count, __u32 *lens,
416 char **bufs, int flags)
419 __u32 size[] = { sizeof(struct ptlrpc_body) };
427 LASSERT(lens[MSG_PTLRPC_BODY_OFF] == sizeof(struct ptlrpc_body));
429 switch (req->rq_reqmsg->lm_magic) {
430 case LUSTRE_MSG_MAGIC_V2:
431 rc = lustre_pack_reply_v2(req, count, lens, bufs, flags);
434 LASSERTF(0, "incorrect message magic: %08x\n",
435 req->rq_reqmsg->lm_magic);
439 CERROR("lustre_pack_reply failed: rc=%d size=%d\n", rc,
440 lustre_msg_size(req->rq_reqmsg->lm_magic, count, lens));
443 EXPORT_SYMBOL(lustre_pack_reply_flags);
445 int lustre_pack_reply(struct ptlrpc_request *req, int count, __u32 *lens,
448 return lustre_pack_reply_flags(req, count, lens, bufs, 0);
450 EXPORT_SYMBOL(lustre_pack_reply);
452 void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, int n, int min_size)
454 int i, offset, buflen, bufcount;
459 bufcount = m->lm_bufcount;
460 if (unlikely(n >= bufcount)) {
461 CDEBUG(D_INFO, "msg %p buffer[%d] not present (count %d)\n",
466 buflen = m->lm_buflens[n];
467 if (unlikely(buflen < min_size)) {
468 CERROR("msg %p buffer[%d] size %d too small "
469 "(required %d, opc=%d)\n", m, n, buflen, min_size,
470 n == MSG_PTLRPC_BODY_OFF ? -1 : lustre_msg_get_opc(m));
474 offset = lustre_msg_hdr_size_v2(bufcount);
475 for (i = 0; i < n; i++)
476 offset += cfs_size_round(m->lm_buflens[i]);
478 return (char *)m + offset;
481 void *lustre_msg_buf(struct lustre_msg *m, int n, int min_size)
483 switch (m->lm_magic) {
484 case LUSTRE_MSG_MAGIC_V2:
485 return lustre_msg_buf_v2(m, n, min_size);
487 LASSERTF(0, "incorrect message magic: %08x(msg:%p)\n", m->lm_magic, m);
491 EXPORT_SYMBOL(lustre_msg_buf);
493 int lustre_shrink_msg_v2(struct lustre_msg_v2 *msg, int segment,
494 unsigned int newlen, int move_data)
496 char *tail = NULL, *newpos;
500 LASSERT(msg->lm_bufcount > segment);
501 LASSERT(msg->lm_buflens[segment] >= newlen);
503 if (msg->lm_buflens[segment] == newlen)
506 if (move_data && msg->lm_bufcount > segment + 1) {
507 tail = lustre_msg_buf_v2(msg, segment + 1, 0);
508 for (n = segment + 1; n < msg->lm_bufcount; n++)
509 tail_len += cfs_size_round(msg->lm_buflens[n]);
512 msg->lm_buflens[segment] = newlen;
514 if (tail && tail_len) {
515 newpos = lustre_msg_buf_v2(msg, segment + 1, 0);
516 LASSERT(newpos <= tail);
518 memmove(newpos, tail, tail_len);
521 return lustre_msg_size_v2(msg->lm_bufcount, msg->lm_buflens);
525 * for @msg, shrink @segment to size @newlen. if @move_data is non-zero,
526 * we also move data forward from @segment + 1.
528 * if @newlen == 0, we remove the segment completely, but we still keep the
529 * totally bufcount the same to save possible data moving. this will leave a
530 * unused segment with size 0 at the tail, but that's ok.
532 * return new msg size after shrinking.
535 * + if any buffers higher than @segment has been filled in, must call shrink
536 * with non-zero @move_data.
537 * + caller should NOT keep pointers to msg buffers which higher than @segment
540 int lustre_shrink_msg(struct lustre_msg *msg, int segment,
541 unsigned int newlen, int move_data)
543 switch (msg->lm_magic) {
544 case LUSTRE_MSG_MAGIC_V2:
545 return lustre_shrink_msg_v2(msg, segment, newlen, move_data);
547 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
550 EXPORT_SYMBOL(lustre_shrink_msg);
552 void lustre_free_reply_state(struct ptlrpc_reply_state *rs)
554 PTLRPC_RS_DEBUG_LRU_DEL(rs);
556 LASSERT(atomic_read(&rs->rs_refcount) == 0);
557 LASSERT(!rs->rs_difficult || rs->rs_handled);
558 LASSERT(!rs->rs_on_net);
559 LASSERT(!rs->rs_scheduled);
560 LASSERT(rs->rs_export == NULL);
561 LASSERT(rs->rs_nlocks == 0);
562 LASSERT(cfs_list_empty(&rs->rs_exp_list));
563 LASSERT(cfs_list_empty(&rs->rs_obd_list));
565 sptlrpc_svc_free_rs(rs);
567 EXPORT_SYMBOL(lustre_free_reply_state);
569 static int lustre_unpack_msg_v2(struct lustre_msg_v2 *m, int len)
571 int swabbed, required_len, i;
573 /* Now we know the sender speaks my language. */
574 required_len = lustre_msg_hdr_size_v2(0);
575 if (len < required_len) {
576 /* can't even look inside the message */
577 CERROR("message length %d too small for lustre_msg\n", len);
581 swabbed = (m->lm_magic == LUSTRE_MSG_MAGIC_V2_SWABBED);
584 __swab32s(&m->lm_magic);
585 __swab32s(&m->lm_bufcount);
586 __swab32s(&m->lm_secflvr);
587 __swab32s(&m->lm_repsize);
588 __swab32s(&m->lm_cksum);
589 __swab32s(&m->lm_flags);
590 CLASSERT(offsetof(typeof(*m), lm_padding_2) != 0);
591 CLASSERT(offsetof(typeof(*m), lm_padding_3) != 0);
594 required_len = lustre_msg_hdr_size_v2(m->lm_bufcount);
595 if (len < required_len) {
596 /* didn't receive all the buffer lengths */
597 CERROR ("message length %d too small for %d buflens\n",
598 len, m->lm_bufcount);
602 for (i = 0; i < m->lm_bufcount; i++) {
604 __swab32s(&m->lm_buflens[i]);
605 required_len += cfs_size_round(m->lm_buflens[i]);
608 if (len < required_len) {
609 CERROR("len: %d, required_len %d\n", len, required_len);
610 CERROR("bufcount: %d\n", m->lm_bufcount);
611 for (i = 0; i < m->lm_bufcount; i++)
612 CERROR("buffer %d length %d\n", i, m->lm_buflens[i]);
619 int __lustre_unpack_msg(struct lustre_msg *m, int len)
621 int required_len, rc;
624 /* We can provide a slightly better error log, if we check the
625 * message magic and version first. In the future, struct
626 * lustre_msg may grow, and we'd like to log a version mismatch,
627 * rather than a short message.
630 required_len = offsetof(struct lustre_msg, lm_magic) +
632 if (len < required_len) {
633 /* can't even look inside the message */
634 CERROR("message length %d too small for magic/version check\n",
639 rc = lustre_unpack_msg_v2(m, len);
643 EXPORT_SYMBOL(__lustre_unpack_msg);
645 int ptlrpc_unpack_req_msg(struct ptlrpc_request *req, int len)
648 rc = __lustre_unpack_msg(req->rq_reqmsg, len);
650 lustre_set_req_swabbed(req, MSG_PTLRPC_HEADER_OFF);
655 EXPORT_SYMBOL(ptlrpc_unpack_req_msg);
657 int ptlrpc_unpack_rep_msg(struct ptlrpc_request *req, int len)
660 rc = __lustre_unpack_msg(req->rq_repmsg, len);
662 lustre_set_rep_swabbed(req, MSG_PTLRPC_HEADER_OFF);
667 EXPORT_SYMBOL(ptlrpc_unpack_rep_msg);
669 static inline int lustre_unpack_ptlrpc_body_v2(struct ptlrpc_request *req,
670 const int inout, int offset)
672 struct ptlrpc_body *pb;
673 struct lustre_msg_v2 *m = inout ? req->rq_reqmsg : req->rq_repmsg;
675 pb = lustre_msg_buf_v2(m, offset, sizeof(struct ptlrpc_body_v2));
677 CERROR("error unpacking ptlrpc body\n");
680 if (ptlrpc_buf_need_swab(req, inout, offset)) {
681 lustre_swab_ptlrpc_body(pb);
682 ptlrpc_buf_set_swabbed(req, inout, offset);
685 if ((pb->pb_version & ~LUSTRE_VERSION_MASK) != PTLRPC_MSG_VERSION) {
686 CERROR("wrong lustre_msg version %08x\n", pb->pb_version);
691 pb->pb_status = ptlrpc_status_ntoh(pb->pb_status);
696 int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset)
698 switch (req->rq_reqmsg->lm_magic) {
699 case LUSTRE_MSG_MAGIC_V2:
700 return lustre_unpack_ptlrpc_body_v2(req, 1, offset);
702 CERROR("bad lustre msg magic: %08x\n",
703 req->rq_reqmsg->lm_magic);
708 int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset)
710 switch (req->rq_repmsg->lm_magic) {
711 case LUSTRE_MSG_MAGIC_V2:
712 return lustre_unpack_ptlrpc_body_v2(req, 0, offset);
714 CERROR("bad lustre msg magic: %08x\n",
715 req->rq_repmsg->lm_magic);
720 static inline int lustre_msg_buflen_v2(struct lustre_msg_v2 *m, int n)
722 if (n >= m->lm_bufcount)
725 return m->lm_buflens[n];
729 * lustre_msg_buflen - return the length of buffer \a n in message \a m
730 * \param m lustre_msg (request or reply) to look at
731 * \param n message index (base 0)
733 * returns zero for non-existent message indices
735 int lustre_msg_buflen(struct lustre_msg *m, int n)
737 switch (m->lm_magic) {
738 case LUSTRE_MSG_MAGIC_V2:
739 return lustre_msg_buflen_v2(m, n);
741 CERROR("incorrect message magic: %08x\n", m->lm_magic);
745 EXPORT_SYMBOL(lustre_msg_buflen);
748 lustre_msg_set_buflen_v2(struct lustre_msg_v2 *m, int n, int len)
750 if (n >= m->lm_bufcount)
753 m->lm_buflens[n] = len;
756 void lustre_msg_set_buflen(struct lustre_msg *m, int n, int len)
758 switch (m->lm_magic) {
759 case LUSTRE_MSG_MAGIC_V2:
760 lustre_msg_set_buflen_v2(m, n, len);
763 LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic);
767 EXPORT_SYMBOL(lustre_msg_set_buflen);
769 /* NB return the bufcount for lustre_msg_v2 format, so if message is packed
770 * in V1 format, the result is one bigger. (add struct ptlrpc_body). */
771 int lustre_msg_bufcount(struct lustre_msg *m)
773 switch (m->lm_magic) {
774 case LUSTRE_MSG_MAGIC_V2:
775 return m->lm_bufcount;
777 CERROR("incorrect message magic: %08x\n", m->lm_magic);
781 EXPORT_SYMBOL(lustre_msg_bufcount);
783 char *lustre_msg_string(struct lustre_msg *m, int index, int max_len)
785 /* max_len == 0 means the string should fill the buffer */
789 switch (m->lm_magic) {
790 case LUSTRE_MSG_MAGIC_V2:
791 str = lustre_msg_buf_v2(m, index, 0);
792 blen = lustre_msg_buflen_v2(m, index);
795 LASSERTF(0, "incorrect message magic: %08x\n", m->lm_magic);
799 CERROR ("can't unpack string in msg %p buffer[%d]\n", m, index);
803 slen = strnlen(str, blen);
805 if (slen == blen) { /* not NULL terminated */
806 CERROR("can't unpack non-NULL terminated string in "
807 "msg %p buffer[%d] len %d\n", m, index, blen);
812 if (slen != blen - 1) {
813 CERROR("can't unpack short string in msg %p "
814 "buffer[%d] len %d: strlen %d\n",
815 m, index, blen, slen);
818 } else if (slen > max_len) {
819 CERROR("can't unpack oversized string in msg %p "
820 "buffer[%d] len %d strlen %d: max %d expected\n",
821 m, index, blen, slen, max_len);
827 EXPORT_SYMBOL(lustre_msg_string);
829 /* Wrap up the normal fixed length cases */
830 static inline void *__lustre_swab_buf(struct lustre_msg *msg, int index,
831 int min_size, void *swabber)
835 LASSERT(msg != NULL);
836 switch (msg->lm_magic) {
837 case LUSTRE_MSG_MAGIC_V2:
838 ptr = lustre_msg_buf_v2(msg, index, min_size);
841 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
845 ((void (*)(void *))swabber)(ptr);
850 static inline struct ptlrpc_body *lustre_msg_ptlrpc_body(struct lustre_msg *msg)
852 return lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF,
853 sizeof(struct ptlrpc_body_v2));
856 __u32 lustre_msghdr_get_flags(struct lustre_msg *msg)
858 switch (msg->lm_magic) {
859 case LUSTRE_MSG_MAGIC_V1:
860 case LUSTRE_MSG_MAGIC_V1_SWABBED:
862 case LUSTRE_MSG_MAGIC_V2:
863 /* already in host endian */
864 return msg->lm_flags;
866 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
870 EXPORT_SYMBOL(lustre_msghdr_get_flags);
872 void lustre_msghdr_set_flags(struct lustre_msg *msg, __u32 flags)
874 switch (msg->lm_magic) {
875 case LUSTRE_MSG_MAGIC_V1:
877 case LUSTRE_MSG_MAGIC_V2:
878 msg->lm_flags = flags;
881 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
885 __u32 lustre_msg_get_flags(struct lustre_msg *msg)
887 switch (msg->lm_magic) {
888 case LUSTRE_MSG_MAGIC_V2: {
889 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
891 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
897 /* flags might be printed in debug code while message
902 EXPORT_SYMBOL(lustre_msg_get_flags);
904 void lustre_msg_add_flags(struct lustre_msg *msg, int flags)
906 switch (msg->lm_magic) {
907 case LUSTRE_MSG_MAGIC_V2: {
908 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
909 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
910 pb->pb_flags |= flags;
914 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
917 EXPORT_SYMBOL(lustre_msg_add_flags);
919 void lustre_msg_set_flags(struct lustre_msg *msg, int flags)
921 switch (msg->lm_magic) {
922 case LUSTRE_MSG_MAGIC_V2: {
923 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
924 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
925 pb->pb_flags = flags;
929 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
932 EXPORT_SYMBOL(lustre_msg_set_flags);
934 void lustre_msg_clear_flags(struct lustre_msg *msg, int flags)
936 switch (msg->lm_magic) {
937 case LUSTRE_MSG_MAGIC_V2: {
938 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
939 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
940 pb->pb_flags &= ~(MSG_GEN_FLAG_MASK & flags);
944 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
947 EXPORT_SYMBOL(lustre_msg_clear_flags);
949 __u32 lustre_msg_get_op_flags(struct lustre_msg *msg)
951 switch (msg->lm_magic) {
952 case LUSTRE_MSG_MAGIC_V2: {
953 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
955 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
958 return pb->pb_op_flags;
964 EXPORT_SYMBOL(lustre_msg_get_op_flags);
966 void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags)
968 switch (msg->lm_magic) {
969 case LUSTRE_MSG_MAGIC_V2: {
970 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
971 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
972 pb->pb_op_flags |= flags;
976 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
979 EXPORT_SYMBOL(lustre_msg_add_op_flags);
981 void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
983 switch (msg->lm_magic) {
984 case LUSTRE_MSG_MAGIC_V2: {
985 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
986 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
987 pb->pb_op_flags |= flags;
991 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
994 EXPORT_SYMBOL(lustre_msg_set_op_flags);
996 struct lustre_handle *lustre_msg_get_handle(struct lustre_msg *msg)
998 switch (msg->lm_magic) {
999 case LUSTRE_MSG_MAGIC_V2: {
1000 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1002 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1005 return &pb->pb_handle;
1008 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1012 EXPORT_SYMBOL(lustre_msg_get_handle);
1014 __u32 lustre_msg_get_type(struct lustre_msg *msg)
1016 switch (msg->lm_magic) {
1017 case LUSTRE_MSG_MAGIC_V2: {
1018 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1020 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1021 return PTL_RPC_MSG_ERR;
1026 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1027 return PTL_RPC_MSG_ERR;
1030 EXPORT_SYMBOL(lustre_msg_get_type);
1032 __u32 lustre_msg_get_version(struct lustre_msg *msg)
1034 switch (msg->lm_magic) {
1035 case LUSTRE_MSG_MAGIC_V2: {
1036 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1038 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1041 return pb->pb_version;
1044 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1048 EXPORT_SYMBOL(lustre_msg_get_version);
1050 void lustre_msg_add_version(struct lustre_msg *msg, int version)
1052 switch (msg->lm_magic) {
1053 case LUSTRE_MSG_MAGIC_V2: {
1054 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1055 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1056 pb->pb_version |= version;
1060 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1063 EXPORT_SYMBOL(lustre_msg_add_version);
1065 __u32 lustre_msg_get_opc(struct lustre_msg *msg)
1067 switch (msg->lm_magic) {
1068 case LUSTRE_MSG_MAGIC_V2: {
1069 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1071 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1077 CERROR("incorrect message magic: %08x(msg:%p)\n", msg->lm_magic, msg);
1082 EXPORT_SYMBOL(lustre_msg_get_opc);
1084 __u64 lustre_msg_get_last_xid(struct lustre_msg *msg)
1086 switch (msg->lm_magic) {
1087 case LUSTRE_MSG_MAGIC_V2: {
1088 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1090 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1093 return pb->pb_last_xid;
1096 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1100 EXPORT_SYMBOL(lustre_msg_get_last_xid);
1102 __u64 lustre_msg_get_last_committed(struct lustre_msg *msg)
1104 switch (msg->lm_magic) {
1105 case LUSTRE_MSG_MAGIC_V2: {
1106 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1108 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1111 return pb->pb_last_committed;
1114 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1118 EXPORT_SYMBOL(lustre_msg_get_last_committed);
1120 __u64 *lustre_msg_get_versions(struct lustre_msg *msg)
1122 switch (msg->lm_magic) {
1123 case LUSTRE_MSG_MAGIC_V1:
1125 case LUSTRE_MSG_MAGIC_V2: {
1126 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1128 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1131 return pb->pb_pre_versions;
1134 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1138 EXPORT_SYMBOL(lustre_msg_get_versions);
1140 __u64 lustre_msg_get_transno(struct lustre_msg *msg)
1142 switch (msg->lm_magic) {
1143 case LUSTRE_MSG_MAGIC_V2: {
1144 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1146 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1149 return pb->pb_transno;
1152 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1156 EXPORT_SYMBOL(lustre_msg_get_transno);
1158 int lustre_msg_get_status(struct lustre_msg *msg)
1160 switch (msg->lm_magic) {
1161 case LUSTRE_MSG_MAGIC_V2: {
1162 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1164 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1167 return pb->pb_status;
1170 /* status might be printed in debug code while message
1175 EXPORT_SYMBOL(lustre_msg_get_status);
1177 __u64 lustre_msg_get_slv(struct lustre_msg *msg)
1179 switch (msg->lm_magic) {
1180 case LUSTRE_MSG_MAGIC_V2: {
1181 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1183 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1189 CERROR("invalid msg magic %08x\n", msg->lm_magic);
1193 EXPORT_SYMBOL(lustre_msg_get_slv);
1196 void lustre_msg_set_slv(struct lustre_msg *msg, __u64 slv)
1198 switch (msg->lm_magic) {
1199 case LUSTRE_MSG_MAGIC_V2: {
1200 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1202 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1209 CERROR("invalid msg magic %x\n", msg->lm_magic);
1213 EXPORT_SYMBOL(lustre_msg_set_slv);
1215 __u32 lustre_msg_get_limit(struct lustre_msg *msg)
1217 switch (msg->lm_magic) {
1218 case LUSTRE_MSG_MAGIC_V2: {
1219 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1221 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1224 return pb->pb_limit;
1227 CERROR("invalid msg magic %x\n", msg->lm_magic);
1231 EXPORT_SYMBOL(lustre_msg_get_limit);
1234 void lustre_msg_set_limit(struct lustre_msg *msg, __u64 limit)
1236 switch (msg->lm_magic) {
1237 case LUSTRE_MSG_MAGIC_V2: {
1238 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1240 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1243 pb->pb_limit = limit;
1247 CERROR("invalid msg magic %08x\n", msg->lm_magic);
1251 EXPORT_SYMBOL(lustre_msg_set_limit);
1253 __u32 lustre_msg_get_conn_cnt(struct lustre_msg *msg)
1255 switch (msg->lm_magic) {
1256 case LUSTRE_MSG_MAGIC_V2: {
1257 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1259 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1262 return pb->pb_conn_cnt;
1265 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1269 EXPORT_SYMBOL(lustre_msg_get_conn_cnt);
1271 int lustre_msg_is_v1(struct lustre_msg *msg)
1273 switch (msg->lm_magic) {
1274 case LUSTRE_MSG_MAGIC_V1:
1275 case LUSTRE_MSG_MAGIC_V1_SWABBED:
1281 EXPORT_SYMBOL(lustre_msg_is_v1);
1283 __u32 lustre_msg_get_magic(struct lustre_msg *msg)
1285 switch (msg->lm_magic) {
1286 case LUSTRE_MSG_MAGIC_V2:
1287 return msg->lm_magic;
1289 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1293 EXPORT_SYMBOL(lustre_msg_get_magic);
1295 __u32 lustre_msg_get_timeout(struct lustre_msg *msg)
1297 switch (msg->lm_magic) {
1298 case LUSTRE_MSG_MAGIC_V1:
1299 case LUSTRE_MSG_MAGIC_V1_SWABBED:
1301 case LUSTRE_MSG_MAGIC_V2: {
1302 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1304 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1308 return pb->pb_timeout;
1311 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1316 __u32 lustre_msg_get_service_time(struct lustre_msg *msg)
1318 switch (msg->lm_magic) {
1319 case LUSTRE_MSG_MAGIC_V1:
1320 case LUSTRE_MSG_MAGIC_V1_SWABBED:
1322 case LUSTRE_MSG_MAGIC_V2: {
1323 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1325 CERROR("invalid msg %p: no ptlrpc body!\n", msg);
1329 return pb->pb_service_time;
1332 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1337 char *lustre_msg_get_jobid(struct lustre_msg *msg)
1339 switch (msg->lm_magic) {
1340 case LUSTRE_MSG_MAGIC_V1:
1341 case LUSTRE_MSG_MAGIC_V1_SWABBED:
1343 case LUSTRE_MSG_MAGIC_V2: {
1344 struct ptlrpc_body *pb =
1345 lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF,
1346 sizeof(struct ptlrpc_body));
1350 return pb->pb_jobid;
1353 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1357 EXPORT_SYMBOL(lustre_msg_get_jobid);
1359 __u32 lustre_msg_get_cksum(struct lustre_msg *msg)
1361 switch (msg->lm_magic) {
1362 case LUSTRE_MSG_MAGIC_V2:
1363 return msg->lm_cksum;
1365 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1370 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0)
1372 * In 1.6 and 1.8 the checksum was computed only on struct ptlrpc_body as
1373 * it was in 1.6 (88 bytes, smaller than the full size in 1.8). It makes
1374 * more sense to compute the checksum on the full ptlrpc_body, regardless
1375 * of what size it is, but in order to keep interoperability with 1.8 we
1376 * can optionally also checksum only the first 88 bytes (caller decides). */
1377 # define ptlrpc_body_cksum_size_compat18 88
1379 __u32 lustre_msg_calc_cksum(struct lustre_msg *msg, int compat18)
1381 # warning "remove checksum compatibility support for b1_8"
1382 __u32 lustre_msg_calc_cksum(struct lustre_msg *msg)
1385 switch (msg->lm_magic) {
1386 case LUSTRE_MSG_MAGIC_V2: {
1387 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1388 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 7, 50, 0)
1390 unsigned int hsize = 4;
1391 __u32 len = compat18 ? ptlrpc_body_cksum_size_compat18 :
1392 lustre_msg_buflen(msg, MSG_PTLRPC_BODY_OFF);
1393 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1394 cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32, (unsigned char *)pb,
1395 len, NULL, 0, (unsigned char *)&crc,
1399 # warning "remove checksum compatibility support for b1_8"
1401 unsigned int hsize = 4;
1402 cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32, (unsigned char *)pb,
1403 lustre_msg_buflen(msg, MSG_PTLRPC_BODY_OFF),
1404 NULL, 0, (unsigned char *)&crc, &hsize);
1409 CERROR("incorrect message magic: %08x\n", msg->lm_magic);
1414 void lustre_msg_set_handle(struct lustre_msg *msg, struct lustre_handle *handle)
1416 switch (msg->lm_magic) {
1417 case LUSTRE_MSG_MAGIC_V2: {
1418 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1419 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1420 pb->pb_handle = *handle;
1424 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1427 EXPORT_SYMBOL(lustre_msg_set_handle);
1429 void lustre_msg_set_type(struct lustre_msg *msg, __u32 type)
1431 switch (msg->lm_magic) {
1432 case LUSTRE_MSG_MAGIC_V2: {
1433 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1434 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1439 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1442 EXPORT_SYMBOL(lustre_msg_set_type);
1444 void lustre_msg_set_opc(struct lustre_msg *msg, __u32 opc)
1446 switch (msg->lm_magic) {
1447 case LUSTRE_MSG_MAGIC_V2: {
1448 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1449 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1454 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1457 EXPORT_SYMBOL(lustre_msg_set_opc);
1459 void lustre_msg_set_last_xid(struct lustre_msg *msg, __u64 last_xid)
1461 switch (msg->lm_magic) {
1462 case LUSTRE_MSG_MAGIC_V2: {
1463 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1464 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1465 pb->pb_last_xid = last_xid;
1469 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1472 EXPORT_SYMBOL(lustre_msg_set_last_xid);
1474 void lustre_msg_set_last_committed(struct lustre_msg *msg, __u64 last_committed)
1476 switch (msg->lm_magic) {
1477 case LUSTRE_MSG_MAGIC_V2: {
1478 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1479 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1480 pb->pb_last_committed = last_committed;
1484 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1487 EXPORT_SYMBOL(lustre_msg_set_last_committed);
1489 void lustre_msg_set_versions(struct lustre_msg *msg, __u64 *versions)
1491 switch (msg->lm_magic) {
1492 case LUSTRE_MSG_MAGIC_V1:
1494 case LUSTRE_MSG_MAGIC_V2: {
1495 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1496 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1497 pb->pb_pre_versions[0] = versions[0];
1498 pb->pb_pre_versions[1] = versions[1];
1499 pb->pb_pre_versions[2] = versions[2];
1500 pb->pb_pre_versions[3] = versions[3];
1504 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1507 EXPORT_SYMBOL(lustre_msg_set_versions);
1509 void lustre_msg_set_transno(struct lustre_msg *msg, __u64 transno)
1511 switch (msg->lm_magic) {
1512 case LUSTRE_MSG_MAGIC_V2: {
1513 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1514 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1515 pb->pb_transno = transno;
1519 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1522 EXPORT_SYMBOL(lustre_msg_set_transno);
1524 void lustre_msg_set_status(struct lustre_msg *msg, __u32 status)
1526 switch (msg->lm_magic) {
1527 case LUSTRE_MSG_MAGIC_V2: {
1528 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1529 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1530 pb->pb_status = status;
1534 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1537 EXPORT_SYMBOL(lustre_msg_set_status);
1539 void lustre_msg_set_conn_cnt(struct lustre_msg *msg, __u32 conn_cnt)
1541 switch (msg->lm_magic) {
1542 case LUSTRE_MSG_MAGIC_V2: {
1543 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1544 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1545 pb->pb_conn_cnt = conn_cnt;
1549 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1552 EXPORT_SYMBOL(lustre_msg_set_conn_cnt);
1554 void lustre_msg_set_timeout(struct lustre_msg *msg, __u32 timeout)
1556 switch (msg->lm_magic) {
1557 case LUSTRE_MSG_MAGIC_V1:
1559 case LUSTRE_MSG_MAGIC_V2: {
1560 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1561 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1562 pb->pb_timeout = timeout;
1566 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1570 void lustre_msg_set_service_time(struct lustre_msg *msg, __u32 service_time)
1572 switch (msg->lm_magic) {
1573 case LUSTRE_MSG_MAGIC_V1:
1575 case LUSTRE_MSG_MAGIC_V2: {
1576 struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
1577 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1578 pb->pb_service_time = service_time;
1582 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1586 void lustre_msg_set_jobid(struct lustre_msg *msg, char *jobid)
1588 switch (msg->lm_magic) {
1589 case LUSTRE_MSG_MAGIC_V1:
1591 case LUSTRE_MSG_MAGIC_V2: {
1592 __u32 opc = lustre_msg_get_opc(msg);
1593 struct ptlrpc_body *pb;
1595 /* Don't set jobid for ldlm ast RPCs, they've been shrinked.
1596 * See the comment in ptlrpc_request_pack(). */
1597 if (!opc || opc == LDLM_BL_CALLBACK ||
1598 opc == LDLM_CP_CALLBACK || opc == LDLM_GL_CALLBACK)
1601 pb = lustre_msg_buf_v2(msg, MSG_PTLRPC_BODY_OFF,
1602 sizeof(struct ptlrpc_body));
1603 LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
1606 memcpy(pb->pb_jobid, jobid, JOBSTATS_JOBID_SIZE);
1607 else if (pb->pb_jobid[0] == '\0')
1608 lustre_get_jobid(pb->pb_jobid);
1612 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1615 EXPORT_SYMBOL(lustre_msg_set_jobid);
1617 void lustre_msg_set_cksum(struct lustre_msg *msg, __u32 cksum)
1619 switch (msg->lm_magic) {
1620 case LUSTRE_MSG_MAGIC_V1:
1622 case LUSTRE_MSG_MAGIC_V2:
1623 msg->lm_cksum = cksum;
1626 LASSERTF(0, "incorrect message magic: %08x\n", msg->lm_magic);
1631 void ptlrpc_request_set_replen(struct ptlrpc_request *req)
1633 int count = req_capsule_filled_sizes(&req->rq_pill, RCL_SERVER);
1635 req->rq_replen = lustre_msg_size(req->rq_reqmsg->lm_magic, count,
1636 req->rq_pill.rc_area[RCL_SERVER]);
1637 if (req->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V2)
1638 req->rq_reqmsg->lm_repsize = req->rq_replen;
1640 EXPORT_SYMBOL(ptlrpc_request_set_replen);
1642 void ptlrpc_req_set_repsize(struct ptlrpc_request *req, int count, __u32 *lens)
1644 req->rq_replen = lustre_msg_size(req->rq_reqmsg->lm_magic, count, lens);
1645 if (req->rq_reqmsg->lm_magic == LUSTRE_MSG_MAGIC_V2)
1646 req->rq_reqmsg->lm_repsize = req->rq_replen;
1648 EXPORT_SYMBOL(ptlrpc_req_set_repsize);
1651 * Send a remote set_info_async.
1653 * This may go from client to server or server to client.
1655 int do_set_info_async(struct obd_import *imp,
1656 int opcode, int version,
1657 obd_count keylen, void *key,
1658 obd_count vallen, void *val,
1659 struct ptlrpc_request_set *set)
1661 struct ptlrpc_request *req;
1666 req = ptlrpc_request_alloc(imp, &RQF_OBD_SET_INFO);
1670 req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY,
1671 RCL_CLIENT, keylen);
1672 req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_VAL,
1673 RCL_CLIENT, vallen);
1674 rc = ptlrpc_request_pack(req, version, opcode);
1676 ptlrpc_request_free(req);
1680 tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY);
1681 memcpy(tmp, key, keylen);
1682 tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_VAL);
1683 memcpy(tmp, val, vallen);
1685 ptlrpc_request_set_replen(req);
1688 ptlrpc_set_add_req(set, req);
1689 ptlrpc_check_set(NULL, set);
1691 rc = ptlrpc_queue_wait(req);
1692 ptlrpc_req_finished(req);
1697 EXPORT_SYMBOL(do_set_info_async);
1699 /* byte flipping routines for all wire types declared in
1700 * lustre_idl.h implemented here.
1702 void lustre_swab_ptlrpc_body(struct ptlrpc_body *b)
1704 __swab32s (&b->pb_type);
1705 __swab32s (&b->pb_version);
1706 __swab32s (&b->pb_opc);
1707 __swab32s (&b->pb_status);
1708 __swab64s (&b->pb_last_xid);
1709 __swab64s (&b->pb_last_seen);
1710 __swab64s (&b->pb_last_committed);
1711 __swab64s (&b->pb_transno);
1712 __swab32s (&b->pb_flags);
1713 __swab32s (&b->pb_op_flags);
1714 __swab32s (&b->pb_conn_cnt);
1715 __swab32s (&b->pb_timeout);
1716 __swab32s (&b->pb_service_time);
1717 __swab32s (&b->pb_limit);
1718 __swab64s (&b->pb_slv);
1719 __swab64s (&b->pb_pre_versions[0]);
1720 __swab64s (&b->pb_pre_versions[1]);
1721 __swab64s (&b->pb_pre_versions[2]);
1722 __swab64s (&b->pb_pre_versions[3]);
1723 CLASSERT(offsetof(typeof(*b), pb_padding) != 0);
1724 /* While we need to maintain compatibility between
1725 * clients and servers without ptlrpc_body_v2 (< 2.3)
1726 * do not swab any fields beyond pb_jobid, as we are
1727 * using this swab function for both ptlrpc_body
1728 * and ptlrpc_body_v2. */
1729 CLASSERT(offsetof(typeof(*b), pb_jobid) != 0);
1731 EXPORT_SYMBOL(lustre_swab_ptlrpc_body);
1733 void lustre_swab_connect(struct obd_connect_data *ocd)
1735 __swab64s(&ocd->ocd_connect_flags);
1736 __swab32s(&ocd->ocd_version);
1737 __swab32s(&ocd->ocd_grant);
1738 __swab64s(&ocd->ocd_ibits_known);
1739 __swab32s(&ocd->ocd_index);
1740 __swab32s(&ocd->ocd_brw_size);
1741 /* ocd_blocksize and ocd_inodespace don't need to be swabbed because
1742 * they are 8-byte values */
1743 __swab16s(&ocd->ocd_grant_extent);
1744 __swab32s(&ocd->ocd_unused);
1745 __swab64s(&ocd->ocd_transno);
1746 __swab32s(&ocd->ocd_group);
1747 __swab32s(&ocd->ocd_cksum_types);
1748 __swab32s(&ocd->ocd_instance);
1749 /* Fields after ocd_cksum_types are only accessible by the receiver
1750 * if the corresponding flag in ocd_connect_flags is set. Accessing
1751 * any field after ocd_maxbytes on the receiver without a valid flag
1752 * may result in out-of-bound memory access and kernel oops. */
1753 if (ocd->ocd_connect_flags & OBD_CONNECT_MAX_EASIZE)
1754 __swab32s(&ocd->ocd_max_easize);
1755 if (ocd->ocd_connect_flags & OBD_CONNECT_MAXBYTES)
1756 __swab64s(&ocd->ocd_maxbytes);
1757 CLASSERT(offsetof(typeof(*ocd), padding1) != 0);
1758 CLASSERT(offsetof(typeof(*ocd), padding2) != 0);
1759 CLASSERT(offsetof(typeof(*ocd), padding3) != 0);
1760 CLASSERT(offsetof(typeof(*ocd), padding4) != 0);
1761 CLASSERT(offsetof(typeof(*ocd), padding5) != 0);
1762 CLASSERT(offsetof(typeof(*ocd), padding6) != 0);
1763 CLASSERT(offsetof(typeof(*ocd), padding7) != 0);
1764 CLASSERT(offsetof(typeof(*ocd), padding8) != 0);
1765 CLASSERT(offsetof(typeof(*ocd), padding9) != 0);
1766 CLASSERT(offsetof(typeof(*ocd), paddingA) != 0);
1767 CLASSERT(offsetof(typeof(*ocd), paddingB) != 0);
1768 CLASSERT(offsetof(typeof(*ocd), paddingC) != 0);
1769 CLASSERT(offsetof(typeof(*ocd), paddingD) != 0);
1770 CLASSERT(offsetof(typeof(*ocd), paddingE) != 0);
1771 CLASSERT(offsetof(typeof(*ocd), paddingF) != 0);
1774 void lustre_swab_obdo (struct obdo *o)
1776 __swab64s (&o->o_valid);
1777 lustre_swab_ost_id(&o->o_oi);
1778 __swab64s (&o->o_parent_seq);
1779 __swab64s (&o->o_size);
1780 __swab64s (&o->o_mtime);
1781 __swab64s (&o->o_atime);
1782 __swab64s (&o->o_ctime);
1783 __swab64s (&o->o_blocks);
1784 __swab64s (&o->o_grant);
1785 __swab32s (&o->o_blksize);
1786 __swab32s (&o->o_mode);
1787 __swab32s (&o->o_uid);
1788 __swab32s (&o->o_gid);
1789 __swab32s (&o->o_flags);
1790 __swab32s (&o->o_nlink);
1791 __swab32s (&o->o_parent_oid);
1792 __swab32s (&o->o_misc);
1793 __swab64s (&o->o_ioepoch);
1794 __swab32s (&o->o_stripe_idx);
1795 __swab32s (&o->o_parent_ver);
1796 /* o_handle is opaque */
1797 /* o_lcookie is swabbed elsewhere */
1798 __swab32s (&o->o_uid_h);
1799 __swab32s (&o->o_gid_h);
1800 __swab64s (&o->o_data_version);
1801 CLASSERT(offsetof(typeof(*o), o_padding_4) != 0);
1802 CLASSERT(offsetof(typeof(*o), o_padding_5) != 0);
1803 CLASSERT(offsetof(typeof(*o), o_padding_6) != 0);
1806 EXPORT_SYMBOL(lustre_swab_obdo);
1808 void lustre_swab_obd_statfs (struct obd_statfs *os)
1810 __swab64s (&os->os_type);
1811 __swab64s (&os->os_blocks);
1812 __swab64s (&os->os_bfree);
1813 __swab64s (&os->os_bavail);
1814 __swab64s (&os->os_files);
1815 __swab64s (&os->os_ffree);
1816 /* no need to swab os_fsid */
1817 __swab32s (&os->os_bsize);
1818 __swab32s (&os->os_namelen);
1819 __swab64s (&os->os_maxbytes);
1820 __swab32s (&os->os_state);
1821 CLASSERT(offsetof(typeof(*os), os_fprecreated) != 0);
1822 CLASSERT(offsetof(typeof(*os), os_spare2) != 0);
1823 CLASSERT(offsetof(typeof(*os), os_spare3) != 0);
1824 CLASSERT(offsetof(typeof(*os), os_spare4) != 0);
1825 CLASSERT(offsetof(typeof(*os), os_spare5) != 0);
1826 CLASSERT(offsetof(typeof(*os), os_spare6) != 0);
1827 CLASSERT(offsetof(typeof(*os), os_spare7) != 0);
1828 CLASSERT(offsetof(typeof(*os), os_spare8) != 0);
1829 CLASSERT(offsetof(typeof(*os), os_spare9) != 0);
1831 EXPORT_SYMBOL(lustre_swab_obd_statfs);
1833 void lustre_swab_obd_ioobj(struct obd_ioobj *ioo)
1835 lustre_swab_ost_id(&ioo->ioo_oid);
1836 __swab32s(&ioo->ioo_max_brw);
1837 __swab32s(&ioo->ioo_bufcnt);
1839 EXPORT_SYMBOL(lustre_swab_obd_ioobj);
1841 void lustre_swab_niobuf_remote (struct niobuf_remote *nbr)
1843 __swab64s (&nbr->offset);
1844 __swab32s (&nbr->len);
1845 __swab32s (&nbr->flags);
1847 EXPORT_SYMBOL(lustre_swab_niobuf_remote);
1849 void lustre_swab_ost_body (struct ost_body *b)
1851 lustre_swab_obdo (&b->oa);
1853 EXPORT_SYMBOL(lustre_swab_ost_body);
1855 void lustre_swab_ost_last_id(obd_id *id)
1859 EXPORT_SYMBOL(lustre_swab_ost_last_id);
1861 void lustre_swab_generic_32s(__u32 *val)
1865 EXPORT_SYMBOL(lustre_swab_generic_32s);
1867 void lustre_swab_gl_desc(union ldlm_gl_desc *desc)
1869 lustre_swab_lu_fid(&desc->lquota_desc.gl_id.qid_fid);
1870 __swab64s(&desc->lquota_desc.gl_flags);
1871 __swab64s(&desc->lquota_desc.gl_ver);
1872 __swab64s(&desc->lquota_desc.gl_hardlimit);
1873 __swab64s(&desc->lquota_desc.gl_softlimit);
1874 __swab64s(&desc->lquota_desc.gl_time);
1875 CLASSERT(offsetof(typeof(desc->lquota_desc), gl_pad2) != 0);
1878 void lustre_swab_ost_lvb_v1(struct ost_lvb_v1 *lvb)
1880 __swab64s(&lvb->lvb_size);
1881 __swab64s(&lvb->lvb_mtime);
1882 __swab64s(&lvb->lvb_atime);
1883 __swab64s(&lvb->lvb_ctime);
1884 __swab64s(&lvb->lvb_blocks);
1886 EXPORT_SYMBOL(lustre_swab_ost_lvb_v1);
1888 void lustre_swab_ost_lvb(struct ost_lvb *lvb)
1890 __swab64s(&lvb->lvb_size);
1891 __swab64s(&lvb->lvb_mtime);
1892 __swab64s(&lvb->lvb_atime);
1893 __swab64s(&lvb->lvb_ctime);
1894 __swab64s(&lvb->lvb_blocks);
1895 __swab32s(&lvb->lvb_mtime_ns);
1896 __swab32s(&lvb->lvb_atime_ns);
1897 __swab32s(&lvb->lvb_ctime_ns);
1898 __swab32s(&lvb->lvb_padding);
1900 EXPORT_SYMBOL(lustre_swab_ost_lvb);
1902 void lustre_swab_lquota_lvb(struct lquota_lvb *lvb)
1904 __swab64s(&lvb->lvb_flags);
1905 __swab64s(&lvb->lvb_id_may_rel);
1906 __swab64s(&lvb->lvb_id_rel);
1907 __swab64s(&lvb->lvb_id_qunit);
1908 __swab64s(&lvb->lvb_pad1);
1910 EXPORT_SYMBOL(lustre_swab_lquota_lvb);
1912 void lustre_swab_mdt_body (struct mdt_body *b)
1914 lustre_swab_lu_fid(&b->fid1);
1915 lustre_swab_lu_fid(&b->fid2);
1916 /* handle is opaque */
1917 __swab64s(&b->valid);
1918 __swab64s(&b->size);
1919 __swab64s(&b->mtime);
1920 __swab64s(&b->atime);
1921 __swab64s(&b->ctime);
1922 __swab64s(&b->blocks);
1923 __swab64s(&b->ioepoch);
1924 __swab64s(&b->t_state);
1925 __swab32s(&b->fsuid);
1926 __swab32s(&b->fsgid);
1927 __swab32s(&b->capability);
1928 __swab32s(&b->mode);
1931 __swab32s(&b->flags);
1932 __swab32s(&b->rdev);
1933 __swab32s(&b->nlink);
1934 CLASSERT(offsetof(typeof(*b), unused2) != 0);
1935 __swab32s(&b->suppgid);
1936 __swab32s(&b->eadatasize);
1937 __swab32s(&b->aclsize);
1938 __swab32s(&b->max_mdsize);
1939 __swab32s(&b->max_cookiesize);
1940 __swab32s(&b->uid_h);
1941 __swab32s(&b->gid_h);
1942 CLASSERT(offsetof(typeof(*b), padding_5) != 0);
1944 EXPORT_SYMBOL(lustre_swab_mdt_body);
1946 void lustre_swab_mdt_ioepoch (struct mdt_ioepoch *b)
1948 /* handle is opaque */
1949 __swab64s (&b->ioepoch);
1950 __swab32s (&b->flags);
1951 CLASSERT(offsetof(typeof(*b), padding) != 0);
1953 EXPORT_SYMBOL(lustre_swab_mdt_ioepoch);
1955 void lustre_swab_mgs_target_info(struct mgs_target_info *mti)
1958 __swab32s(&mti->mti_lustre_ver);
1959 __swab32s(&mti->mti_stripe_index);
1960 __swab32s(&mti->mti_config_ver);
1961 __swab32s(&mti->mti_flags);
1962 __swab32s(&mti->mti_instance);
1963 __swab32s(&mti->mti_nid_count);
1964 CLASSERT(sizeof(lnet_nid_t) == sizeof(__u64));
1965 for (i = 0; i < MTI_NIDS_MAX; i++)
1966 __swab64s(&mti->mti_nids[i]);
1968 EXPORT_SYMBOL(lustre_swab_mgs_target_info);
1970 void lustre_swab_mgs_nidtbl_entry(struct mgs_nidtbl_entry *entry)
1974 __swab64s(&entry->mne_version);
1975 __swab32s(&entry->mne_instance);
1976 __swab32s(&entry->mne_index);
1977 __swab32s(&entry->mne_length);
1979 /* mne_nid_(count|type) must be one byte size because we're gonna
1980 * access it w/o swapping. */
1981 CLASSERT(sizeof(entry->mne_nid_count) == sizeof(__u8));
1982 CLASSERT(sizeof(entry->mne_nid_type) == sizeof(__u8));
1984 /* remove this assertion if ipv6 is supported. */
1985 LASSERT(entry->mne_nid_type == 0);
1986 for (i = 0; i < entry->mne_nid_count; i++) {
1987 CLASSERT(sizeof(lnet_nid_t) == sizeof(__u64));
1988 __swab64s(&entry->u.nids[i]);
1991 EXPORT_SYMBOL(lustre_swab_mgs_nidtbl_entry);
1993 void lustre_swab_mgs_config_body(struct mgs_config_body *body)
1995 __swab64s(&body->mcb_offset);
1996 __swab32s(&body->mcb_units);
1997 __swab16s(&body->mcb_type);
1999 EXPORT_SYMBOL(lustre_swab_mgs_config_body);
2001 void lustre_swab_mgs_config_res(struct mgs_config_res *body)
2003 __swab64s(&body->mcr_offset);
2004 __swab64s(&body->mcr_size);
2006 EXPORT_SYMBOL(lustre_swab_mgs_config_res);
2008 static void lustre_swab_obd_dqinfo (struct obd_dqinfo *i)
2010 __swab64s (&i->dqi_bgrace);
2011 __swab64s (&i->dqi_igrace);
2012 __swab32s (&i->dqi_flags);
2013 __swab32s (&i->dqi_valid);
2016 static void lustre_swab_obd_dqblk (struct obd_dqblk *b)
2018 __swab64s (&b->dqb_ihardlimit);
2019 __swab64s (&b->dqb_isoftlimit);
2020 __swab64s (&b->dqb_curinodes);
2021 __swab64s (&b->dqb_bhardlimit);
2022 __swab64s (&b->dqb_bsoftlimit);
2023 __swab64s (&b->dqb_curspace);
2024 __swab64s (&b->dqb_btime);
2025 __swab64s (&b->dqb_itime);
2026 __swab32s (&b->dqb_valid);
2027 CLASSERT(offsetof(typeof(*b), dqb_padding) != 0);
2030 void lustre_swab_obd_quotactl (struct obd_quotactl *q)
2032 __swab32s (&q->qc_cmd);
2033 __swab32s (&q->qc_type);
2034 __swab32s (&q->qc_id);
2035 __swab32s (&q->qc_stat);
2036 lustre_swab_obd_dqinfo (&q->qc_dqinfo);
2037 lustre_swab_obd_dqblk (&q->qc_dqblk);
2039 EXPORT_SYMBOL(lustre_swab_obd_quotactl);
2041 void lustre_swab_mdt_remote_perm (struct mdt_remote_perm *p)
2043 __swab32s (&p->rp_uid);
2044 __swab32s (&p->rp_gid);
2045 __swab32s (&p->rp_fsuid);
2046 __swab32s (&p->rp_fsuid_h);
2047 __swab32s (&p->rp_fsgid);
2048 __swab32s (&p->rp_fsgid_h);
2049 __swab32s (&p->rp_access_perm);
2050 __swab32s (&p->rp_padding);
2052 EXPORT_SYMBOL(lustre_swab_mdt_remote_perm);
2054 void lustre_swab_fid2path(struct getinfo_fid2path *gf)
2056 lustre_swab_lu_fid(&gf->gf_fid);
2057 __swab64s(&gf->gf_recno);
2058 __swab32s(&gf->gf_linkno);
2059 __swab32s(&gf->gf_pathlen);
2061 EXPORT_SYMBOL(lustre_swab_fid2path);
2063 void lustre_swab_fiemap_extent(struct ll_fiemap_extent *fm_extent)
2065 __swab64s(&fm_extent->fe_logical);
2066 __swab64s(&fm_extent->fe_physical);
2067 __swab64s(&fm_extent->fe_length);
2068 __swab32s(&fm_extent->fe_flags);
2069 __swab32s(&fm_extent->fe_device);
2072 void lustre_swab_fiemap(struct ll_user_fiemap *fiemap)
2076 __swab64s(&fiemap->fm_start);
2077 __swab64s(&fiemap->fm_length);
2078 __swab32s(&fiemap->fm_flags);
2079 __swab32s(&fiemap->fm_mapped_extents);
2080 __swab32s(&fiemap->fm_extent_count);
2081 __swab32s(&fiemap->fm_reserved);
2083 for (i = 0; i < fiemap->fm_mapped_extents; i++)
2084 lustre_swab_fiemap_extent(&fiemap->fm_extents[i]);
2086 EXPORT_SYMBOL(lustre_swab_fiemap);
2088 void lustre_swab_idx_info(struct idx_info *ii)
2090 __swab32s(&ii->ii_magic);
2091 __swab32s(&ii->ii_flags);
2092 __swab16s(&ii->ii_count);
2093 __swab32s(&ii->ii_attrs);
2094 lustre_swab_lu_fid(&ii->ii_fid);
2095 __swab64s(&ii->ii_version);
2096 __swab64s(&ii->ii_hash_start);
2097 __swab64s(&ii->ii_hash_end);
2098 __swab16s(&ii->ii_keysize);
2099 __swab16s(&ii->ii_recsize);
2102 void lustre_swab_lip_header(struct lu_idxpage *lip)
2105 __swab32s(&lip->lip_magic);
2106 __swab16s(&lip->lip_flags);
2107 __swab16s(&lip->lip_nr);
2109 EXPORT_SYMBOL(lustre_swab_lip_header);
2111 void lustre_swab_mdt_rec_reint (struct mdt_rec_reint *rr)
2113 __swab32s(&rr->rr_opcode);
2114 __swab32s(&rr->rr_cap);
2115 __swab32s(&rr->rr_fsuid);
2116 /* rr_fsuid_h is unused */
2117 __swab32s(&rr->rr_fsgid);
2118 /* rr_fsgid_h is unused */
2119 __swab32s(&rr->rr_suppgid1);
2120 /* rr_suppgid1_h is unused */
2121 __swab32s(&rr->rr_suppgid2);
2122 /* rr_suppgid2_h is unused */
2123 lustre_swab_lu_fid(&rr->rr_fid1);
2124 lustre_swab_lu_fid(&rr->rr_fid2);
2125 __swab64s(&rr->rr_mtime);
2126 __swab64s(&rr->rr_atime);
2127 __swab64s(&rr->rr_ctime);
2128 __swab64s(&rr->rr_size);
2129 __swab64s(&rr->rr_blocks);
2130 __swab32s(&rr->rr_bias);
2131 __swab32s(&rr->rr_mode);
2132 __swab32s(&rr->rr_flags);
2133 __swab32s(&rr->rr_flags_h);
2134 __swab32s(&rr->rr_umask);
2136 CLASSERT(offsetof(typeof(*rr), rr_padding_4) != 0);
2138 EXPORT_SYMBOL(lustre_swab_mdt_rec_reint);
2140 void lustre_swab_lov_desc (struct lov_desc *ld)
2142 __swab32s (&ld->ld_tgt_count);
2143 __swab32s (&ld->ld_active_tgt_count);
2144 __swab32s (&ld->ld_default_stripe_count);
2145 __swab32s (&ld->ld_pattern);
2146 __swab64s (&ld->ld_default_stripe_size);
2147 __swab64s (&ld->ld_default_stripe_offset);
2148 __swab32s (&ld->ld_qos_maxage);
2149 /* uuid endian insensitive */
2151 EXPORT_SYMBOL(lustre_swab_lov_desc);
2153 void lustre_swab_lmv_desc (struct lmv_desc *ld)
2155 __swab32s (&ld->ld_tgt_count);
2156 __swab32s (&ld->ld_active_tgt_count);
2157 __swab32s (&ld->ld_default_stripe_count);
2158 __swab32s (&ld->ld_pattern);
2159 __swab64s (&ld->ld_default_hash_size);
2160 __swab32s (&ld->ld_qos_maxage);
2161 /* uuid endian insensitive */
2164 /* This structure is always in little-endian */
2165 static void lustre_swab_lmv_mds_md_v1(struct lmv_mds_md_v1 *lmm1)
2169 __swab32s(&lmm1->lmv_magic);
2170 __swab32s(&lmm1->lmv_stripe_count);
2171 __swab32s(&lmm1->lmv_master_mdt_index);
2172 __swab32s(&lmm1->lmv_hash_type);
2173 __swab32s(&lmm1->lmv_layout_version);
2174 for (i = 0; i < lmm1->lmv_stripe_count; i++)
2175 lustre_swab_lu_fid(&lmm1->lmv_stripe_fids[i]);
2178 void lustre_swab_lmv_mds_md(union lmv_mds_md *lmm)
2180 switch (lmm->lmv_magic) {
2182 lustre_swab_lmv_mds_md_v1(&lmm->lmv_md_v1);
2189 void lustre_swab_lmv_user_md(struct lmv_user_md *lum)
2193 __swab32s(&lum->lum_magic);
2194 __swab32s(&lum->lum_stripe_count);
2195 __swab32s(&lum->lum_stripe_offset);
2196 __swab32s(&lum->lum_hash_type);
2197 __swab32s(&lum->lum_type);
2198 CLASSERT(offsetof(typeof(*lum), lum_padding1) != 0);
2199 for (i = 0; i < lum->lum_stripe_count; i++) {
2200 __swab32s(&lum->lum_objects[i].lum_mds);
2201 lustre_swab_lu_fid(&lum->lum_objects[i].lum_fid);
2205 EXPORT_SYMBOL(lustre_swab_lmv_user_md);
2207 static void print_lum (struct lov_user_md *lum)
2209 CDEBUG(D_OTHER, "lov_user_md %p:\n", lum);
2210 CDEBUG(D_OTHER, "\tlmm_magic: %#x\n", lum->lmm_magic);
2211 CDEBUG(D_OTHER, "\tlmm_pattern: %#x\n", lum->lmm_pattern);
2212 CDEBUG(D_OTHER, "\tlmm_object_id: "LPU64"\n", lmm_oi_id(&lum->lmm_oi));
2213 CDEBUG(D_OTHER, "\tlmm_object_gr: "LPU64"\n", lmm_oi_seq(&lum->lmm_oi));
2214 CDEBUG(D_OTHER, "\tlmm_stripe_size: %#x\n", lum->lmm_stripe_size);
2215 CDEBUG(D_OTHER, "\tlmm_stripe_count: %#x\n", lum->lmm_stripe_count);
2216 CDEBUG(D_OTHER, "\tlmm_stripe_offset/lmm_layout_gen: %#x\n",
2217 lum->lmm_stripe_offset);
2220 static void lustre_swab_lmm_oi(struct ost_id *oi)
2222 __swab64s(&oi->oi.oi_id);
2223 __swab64s(&oi->oi.oi_seq);
2226 static void lustre_swab_lov_user_md_common(struct lov_user_md_v1 *lum)
2229 __swab32s(&lum->lmm_magic);
2230 __swab32s(&lum->lmm_pattern);
2231 lustre_swab_lmm_oi(&lum->lmm_oi);
2232 __swab32s(&lum->lmm_stripe_size);
2233 __swab16s(&lum->lmm_stripe_count);
2234 __swab16s(&lum->lmm_stripe_offset);
2239 void lustre_swab_lov_user_md_v1(struct lov_user_md_v1 *lum)
2242 CDEBUG(D_IOCTL, "swabbing lov_user_md v1\n");
2243 lustre_swab_lov_user_md_common(lum);
2246 EXPORT_SYMBOL(lustre_swab_lov_user_md_v1);
2248 void lustre_swab_lov_user_md_v3(struct lov_user_md_v3 *lum)
2251 CDEBUG(D_IOCTL, "swabbing lov_user_md v3\n");
2252 lustre_swab_lov_user_md_common((struct lov_user_md_v1 *)lum);
2253 /* lmm_pool_name nothing to do with char */
2256 EXPORT_SYMBOL(lustre_swab_lov_user_md_v3);
2258 void lustre_swab_lov_mds_md(struct lov_mds_md *lmm)
2261 CDEBUG(D_IOCTL, "swabbing lov_mds_md\n");
2262 __swab32s(&lmm->lmm_magic);
2263 __swab32s(&lmm->lmm_pattern);
2264 lustre_swab_lmm_oi(&lmm->lmm_oi);
2265 __swab32s(&lmm->lmm_stripe_size);
2266 __swab16s(&lmm->lmm_stripe_count);
2267 __swab16s(&lmm->lmm_layout_gen);
2270 EXPORT_SYMBOL(lustre_swab_lov_mds_md);
2272 void lustre_swab_lov_user_md_objects(struct lov_user_ost_data *lod,
2277 for (i = 0; i < stripe_count; i++) {
2278 lustre_swab_ost_id(&(lod[i].l_ost_oi));
2279 __swab32s(&(lod[i].l_ost_gen));
2280 __swab32s(&(lod[i].l_ost_idx));
2284 EXPORT_SYMBOL(lustre_swab_lov_user_md_objects);
2286 void lustre_swab_ldlm_res_id (struct ldlm_res_id *id)
2290 for (i = 0; i < RES_NAME_SIZE; i++)
2291 __swab64s (&id->name[i]);
2293 EXPORT_SYMBOL(lustre_swab_ldlm_res_id);
2295 void lustre_swab_ldlm_policy_data (ldlm_wire_policy_data_t *d)
2297 /* the lock data is a union and the first two fields are always an
2298 * extent so it's ok to process an LDLM_EXTENT and LDLM_FLOCK lock
2299 * data the same way. */
2300 __swab64s(&d->l_extent.start);
2301 __swab64s(&d->l_extent.end);
2302 __swab64s(&d->l_extent.gid);
2303 __swab64s(&d->l_flock.lfw_owner);
2304 __swab32s(&d->l_flock.lfw_pid);
2306 EXPORT_SYMBOL(lustre_swab_ldlm_policy_data);
2308 void lustre_swab_ldlm_intent (struct ldlm_intent *i)
2310 __swab64s (&i->opc);
2312 EXPORT_SYMBOL(lustre_swab_ldlm_intent);
2314 void lustre_swab_ldlm_resource_desc (struct ldlm_resource_desc *r)
2316 __swab32s (&r->lr_type);
2317 CLASSERT(offsetof(typeof(*r), lr_padding) != 0);
2318 lustre_swab_ldlm_res_id (&r->lr_name);
2320 EXPORT_SYMBOL(lustre_swab_ldlm_resource_desc);
2322 void lustre_swab_ldlm_lock_desc (struct ldlm_lock_desc *l)
2324 lustre_swab_ldlm_resource_desc (&l->l_resource);
2325 __swab32s (&l->l_req_mode);
2326 __swab32s (&l->l_granted_mode);
2327 lustre_swab_ldlm_policy_data (&l->l_policy_data);
2329 EXPORT_SYMBOL(lustre_swab_ldlm_lock_desc);
2331 void lustre_swab_ldlm_request (struct ldlm_request *rq)
2333 __swab32s (&rq->lock_flags);
2334 lustre_swab_ldlm_lock_desc (&rq->lock_desc);
2335 __swab32s (&rq->lock_count);
2336 /* lock_handle[] opaque */
2338 EXPORT_SYMBOL(lustre_swab_ldlm_request);
2340 void lustre_swab_ldlm_reply (struct ldlm_reply *r)
2342 __swab32s (&r->lock_flags);
2343 CLASSERT(offsetof(typeof(*r), lock_padding) != 0);
2344 lustre_swab_ldlm_lock_desc (&r->lock_desc);
2345 /* lock_handle opaque */
2346 __swab64s (&r->lock_policy_res1);
2347 __swab64s (&r->lock_policy_res2);
2349 EXPORT_SYMBOL(lustre_swab_ldlm_reply);
2351 void lustre_swab_quota_body(struct quota_body *b)
2353 lustre_swab_lu_fid(&b->qb_fid);
2354 lustre_swab_lu_fid((struct lu_fid *)&b->qb_id);
2355 __swab32s(&b->qb_flags);
2356 __swab64s(&b->qb_count);
2357 __swab64s(&b->qb_usage);
2358 __swab64s(&b->qb_slv_ver);
2361 /* Dump functions */
2362 void dump_ioo(struct obd_ioobj *ioo)
2365 "obd_ioobj: ioo_oid="DOSTID", ioo_max_brw=%#x, "
2366 "ioo_bufct=%d\n", POSTID(&ioo->ioo_oid), ioo->ioo_max_brw,
2369 EXPORT_SYMBOL(dump_ioo);
2371 void dump_rniobuf(struct niobuf_remote *nb)
2373 CDEBUG(D_RPCTRACE, "niobuf_remote: offset="LPU64", len=%d, flags=%x\n",
2374 nb->offset, nb->len, nb->flags);
2376 EXPORT_SYMBOL(dump_rniobuf);
2378 void dump_obdo(struct obdo *oa)
2380 __u32 valid = oa->o_valid;
2382 CDEBUG(D_RPCTRACE, "obdo: o_valid = %08x\n", valid);
2383 if (valid & OBD_MD_FLID)
2384 CDEBUG(D_RPCTRACE, "obdo: id = "DOSTID"\n", POSTID(&oa->o_oi));
2385 if (valid & OBD_MD_FLFID)
2386 CDEBUG(D_RPCTRACE, "obdo: o_parent_seq = "LPX64"\n",
2388 if (valid & OBD_MD_FLSIZE)
2389 CDEBUG(D_RPCTRACE, "obdo: o_size = "LPD64"\n", oa->o_size);
2390 if (valid & OBD_MD_FLMTIME)
2391 CDEBUG(D_RPCTRACE, "obdo: o_mtime = "LPD64"\n", oa->o_mtime);
2392 if (valid & OBD_MD_FLATIME)
2393 CDEBUG(D_RPCTRACE, "obdo: o_atime = "LPD64"\n", oa->o_atime);
2394 if (valid & OBD_MD_FLCTIME)
2395 CDEBUG(D_RPCTRACE, "obdo: o_ctime = "LPD64"\n", oa->o_ctime);
2396 if (valid & OBD_MD_FLBLOCKS) /* allocation of space */
2397 CDEBUG(D_RPCTRACE, "obdo: o_blocks = "LPD64"\n", oa->o_blocks);
2398 if (valid & OBD_MD_FLGRANT)
2399 CDEBUG(D_RPCTRACE, "obdo: o_grant = "LPD64"\n", oa->o_grant);
2400 if (valid & OBD_MD_FLBLKSZ)
2401 CDEBUG(D_RPCTRACE, "obdo: o_blksize = %d\n", oa->o_blksize);
2402 if (valid & (OBD_MD_FLTYPE | OBD_MD_FLMODE))
2403 CDEBUG(D_RPCTRACE, "obdo: o_mode = %o\n",
2404 oa->o_mode & ((valid & OBD_MD_FLTYPE ? S_IFMT : 0) |
2405 (valid & OBD_MD_FLMODE ? ~S_IFMT : 0)));
2406 if (valid & OBD_MD_FLUID)
2407 CDEBUG(D_RPCTRACE, "obdo: o_uid = %u\n", oa->o_uid);
2408 if (valid & OBD_MD_FLUID)
2409 CDEBUG(D_RPCTRACE, "obdo: o_uid_h = %u\n", oa->o_uid_h);
2410 if (valid & OBD_MD_FLGID)
2411 CDEBUG(D_RPCTRACE, "obdo: o_gid = %u\n", oa->o_gid);
2412 if (valid & OBD_MD_FLGID)
2413 CDEBUG(D_RPCTRACE, "obdo: o_gid_h = %u\n", oa->o_gid_h);
2414 if (valid & OBD_MD_FLFLAGS)
2415 CDEBUG(D_RPCTRACE, "obdo: o_flags = %x\n", oa->o_flags);
2416 if (valid & OBD_MD_FLNLINK)
2417 CDEBUG(D_RPCTRACE, "obdo: o_nlink = %u\n", oa->o_nlink);
2418 else if (valid & OBD_MD_FLCKSUM)
2419 CDEBUG(D_RPCTRACE, "obdo: o_checksum (o_nlink) = %u\n",
2421 if (valid & OBD_MD_FLGENER)
2422 CDEBUG(D_RPCTRACE, "obdo: o_parent_oid = %x\n",
2424 if (valid & OBD_MD_FLEPOCH)
2425 CDEBUG(D_RPCTRACE, "obdo: o_ioepoch = "LPD64"\n",
2427 if (valid & OBD_MD_FLFID) {
2428 CDEBUG(D_RPCTRACE, "obdo: o_stripe_idx = %u\n",
2430 CDEBUG(D_RPCTRACE, "obdo: o_parent_ver = %x\n",
2433 if (valid & OBD_MD_FLHANDLE)
2434 CDEBUG(D_RPCTRACE, "obdo: o_handle = "LPD64"\n",
2435 oa->o_handle.cookie);
2436 if (valid & OBD_MD_FLCOOKIE)
2437 CDEBUG(D_RPCTRACE, "obdo: o_lcookie = "
2438 "(llog_cookie dumping not yet implemented)\n");
2440 EXPORT_SYMBOL(dump_obdo);
2442 void dump_ost_body(struct ost_body *ob)
2446 EXPORT_SYMBOL(dump_ost_body);
2448 void dump_rcs(__u32 *rc)
2450 CDEBUG(D_RPCTRACE, "rmf_rcs: %d\n", *rc);
2452 EXPORT_SYMBOL(dump_rcs);
2454 static inline int req_ptlrpc_body_swabbed(struct ptlrpc_request *req)
2456 LASSERT(req->rq_reqmsg);
2458 switch (req->rq_reqmsg->lm_magic) {
2459 case LUSTRE_MSG_MAGIC_V2:
2460 return lustre_req_swabbed(req, MSG_PTLRPC_BODY_OFF);
2462 CERROR("bad lustre msg magic: %#08X\n",
2463 req->rq_reqmsg->lm_magic);
2468 static inline int rep_ptlrpc_body_swabbed(struct ptlrpc_request *req)
2470 LASSERT(req->rq_repmsg);
2472 switch (req->rq_repmsg->lm_magic) {
2473 case LUSTRE_MSG_MAGIC_V2:
2474 return lustre_rep_swabbed(req, MSG_PTLRPC_BODY_OFF);
2476 /* uninitialized yet */
2481 void _debug_req(struct ptlrpc_request *req,
2482 struct libcfs_debug_msg_data *msgdata,
2483 const char *fmt, ... )
2485 int req_ok = req->rq_reqmsg != NULL;
2486 int rep_ok = req->rq_repmsg != NULL;
2487 lnet_nid_t nid = LNET_NID_ANY;
2490 if (ptlrpc_req_need_swab(req)) {
2491 req_ok = req_ok && req_ptlrpc_body_swabbed(req);
2492 rep_ok = rep_ok && rep_ptlrpc_body_swabbed(req);
2495 if (req->rq_import && req->rq_import->imp_connection)
2496 nid = req->rq_import->imp_connection->c_peer.nid;
2497 else if (req->rq_export && req->rq_export->exp_connection)
2498 nid = req->rq_export->exp_connection->c_peer.nid;
2500 va_start(args, fmt);
2501 libcfs_debug_vmsg2(msgdata, fmt, args,
2502 " req@%p x"LPU64"/t"LPD64"("LPD64") o%d->%s@%s:%d/%d"
2503 " lens %d/%d e %d to %d dl "CFS_TIME_T" ref %d "
2504 "fl "REQ_FLAGS_FMT"/%x/%x rc %d/%d\n",
2505 req, req->rq_xid, req->rq_transno,
2506 req_ok ? lustre_msg_get_transno(req->rq_reqmsg) : 0,
2507 req_ok ? lustre_msg_get_opc(req->rq_reqmsg) : -1,
2509 req->rq_import->imp_obd->obd_name :
2511 req->rq_export->exp_client_uuid.uuid :
2513 libcfs_nid2str(nid),
2514 req->rq_request_portal, req->rq_reply_portal,
2515 req->rq_reqlen, req->rq_replen,
2516 req->rq_early_count, req->rq_timedout,
2518 atomic_read(&req->rq_refcount),
2519 DEBUG_REQ_FLAGS(req),
2520 req_ok ? lustre_msg_get_flags(req->rq_reqmsg) : -1,
2521 rep_ok ? lustre_msg_get_flags(req->rq_repmsg) : -1,
2523 rep_ok ? lustre_msg_get_status(req->rq_repmsg) : -1);
2526 EXPORT_SYMBOL(_debug_req);
2528 void lustre_swab_lustre_capa(struct lustre_capa *c)
2530 lustre_swab_lu_fid(&c->lc_fid);
2531 __swab64s (&c->lc_opc);
2532 __swab64s (&c->lc_uid);
2533 __swab64s (&c->lc_gid);
2534 __swab32s (&c->lc_flags);
2535 __swab32s (&c->lc_keyid);
2536 __swab32s (&c->lc_timeout);
2537 __swab32s (&c->lc_expiry);
2539 EXPORT_SYMBOL(lustre_swab_lustre_capa);
2541 void lustre_swab_lustre_capa_key(struct lustre_capa_key *k)
2543 __swab64s (&k->lk_seq);
2544 __swab32s (&k->lk_keyid);
2545 CLASSERT(offsetof(typeof(*k), lk_padding) != 0);
2547 EXPORT_SYMBOL(lustre_swab_lustre_capa_key);
2549 void lustre_swab_hsm_user_state(struct hsm_user_state *state)
2551 __swab32s(&state->hus_states);
2552 __swab32s(&state->hus_archive_id);
2554 EXPORT_SYMBOL(lustre_swab_hsm_user_state);
2556 void lustre_swab_hsm_state_set(struct hsm_state_set *hss)
2558 __swab32s(&hss->hss_valid);
2559 __swab64s(&hss->hss_setmask);
2560 __swab64s(&hss->hss_clearmask);
2561 __swab32s(&hss->hss_archive_id);
2563 EXPORT_SYMBOL(lustre_swab_hsm_state_set);
2565 void lustre_swab_hsm_extent(struct hsm_extent *extent)
2567 __swab64s(&extent->offset);
2568 __swab64s(&extent->length);
2571 void lustre_swab_hsm_current_action(struct hsm_current_action *action)
2573 __swab32s(&action->hca_state);
2574 __swab32s(&action->hca_action);
2575 lustre_swab_hsm_extent(&action->hca_location);
2577 EXPORT_SYMBOL(lustre_swab_hsm_current_action);
2579 void lustre_swab_hsm_user_item(struct hsm_user_item *hui)
2581 lustre_swab_lu_fid(&hui->hui_fid);
2582 lustre_swab_hsm_extent(&hui->hui_extent);
2584 EXPORT_SYMBOL(lustre_swab_hsm_user_item);
2586 void lustre_swab_layout_intent(struct layout_intent *li)
2588 __swab32s(&li->li_opc);
2589 __swab32s(&li->li_flags);
2590 __swab64s(&li->li_start);
2591 __swab64s(&li->li_end);
2593 EXPORT_SYMBOL(lustre_swab_layout_intent);
2595 void lustre_swab_hsm_progress_kernel(struct hsm_progress_kernel *hpk)
2597 lustre_swab_lu_fid(&hpk->hpk_fid);
2598 __swab64s(&hpk->hpk_cookie);
2599 __swab64s(&hpk->hpk_extent.offset);
2600 __swab64s(&hpk->hpk_extent.length);
2601 __swab16s(&hpk->hpk_flags);
2602 __swab16s(&hpk->hpk_errval);
2604 EXPORT_SYMBOL(lustre_swab_hsm_progress_kernel);
2606 void lustre_swab_hsm_request(struct hsm_request *hr)
2608 __swab32s(&hr->hr_action);
2609 __swab32s(&hr->hr_archive_id);
2610 __swab64s(&hr->hr_flags);
2611 __swab32s(&hr->hr_itemcount);
2612 __swab32s(&hr->hr_data_len);
2614 EXPORT_SYMBOL(lustre_swab_hsm_request);
2616 void lustre_swab_object_update(struct object_update *ou)
2618 struct object_update_param *param;
2621 __swab16s(&ou->ou_type);
2622 __swab16s(&ou->ou_params_count);
2623 __swab32s(&ou->ou_master_index);
2624 __swab32s(&ou->ou_flags);
2625 __swab32s(&ou->ou_padding1);
2626 __swab64s(&ou->ou_batchid);
2627 lustre_swab_lu_fid(&ou->ou_fid);
2628 param = &ou->ou_params[0];
2629 for (i = 0; i < ou->ou_params_count; i++) {
2630 __swab16s(¶m->oup_len);
2631 __swab16s(¶m->oup_padding);
2632 __swab32s(¶m->oup_padding2);
2633 param = (struct object_update_param *)((char *)param +
2634 object_update_param_size(param));
2637 EXPORT_SYMBOL(lustre_swab_object_update);
2639 void lustre_swab_object_update_request(struct object_update_request *our)
2642 __swab32s(&our->ourq_magic);
2643 __swab16s(&our->ourq_count);
2644 __swab16s(&our->ourq_padding);
2645 for (i = 0; i < our->ourq_count; i++) {
2646 struct object_update *ou;
2648 ou = object_update_request_get(our, i, NULL);
2651 lustre_swab_object_update(ou);
2654 EXPORT_SYMBOL(lustre_swab_object_update_request);
2656 void lustre_swab_object_update_result(struct object_update_result *our)
2658 __swab32s(&our->our_rc);
2659 __swab16s(&our->our_datalen);
2660 __swab16s(&our->our_padding);
2662 EXPORT_SYMBOL(lustre_swab_object_update_result);
2664 void lustre_swab_object_update_reply(struct object_update_reply *our)
2668 __swab32s(&our->ourp_magic);
2669 __swab16s(&our->ourp_count);
2670 __swab16s(&our->ourp_padding);
2671 for (i = 0; i < our->ourp_count; i++) {
2672 struct object_update_result *ourp;
2674 __swab16s(&our->ourp_lens[i]);
2675 ourp = object_update_result_get(our, i, NULL);
2678 lustre_swab_object_update_result(ourp);
2681 EXPORT_SYMBOL(lustre_swab_object_update_reply);
2683 void lustre_swab_swap_layouts(struct mdc_swap_layouts *msl)
2685 __swab64s(&msl->msl_flags);
2687 EXPORT_SYMBOL(lustre_swab_swap_layouts);
2689 void lustre_swab_close_data(struct close_data *cd)
2691 lustre_swab_lu_fid(&cd->cd_fid);
2692 __swab64s(&cd->cd_data_version);
2694 EXPORT_SYMBOL(lustre_swab_close_data);
2696 void lustre_swab_lfsck_request(struct lfsck_request *lr)
2698 __swab32s(&lr->lr_event);
2699 __swab32s(&lr->lr_index);
2700 __swab32s(&lr->lr_flags);
2701 __swab32s(&lr->lr_valid);
2702 __swab32s(&lr->lr_speed);
2703 __swab16s(&lr->lr_version);
2704 __swab16s(&lr->lr_active);
2705 __swab16s(&lr->lr_param);
2706 __swab16s(&lr->lr_async_windows);
2707 CLASSERT(offsetof(typeof(*lr), lr_padding_1) != 0);
2708 lustre_swab_lu_fid(&lr->lr_fid);
2709 lustre_swab_lu_fid(&lr->lr_fid2);
2710 lustre_swab_lu_fid(&lr->lr_fid3);
2711 CLASSERT(offsetof(typeof(*lr), lr_padding_2) != 0);
2712 CLASSERT(offsetof(typeof(*lr), lr_padding_3) != 0);
2714 EXPORT_SYMBOL(lustre_swab_lfsck_request);
2716 void lustre_swab_lfsck_reply(struct lfsck_reply *lr)
2718 __swab32s(&lr->lr_status);
2719 CLASSERT(offsetof(typeof(*lr), lr_padding_1) != 0);
2720 CLASSERT(offsetof(typeof(*lr), lr_padding_2) != 0);
2722 EXPORT_SYMBOL(lustre_swab_lfsck_reply);
2724 void lustre_swab_orphan_ent(struct lu_orphan_ent *ent)
2726 lustre_swab_lu_fid(&ent->loe_key);
2727 lustre_swab_lu_fid(&ent->loe_rec.lor_fid);
2728 __swab32s(&ent->loe_rec.lor_uid);
2729 __swab32s(&ent->loe_rec.lor_gid);
2731 EXPORT_SYMBOL(lustre_swab_orphan_ent);