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_pack_request (struct ptlrpc_request *req,
78 int count, int *lens, char **bufs)
83 req->rq_reqlen = lustre_msg_size(count, lens);
84 rc = ptlrpcs_cli_alloc_reqbuf(req, req->rq_reqlen);
88 lustre_init_msg(req->rq_reqmsg, count, lens, bufs);
93 LIST_HEAD(ptlrpc_rs_debug_lru);
94 spinlock_t ptlrpc_rs_debug_lock = SPIN_LOCK_UNLOCKED;
96 #define PTLRPC_RS_DEBUG_LRU_ADD(rs) \
98 unsigned long __flags; \
100 spin_lock_irqsave(&ptlrpc_rs_debug_lock, __flags); \
101 list_add_tail(&(rs)->rs_debug_list, &ptlrpc_rs_debug_lru); \
102 spin_unlock_irqrestore(&ptlrpc_rs_debug_lock, __flags); \
105 #define PTLRPC_RS_DEBUG_LRU_DEL(rs) \
107 unsigned long __flags; \
109 spin_lock_irqsave(&ptlrpc_rs_debug_lock, __flags); \
110 list_del(&(rs)->rs_debug_list); \
111 spin_unlock_irqrestore(&ptlrpc_rs_debug_lock, __flags); \
114 # define PTLRPC_RS_DEBUG_LRU_ADD(rs) do {} while(0)
115 # define PTLRPC_RS_DEBUG_LRU_DEL(rs) do {} while(0)
118 int lustre_pack_reply (struct ptlrpc_request *req,
119 int count, int *lens, char **bufs)
121 struct ptlrpc_reply_state *rs;
125 LASSERT(req->rq_reply_state == NULL);
126 LASSERT(req->rq_svcsec);
127 LASSERT(req->rq_repmsg == NULL);
129 req->rq_replen = lustre_msg_size(count, lens);
130 rc = svcsec_alloc_repbuf(req->rq_svcsec, req, req->rq_replen);
133 LASSERT(req->rq_reply_state);
134 LASSERT(req->rq_repmsg == req->rq_reply_state->rs_msg);
136 rs = req->rq_reply_state;
137 rs->rs_svcsec = svcsec_get(req->rq_svcsec);
138 rs->rs_cb_id.cbid_fn = reply_out_callback;
139 rs->rs_cb_id.cbid_arg = rs;
140 rs->rs_srv_ni = req->rq_rqbd->rqbd_srv_ni;
141 INIT_LIST_HEAD(&rs->rs_exp_list);
142 INIT_LIST_HEAD(&rs->rs_obd_list);
144 lustre_init_msg(rs->rs_msg, count, lens, bufs);
146 PTLRPC_RS_DEBUG_LRU_ADD(rs);
151 void lustre_free_reply_state (struct ptlrpc_reply_state *rs)
153 struct ptlrpc_svcsec *svcsec = rs->rs_svcsec;
155 PTLRPC_RS_DEBUG_LRU_DEL(rs);
157 LASSERT (!rs->rs_difficult || rs->rs_handled);
158 LASSERT (!rs->rs_on_net);
159 LASSERT (!rs->rs_scheduled);
160 LASSERT (rs->rs_export == NULL);
161 LASSERT (rs->rs_nlocks == 0);
162 LASSERT (list_empty(&rs->rs_exp_list));
163 LASSERT (list_empty(&rs->rs_obd_list));
166 if (svcsec->free_repbuf)
167 svcsec->free_repbuf(svcsec, rs);
169 svcsec_free_reply_state(rs);
174 /* This returns the size of the buffer that is required to hold a lustre_msg
175 * with the given sub-buffer lengths. */
176 int lustre_msg_size(int count, int *lengths)
181 size = HDR_SIZE (count);
182 for (i = 0; i < count; i++)
183 size += size_round(lengths[i]);
188 int lustre_unpack_msg(struct lustre_msg *m, int len)
195 /* We can provide a slightly better error log, if we check the
196 * message magic and version first. In the future, struct
197 * lustre_msg may grow, and we'd like to log a version mismatch,
198 * rather than a short message.
201 required_len = MAX (offsetof (struct lustre_msg, version) +
203 offsetof (struct lustre_msg, magic) +
205 if (len < required_len) {
206 /* can't even look inside the message */
207 CERROR ("message length %d too small for magic/version check\n",
212 flipped = lustre_msg_swabbed(m);
214 __swab32s (&m->version);
215 else if (m->magic != PTLRPC_MSG_MAGIC) {
216 CERROR("wrong lustre_msg magic %#08x\n", m->magic);
220 if ((m->version & ~LUSTRE_VERSION_MASK) != PTLRPC_MSG_VERSION) {
221 CERROR("wrong lustre_msg version %#08x\n", m->version);
225 /* Now we know the sender speaks my language (but possibly flipped)...*/
226 required_len = HDR_SIZE(0);
227 if (len < required_len) {
228 /* can't even look inside the message */
229 CERROR ("message length %d too small for lustre_msg\n", len);
234 __swab32s (&m->type);
236 __swab64s (&m->last_xid);
237 __swab64s (&m->last_committed);
238 __swab64s (&m->transno);
239 __swab32s (&m->status);
240 __swab32s (&m->bufcount);
241 __swab32s (&m->flags);
244 required_len = HDR_SIZE(m->bufcount);
246 if (len < required_len) {
247 /* didn't receive all the buffer lengths */
248 CERROR ("message length %d too small for %d buflens\n",
253 for (i = 0; i < m->bufcount; i++) {
255 __swab32s (&m->buflens[i]);
256 required_len += size_round(m->buflens[i]);
259 if (len < required_len) {
260 CERROR("len: %d, required_len %d\n", len, required_len);
261 CERROR("bufcount: %d\n", m->bufcount);
262 for (i = 0; i < m->bufcount; i++)
263 CERROR("buffer %d length %d\n", i, m->buflens[i]);
270 void *lustre_msg_buf(struct lustre_msg *m, int n, int min_size)
280 bufcount = m->bufcount;
282 CDEBUG(D_INFO, "msg %p buffer[%d] not present (count %d)\n",
287 buflen = m->buflens[n];
288 if (buflen < min_size) {
289 CERROR("msg %p buffer[%d] size %d too small (required %d)\n",
290 m, n, buflen, min_size);
294 offset = HDR_SIZE(bufcount);
295 for (i = 0; i < n; i++)
296 offset += size_round(m->buflens[i]);
298 return (char *)m + offset;
301 char *lustre_msg_string (struct lustre_msg *m, int index, int max_len)
303 /* max_len == 0 means the string should fill the buffer */
304 char *str = lustre_msg_buf (m, index, 0);
309 CERROR ("can't unpack string in msg %p buffer[%d]\n", m, index);
313 blen = m->buflens[index];
314 slen = strnlen (str, blen);
316 if (slen == blen) { /* not NULL terminated */
317 CERROR ("can't unpack non-NULL terminated string in "
318 "msg %p buffer[%d] len %d\n", m, index, blen);
323 if (slen != blen - 1) {
324 CERROR ("can't unpack short string in msg %p "
325 "buffer[%d] len %d: strlen %d\n",
326 m, index, blen, slen);
329 } else if (slen > max_len) {
330 CERROR ("can't unpack oversized string in msg %p "
331 "buffer[%d] len %d strlen %d: max %d expected\n",
332 m, index, blen, slen, max_len);
339 /* Wrap up the normal fixed length cases */
340 void *lustre_swab_buf(struct lustre_msg *msg, int index, int min_size,
345 ptr = lustre_msg_buf(msg, index, min_size);
349 if (swabber != NULL && lustre_msg_swabbed(msg))
350 ((void (*)(void *))swabber)(ptr);
355 void *lustre_swab_reqbuf(struct ptlrpc_request *req, int index, int min_size,
358 LASSERT_REQSWAB(req, index);
359 return lustre_swab_buf(req->rq_reqmsg, index, min_size, swabber);
362 void *lustre_swab_repbuf(struct ptlrpc_request *req, int index, int min_size,
365 LASSERT_REPSWAB(req, index);
366 return lustre_swab_buf(req->rq_repmsg, index, min_size, swabber);
369 /* byte flipping routines for all wire types declared in
370 * lustre_idl.h implemented here.
373 void lustre_swab_obdo (struct obdo *o)
375 __swab64s (&o->o_id);
376 __swab64s (&o->o_gr);
377 __swab64s (&o->o_atime);
378 __swab64s (&o->o_mtime);
379 __swab64s (&o->o_ctime);
380 __swab64s (&o->o_size);
381 __swab64s (&o->o_blocks);
382 __swab64s (&o->o_grant);
383 __swab32s (&o->o_blksize);
384 __swab32s (&o->o_mode);
385 __swab32s (&o->o_uid);
386 __swab32s (&o->o_gid);
387 __swab32s (&o->o_flags);
388 __swab32s (&o->o_nlink);
389 __swab32s (&o->o_generation);
390 __swab64s (&o->o_valid);
391 __swab32s (&o->o_misc);
392 __swab32s (&o->o_easize);
393 __swab32s (&o->o_mds);
394 __swab64s (&o->o_fid);
395 /* o_inline is opaque */
398 /* mdc pack methods used by mdc and smfs*/
399 void *mdc_create_pack(struct lustre_msg *msg, int offset,
400 struct mdc_op_data *op_data, __u32 mode,
401 __u64 rdev, const void *data, int datalen)
403 struct mds_rec_create *rec;
405 rec = lustre_msg_buf(msg, offset, sizeof (*rec));
407 rec->cr_opcode = REINT_CREATE;
408 rec->cr_id = op_data->id1;
409 memset(&rec->cr_replayid, 0, sizeof(rec->cr_replayid));
412 rec->cr_time = op_data->mod_time;
414 tmp = lustre_msg_buf(msg, offset + 1, op_data->namelen + 1);
415 LOGL0(op_data->name, op_data->namelen, tmp);
418 tmp = lustre_msg_buf(msg, offset + 2, datalen);
419 memcpy (tmp, data, datalen);
421 return ((void*)tmp + size_round(datalen));
424 void *mdc_setattr_pack(struct lustre_msg *msg, int offset,
425 struct mdc_op_data *data, struct iattr *iattr,
426 void *ea, int ealen, void *ea2, int ea2len)
428 struct mds_rec_setattr *rec = lustre_msg_buf(msg, offset, sizeof(*rec));
431 rec->sa_opcode = REINT_SETATTR;
432 rec->sa_id = data->id1;
435 rec->sa_valid = iattr->ia_valid;
436 rec->sa_mode = iattr->ia_mode;
437 rec->sa_uid = iattr->ia_uid;
438 rec->sa_gid = iattr->ia_gid;
439 rec->sa_size = iattr->ia_size;
440 rec->sa_atime = LTIME_S(iattr->ia_atime);
441 rec->sa_mtime = LTIME_S(iattr->ia_mtime);
442 rec->sa_ctime = LTIME_S(iattr->ia_ctime);
443 rec->sa_attr_flags = iattr->ia_attr_flags;
445 tmp = (char*)rec + size_round(sizeof(*rec));
450 memcpy(lustre_msg_buf(msg, offset + 1, ealen), ea, ealen);
451 tmp += size_round(ealen);
456 memcpy(lustre_msg_buf(msg, offset + 2, ea2len), ea2, ea2len);
457 tmp += size_round(ea2len);
461 void *mdc_unlink_pack(struct lustre_msg *msg, int offset,
462 struct mdc_op_data *data)
464 struct mds_rec_unlink *rec;
467 rec = lustre_msg_buf(msg, offset, sizeof (*rec));
468 LASSERT (rec != NULL);
470 rec->ul_opcode = REINT_UNLINK;
471 rec->ul_mode = data->create_mode;
472 rec->ul_id1 = data->id1;
473 rec->ul_id2 = data->id2;
474 rec->ul_time = data->mod_time;
476 tmp = lustre_msg_buf(msg, offset + 1, data->namelen + 1);
477 LASSERT (tmp != NULL);
478 LOGL0(data->name, data->namelen, tmp);
482 void *mdc_link_pack(struct lustre_msg *msg, int offset,
483 struct mdc_op_data *data)
485 struct mds_rec_link *rec;
488 rec = lustre_msg_buf(msg, offset, sizeof (*rec));
490 rec->lk_opcode = REINT_LINK;
491 rec->lk_id1 = data->id1;
492 rec->lk_id2 = data->id2;
493 rec->lk_time = data->mod_time;
495 tmp = lustre_msg_buf(msg, offset + 1, data->namelen + 1);
496 LOGL0(data->name, data->namelen, tmp);
501 void *mdc_rename_pack(struct lustre_msg *msg, int offset,
502 struct mdc_op_data *data,
503 const char *old, int oldlen,
504 const char *new, int newlen)
506 struct mds_rec_rename *rec;
509 rec = lustre_msg_buf(msg, offset, sizeof (*rec));
511 /* XXX do something about time, uid, gid */
512 rec->rn_opcode = REINT_RENAME;
513 rec->rn_id1 = data->id1;
514 rec->rn_id2 = data->id2;
515 rec->rn_time = data->mod_time;
517 tmp = lustre_msg_buf(msg, offset + 1, oldlen + 1);
518 LOGL0(old, oldlen, tmp);
521 tmp = lustre_msg_buf(msg, offset + 2, newlen + 1);
522 LOGL0(new, newlen, tmp);
527 void lustre_swab_obd_statfs (struct obd_statfs *os)
529 __swab64s (&os->os_type);
530 __swab64s (&os->os_blocks);
531 __swab64s (&os->os_bfree);
532 __swab64s (&os->os_bavail);
533 __swab64s (&os->os_ffree);
534 /* no need to swap os_fsid */
535 __swab32s (&os->os_bsize);
536 __swab32s (&os->os_namelen);
537 /* no need to swap os_spare */
540 void lustre_swab_obd_ioobj (struct obd_ioobj *ioo)
542 __swab64s (&ioo->ioo_id);
543 __swab64s (&ioo->ioo_gr);
544 __swab32s (&ioo->ioo_type);
545 __swab32s (&ioo->ioo_bufcnt);
548 void lustre_swab_niobuf_remote (struct niobuf_remote *nbr)
550 __swab64s (&nbr->offset);
551 __swab32s (&nbr->len);
552 __swab32s (&nbr->flags);
555 void lustre_swab_ost_body (struct ost_body *b)
557 lustre_swab_obdo (&b->oa);
560 void lustre_swab_ost_last_id(obd_id *id)
565 void lustre_swab_generic_32s(__u32 *val)
570 void lustre_swab_ost_lvb(struct ost_lvb *lvb)
572 __swab64s(&lvb->lvb_size);
573 __swab64s(&lvb->lvb_mtime);
574 __swab64s(&lvb->lvb_atime);
575 __swab64s(&lvb->lvb_ctime);
576 __swab64s(&lvb->lvb_blocks);
579 void lustre_swab_lustre_stc (struct lustre_stc *stc)
581 __swab64s (&stc->u.e3s.l3s_ino);
582 __swab32s (&stc->u.e3s.l3s_gen);
583 __swab32s (&stc->u.e3s.l3s_type);
586 void lustre_swab_lustre_fid(struct lustre_fid *fid)
588 __swab64s (&fid->lf_id);
589 __swab64s (&fid->lf_group);
590 __swab32s (&fid->lf_version);
593 void lustre_swab_lustre_id (struct lustre_id *id)
595 lustre_swab_lustre_stc(&id->li_stc);
596 lustre_swab_lustre_fid(&id->li_fid);
599 void lustre_swab_mds_status_req (struct mds_status_req *r)
601 __swab32s (&r->flags);
602 __swab32s (&r->repbuf);
606 * because sec_desc is variable buffer, we must check it by hand
608 struct mds_req_sec_desc *lustre_swab_mds_secdesc(struct ptlrpc_request *req,
611 struct mds_req_sec_desc *rsd;
612 struct lustre_msg *m;
615 LASSERT_REQSWAB(req, offset);
618 rsd = lustre_msg_buf(m, offset, sizeof(*rsd));
622 if (lustre_msg_swabbed(m)) {
623 __swab32s(&rsd->rsd_uid);
624 __swab32s(&rsd->rsd_gid);
625 __swab32s(&rsd->rsd_fsuid);
626 __swab32s(&rsd->rsd_fsgid);
627 __swab32s(&rsd->rsd_cap);
628 __swab32s(&rsd->rsd_ngroups);
631 if (rsd->rsd_ngroups > LUSTRE_MAX_GROUPS) {
632 CERROR("%u groups is not allowed\n", rsd->rsd_ngroups);
636 if (m->buflens[offset] !=
637 sizeof(*rsd) + rsd->rsd_ngroups * sizeof(__u32)) {
638 CERROR("bufflen %u while contains %u groups\n",
639 m->buflens[offset], rsd->rsd_ngroups);
643 if (lustre_msg_swabbed(m)) {
644 for (i = 0; i < rsd->rsd_ngroups; i++)
645 __swab32s(&rsd->rsd_groups[i]);
651 void lustre_swab_mds_body (struct mds_body *b)
653 lustre_swab_lustre_id (&b->id1);
654 lustre_swab_lustre_id (&b->id2);
655 /* handle is opaque */
656 __swab64s (&b->size);
657 __swab64s (&b->blocks);
658 __swab64s (&b->valid);
659 __swab32s (&b->mode);
662 __swab32s (&b->mtime);
663 __swab32s (&b->ctime);
664 __swab32s (&b->atime);
665 __swab32s (&b->flags);
666 __swab32s (&b->rdev);
667 __swab32s (&b->nlink);
668 __swab32s (&b->eadatasize);
670 void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa)
672 __swab32s (&sa->sa_opcode);
673 __swab32s (&sa->sa_valid);
674 lustre_swab_lustre_id (&sa->sa_id);
675 __swab32s (&sa->sa_mode);
676 __swab32s (&sa->sa_uid);
677 __swab32s (&sa->sa_gid);
678 __swab32s (&sa->sa_attr_flags);
679 __swab64s (&sa->sa_size);
680 __swab64s (&sa->sa_atime);
681 __swab64s (&sa->sa_mtime);
682 __swab64s (&sa->sa_ctime);
685 void lustre_swab_mds_rec_create (struct mds_rec_create *cr)
687 __swab32s (&cr->cr_opcode);
688 __swab32s (&cr->cr_flags); /* for use with open */
689 __swab32s (&cr->cr_mode);
690 lustre_swab_lustre_id (&cr->cr_id);
691 lustre_swab_lustre_id (&cr->cr_replayid);
692 __swab64s (&cr->cr_time);
693 __swab64s (&cr->cr_rdev);
696 void lustre_swab_mds_rec_link (struct mds_rec_link *lk)
698 __swab32s (&lk->lk_opcode);
699 lustre_swab_lustre_id (&lk->lk_id1);
700 lustre_swab_lustre_id (&lk->lk_id2);
703 void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul)
705 __swab32s (&ul->ul_opcode);
706 __swab32s (&ul->ul_mode);
707 lustre_swab_lustre_id (&ul->ul_id1);
708 lustre_swab_lustre_id (&ul->ul_id2);
711 void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn)
713 __swab32s (&rn->rn_opcode);
714 lustre_swab_lustre_id (&rn->rn_id1);
715 lustre_swab_lustre_id (&rn->rn_id2);
718 void lustre_swab_lov_desc (struct lov_desc *ld)
720 __swab32s (&ld->ld_tgt_count);
721 __swab32s (&ld->ld_active_tgt_count);
722 __swab32s (&ld->ld_default_stripe_count);
723 __swab64s (&ld->ld_default_stripe_size);
724 __swab64s (&ld->ld_default_stripe_offset);
725 __swab32s (&ld->ld_pattern);
726 /* uuid endian insensitive */
729 void lustre_swab_ldlm_res_id (struct ldlm_res_id *id)
733 for (i = 0; i < RES_NAME_SIZE; i++)
734 __swab64s (&id->name[i]);
737 void lustre_swab_ldlm_policy_data (ldlm_policy_data_t *d)
739 /* the lock data is a union and the first three fields of both EXTENT
740 * and FLOCK types are __u64, so it's ok to swab them in the same way */
741 __swab64s (&d->l_flock.start);
742 __swab64s (&d->l_flock.end);
743 __swab64s (&d->l_flock.pid);
744 __swab64s (&d->l_flock.blocking_pid);
747 void lustre_swab_ldlm_intent (struct ldlm_intent *i)
752 void lustre_swab_ldlm_resource_desc (struct ldlm_resource_desc *r)
754 __swab32s (&r->lr_type);
755 lustre_swab_ldlm_res_id (&r->lr_name);
758 void lustre_swab_ldlm_lock_desc (struct ldlm_lock_desc *l)
760 lustre_swab_ldlm_resource_desc (&l->l_resource);
761 __swab32s (&l->l_req_mode);
762 __swab32s (&l->l_granted_mode);
763 lustre_swab_ldlm_policy_data (&l->l_policy_data);
766 void lustre_swab_ldlm_request (struct ldlm_request *rq)
768 __swab32s (&rq->lock_flags);
769 lustre_swab_ldlm_lock_desc (&rq->lock_desc);
770 /* lock_handle1 opaque */
771 /* lock_handle2 opaque */
774 void lustre_swab_ldlm_reply (struct ldlm_reply *r)
776 __swab32s (&r->lock_flags);
777 lustre_swab_ldlm_lock_desc (&r->lock_desc);
778 /* lock_handle opaque */
779 __swab64s (&r->lock_policy_res1);
780 __swab64s (&r->lock_policy_res2);
783 void lustre_swab_ptlbd_op (struct ptlbd_op *op)
785 __swab16s (&op->op_cmd);
786 __swab16s (&op->op_lun);
787 __swab16s (&op->op_niob_cnt);
788 /* ignore op__padding */
789 __swab32s (&op->op_block_cnt);
792 void lustre_swab_ptlbd_niob (struct ptlbd_niob *n)
794 __swab64s (&n->n_xid);
795 __swab64s (&n->n_block_nr);
796 __swab32s (&n->n_offset);
797 __swab32s (&n->n_length);
800 void lustre_swab_ptlbd_rsp (struct ptlbd_rsp *r)
802 __swab16s (&r->r_status);
803 __swab16s (&r->r_error_cnt);
806 /* no one calls this */
807 int llog_log_swabbed(struct llog_log_hdr *hdr)
809 if (hdr->llh_hdr.lrh_type == __swab32(LLOG_HDR_MAGIC))
811 if (hdr->llh_hdr.lrh_type == LLOG_HDR_MAGIC)
816 void lustre_swab_llogd_body (struct llogd_body *d)
818 __swab64s (&d->lgd_logid.lgl_oid);
819 __swab64s (&d->lgd_logid.lgl_ogr);
820 __swab32s (&d->lgd_logid.lgl_ogen);
821 __swab32s (&d->lgd_ctxt_idx);
822 __swab32s (&d->lgd_llh_flags);
823 __swab32s (&d->lgd_index);
824 __swab32s (&d->lgd_saved_index);
825 __swab32s (&d->lgd_len);
826 __swab64s (&d->lgd_cur_offset);
829 void lustre_swab_llog_hdr (struct llog_log_hdr *h)
831 __swab32s (&h->llh_hdr.lrh_index);
832 __swab32s (&h->llh_hdr.lrh_len);
833 __swab32s (&h->llh_hdr.lrh_type);
834 __swab64s (&h->llh_timestamp);
835 __swab32s (&h->llh_count);
836 __swab32s (&h->llh_bitmap_offset);
837 __swab32s (&h->llh_flags);
838 __swab32s (&h->llh_tail.lrt_index);
839 __swab32s (&h->llh_tail.lrt_len);
842 void lustre_swab_llogd_conn_body (struct llogd_conn_body *d)
844 __swab64s (&d->lgdc_gen.mnt_cnt);
845 __swab64s (&d->lgdc_gen.conn_cnt);
846 __swab64s (&d->lgdc_logid.lgl_oid);
847 __swab64s (&d->lgdc_logid.lgl_ogr);
848 __swab32s (&d->lgdc_logid.lgl_ogen);
849 __swab32s (&d->lgdc_ctxt_idx);
852 void lustre_assert_wire_constants(void)