1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001-2003 Cluster File Systems, Inc.
5 * Author: Peter J. Braam <braam@clusterfs.com>
6 * Author: Phil Schwan <phil@clusterfs.com>
7 * Author: Eric Barton <eeb@clusterfs.com>
9 * This file is part of Lustre, http://www.lustre.org.
11 * Lustre is free software; you can redistribute it and/or
12 * modify it under the terms of version 2 of the GNU General Public
13 * License as published by the Free Software Foundation.
15 * Lustre is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Lustre; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 * (Un)packing of OST requests
28 #define DEBUG_SUBSYSTEM S_RPC
30 # include <liblustre.h>
33 #include <linux/obd_support.h>
34 #include <linux/obd_class.h>
35 #include <linux/lustre_net.h>
36 #include <linux/lustre_sec.h>
37 #include <linux/fcntl.h>
40 #define HDR_SIZE(count) \
41 size_round(offsetof (struct lustre_msg, buflens[(count)]))
43 int lustre_msg_swabbed(struct lustre_msg *msg)
45 return (msg->magic == __swab32(PTLRPC_MSG_MAGIC));
48 int lustre_msg_check_version(struct lustre_msg *msg, __u32 version)
50 if (!lustre_msg_swabbed(msg))
51 return (msg->version & LUSTRE_VERSION_MASK) != version;
53 return (__swab32(msg->version) & LUSTRE_VERSION_MASK) != version;
56 void lustre_init_msg(struct lustre_msg *msg, int count,
57 int *lens, char **bufs)
62 msg->magic = PTLRPC_MSG_MAGIC;
63 msg->version = PTLRPC_MSG_VERSION;
64 msg->bufcount = count;
65 for (i = 0; i < count; i++)
66 msg->buflens[i] = lens[i];
71 ptr = (char *)msg + HDR_SIZE(count);
72 for (i = 0; i < count; i++) {
74 LOGL(tmp, lens[i], ptr);
78 int lustre_secdesc_size(void)
81 int ngroups = current_ngroups;
83 if (ngroups > LUSTRE_MAX_GROUPS)
84 ngroups = LUSTRE_MAX_GROUPS;
86 return sizeof(struct mds_req_sec_desc) +
87 sizeof(__u32) * ngroups;
94 * because group info might have changed since last time we call
95 * secdesc_size(), so here we did more sanity check to prevent garbage gids
97 void lustre_pack_secdesc(struct ptlrpc_request *req, int size)
100 struct mds_req_sec_desc *rsd;
102 rsd = lustre_msg_buf(req->rq_reqmsg,
103 MDS_REQ_SECDESC_OFF, size);
105 rsd->rsd_uid = current->uid;
106 rsd->rsd_gid = current->gid;
107 rsd->rsd_fsuid = current->fsuid;
108 rsd->rsd_fsgid = current->fsgid;
109 rsd->rsd_cap = current->cap_effective;
110 rsd->rsd_ngroups = (size - sizeof(*rsd)) / sizeof(__u32);
111 LASSERT(rsd->rsd_ngroups <= LUSTRE_MAX_GROUPS);
113 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
115 if (rsd->rsd_ngroups > current->group_info->ngroups)
116 rsd->rsd_ngroups = current->group_info->ngroups;
117 memcpy(rsd->rsd_groups, current->group_info->blocks[0],
118 rsd->rsd_ngroups * sizeof(__u32));
119 task_unlock(current);
121 LASSERT(rsd->rsd_ngroups <= NGROUPS);
122 if (rsd->rsd_ngroups > current->ngroups)
123 rsd->rsd_ngroups = current->ngroups;
124 memcpy(rsd->rsd_groups, current->groups,
125 rsd->rsd_ngroups * sizeof(__u32));
130 int lustre_pack_request(struct ptlrpc_request *req,
131 int count, int *lens, char **bufs)
136 req->rq_reqlen = lustre_msg_size(count, lens);
137 rc = ptlrpcs_cli_alloc_reqbuf(req, req->rq_reqlen);
141 lustre_init_msg(req->rq_reqmsg, count, lens, bufs);
146 LIST_HEAD(ptlrpc_rs_debug_lru);
147 spinlock_t ptlrpc_rs_debug_lock = SPIN_LOCK_UNLOCKED;
149 #define PTLRPC_RS_DEBUG_LRU_ADD(rs) \
151 unsigned long __flags; \
153 spin_lock_irqsave(&ptlrpc_rs_debug_lock, __flags); \
154 list_add_tail(&(rs)->rs_debug_list, &ptlrpc_rs_debug_lru); \
155 spin_unlock_irqrestore(&ptlrpc_rs_debug_lock, __flags); \
158 #define PTLRPC_RS_DEBUG_LRU_DEL(rs) \
160 unsigned long __flags; \
162 spin_lock_irqsave(&ptlrpc_rs_debug_lock, __flags); \
163 list_del(&(rs)->rs_debug_list); \
164 spin_unlock_irqrestore(&ptlrpc_rs_debug_lock, __flags); \
167 # define PTLRPC_RS_DEBUG_LRU_ADD(rs) do {} while(0)
168 # define PTLRPC_RS_DEBUG_LRU_DEL(rs) do {} while(0)
171 int lustre_pack_reply(struct ptlrpc_request *req,
172 int count, int *lens, char **bufs)
174 struct ptlrpc_reply_state *rs;
178 LASSERT(req->rq_reply_state == NULL);
179 LASSERT(req->rq_svcsec);
180 LASSERT(req->rq_repmsg == NULL);
182 req->rq_replen = lustre_msg_size(count, lens);
183 rc = svcsec_alloc_repbuf(req->rq_svcsec, req, req->rq_replen);
186 LASSERT(req->rq_reply_state);
187 LASSERT(req->rq_repmsg == req->rq_reply_state->rs_msg);
189 rs = req->rq_reply_state;
190 rs->rs_svcsec = svcsec_get(req->rq_svcsec);
191 rs->rs_cb_id.cbid_fn = reply_out_callback;
192 rs->rs_cb_id.cbid_arg = rs;
193 rs->rs_srv_ni = req->rq_rqbd->rqbd_srv_ni;
194 INIT_LIST_HEAD(&rs->rs_exp_list);
195 INIT_LIST_HEAD(&rs->rs_obd_list);
197 lustre_init_msg(rs->rs_msg, count, lens, bufs);
199 PTLRPC_RS_DEBUG_LRU_ADD(rs);
204 void lustre_free_reply_state(struct ptlrpc_reply_state *rs)
206 struct ptlrpc_svcsec *svcsec = rs->rs_svcsec;
208 PTLRPC_RS_DEBUG_LRU_DEL(rs);
210 LASSERT(!rs->rs_difficult || rs->rs_handled);
211 LASSERT(!rs->rs_on_net);
212 LASSERT(!rs->rs_scheduled);
213 LASSERT(rs->rs_export == NULL);
214 LASSERT(rs->rs_nlocks == 0);
215 LASSERT(list_empty(&rs->rs_exp_list));
216 LASSERT(list_empty(&rs->rs_obd_list));
219 if (svcsec->free_repbuf)
220 svcsec->free_repbuf(svcsec, rs);
222 svcsec_free_reply_state(rs);
227 /* This returns the size of the buffer that is required to hold a lustre_msg
228 * with the given sub-buffer lengths. */
229 int lustre_msg_size(int count, int *lengths)
234 size = HDR_SIZE (count);
235 for (i = 0; i < count; i++)
236 size += size_round(lengths[i]);
241 int lustre_unpack_msg(struct lustre_msg *m, int len)
248 /* We can provide a slightly better error log, if we check the
249 * message magic and version first. In the future, struct
250 * lustre_msg may grow, and we'd like to log a version mismatch,
251 * rather than a short message.
254 required_len = MAX(offsetof(struct lustre_msg, version) +
256 offsetof(struct lustre_msg, magic) +
258 if (len < required_len) {
259 /* can't even look inside the message */
260 CERROR ("message length %d too small for magic/version check\n",
265 flipped = lustre_msg_swabbed(m);
267 __swab32s(&m->version);
268 else if (m->magic != PTLRPC_MSG_MAGIC) {
269 CERROR("wrong lustre_msg magic %#08x\n", m->magic);
273 if ((m->version & ~LUSTRE_VERSION_MASK) != PTLRPC_MSG_VERSION) {
274 CERROR("wrong lustre_msg version %#08x\n", m->version);
278 /* Now we know the sender speaks my language (but possibly flipped)...*/
279 required_len = HDR_SIZE(0);
280 if (len < required_len) {
281 /* can't even look inside the message */
282 CERROR("message length %d too small for lustre_msg\n", len);
289 __swab64s(&m->last_xid);
290 __swab64s(&m->last_committed);
291 __swab64s(&m->transno);
292 __swab32s(&m->status);
293 __swab32s(&m->bufcount);
294 __swab32s(&m->flags);
297 required_len = HDR_SIZE(m->bufcount);
299 if (len < required_len) {
300 /* didn't receive all the buffer lengths */
301 CERROR ("message length %d too small for %d buflens\n",
306 for (i = 0; i < m->bufcount; i++) {
308 __swab32s (&m->buflens[i]);
309 required_len += size_round(m->buflens[i]);
312 if (len < required_len) {
313 CERROR("len: %d, required_len %d\n", len, required_len);
314 CERROR("bufcount: %d\n", m->bufcount);
315 for (i = 0; i < m->bufcount; i++)
316 CERROR("buffer %d length %d\n", i, m->buflens[i]);
323 void *lustre_msg_buf(struct lustre_msg *m, int n, int min_size)
333 bufcount = m->bufcount;
335 CDEBUG(D_INFO, "msg %p buffer[%d] not present (count %d)\n",
340 buflen = m->buflens[n];
341 if (buflen < min_size) {
342 CERROR("msg %p buffer[%d] size %d too small (required %d)\n",
343 m, n, buflen, min_size);
347 offset = HDR_SIZE(bufcount);
348 for (i = 0; i < n; i++)
349 offset += size_round(m->buflens[i]);
351 return (char *)m + offset;
354 char *lustre_msg_string(struct lustre_msg *m, int index, int max_len)
356 /* max_len == 0 means the string should fill the buffer */
357 char *str = lustre_msg_buf(m, index, 0);
362 CERROR ("can't unpack string in msg %p buffer[%d]\n", m, index);
366 blen = m->buflens[index];
367 slen = strnlen(str, blen);
369 if (slen == blen) { /* not NULL terminated */
370 CERROR ("can't unpack non-NULL terminated string in "
371 "msg %p buffer[%d] len %d\n", m, index, blen);
376 if (slen != blen - 1) {
377 CERROR ("can't unpack short string in msg %p "
378 "buffer[%d] len %d: strlen %d\n",
379 m, index, blen, slen);
382 } else if (slen > max_len) {
383 CERROR ("can't unpack oversized string in msg %p "
384 "buffer[%d] len %d strlen %d: max %d expected\n",
385 m, index, blen, slen, max_len);
392 /* Wrap up the normal fixed length cases */
393 void *lustre_swab_buf(struct lustre_msg *msg, int index, int min_size,
398 ptr = lustre_msg_buf(msg, index, min_size);
402 if (swabber != NULL && lustre_msg_swabbed(msg))
403 ((void (*)(void *))swabber)(ptr);
408 void *lustre_swab_reqbuf(struct ptlrpc_request *req, int index, int min_size,
411 LASSERT_REQSWAB(req, index);
412 return lustre_swab_buf(req->rq_reqmsg, index, min_size, swabber);
415 void *lustre_swab_repbuf(struct ptlrpc_request *req, int index, int min_size,
418 LASSERT_REPSWAB(req, index);
419 return lustre_swab_buf(req->rq_repmsg, index, min_size, swabber);
422 /* byte flipping routines for all wire types declared in
423 * lustre_idl.h implemented here.
426 void lustre_swab_connect(struct obd_connect_data *ocd)
428 __swab64s(&ocd->ocd_connect_flags);
429 __swab32s(&ocd->ocd_nllu[0]);
430 __swab32s(&ocd->ocd_nllu[1]);
433 void lustre_swab_obdo(struct obdo *o)
437 __swab64s(&o->o_atime);
438 __swab64s(&o->o_mtime);
439 __swab64s(&o->o_ctime);
440 __swab64s(&o->o_size);
441 __swab64s(&o->o_blocks);
442 __swab64s(&o->o_grant);
443 __swab32s(&o->o_blksize);
444 __swab32s(&o->o_mode);
445 __swab32s(&o->o_uid);
446 __swab32s(&o->o_gid);
447 __swab32s(&o->o_flags);
448 __swab32s(&o->o_nlink);
449 __swab32s(&o->o_generation);
450 __swab64s(&o->o_valid);
451 __swab32s(&o->o_misc);
452 __swab32s(&o->o_easize);
453 __swab32s(&o->o_mds);
454 __swab64s(&o->o_fid);
455 /* o_inline is opaque */
458 /* mdc pack methods used by mdc and smfs*/
459 void *mdc_create_pack(struct lustre_msg *msg, int offset,
460 struct mdc_op_data *op_data, __u32 mode,
461 __u64 rdev, const void *data, int datalen)
463 struct mds_rec_create *rec;
465 rec = lustre_msg_buf(msg, offset, sizeof (*rec));
467 rec->cr_opcode = REINT_CREATE;
468 rec->cr_id = op_data->id1;
469 memset(&rec->cr_replayid, 0, sizeof(rec->cr_replayid));
472 rec->cr_time = op_data->mod_time;
474 tmp = lustre_msg_buf(msg, offset + 1, op_data->namelen + 1);
475 LOGL0(op_data->name, op_data->namelen, tmp);
478 tmp = lustre_msg_buf(msg, offset + 2, datalen);
479 memcpy (tmp, data, datalen);
481 return ((void*)tmp + size_round(datalen));
484 void *mdc_setattr_pack(struct lustre_msg *msg, int offset,
485 struct mdc_op_data *data, struct iattr *iattr,
486 void *ea, int ealen, void *ea2, int ea2len)
488 struct mds_rec_setattr *rec = lustre_msg_buf(msg, offset, sizeof(*rec));
491 rec->sa_opcode = REINT_SETATTR;
492 rec->sa_id = data->id1;
495 rec->sa_valid = iattr->ia_valid;
496 rec->sa_mode = iattr->ia_mode;
497 rec->sa_uid = iattr->ia_uid;
498 rec->sa_gid = iattr->ia_gid;
499 rec->sa_size = iattr->ia_size;
500 rec->sa_atime = LTIME_S(iattr->ia_atime);
501 rec->sa_mtime = LTIME_S(iattr->ia_mtime);
502 rec->sa_ctime = LTIME_S(iattr->ia_ctime);
503 rec->sa_attr_flags = iattr->ia_attr_flags;
505 tmp = (char*)rec + size_round(sizeof(*rec));
510 memcpy(lustre_msg_buf(msg, offset + 1, ealen), ea, ealen);
511 tmp += size_round(ealen);
516 memcpy(lustre_msg_buf(msg, offset + 2, ea2len), ea2, ea2len);
517 tmp += size_round(ea2len);
521 void *mdc_unlink_pack(struct lustre_msg *msg, int offset,
522 struct mdc_op_data *data)
524 struct mds_rec_unlink *rec;
527 rec = lustre_msg_buf(msg, offset, sizeof (*rec));
528 LASSERT (rec != NULL);
530 rec->ul_opcode = REINT_UNLINK;
531 rec->ul_mode = data->create_mode;
532 rec->ul_id1 = data->id1;
533 rec->ul_id2 = data->id2;
534 rec->ul_time = data->mod_time;
536 tmp = lustre_msg_buf(msg, offset + 1, data->namelen + 1);
537 LASSERT (tmp != NULL);
538 LOGL0(data->name, data->namelen, tmp);
542 void *mdc_link_pack(struct lustre_msg *msg, int offset,
543 struct mdc_op_data *data)
545 struct mds_rec_link *rec;
548 rec = lustre_msg_buf(msg, offset, sizeof (*rec));
550 rec->lk_opcode = REINT_LINK;
551 rec->lk_id1 = data->id1;
552 rec->lk_id2 = data->id2;
553 rec->lk_time = data->mod_time;
555 tmp = lustre_msg_buf(msg, offset + 1, data->namelen + 1);
556 LOGL0(data->name, data->namelen, tmp);
561 void *mdc_rename_pack(struct lustre_msg *msg, int offset,
562 struct mdc_op_data *data,
563 const char *old, int oldlen,
564 const char *new, int newlen)
566 struct mds_rec_rename *rec;
569 rec = lustre_msg_buf(msg, offset, sizeof (*rec));
571 /* XXX do something about time, uid, gid */
572 rec->rn_opcode = REINT_RENAME;
573 rec->rn_id1 = data->id1;
574 rec->rn_id2 = data->id2;
575 rec->rn_time = data->mod_time;
577 tmp = lustre_msg_buf(msg, offset + 1, oldlen + 1);
578 LOGL0(old, oldlen, tmp);
581 tmp = lustre_msg_buf(msg, offset + 2, newlen + 1);
582 LOGL0(new, newlen, tmp);
587 void lustre_swab_obd_statfs(struct obd_statfs *os)
589 __swab64s(&os->os_type);
590 __swab64s(&os->os_blocks);
591 __swab64s(&os->os_bfree);
592 __swab64s(&os->os_bavail);
593 __swab64s(&os->os_ffree);
594 /* no need to swap os_fsid */
595 __swab32s(&os->os_bsize);
596 __swab32s(&os->os_namelen);
597 /* no need to swap os_spare */
600 void lustre_swab_obd_ioobj(struct obd_ioobj *ioo)
602 __swab64s(&ioo->ioo_id);
603 __swab64s(&ioo->ioo_gr);
604 __swab32s(&ioo->ioo_type);
605 __swab32s(&ioo->ioo_bufcnt);
608 void lustre_swab_niobuf_remote(struct niobuf_remote *nbr)
610 __swab64s(&nbr->offset);
611 __swab32s(&nbr->len);
612 __swab32s(&nbr->flags);
615 void lustre_swab_ost_body(struct ost_body *b)
617 lustre_swab_obdo(&b->oa);
620 void lustre_swab_ost_last_id(obd_id *id)
625 void lustre_swab_generic_32s(__u32 *val)
630 void lustre_swab_ost_lvb(struct ost_lvb *lvb)
632 __swab64s(&lvb->lvb_size);
633 __swab64s(&lvb->lvb_mtime);
634 __swab64s(&lvb->lvb_atime);
635 __swab64s(&lvb->lvb_ctime);
636 __swab64s(&lvb->lvb_blocks);
639 void lustre_swab_lustre_stc (struct lustre_stc *stc)
641 __swab64s(&stc->u.e3s.l3s_ino);
642 __swab32s(&stc->u.e3s.l3s_gen);
643 __swab32s(&stc->u.e3s.l3s_type);
646 void lustre_swab_lustre_fid(struct lustre_fid *fid)
648 __swab64s(&fid->lf_id);
649 __swab64s(&fid->lf_group);
650 /*__swab32s (&fid->lf_version);*/
653 void lustre_swab_lustre_id(struct lustre_id *id)
655 lustre_swab_lustre_stc(&id->li_stc);
656 lustre_swab_lustre_fid(&id->li_fid);
659 void lustre_swab_mds_status_req(struct mds_status_req *r)
661 __swab32s(&r->flags);
662 __swab32s(&r->repbuf);
666 * because sec_desc is variable buffer, we must check it by hand
668 struct mds_req_sec_desc *lustre_swab_mds_secdesc(struct ptlrpc_request *req,
671 struct mds_req_sec_desc *rsd;
672 struct lustre_msg *m;
675 LASSERT_REQSWAB(req, offset);
678 rsd = lustre_msg_buf(m, offset, sizeof(*rsd));
682 if (lustre_msg_swabbed(m)) {
683 __swab32s(&rsd->rsd_uid);
684 __swab32s(&rsd->rsd_gid);
685 __swab32s(&rsd->rsd_fsuid);
686 __swab32s(&rsd->rsd_fsgid);
687 __swab32s(&rsd->rsd_cap);
688 __swab32s(&rsd->rsd_ngroups);
691 if (rsd->rsd_ngroups > LUSTRE_MAX_GROUPS) {
692 CERROR("%u groups is not allowed\n", rsd->rsd_ngroups);
696 if (m->buflens[offset] !=
697 sizeof(*rsd) + rsd->rsd_ngroups * sizeof(__u32)) {
698 CERROR("bufflen %u while contains %u groups\n",
699 m->buflens[offset], rsd->rsd_ngroups);
703 if (lustre_msg_swabbed(m)) {
704 for (i = 0; i < rsd->rsd_ngroups; i++)
705 __swab32s(&rsd->rsd_groups[i]);
711 void lustre_swab_mds_body(struct mds_body *b)
713 lustre_swab_lustre_id(&b->id1);
714 lustre_swab_lustre_id(&b->id2);
715 /* handle is opaque */
717 __swab64s(&b->blocks);
718 __swab64s(&b->valid);
722 __swab32s(&b->mtime);
723 __swab32s(&b->ctime);
724 __swab32s(&b->atime);
725 __swab32s(&b->flags);
727 __swab32s(&b->nlink);
728 __swab32s(&b->eadatasize);
730 void lustre_swab_mds_rec_setattr(struct mds_rec_setattr *sa)
732 __swab32s(&sa->sa_opcode);
733 __swab32s(&sa->sa_valid);
734 lustre_swab_lustre_id(&sa->sa_id);
735 __swab32s(&sa->sa_mode);
736 __swab32s(&sa->sa_uid);
737 __swab32s(&sa->sa_gid);
738 __swab32s(&sa->sa_attr_flags);
739 __swab64s(&sa->sa_size);
740 __swab64s(&sa->sa_atime);
741 __swab64s(&sa->sa_mtime);
742 __swab64s(&sa->sa_ctime);
745 void lustre_swab_mds_rec_create(struct mds_rec_create *cr)
747 __swab32s(&cr->cr_opcode);
748 __swab32s(&cr->cr_flags); /* for use with open */
749 __swab32s(&cr->cr_mode);
750 lustre_swab_lustre_id(&cr->cr_id);
751 lustre_swab_lustre_id(&cr->cr_replayid);
752 __swab64s(&cr->cr_time);
753 __swab64s(&cr->cr_rdev);
756 void lustre_swab_mds_rec_link(struct mds_rec_link *lk)
758 __swab32s(&lk->lk_opcode);
759 lustre_swab_lustre_id(&lk->lk_id1);
760 lustre_swab_lustre_id(&lk->lk_id2);
763 void lustre_swab_mds_rec_unlink(struct mds_rec_unlink *ul)
765 __swab32s(&ul->ul_opcode);
766 __swab32s(&ul->ul_mode);
767 lustre_swab_lustre_id(&ul->ul_id1);
768 lustre_swab_lustre_id(&ul->ul_id2);
771 void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn)
773 __swab32s(&rn->rn_opcode);
774 lustre_swab_lustre_id(&rn->rn_id1);
775 lustre_swab_lustre_id(&rn->rn_id2);
778 void lustre_swab_lov_desc(struct lov_desc *ld)
780 __swab32s(&ld->ld_tgt_count);
781 __swab32s(&ld->ld_active_tgt_count);
782 __swab32s(&ld->ld_default_stripe_count);
783 __swab64s(&ld->ld_default_stripe_size);
784 __swab64s(&ld->ld_default_stripe_offset);
785 __swab32s(&ld->ld_pattern);
786 /* uuid endian insensitive */
789 void lustre_swab_ldlm_res_id(struct ldlm_res_id *id)
793 for (i = 0; i < RES_NAME_SIZE; i++)
794 __swab64s(&id->name[i]);
797 void lustre_swab_ldlm_policy_data(ldlm_policy_data_t *d)
799 /* the lock data is a union and the first three fields of both EXTENT
800 * and FLOCK types are __u64, so it's ok to swab them in the same way */
801 __swab64s(&d->l_flock.start);
802 __swab64s(&d->l_flock.end);
803 __swab64s(&d->l_flock.pid);
804 __swab64s(&d->l_flock.blocking_pid);
807 void lustre_swab_ldlm_intent(struct ldlm_intent *i)
812 void lustre_swab_ldlm_resource_desc(struct ldlm_resource_desc *r)
814 __swab32s(&r->lr_type);
815 lustre_swab_ldlm_res_id(&r->lr_name);
818 void lustre_swab_ldlm_lock_desc(struct ldlm_lock_desc *l)
820 lustre_swab_ldlm_resource_desc(&l->l_resource);
821 __swab32s(&l->l_req_mode);
822 __swab32s(&l->l_granted_mode);
823 lustre_swab_ldlm_policy_data(&l->l_policy_data);
826 void lustre_swab_ldlm_request(struct ldlm_request *rq)
828 __swab32s(&rq->lock_flags);
829 lustre_swab_ldlm_lock_desc(&rq->lock_desc);
830 /* lock_handle1 opaque */
831 /* lock_handle2 opaque */
834 void lustre_swab_ldlm_reply(struct ldlm_reply *r)
836 __swab32s(&r->lock_flags);
837 lustre_swab_ldlm_lock_desc(&r->lock_desc);
838 /* lock_handle opaque */
839 __swab64s(&r->lock_policy_res1);
840 __swab64s(&r->lock_policy_res2);
843 void lustre_swab_ptlbd_op(struct ptlbd_op *op)
845 __swab16s(&op->op_cmd);
846 __swab16s(&op->op_lun);
847 __swab16s(&op->op_niob_cnt);
848 /* ignore op__padding */
849 __swab32s(&op->op_block_cnt);
852 void lustre_swab_ptlbd_niob(struct ptlbd_niob *n)
854 __swab64s(&n->n_xid);
855 __swab64s(&n->n_block_nr);
856 __swab32s(&n->n_offset);
857 __swab32s(&n->n_length);
860 void lustre_swab_ptlbd_rsp(struct ptlbd_rsp *r)
862 __swab16s(&r->r_status);
863 __swab16s(&r->r_error_cnt);
866 /* no one calls this */
867 int llog_log_swabbed(struct llog_log_hdr *hdr)
869 if (hdr->llh_hdr.lrh_type == __swab32(LLOG_HDR_MAGIC))
871 if (hdr->llh_hdr.lrh_type == LLOG_HDR_MAGIC)
876 void lustre_assert_wire_constants(void)