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, int *lens, char **bufs)
61 msg->magic = PTLRPC_MSG_MAGIC;
62 msg->version = PTLRPC_MSG_VERSION;
63 msg->bufcount = count;
64 for (i = 0; i < count; i++)
65 msg->buflens[i] = lens[i];
70 ptr = (char *)msg + HDR_SIZE(count);
71 for (i = 0; i < count; i++) {
73 LOGL(tmp, lens[i], ptr);
77 int lustre_secdesc_size(void)
80 int ngroups = current_ngroups;
82 if (ngroups > LUSTRE_MAX_GROUPS)
83 ngroups = LUSTRE_MAX_GROUPS;
85 return sizeof(struct mds_req_sec_desc) +
86 sizeof(__u32) * ngroups;
93 * because group info might have changed since last time we call
94 * secdesc_size(), so here we did more sanity check to prevent garbage gids
96 void lustre_pack_secdesc(struct ptlrpc_request *req, int size)
99 struct mds_req_sec_desc *rsd;
101 rsd = lustre_msg_buf(req->rq_reqmsg,
102 MDS_REQ_SECDESC_OFF, size);
104 rsd->rsd_uid = current->uid;
105 rsd->rsd_gid = current->gid;
106 rsd->rsd_fsuid = current->fsuid;
107 rsd->rsd_fsgid = current->fsgid;
108 rsd->rsd_cap = current->cap_effective;
109 rsd->rsd_ngroups = (size - sizeof(*rsd)) / sizeof(__u32);
110 LASSERT(rsd->rsd_ngroups <= LUSTRE_MAX_GROUPS);
112 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
114 if (rsd->rsd_ngroups > current->group_info->ngroups)
115 rsd->rsd_ngroups = current->group_info->ngroups;
116 memcpy(rsd->rsd_groups, current->group_info->blocks[0],
117 rsd->rsd_ngroups * sizeof(__u32));
118 task_unlock(current);
120 LASSERT(rsd->rsd_ngroups <= NGROUPS);
121 if (rsd->rsd_ngroups > current->ngroups)
122 rsd->rsd_ngroups = current->ngroups;
123 memcpy(rsd->rsd_groups, current->groups,
124 rsd->rsd_ngroups * sizeof(__u32));
129 int lustre_pack_request (struct ptlrpc_request *req,
130 int count, int *lens, char **bufs)
135 req->rq_reqlen = lustre_msg_size(count, lens);
136 rc = ptlrpcs_cli_alloc_reqbuf(req, req->rq_reqlen);
140 lustre_init_msg(req->rq_reqmsg, count, lens, bufs);
145 LIST_HEAD(ptlrpc_rs_debug_lru);
146 spinlock_t ptlrpc_rs_debug_lock = SPIN_LOCK_UNLOCKED;
148 #define PTLRPC_RS_DEBUG_LRU_ADD(rs) \
150 unsigned long __flags; \
152 spin_lock_irqsave(&ptlrpc_rs_debug_lock, __flags); \
153 list_add_tail(&(rs)->rs_debug_list, &ptlrpc_rs_debug_lru); \
154 spin_unlock_irqrestore(&ptlrpc_rs_debug_lock, __flags); \
157 #define PTLRPC_RS_DEBUG_LRU_DEL(rs) \
159 unsigned long __flags; \
161 spin_lock_irqsave(&ptlrpc_rs_debug_lock, __flags); \
162 list_del(&(rs)->rs_debug_list); \
163 spin_unlock_irqrestore(&ptlrpc_rs_debug_lock, __flags); \
166 # define PTLRPC_RS_DEBUG_LRU_ADD(rs) do {} while(0)
167 # define PTLRPC_RS_DEBUG_LRU_DEL(rs) do {} while(0)
170 int lustre_pack_reply (struct ptlrpc_request *req,
171 int count, int *lens, char **bufs)
173 struct ptlrpc_reply_state *rs;
177 LASSERT(req->rq_reply_state == NULL);
178 LASSERT(req->rq_svcsec);
179 LASSERT(req->rq_repmsg == NULL);
181 req->rq_replen = lustre_msg_size(count, lens);
182 rc = svcsec_alloc_repbuf(req->rq_svcsec, req, req->rq_replen);
185 LASSERT(req->rq_reply_state);
186 LASSERT(req->rq_repmsg == req->rq_reply_state->rs_msg);
188 rs = req->rq_reply_state;
189 rs->rs_svcsec = svcsec_get(req->rq_svcsec);
190 rs->rs_cb_id.cbid_fn = reply_out_callback;
191 rs->rs_cb_id.cbid_arg = rs;
192 rs->rs_srv_ni = req->rq_rqbd->rqbd_srv_ni;
193 INIT_LIST_HEAD(&rs->rs_exp_list);
194 INIT_LIST_HEAD(&rs->rs_obd_list);
196 lustre_init_msg(rs->rs_msg, count, lens, bufs);
198 PTLRPC_RS_DEBUG_LRU_ADD(rs);
203 void lustre_free_reply_state (struct ptlrpc_reply_state *rs)
205 struct ptlrpc_svcsec *svcsec = rs->rs_svcsec;
207 PTLRPC_RS_DEBUG_LRU_DEL(rs);
209 LASSERT (!rs->rs_difficult || rs->rs_handled);
210 LASSERT (!rs->rs_on_net);
211 LASSERT (!rs->rs_scheduled);
212 LASSERT (rs->rs_export == NULL);
213 LASSERT (rs->rs_nlocks == 0);
214 LASSERT (list_empty(&rs->rs_exp_list));
215 LASSERT (list_empty(&rs->rs_obd_list));
218 if (svcsec->free_repbuf)
219 svcsec->free_repbuf(svcsec, rs);
221 svcsec_free_reply_state(rs);
226 /* This returns the size of the buffer that is required to hold a lustre_msg
227 * with the given sub-buffer lengths. */
228 int lustre_msg_size(int count, int *lengths)
233 size = HDR_SIZE (count);
234 for (i = 0; i < count; i++)
235 size += size_round(lengths[i]);
240 int lustre_unpack_msg(struct lustre_msg *m, int len)
247 /* We can provide a slightly better error log, if we check the
248 * message magic and version first. In the future, struct
249 * lustre_msg may grow, and we'd like to log a version mismatch,
250 * rather than a short message.
253 required_len = MAX (offsetof (struct lustre_msg, version) +
255 offsetof (struct lustre_msg, magic) +
257 if (len < required_len) {
258 /* can't even look inside the message */
259 CERROR ("message length %d too small for magic/version check\n",
264 flipped = lustre_msg_swabbed(m);
266 __swab32s (&m->version);
267 else if (m->magic != PTLRPC_MSG_MAGIC) {
268 CERROR("wrong lustre_msg magic %#08x\n", m->magic);
272 if ((m->version & ~LUSTRE_VERSION_MASK) != PTLRPC_MSG_VERSION) {
273 CERROR("wrong lustre_msg version %#08x\n", m->version);
277 /* Now we know the sender speaks my language (but possibly flipped)...*/
278 required_len = HDR_SIZE(0);
279 if (len < required_len) {
280 /* can't even look inside the message */
281 CERROR ("message length %d too small for lustre_msg\n", len);
286 __swab32s (&m->type);
288 __swab64s (&m->last_xid);
289 __swab64s (&m->last_committed);
290 __swab64s (&m->transno);
291 __swab32s (&m->status);
292 __swab32s (&m->bufcount);
293 __swab32s (&m->flags);
296 required_len = HDR_SIZE(m->bufcount);
298 if (len < required_len) {
299 /* didn't receive all the buffer lengths */
300 CERROR ("message length %d too small for %d buflens\n",
305 for (i = 0; i < m->bufcount; i++) {
307 __swab32s (&m->buflens[i]);
308 required_len += size_round(m->buflens[i]);
311 if (len < required_len) {
312 CERROR("len: %d, required_len %d\n", len, required_len);
313 CERROR("bufcount: %d\n", m->bufcount);
314 for (i = 0; i < m->bufcount; i++)
315 CERROR("buffer %d length %d\n", i, m->buflens[i]);
322 void *lustre_msg_buf(struct lustre_msg *m, int n, int min_size)
332 bufcount = m->bufcount;
334 CDEBUG(D_INFO, "msg %p buffer[%d] not present (count %d)\n",
339 buflen = m->buflens[n];
340 if (buflen < min_size) {
341 CERROR("msg %p buffer[%d] size %d too small (required %d)\n",
342 m, n, buflen, min_size);
346 offset = HDR_SIZE(bufcount);
347 for (i = 0; i < n; i++)
348 offset += size_round(m->buflens[i]);
350 return (char *)m + offset;
353 char *lustre_msg_string (struct lustre_msg *m, int index, int max_len)
355 /* max_len == 0 means the string should fill the buffer */
356 char *str = lustre_msg_buf (m, index, 0);
361 CERROR ("can't unpack string in msg %p buffer[%d]\n", m, index);
365 blen = m->buflens[index];
366 slen = strnlen (str, blen);
368 if (slen == blen) { /* not NULL terminated */
369 CERROR ("can't unpack non-NULL terminated string in "
370 "msg %p buffer[%d] len %d\n", m, index, blen);
375 if (slen != blen - 1) {
376 CERROR ("can't unpack short string in msg %p "
377 "buffer[%d] len %d: strlen %d\n",
378 m, index, blen, slen);
381 } else if (slen > max_len) {
382 CERROR ("can't unpack oversized string in msg %p "
383 "buffer[%d] len %d strlen %d: max %d expected\n",
384 m, index, blen, slen, max_len);
391 /* Wrap up the normal fixed length cases */
392 void *lustre_swab_buf(struct lustre_msg *msg, int index, int min_size,
397 ptr = lustre_msg_buf(msg, index, min_size);
401 if (swabber != NULL && lustre_msg_swabbed(msg))
402 ((void (*)(void *))swabber)(ptr);
407 void *lustre_swab_reqbuf(struct ptlrpc_request *req, int index, int min_size,
410 LASSERT_REQSWAB(req, index);
411 return lustre_swab_buf(req->rq_reqmsg, index, min_size, swabber);
414 void *lustre_swab_repbuf(struct ptlrpc_request *req, int index, int min_size,
417 LASSERT_REPSWAB(req, index);
418 return lustre_swab_buf(req->rq_repmsg, index, min_size, swabber);
421 /* byte flipping routines for all wire types declared in
422 * lustre_idl.h implemented here.
425 void lustre_swab_connect(struct obd_connect_data *ocd)
427 __swab64s (&ocd->ocd_connect_flags);
428 __swab32s (&ocd->ocd_nllu[0]);
429 __swab32s (&ocd->ocd_nllu[1]);
432 void lustre_swab_obdo (struct obdo *o)
434 __swab64s (&o->o_id);
435 __swab64s (&o->o_gr);
436 __swab64s (&o->o_atime);
437 __swab64s (&o->o_mtime);
438 __swab64s (&o->o_ctime);
439 __swab64s (&o->o_size);
440 __swab64s (&o->o_blocks);
441 __swab64s (&o->o_grant);
442 __swab32s (&o->o_blksize);
443 __swab32s (&o->o_mode);
444 __swab32s (&o->o_uid);
445 __swab32s (&o->o_gid);
446 __swab32s (&o->o_flags);
447 __swab32s (&o->o_nlink);
448 __swab32s (&o->o_generation);
449 __swab64s (&o->o_valid);
450 __swab32s (&o->o_misc);
451 __swab32s (&o->o_easize);
452 __swab32s (&o->o_mds);
453 __swab64s (&o->o_fid);
454 /* o_inline is opaque */
457 /* mdc pack methods used by mdc and smfs*/
458 void *mdc_create_pack(struct lustre_msg *msg, int offset,
459 struct mdc_op_data *op_data, __u32 mode,
460 __u64 rdev, const void *data, int datalen)
462 struct mds_rec_create *rec;
464 rec = lustre_msg_buf(msg, offset, sizeof (*rec));
466 rec->cr_opcode = REINT_CREATE;
467 rec->cr_id = op_data->id1;
468 memset(&rec->cr_replayid, 0, sizeof(rec->cr_replayid));
471 rec->cr_time = op_data->mod_time;
473 tmp = lustre_msg_buf(msg, offset + 1, op_data->namelen + 1);
474 LOGL0(op_data->name, op_data->namelen, tmp);
477 tmp = lustre_msg_buf(msg, offset + 2, datalen);
478 memcpy (tmp, data, datalen);
480 return ((void*)tmp + size_round(datalen));
483 void *mdc_setattr_pack(struct lustre_msg *msg, int offset,
484 struct mdc_op_data *data, struct iattr *iattr,
485 void *ea, int ealen, void *ea2, int ea2len)
487 struct mds_rec_setattr *rec = lustre_msg_buf(msg, offset, sizeof(*rec));
490 rec->sa_opcode = REINT_SETATTR;
491 rec->sa_id = data->id1;
494 rec->sa_valid = iattr->ia_valid;
495 rec->sa_mode = iattr->ia_mode;
496 rec->sa_uid = iattr->ia_uid;
497 rec->sa_gid = iattr->ia_gid;
498 rec->sa_size = iattr->ia_size;
499 rec->sa_atime = LTIME_S(iattr->ia_atime);
500 rec->sa_mtime = LTIME_S(iattr->ia_mtime);
501 rec->sa_ctime = LTIME_S(iattr->ia_ctime);
502 rec->sa_attr_flags = iattr->ia_attr_flags;
504 tmp = (char*)rec + size_round(sizeof(*rec));
509 memcpy(lustre_msg_buf(msg, offset + 1, ealen), ea, ealen);
510 tmp += size_round(ealen);
515 memcpy(lustre_msg_buf(msg, offset + 2, ea2len), ea2, ea2len);
516 tmp += size_round(ea2len);
520 void *mdc_unlink_pack(struct lustre_msg *msg, int offset,
521 struct mdc_op_data *data)
523 struct mds_rec_unlink *rec;
526 rec = lustre_msg_buf(msg, offset, sizeof (*rec));
527 LASSERT (rec != NULL);
529 rec->ul_opcode = REINT_UNLINK;
530 rec->ul_mode = data->create_mode;
531 rec->ul_id1 = data->id1;
532 rec->ul_id2 = data->id2;
533 rec->ul_time = data->mod_time;
535 tmp = lustre_msg_buf(msg, offset + 1, data->namelen + 1);
536 LASSERT (tmp != NULL);
537 LOGL0(data->name, data->namelen, tmp);
541 void *mdc_link_pack(struct lustre_msg *msg, int offset,
542 struct mdc_op_data *data)
544 struct mds_rec_link *rec;
547 rec = lustre_msg_buf(msg, offset, sizeof (*rec));
549 rec->lk_opcode = REINT_LINK;
550 rec->lk_id1 = data->id1;
551 rec->lk_id2 = data->id2;
552 rec->lk_time = data->mod_time;
554 tmp = lustre_msg_buf(msg, offset + 1, data->namelen + 1);
555 LOGL0(data->name, data->namelen, tmp);
560 void *mdc_rename_pack(struct lustre_msg *msg, int offset,
561 struct mdc_op_data *data,
562 const char *old, int oldlen,
563 const char *new, int newlen)
565 struct mds_rec_rename *rec;
568 rec = lustre_msg_buf(msg, offset, sizeof (*rec));
570 /* XXX do something about time, uid, gid */
571 rec->rn_opcode = REINT_RENAME;
572 rec->rn_id1 = data->id1;
573 rec->rn_id2 = data->id2;
574 rec->rn_time = data->mod_time;
576 tmp = lustre_msg_buf(msg, offset + 1, oldlen + 1);
577 LOGL0(old, oldlen, tmp);
580 tmp = lustre_msg_buf(msg, offset + 2, newlen + 1);
581 LOGL0(new, newlen, tmp);
586 void lustre_swab_obd_statfs (struct obd_statfs *os)
588 __swab64s (&os->os_type);
589 __swab64s (&os->os_blocks);
590 __swab64s (&os->os_bfree);
591 __swab64s (&os->os_bavail);
592 __swab64s (&os->os_ffree);
593 /* no need to swap os_fsid */
594 __swab32s (&os->os_bsize);
595 __swab32s (&os->os_namelen);
596 /* no need to swap os_spare */
599 void lustre_swab_obd_ioobj (struct obd_ioobj *ioo)
601 __swab64s (&ioo->ioo_id);
602 __swab64s (&ioo->ioo_gr);
603 __swab32s (&ioo->ioo_type);
604 __swab32s (&ioo->ioo_bufcnt);
607 void lustre_swab_niobuf_remote (struct niobuf_remote *nbr)
609 __swab64s (&nbr->offset);
610 __swab32s (&nbr->len);
611 __swab32s (&nbr->flags);
614 void lustre_swab_ost_body (struct ost_body *b)
616 lustre_swab_obdo (&b->oa);
619 void lustre_swab_ost_last_id(obd_id *id)
624 void lustre_swab_generic_32s(__u32 *val)
629 void lustre_swab_ost_lvb(struct ost_lvb *lvb)
631 __swab64s(&lvb->lvb_size);
632 __swab64s(&lvb->lvb_mtime);
633 __swab64s(&lvb->lvb_atime);
634 __swab64s(&lvb->lvb_ctime);
635 __swab64s(&lvb->lvb_blocks);
638 void lustre_swab_lustre_stc (struct lustre_stc *stc)
640 __swab64s (&stc->u.e3s.l3s_ino);
641 __swab32s (&stc->u.e3s.l3s_gen);
642 __swab32s (&stc->u.e3s.l3s_type);
645 void lustre_swab_lustre_fid(struct lustre_fid *fid)
647 __swab64s (&fid->lf_id);
648 __swab64s (&fid->lf_group);
649 /*__swab32s (&fid->lf_version);*/
652 void lustre_swab_lustre_id (struct lustre_id *id)
654 lustre_swab_lustre_stc(&id->li_stc);
655 lustre_swab_lustre_fid(&id->li_fid);
658 void lustre_swab_mds_status_req (struct mds_status_req *r)
660 __swab32s (&r->flags);
661 __swab32s (&r->repbuf);
665 * because sec_desc is variable buffer, we must check it by hand
667 struct mds_req_sec_desc *lustre_swab_mds_secdesc(struct ptlrpc_request *req,
670 struct mds_req_sec_desc *rsd;
671 struct lustre_msg *m;
674 LASSERT_REQSWAB(req, offset);
677 rsd = lustre_msg_buf(m, offset, sizeof(*rsd));
681 if (lustre_msg_swabbed(m)) {
682 __swab32s(&rsd->rsd_uid);
683 __swab32s(&rsd->rsd_gid);
684 __swab32s(&rsd->rsd_fsuid);
685 __swab32s(&rsd->rsd_fsgid);
686 __swab32s(&rsd->rsd_cap);
687 __swab32s(&rsd->rsd_ngroups);
690 if (rsd->rsd_ngroups > LUSTRE_MAX_GROUPS) {
691 CERROR("%u groups is not allowed\n", rsd->rsd_ngroups);
695 if (m->buflens[offset] !=
696 sizeof(*rsd) + rsd->rsd_ngroups * sizeof(__u32)) {
697 CERROR("bufflen %u while contains %u groups\n",
698 m->buflens[offset], rsd->rsd_ngroups);
702 if (lustre_msg_swabbed(m)) {
703 for (i = 0; i < rsd->rsd_ngroups; i++)
704 __swab32s(&rsd->rsd_groups[i]);
710 void lustre_swab_mds_body (struct mds_body *b)
712 lustre_swab_lustre_id (&b->id1);
713 lustre_swab_lustre_id (&b->id2);
714 /* handle is opaque */
715 __swab64s (&b->size);
716 __swab64s (&b->blocks);
717 __swab64s (&b->valid);
718 __swab32s (&b->mode);
721 __swab32s (&b->mtime);
722 __swab32s (&b->ctime);
723 __swab32s (&b->atime);
724 __swab32s (&b->flags);
725 __swab32s (&b->rdev);
726 __swab32s (&b->nlink);
727 __swab32s (&b->eadatasize);
729 void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa)
731 __swab32s (&sa->sa_opcode);
732 __swab32s (&sa->sa_valid);
733 lustre_swab_lustre_id (&sa->sa_id);
734 __swab32s (&sa->sa_mode);
735 __swab32s (&sa->sa_uid);
736 __swab32s (&sa->sa_gid);
737 __swab32s (&sa->sa_attr_flags);
738 __swab64s (&sa->sa_size);
739 __swab64s (&sa->sa_atime);
740 __swab64s (&sa->sa_mtime);
741 __swab64s (&sa->sa_ctime);
744 void lustre_swab_mds_rec_create (struct mds_rec_create *cr)
746 __swab32s (&cr->cr_opcode);
747 __swab32s (&cr->cr_flags); /* for use with open */
748 __swab32s (&cr->cr_mode);
749 lustre_swab_lustre_id (&cr->cr_id);
750 lustre_swab_lustre_id (&cr->cr_replayid);
751 __swab64s (&cr->cr_time);
752 __swab64s (&cr->cr_rdev);
755 void lustre_swab_mds_rec_link (struct mds_rec_link *lk)
757 __swab32s (&lk->lk_opcode);
758 lustre_swab_lustre_id (&lk->lk_id1);
759 lustre_swab_lustre_id (&lk->lk_id2);
762 void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul)
764 __swab32s (&ul->ul_opcode);
765 __swab32s (&ul->ul_mode);
766 lustre_swab_lustre_id (&ul->ul_id1);
767 lustre_swab_lustre_id (&ul->ul_id2);
770 void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn)
772 __swab32s (&rn->rn_opcode);
773 lustre_swab_lustre_id (&rn->rn_id1);
774 lustre_swab_lustre_id (&rn->rn_id2);
777 void lustre_swab_lov_desc (struct lov_desc *ld)
779 __swab32s (&ld->ld_tgt_count);
780 __swab32s (&ld->ld_active_tgt_count);
781 __swab32s (&ld->ld_default_stripe_count);
782 __swab64s (&ld->ld_default_stripe_size);
783 __swab64s (&ld->ld_default_stripe_offset);
784 __swab32s (&ld->ld_pattern);
785 /* uuid endian insensitive */
788 void lustre_swab_ldlm_res_id (struct ldlm_res_id *id)
792 for (i = 0; i < RES_NAME_SIZE; i++)
793 __swab64s (&id->name[i]);
796 void lustre_swab_ldlm_policy_data (ldlm_policy_data_t *d)
798 /* the lock data is a union and the first three fields of both EXTENT
799 * and FLOCK types are __u64, so it's ok to swab them in the same way */
800 __swab64s (&d->l_flock.start);
801 __swab64s (&d->l_flock.end);
802 __swab64s (&d->l_flock.pid);
803 __swab64s (&d->l_flock.blocking_pid);
806 void lustre_swab_ldlm_intent (struct ldlm_intent *i)
811 void lustre_swab_ldlm_resource_desc (struct ldlm_resource_desc *r)
813 __swab32s (&r->lr_type);
814 lustre_swab_ldlm_res_id (&r->lr_name);
817 void lustre_swab_ldlm_lock_desc (struct ldlm_lock_desc *l)
819 lustre_swab_ldlm_resource_desc (&l->l_resource);
820 __swab32s (&l->l_req_mode);
821 __swab32s (&l->l_granted_mode);
822 lustre_swab_ldlm_policy_data (&l->l_policy_data);
825 void lustre_swab_ldlm_request (struct ldlm_request *rq)
827 __swab32s (&rq->lock_flags);
828 lustre_swab_ldlm_lock_desc (&rq->lock_desc);
829 /* lock_handle1 opaque */
830 /* lock_handle2 opaque */
833 void lustre_swab_ldlm_reply (struct ldlm_reply *r)
835 __swab32s (&r->lock_flags);
836 lustre_swab_ldlm_lock_desc (&r->lock_desc);
837 /* lock_handle opaque */
838 __swab64s (&r->lock_policy_res1);
839 __swab64s (&r->lock_policy_res2);
842 void lustre_swab_ptlbd_op (struct ptlbd_op *op)
844 __swab16s (&op->op_cmd);
845 __swab16s (&op->op_lun);
846 __swab16s (&op->op_niob_cnt);
847 /* ignore op__padding */
848 __swab32s (&op->op_block_cnt);
851 void lustre_swab_ptlbd_niob (struct ptlbd_niob *n)
853 __swab64s (&n->n_xid);
854 __swab64s (&n->n_block_nr);
855 __swab32s (&n->n_offset);
856 __swab32s (&n->n_length);
859 void lustre_swab_ptlbd_rsp (struct ptlbd_rsp *r)
861 __swab16s (&r->r_status);
862 __swab16s (&r->r_error_cnt);
865 /* no one calls this */
866 int llog_log_swabbed(struct llog_log_hdr *hdr)
868 if (hdr->llh_hdr.lrh_type == __swab32(LLOG_HDR_MAGIC))
870 if (hdr->llh_hdr.lrh_type == LLOG_HDR_MAGIC)
874 void lustre_assert_wire_constants(void)