Whamcloud - gitweb
- tagging RC_CURRENT
[fs/lustre-release.git] / lustre / ptlrpc / pack_generic.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
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>
8  *
9  *   This file is part of Lustre, http://www.lustre.org.
10  *
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.
14  *
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.
19  *
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.
23  *
24  * (Un)packing of OST requests
25  *
26  */
27
28 #define DEBUG_SUBSYSTEM S_RPC
29 #ifndef __KERNEL__
30 #include <liblustre.h>
31 #endif
32
33 #include <linux/obd_support.h>
34 #include <linux/obd_class.h>
35 #include <linux/lustre_net.h>
36
37
38 #define HDR_SIZE(count) \
39     size_round(offsetof (struct lustre_msg, buflens[(count)]))
40
41 int lustre_msg_swabbed(struct lustre_msg *msg)
42 {
43         return (msg->magic == __swab32(PTLRPC_MSG_MAGIC));
44 }
45
46 static void
47 lustre_init_msg (struct lustre_msg *msg, int count, int *lens, char **bufs)
48 {
49         char *ptr;
50         int   i;
51         
52         msg->magic = PTLRPC_MSG_MAGIC;
53         msg->version = PTLRPC_MSG_VERSION;
54         msg->bufcount = count;
55         for (i = 0; i < count; i++)
56                 msg->buflens[i] = lens[i];
57
58         if (bufs == NULL)
59                 return;
60
61         ptr = (char *)msg + HDR_SIZE(count);
62         for (i = 0; i < count; i++) {
63                 char *tmp = bufs[i];
64                 LOGL(tmp, lens[i], ptr);
65         }
66 }
67
68 int lustre_pack_request (struct ptlrpc_request *req, 
69                          int count, int *lens, char **bufs)
70 {
71         ENTRY;
72         
73         req->rq_reqlen = lustre_msg_size (count, lens);
74         OBD_ALLOC(req->rq_reqmsg, req->rq_reqlen);
75         if (req->rq_reqmsg == NULL)
76                 RETURN(-ENOMEM);
77
78         lustre_init_msg (req->rq_reqmsg, count, lens, bufs);
79         RETURN (0);
80 }
81
82 #if RS_DEBUG
83 LIST_HEAD(ptlrpc_rs_debug_lru);
84 spinlock_t ptlrpc_rs_debug_lock = SPIN_LOCK_UNLOCKED;
85
86 #define PTLRPC_RS_DEBUG_LRU_ADD(rs)                                     \
87 do {                                                                    \
88         unsigned long __flags;                                          \
89                                                                         \
90         spin_lock_irqsave(&ptlrpc_rs_debug_lock, __flags);              \
91         list_add_tail(&(rs)->rs_debug_list, &ptlrpc_rs_debug_lru);      \
92         spin_unlock_irqrestore(&ptlrpc_rs_debug_lock, __flags);         \
93 } while (0)
94
95 #define PTLRPC_RS_DEBUG_LRU_DEL(rs)                                     \
96 do {                                                                    \
97         unsigned long __flags;                                          \
98                                                                         \
99         spin_lock_irqsave(&ptlrpc_rs_debug_lock, __flags);              \
100         list_del(&(rs)->rs_debug_list);                                 \
101         spin_unlock_irqrestore(&ptlrpc_rs_debug_lock, __flags);         \
102 } while (0)
103 #else
104 # define PTLRPC_RS_DEBUG_LRU_ADD(rs) do {} while(0)
105 # define PTLRPC_RS_DEBUG_LRU_DEL(rs) do {} while(0)
106 #endif
107
108 int lustre_pack_reply (struct ptlrpc_request *req,
109                        int count, int *lens, char **bufs)
110 {
111         struct ptlrpc_reply_state *rs;
112         int                        msg_len;
113         int                        size;
114         ENTRY;
115
116         LASSERT (req->rq_reply_state == NULL);
117
118         msg_len = lustre_msg_size (count, lens);
119         size = offsetof (struct ptlrpc_reply_state, rs_msg) + msg_len;
120         OBD_ALLOC (rs, size);
121         if (rs == NULL)
122                 RETURN (-ENOMEM);
123
124         rs->rs_cb_id.cbid_fn = reply_out_callback;
125         rs->rs_cb_id.cbid_arg = rs;
126         rs->rs_srv_ni = req->rq_rqbd->rqbd_srv_ni;
127         rs->rs_size = size;
128         INIT_LIST_HEAD(&rs->rs_exp_list);
129         INIT_LIST_HEAD(&rs->rs_obd_list);
130
131         req->rq_replen = msg_len;
132         req->rq_reply_state = rs;
133         req->rq_repmsg = &rs->rs_msg;
134         lustre_init_msg (&rs->rs_msg, count, lens, bufs);
135
136         PTLRPC_RS_DEBUG_LRU_ADD(rs);
137
138         RETURN (0);
139 }
140
141 void lustre_free_reply_state (struct ptlrpc_reply_state *rs)
142 {
143         PTLRPC_RS_DEBUG_LRU_DEL(rs);
144
145         LASSERT (!rs->rs_difficult || rs->rs_handled);
146         LASSERT (!rs->rs_on_net);
147         LASSERT (!rs->rs_scheduled);
148         LASSERT (rs->rs_export == NULL);
149         LASSERT (rs->rs_nlocks == 0);
150         LASSERT (list_empty(&rs->rs_exp_list));
151         LASSERT (list_empty(&rs->rs_obd_list));
152
153         OBD_FREE (rs, rs->rs_size);
154 }
155
156 /* This returns the size of the buffer that is required to hold a lustre_msg
157  * with the given sub-buffer lengths. */
158 int lustre_msg_size(int count, int *lengths)
159 {
160         int size;
161         int i;
162
163         size = HDR_SIZE (count);
164         for (i = 0; i < count; i++)
165                 size += size_round(lengths[i]);
166
167         return size;
168 }
169
170 int lustre_unpack_msg(struct lustre_msg *m, int len)
171 {
172         int   flipped;
173         int   required_len;
174         int   i;
175         ENTRY;
176
177         /* We can provide a slightly better error log, if we check the
178          * message magic and version first.  In the future, struct
179          * lustre_msg may grow, and we'd like to log a version mismatch,
180          * rather than a short message.
181          *
182          */
183         required_len = MAX (offsetof (struct lustre_msg, version) +
184                             sizeof (m->version),
185                             offsetof (struct lustre_msg, magic) +
186                             sizeof (m->magic));
187         if (len < required_len) {
188                 /* can't even look inside the message */
189                 CERROR ("message length %d too small for magic/version check\n",
190                         len);
191                 RETURN (-EINVAL);
192         }
193
194         flipped = lustre_msg_swabbed(m);
195         if (flipped)
196                 __swab32s (&m->version);
197         else if (m->magic != PTLRPC_MSG_MAGIC) {
198                 CERROR("wrong lustre_msg magic %#08x\n", m->magic);
199                 RETURN (-EINVAL);
200         }
201
202         if (m->version != PTLRPC_MSG_VERSION) {
203                 CERROR("wrong lustre_msg version %#08x\n", m->version);
204                 RETURN (-EINVAL);
205         }
206
207         /* Now we know the sender speaks my language (but possibly flipped)...*/
208         required_len = HDR_SIZE(0);
209         if (len < required_len) {
210                 /* can't even look inside the message */
211                 CERROR ("message length %d too small for lustre_msg\n", len);
212                 RETURN (-EINVAL);
213         }
214
215         if (flipped) {
216                 __swab32s (&m->type);
217                 __swab32s (&m->opc);
218                 __swab64s (&m->last_xid);
219                 __swab64s (&m->last_committed);
220                 __swab64s (&m->transno);
221                 __swab32s (&m->status);
222                 __swab32s (&m->bufcount);
223                 __swab32s (&m->flags);
224         }
225
226         required_len = HDR_SIZE(m->bufcount);
227
228         if (len < required_len) {
229                 /* didn't receive all the buffer lengths */
230                 CERROR ("message length %d too small for %d buflens\n",
231                         len, m->bufcount);
232                 RETURN(-EINVAL);
233         }
234
235         for (i = 0; i < m->bufcount; i++) {
236                 if (flipped)
237                         __swab32s (&m->buflens[i]);
238                 required_len += size_round(m->buflens[i]);
239         }
240
241         if (len < required_len) {
242                 CERROR("len: %d, required_len %d\n", len, required_len);
243                 CERROR("bufcount: %d\n", m->bufcount);
244                 for (i = 0; i < m->bufcount; i++)
245                         CERROR("buffer %d length %d\n", i, m->buflens[i]);
246                 RETURN(-EINVAL);
247         }
248
249         RETURN(0);
250 }
251
252 void *lustre_msg_buf(struct lustre_msg *m, int n, int min_size)
253 {
254         int i;
255         int offset;
256         int buflen;
257         int bufcount;
258
259         LASSERT (m != NULL);
260         LASSERT (n >= 0);
261
262         bufcount = m->bufcount;
263         if (n >= bufcount) {
264                 CDEBUG(D_INFO, "msg %p buffer[%d] not present (count %d)\n",
265                        m, n, bufcount);
266                 return NULL;
267         }
268
269         buflen = m->buflens[n];
270         if (buflen < min_size) {
271                 CERROR("msg %p buffer[%d] size %d too small (required %d)\n",
272                        m, n, buflen, min_size);
273                 return NULL;
274         }
275
276         offset = HDR_SIZE(bufcount);
277         for (i = 0; i < n; i++)
278                 offset += size_round(m->buflens[i]);
279
280         return (char *)m + offset;
281 }
282
283 char *lustre_msg_string (struct lustre_msg *m, int index, int max_len)
284 {
285         /* max_len == 0 means the string should fill the buffer */
286         char *str = lustre_msg_buf (m, index, 0);
287         int   slen;
288         int   blen;
289
290         if (str == NULL) {
291                 CERROR ("can't unpack string in msg %p buffer[%d]\n", m, index);
292                 return (NULL);
293         }
294
295         blen = m->buflens[index];
296         slen = strnlen (str, blen);
297
298         if (slen == blen) {                     /* not NULL terminated */
299                 CERROR ("can't unpack non-NULL terminated string in "
300                         "msg %p buffer[%d] len %d\n", m, index, blen);
301                 return (NULL);
302         }
303
304         if (max_len == 0) {
305                 if (slen != blen - 1) {
306                         CERROR ("can't unpack short string in msg %p "
307                                 "buffer[%d] len %d: strlen %d\n",
308                                 m, index, blen, slen);
309                         return (NULL);
310                 }
311         } else if (slen > max_len) {
312                 CERROR ("can't unpack oversized string in msg %p "
313                         "buffer[%d] len %d strlen %d: max %d expected\n",
314                         m, index, blen, slen, max_len);
315                 return (NULL);
316         }
317
318         return (str);
319 }
320
321 /* Wrap up the normal fixed length cases */
322 void *lustre_swab_buf(struct lustre_msg *msg, int index, int min_size,
323                       void *swabber)
324 {
325         void *ptr;
326
327         ptr = lustre_msg_buf(msg, index, min_size);
328         if (ptr == NULL)
329                 return NULL;
330
331         if (swabber != NULL && lustre_msg_swabbed(msg))
332                 ((void (*)(void *))swabber)(ptr);
333
334         return ptr;
335 }
336
337 void *lustre_swab_reqbuf(struct ptlrpc_request *req, int index, int min_size,
338                          void *swabber)
339 {
340         LASSERT_REQSWAB(req, index);
341         return lustre_swab_buf(req->rq_reqmsg, index, min_size, swabber);
342 }
343
344 void *lustre_swab_repbuf(struct ptlrpc_request *req, int index, int min_size,
345                          void *swabber)
346 {
347         LASSERT_REPSWAB(req, index);
348         return lustre_swab_buf(req->rq_repmsg, index, min_size, swabber);
349 }
350
351 /* byte flipping routines for all wire types declared in
352  * lustre_idl.h implemented here.
353  */
354
355 void lustre_swab_obdo (struct obdo  *o)
356 {
357         __swab64s (&o->o_id);
358         __swab64s (&o->o_gr);
359         __swab64s (&o->o_atime);
360         __swab64s (&o->o_mtime);
361         __swab64s (&o->o_ctime);
362         __swab64s (&o->o_size);
363         __swab64s (&o->o_blocks);
364         __swab64s (&o->o_grant);
365         __swab32s (&o->o_blksize);
366         __swab32s (&o->o_mode);
367         __swab32s (&o->o_uid);
368         __swab32s (&o->o_gid);
369         __swab32s (&o->o_flags);
370         __swab32s (&o->o_nlink);
371         __swab32s (&o->o_generation);
372         __swab32s (&o->o_valid);
373         __swab32s (&o->o_misc);
374         __swab32s (&o->o_easize);
375         /* o_inline is opaque */
376 }
377
378 void lustre_swab_obd_statfs (struct obd_statfs *os)
379 {
380         __swab64s (&os->os_type);
381         __swab64s (&os->os_blocks);
382         __swab64s (&os->os_bfree);
383         __swab64s (&os->os_bavail);
384         __swab64s (&os->os_ffree);
385         /* no need to swap os_fsid */
386         __swab32s (&os->os_bsize);
387         __swab32s (&os->os_namelen);
388         /* no need to swap os_spare */
389 }
390
391 void lustre_swab_obd_ioobj (struct obd_ioobj *ioo)
392 {
393         __swab64s (&ioo->ioo_id);
394         __swab64s (&ioo->ioo_gr);
395         __swab32s (&ioo->ioo_type);
396         __swab32s (&ioo->ioo_bufcnt);
397 }
398
399 void lustre_swab_niobuf_remote (struct niobuf_remote *nbr)
400 {
401         __swab64s (&nbr->offset);
402         __swab32s (&nbr->len);
403         __swab32s (&nbr->flags);
404 }
405
406 void lustre_swab_ost_body (struct ost_body *b)
407 {
408         lustre_swab_obdo (&b->oa);
409 }
410
411 void lustre_swab_ost_last_id(obd_id *id)
412 {
413         __swab64s(id);
414 }
415
416 void lustre_swab_ost_lvb(struct ost_lvb *lvb)
417 {
418         __swab64s(&lvb->lvb_size);
419         __swab64s(&lvb->lvb_time);
420 }
421
422 void lustre_swab_ll_fid (struct ll_fid *fid)
423 {
424         __swab64s (&fid->id);
425         __swab32s (&fid->generation);
426         __swab32s (&fid->f_type);
427 }
428
429 void lustre_swab_mds_status_req (struct mds_status_req *r)
430 {
431         __swab32s (&r->flags);
432         __swab32s (&r->repbuf);
433 }
434
435 void lustre_swab_mds_body (struct mds_body *b)
436 {
437         lustre_swab_ll_fid (&b->fid1);
438         lustre_swab_ll_fid (&b->fid2);
439         /* handle is opaque */
440         __swab64s (&b->size);
441         __swab64s (&b->blocks);
442         __swab32s (&b->ino);
443         __swab32s (&b->valid);
444         __swab32s (&b->fsuid);
445         __swab32s (&b->fsgid);
446         __swab32s (&b->capability);
447         __swab32s (&b->mode);
448         __swab32s (&b->uid);
449         __swab32s (&b->gid);
450         __swab32s (&b->mtime);
451         __swab32s (&b->ctime);
452         __swab32s (&b->atime);
453         __swab32s (&b->flags);
454         __swab32s (&b->rdev);
455         __swab32s (&b->nlink);
456         __swab32s (&b->generation);
457         __swab32s (&b->suppgid);
458         __swab32s (&b->eadatasize);
459 }
460
461 void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa)
462 {
463         __swab32s (&sa->sa_opcode);
464         __swab32s (&sa->sa_fsuid);
465         __swab32s (&sa->sa_fsgid);
466         __swab32s (&sa->sa_cap);
467         __swab32s (&sa->sa_suppgid);
468         __swab32s (&sa->sa_valid);
469         lustre_swab_ll_fid (&sa->sa_fid);
470         __swab32s (&sa->sa_mode);
471         __swab32s (&sa->sa_uid);
472         __swab32s (&sa->sa_gid);
473         __swab32s (&sa->sa_attr_flags);
474         __swab64s (&sa->sa_size);
475         __swab64s (&sa->sa_atime);
476         __swab64s (&sa->sa_mtime);
477         __swab64s (&sa->sa_ctime);
478 }
479
480 void lustre_swab_mds_rec_create (struct mds_rec_create *cr)
481 {
482         __swab32s (&cr->cr_opcode);
483         __swab32s (&cr->cr_fsuid);
484         __swab32s (&cr->cr_fsgid);
485         __swab32s (&cr->cr_cap);
486         __swab32s (&cr->cr_flags); /* for use with open */
487         __swab32s (&cr->cr_mode);
488         lustre_swab_ll_fid (&cr->cr_fid);
489         lustre_swab_ll_fid (&cr->cr_replayfid);
490         __swab64s (&cr->cr_time);
491         __swab64s (&cr->cr_rdev);
492         __swab32s (&cr->cr_suppgid);
493 }
494
495 void lustre_swab_mds_rec_link (struct mds_rec_link *lk)
496 {
497         __swab32s (&lk->lk_opcode);
498         __swab32s (&lk->lk_fsuid);
499         __swab32s (&lk->lk_fsgid);
500         __swab32s (&lk->lk_cap);
501         __swab32s (&lk->lk_suppgid1);
502         __swab32s (&lk->lk_suppgid2);
503         lustre_swab_ll_fid (&lk->lk_fid1);
504         lustre_swab_ll_fid (&lk->lk_fid2);
505 }
506
507 void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul)
508 {
509         __swab32s (&ul->ul_opcode);
510         __swab32s (&ul->ul_fsuid);
511         __swab32s (&ul->ul_fsgid);
512         __swab32s (&ul->ul_cap);
513         __swab32s (&ul->ul_suppgid);
514         __swab32s (&ul->ul_mode);
515         lustre_swab_ll_fid (&ul->ul_fid1);
516         lustre_swab_ll_fid (&ul->ul_fid2);
517 }
518
519 void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn)
520 {
521         __swab32s (&rn->rn_opcode);
522         __swab32s (&rn->rn_fsuid);
523         __swab32s (&rn->rn_fsgid);
524         __swab32s (&rn->rn_cap);
525         __swab32s (&rn->rn_suppgid1);
526         __swab32s (&rn->rn_suppgid2);
527         lustre_swab_ll_fid (&rn->rn_fid1);
528         lustre_swab_ll_fid (&rn->rn_fid2);
529 }
530
531 void lustre_swab_lov_desc (struct lov_desc *ld)
532 {
533         __swab32s (&ld->ld_tgt_count);
534         __swab32s (&ld->ld_active_tgt_count);
535         __swab32s (&ld->ld_default_stripe_count);
536         __swab64s (&ld->ld_default_stripe_size);
537         __swab64s (&ld->ld_default_stripe_offset);
538         __swab32s (&ld->ld_pattern);
539         /* uuid endian insensitive */
540 }
541
542 void lustre_swab_ldlm_res_id (struct ldlm_res_id *id)
543 {
544         int  i;
545
546         for (i = 0; i < RES_NAME_SIZE; i++)
547                 __swab64s (&id->name[i]);
548 }
549
550 void lustre_swab_ldlm_policy_data (ldlm_policy_data_t *d)
551 {
552         /* the lock data is a union and the first two fields are always an
553          * extent so it's ok to process an LDLM_EXTENT and LDLM_FLOCK lock
554          * data the same way. */
555         __swab64s (&d->l_flock.start);
556         __swab64s (&d->l_flock.end);
557         __swab32s (&d->l_flock.pid);
558 }
559
560 void lustre_swab_ldlm_intent (struct ldlm_intent *i)
561 {
562         __swab64s (&i->opc);
563 }
564
565 void lustre_swab_ldlm_resource_desc (struct ldlm_resource_desc *r)
566 {
567         __swab32s (&r->lr_type);
568         lustre_swab_ldlm_res_id (&r->lr_name);
569 }
570
571 void lustre_swab_ldlm_lock_desc (struct ldlm_lock_desc *l)
572 {
573         lustre_swab_ldlm_resource_desc (&l->l_resource);
574         __swab32s (&l->l_req_mode);
575         __swab32s (&l->l_granted_mode);
576         lustre_swab_ldlm_policy_data (&l->l_policy_data);
577 }
578
579 void lustre_swab_ldlm_request (struct ldlm_request *rq)
580 {
581         __swab32s (&rq->lock_flags);
582         lustre_swab_ldlm_lock_desc (&rq->lock_desc);
583         /* lock_handle1 opaque */
584         /* lock_handle2 opaque */
585 }
586
587 void lustre_swab_ldlm_reply (struct ldlm_reply *r)
588 {
589         __swab32s (&r->lock_flags);
590         lustre_swab_ldlm_lock_desc (&r->lock_desc);
591         /* lock_handle opaque */
592         __swab64s (&r->lock_policy_res1);
593         __swab64s (&r->lock_policy_res2);
594 }
595
596 void lustre_swab_ptlbd_op (struct ptlbd_op *op)
597 {
598         __swab16s (&op->op_cmd);
599         __swab16s (&op->op_lun);
600         __swab16s (&op->op_niob_cnt);
601         /* ignore op__padding */
602         __swab32s (&op->op_block_cnt);
603 }
604
605 void lustre_swab_ptlbd_niob (struct ptlbd_niob *n)
606 {
607         __swab64s (&n->n_xid);
608         __swab64s (&n->n_block_nr);
609         __swab32s (&n->n_offset);
610         __swab32s (&n->n_length);
611 }
612
613 void lustre_swab_ptlbd_rsp (struct ptlbd_rsp *r)
614 {
615         __swab16s (&r->r_status);
616         __swab16s (&r->r_error_cnt);
617 }
618
619 /* no one calls this */
620 int llog_log_swabbed(struct llog_log_hdr *hdr)
621 {
622         if (hdr->llh_hdr.lrh_type == __swab32(LLOG_HDR_MAGIC))
623                 return 1;
624         if (hdr->llh_hdr.lrh_type == LLOG_HDR_MAGIC)
625                 return 0;
626         return -1;
627 }
628
629 void lustre_swab_llogd_body (struct llogd_body *d)
630 {
631         __swab64s (&d->lgd_logid.lgl_oid);
632         __swab64s (&d->lgd_logid.lgl_ogr);
633         __swab32s (&d->lgd_logid.lgl_ogen);
634         __swab32s (&d->lgd_ctxt_idx);
635         __swab32s (&d->lgd_llh_flags);
636         __swab32s (&d->lgd_index);
637         __swab32s (&d->lgd_saved_index);
638         __swab32s (&d->lgd_len);
639         __swab64s (&d->lgd_cur_offset);
640 }
641
642 void lustre_swab_llog_hdr (struct llog_log_hdr *h)
643 {
644         __swab32s (&h->llh_hdr.lrh_index);
645         __swab32s (&h->llh_hdr.lrh_len);
646         __swab32s (&h->llh_hdr.lrh_type);
647         __swab64s (&h->llh_timestamp);
648         __swab32s (&h->llh_count);
649         __swab32s (&h->llh_bitmap_offset);
650         __swab32s (&h->llh_flags);
651         __swab32s (&h->llh_tail.lrt_index);
652         __swab32s (&h->llh_tail.lrt_len);
653 }
654
655 void lustre_swab_llogd_conn_body (struct llogd_conn_body *d)
656 {
657         __swab64s (&d->lgdc_gen.mnt_cnt);
658         __swab64s (&d->lgdc_gen.conn_cnt);
659         __swab64s (&d->lgdc_logid.lgl_oid);
660         __swab64s (&d->lgdc_logid.lgl_ogr);
661         __swab32s (&d->lgdc_logid.lgl_ogen);
662         __swab32s (&d->lgdc_ctxt_idx);
663 }
664
665 #ifdef BUG_1343
666 void lustre_assert_wire_constants(void)
667 {
668         /* Wire protocol assertions generated by 'wirecheck'
669          * running on Linux schnapps.adilger.int 2.4.22-l32 #4 Thu Jan 8 14:32:57 MST 2004 i686 i686 
670          * with gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5) */
671
672
673         /* Constants... */
674         LASSERT(PTLRPC_MSG_MAGIC == 0x0BD00BD0);
675         LASSERT(PTLRPC_MSG_VERSION == 0x00000003);
676         LASSERT(PTL_RPC_MSG_REQUEST == 4711);
677         LASSERT(PTL_RPC_MSG_ERR == 4712);
678         LASSERT(PTL_RPC_MSG_REPLY == 4713);
679         LASSERT(MSG_LAST_REPLAY == 1);
680         LASSERT(MSG_RESENT == 2);
681         LASSERT(MSG_REPLAY == 4);
682         LASSERT(MSG_CONNECT_RECOVERING == 1);
683         LASSERT(MSG_CONNECT_RECONNECT == 2);
684         LASSERT(MSG_CONNECT_REPLAYABLE == 4);
685         LASSERT(OST_REPLY == 0);
686         LASSERT(OST_GETATTR == 1);
687         LASSERT(OST_SETATTR == 2);
688         LASSERT(OST_READ == 3);
689         LASSERT(OST_WRITE == 4);
690         LASSERT(OST_CREATE == 5);
691         LASSERT(OST_DESTROY == 6);
692         LASSERT(OST_GET_INFO == 7);
693         LASSERT(OST_CONNECT == 8);
694         LASSERT(OST_DISCONNECT == 9);
695         LASSERT(OST_PUNCH == 10);
696         LASSERT(OST_OPEN == 11);
697         LASSERT(OST_CLOSE == 12);
698         LASSERT(OST_STATFS == 13);
699         LASSERT(OST_SAN_READ == 14);
700         LASSERT(OST_SAN_WRITE == 15);
701         LASSERT(OST_SYNC == 16);
702         LASSERT(OST_LAST_OPC == 18);
703         LASSERT(OBD_OBJECT_EOF == 0xffffffffffffffffULL);
704         LASSERT(OST_REQ_HAS_OA1 == 1);
705         LASSERT(MDS_GETATTR == 33);
706         LASSERT(MDS_GETATTR_NAME == 34);
707         LASSERT(MDS_CLOSE == 35);
708         LASSERT(MDS_REINT == 36);
709         LASSERT(MDS_READPAGE == 37);
710         LASSERT(MDS_CONNECT == 38);
711         LASSERT(MDS_DISCONNECT == 39);
712         LASSERT(MDS_GETSTATUS == 40);
713         LASSERT(MDS_STATFS == 41);
714         LASSERT(MDS_PIN == 42);
715         LASSERT(MDS_UNPIN == 43);
716         LASSERT(MDS_SYNC == 44);
717         LASSERT(MDS_DONE_WRITING == 45);
718         LASSERT(MDS_LAST_OPC == 46);
719         LASSERT(REINT_SETATTR == 1);
720         LASSERT(REINT_CREATE == 2);
721         LASSERT(REINT_LINK == 3);
722         LASSERT(REINT_UNLINK == 4);
723         LASSERT(REINT_RENAME == 5);
724         LASSERT(REINT_OPEN == 6);
725         LASSERT(REINT_MAX == 6);
726         LASSERT(DISP_IT_EXECD == 1);
727         LASSERT(DISP_LOOKUP_EXECD == 2);
728         LASSERT(DISP_LOOKUP_NEG == 4);
729         LASSERT(DISP_LOOKUP_POS == 8);
730         LASSERT(DISP_OPEN_CREATE == 16);
731         LASSERT(DISP_OPEN_OPEN == 32);
732         LASSERT(MDS_STATUS_CONN == 1);
733         LASSERT(MDS_STATUS_LOV == 2);
734         LASSERT(MDS_OPEN_HAS_EA == 1073741824);
735         LASSERT(LDLM_ENQUEUE == 101);
736         LASSERT(LDLM_CONVERT == 102);
737         LASSERT(LDLM_CANCEL == 103);
738         LASSERT(LDLM_BL_CALLBACK == 104);
739         LASSERT(LDLM_CP_CALLBACK == 105);
740         LASSERT(LDLM_LAST_OPC == 106);
741         LASSERT(LCK_EX == 1);
742         LASSERT(LCK_PW == 2);
743         LASSERT(LCK_PR == 3);
744         LASSERT(LCK_CW == 4);
745         LASSERT(LCK_CR == 5);
746         LASSERT(LCK_NL == 6);
747         LASSERT(PTLBD_QUERY == 200);
748         LASSERT(PTLBD_READ == 201);
749         LASSERT(PTLBD_WRITE == 202);
750         LASSERT(PTLBD_FLUSH == 203);
751         LASSERT(PTLBD_CONNECT == 204);
752         LASSERT(PTLBD_DISCONNECT == 205);
753         LASSERT(PTLBD_LAST_OPC == 206);
754         LASSERT(MGMT_CONNECT == 250);
755         LASSERT(MGMT_DISCONNECT == 251);
756         LASSERT(MGMT_EXCEPTION == 252);
757         LASSERT(OBD_PING == 400);
758         LASSERT(OBD_LOG_CANCEL == 401);
759         LASSERT(OBD_LAST_OPC == 402);
760         /* Sizes and Offsets */
761
762
763         /* Checks for struct lustre_handle */
764         LASSERT((int)sizeof(struct lustre_handle) == 8);
765         LASSERT(offsetof(struct lustre_handle, cookie) == 0);
766         LASSERT((int)sizeof(((struct lustre_handle *)0)->cookie) == 8);
767
768         /* Checks for struct lustre_msg */
769         LASSERT((int)sizeof(struct lustre_msg) == 64);
770         LASSERT(offsetof(struct lustre_msg, handle) == 0);
771         LASSERT((int)sizeof(((struct lustre_msg *)0)->handle) == 8);
772         LASSERT(offsetof(struct lustre_msg, magic) == 8);
773         LASSERT((int)sizeof(((struct lustre_msg *)0)->magic) == 4);
774         LASSERT(offsetof(struct lustre_msg, type) == 12);
775         LASSERT((int)sizeof(((struct lustre_msg *)0)->type) == 4);
776         LASSERT(offsetof(struct lustre_msg, version) == 16);
777         LASSERT((int)sizeof(((struct lustre_msg *)0)->version) == 4);
778         LASSERT(offsetof(struct lustre_msg, opc) == 20);
779         LASSERT((int)sizeof(((struct lustre_msg *)0)->opc) == 4);
780         LASSERT(offsetof(struct lustre_msg, last_xid) == 24);
781         LASSERT((int)sizeof(((struct lustre_msg *)0)->last_xid) == 8);
782         LASSERT(offsetof(struct lustre_msg, last_committed) == 32);
783         LASSERT((int)sizeof(((struct lustre_msg *)0)->last_committed) == 8);
784         LASSERT(offsetof(struct lustre_msg, transno) == 40);
785         LASSERT((int)sizeof(((struct lustre_msg *)0)->transno) == 8);
786         LASSERT(offsetof(struct lustre_msg, status) == 48);
787         LASSERT((int)sizeof(((struct lustre_msg *)0)->status) == 4);
788         LASSERT(offsetof(struct lustre_msg, flags) == 52);
789         LASSERT((int)sizeof(((struct lustre_msg *)0)->flags) == 4);
790         LASSERT(offsetof(struct lustre_msg, bufcount) == 60);
791         LASSERT((int)sizeof(((struct lustre_msg *)0)->bufcount) == 4);
792         LASSERT(offsetof(struct lustre_msg, buflens[7]) == 92);
793         LASSERT((int)sizeof(((struct lustre_msg *)0)->buflens[7]) == 4);
794
795         /* Checks for struct obdo */
796         LASSERT((int)sizeof(struct obdo) == 168);
797         LASSERT(offsetof(struct obdo, o_id) == 0);
798         LASSERT((int)sizeof(((struct obdo *)0)->o_id) == 8);
799         LASSERT(offsetof(struct obdo, o_gr) == 8);
800         LASSERT((int)sizeof(((struct obdo *)0)->o_gr) == 8);
801         LASSERT(offsetof(struct obdo, o_atime) == 16);
802         LASSERT((int)sizeof(((struct obdo *)0)->o_atime) == 8);
803         LASSERT(offsetof(struct obdo, o_mtime) == 24);
804         LASSERT((int)sizeof(((struct obdo *)0)->o_mtime) == 8);
805         LASSERT(offsetof(struct obdo, o_ctime) == 32);
806         LASSERT((int)sizeof(((struct obdo *)0)->o_ctime) == 8);
807         LASSERT(offsetof(struct obdo, o_size) == 40);
808         LASSERT((int)sizeof(((struct obdo *)0)->o_size) == 8);
809         LASSERT(offsetof(struct obdo, o_blocks) == 48);
810         LASSERT((int)sizeof(((struct obdo *)0)->o_blocks) == 8);
811         LASSERT(offsetof(struct obdo, o_grant) == 56);
812         LASSERT((int)sizeof(((struct obdo *)0)->o_grant) == 8);
813         LASSERT(offsetof(struct obdo, o_blksize) == 64);
814         LASSERT((int)sizeof(((struct obdo *)0)->o_blksize) == 4);
815         LASSERT(offsetof(struct obdo, o_mode) == 68);
816         LASSERT((int)sizeof(((struct obdo *)0)->o_mode) == 4);
817         LASSERT(offsetof(struct obdo, o_uid) == 72);
818         LASSERT((int)sizeof(((struct obdo *)0)->o_uid) == 4);
819         LASSERT(offsetof(struct obdo, o_gid) == 76);
820         LASSERT((int)sizeof(((struct obdo *)0)->o_gid) == 4);
821         LASSERT(offsetof(struct obdo, o_flags) == 80);
822         LASSERT((int)sizeof(((struct obdo *)0)->o_flags) == 4);
823         LASSERT(offsetof(struct obdo, o_nlink) == 84);
824         LASSERT((int)sizeof(((struct obdo *)0)->o_nlink) == 4);
825         LASSERT(offsetof(struct obdo, o_generation) == 88);
826         LASSERT((int)sizeof(((struct obdo *)0)->o_generation) == 4);
827         LASSERT(offsetof(struct obdo, o_valid) == 92);
828         LASSERT((int)sizeof(((struct obdo *)0)->o_valid) == 4);
829         LASSERT(offsetof(struct obdo, o_misc) == 96);
830         LASSERT((int)sizeof(((struct obdo *)0)->o_misc) == 4);
831         LASSERT(offsetof(struct obdo, o_easize) == 100);
832         LASSERT((int)sizeof(((struct obdo *)0)->o_easize) == 4);
833         LASSERT(offsetof(struct obdo, o_inline) == 104);
834         LASSERT((int)sizeof(((struct obdo *)0)->o_inline) == 64);
835         LASSERT(OBD_MD_FLID == 1);
836         LASSERT(OBD_MD_FLATIME == 2);
837         LASSERT(OBD_MD_FLMTIME == 4);
838         LASSERT(OBD_MD_FLCTIME == 8);
839         LASSERT(OBD_MD_FLSIZE == 16);
840         LASSERT(OBD_MD_FLBLOCKS == 32);
841         LASSERT(OBD_MD_FLBLKSZ == 64);
842         LASSERT(OBD_MD_FLMODE == 128);
843         LASSERT(OBD_MD_FLTYPE == 256);
844         LASSERT(OBD_MD_FLUID == 512);
845         LASSERT(OBD_MD_FLGID == 1024);
846         LASSERT(OBD_MD_FLFLAGS == 2048);
847         LASSERT(OBD_MD_FLNLINK == 8192);
848         LASSERT(OBD_MD_FLGENER == 16384);
849         LASSERT(OBD_MD_FLINLINE == 32768);
850         LASSERT(OBD_MD_FLRDEV == 65536);
851         LASSERT(OBD_MD_FLEASIZE == 131072);
852         LASSERT(OBD_MD_LINKNAME == 262144);
853         LASSERT(OBD_MD_FLHANDLE == 524288);
854         LASSERT(OBD_MD_FLCKSUM == 1048576);
855         LASSERT(OBD_MD_FLQOS == 2097152);
856         LASSERT(OBD_MD_FLOSCOPQ == 4194304);
857         LASSERT(OBD_MD_FLCOOKIE == 8388608);
858         LASSERT(OBD_MD_FLGROUP == 16777216);
859         LASSERT(OBD_FL_INLINEDATA == 1);
860         LASSERT(OBD_FL_OBDMDEXISTS == 2);
861         LASSERT(OBD_FL_DELORPHAN == 4);
862         LASSERT(OBD_FL_NORPC == 8);
863         LASSERT(OBD_FL_IDONLY == 16);
864         LASSERT(OBD_FL_RECREATE_OBJS == 32);
865
866         /* Checks for struct lov_mds_md_v1 */
867         LASSERT((int)sizeof(struct lov_mds_md_v1) == 32);
868         LASSERT(offsetof(struct lov_mds_md_v1, lmm_magic) == 0);
869         LASSERT((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_magic) == 4);
870         LASSERT(offsetof(struct lov_mds_md_v1, lmm_pattern) == 4);
871         LASSERT((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_pattern) == 4);
872         LASSERT(offsetof(struct lov_mds_md_v1, lmm_object_id) == 8);
873         LASSERT((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_object_id) == 8);
874         LASSERT(offsetof(struct lov_mds_md_v1, lmm_object_gr) == 16);
875         LASSERT((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_object_gr) == 8);
876         LASSERT(offsetof(struct lov_mds_md_v1, lmm_stripe_size) == 24);
877         LASSERT((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_stripe_size) == 4);
878         LASSERT(offsetof(struct lov_mds_md_v1, lmm_stripe_count) == 28);
879         LASSERT((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_stripe_count) == 4);
880         LASSERT(offsetof(struct lov_mds_md_v1, lmm_objects) == 32);
881         LASSERT((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_objects) == 0);
882
883         /* Checks for struct lov_ost_data_v1 */
884         LASSERT((int)sizeof(struct lov_ost_data_v1) == 24);
885         LASSERT(offsetof(struct lov_ost_data_v1, l_object_id) == 0);
886         LASSERT((int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_id) == 8);
887         LASSERT(offsetof(struct lov_ost_data_v1, l_object_gr) == 8);
888         LASSERT((int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_gr) == 8);
889         LASSERT(offsetof(struct lov_ost_data_v1, l_ost_gen) == 16);
890         LASSERT((int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_gen) == 4);
891         LASSERT(offsetof(struct lov_ost_data_v1, l_ost_idx) == 20);
892         LASSERT((int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_idx) == 4);
893         LASSERT(LOV_MAGIC_V0 == 198183888);
894         LASSERT(LOV_MAGIC_V1 == 198249424);
895         LASSERT(LOV_PATTERN_RAID0 == 1);
896         LASSERT(LOV_PATTERN_RAID1 == 2);
897
898         /* Checks for struct obd_statfs */
899         LASSERT((int)sizeof(struct obd_statfs) == 144);
900         LASSERT(offsetof(struct obd_statfs, os_type) == 0);
901         LASSERT((int)sizeof(((struct obd_statfs *)0)->os_type) == 8);
902         LASSERT(offsetof(struct obd_statfs, os_blocks) == 8);
903         LASSERT((int)sizeof(((struct obd_statfs *)0)->os_blocks) == 8);
904         LASSERT(offsetof(struct obd_statfs, os_bfree) == 16);
905         LASSERT((int)sizeof(((struct obd_statfs *)0)->os_bfree) == 8);
906         LASSERT(offsetof(struct obd_statfs, os_bavail) == 24);
907         LASSERT((int)sizeof(((struct obd_statfs *)0)->os_bavail) == 8);
908         LASSERT(offsetof(struct obd_statfs, os_ffree) == 40);
909         LASSERT((int)sizeof(((struct obd_statfs *)0)->os_ffree) == 8);
910         LASSERT(offsetof(struct obd_statfs, os_fsid) == 48);
911         LASSERT((int)sizeof(((struct obd_statfs *)0)->os_fsid) == 40);
912         LASSERT(offsetof(struct obd_statfs, os_bsize) == 88);
913         LASSERT((int)sizeof(((struct obd_statfs *)0)->os_bsize) == 4);
914         LASSERT(offsetof(struct obd_statfs, os_namelen) == 92);
915         LASSERT((int)sizeof(((struct obd_statfs *)0)->os_namelen) == 4);
916         LASSERT(offsetof(struct obd_statfs, os_spare) == 104);
917         LASSERT((int)sizeof(((struct obd_statfs *)0)->os_spare) == 40);
918
919         /* Checks for struct obd_ioobj */
920         LASSERT((int)sizeof(struct obd_ioobj) == 24);
921         LASSERT(offsetof(struct obd_ioobj, ioo_id) == 0);
922         LASSERT((int)sizeof(((struct obd_ioobj *)0)->ioo_id) == 8);
923         LASSERT(offsetof(struct obd_ioobj, ioo_gr) == 8);
924         LASSERT((int)sizeof(((struct obd_ioobj *)0)->ioo_gr) == 8);
925         LASSERT(offsetof(struct obd_ioobj, ioo_type) == 16);
926         LASSERT((int)sizeof(((struct obd_ioobj *)0)->ioo_type) == 4);
927         LASSERT(offsetof(struct obd_ioobj, ioo_bufcnt) == 20);
928         LASSERT((int)sizeof(((struct obd_ioobj *)0)->ioo_bufcnt) == 4);
929
930         /* Checks for struct niobuf_remote */
931         LASSERT((int)sizeof(struct niobuf_remote) == 16);
932         LASSERT(offsetof(struct niobuf_remote, offset) == 0);
933         LASSERT((int)sizeof(((struct niobuf_remote *)0)->offset) == 8);
934         LASSERT(offsetof(struct niobuf_remote, len) == 8);
935         LASSERT((int)sizeof(((struct niobuf_remote *)0)->len) == 4);
936         LASSERT(offsetof(struct niobuf_remote, flags) == 12);
937         LASSERT((int)sizeof(((struct niobuf_remote *)0)->flags) == 4);
938         LASSERT(OBD_BRW_READ == 1);
939         LASSERT(OBD_BRW_WRITE == 2);
940         LASSERT(OBD_BRW_SYNC == 8);
941         LASSERT(OBD_BRW_FROM_GRANT == 32);
942
943         /* Checks for struct ost_body */
944         LASSERT((int)sizeof(struct ost_body) == 168);
945         LASSERT(offsetof(struct ost_body, oa) == 0);
946         LASSERT((int)sizeof(((struct ost_body *)0)->oa) == 168);
947
948         /* Checks for struct ll_fid */
949         LASSERT((int)sizeof(struct ll_fid) == 16);
950         LASSERT(offsetof(struct ll_fid, id) == 0);
951         LASSERT((int)sizeof(((struct ll_fid *)0)->id) == 8);
952         LASSERT(offsetof(struct ll_fid, generation) == 8);
953         LASSERT((int)sizeof(((struct ll_fid *)0)->generation) == 4);
954         LASSERT(offsetof(struct ll_fid, f_type) == 12);
955         LASSERT((int)sizeof(((struct ll_fid *)0)->f_type) == 4);
956
957         /* Checks for struct mds_status_req */
958         LASSERT((int)sizeof(struct mds_status_req) == 8);
959         LASSERT(offsetof(struct mds_status_req, flags) == 0);
960         LASSERT((int)sizeof(((struct mds_status_req *)0)->flags) == 4);
961         LASSERT(offsetof(struct mds_status_req, repbuf) == 4);
962         LASSERT((int)sizeof(((struct mds_status_req *)0)->repbuf) == 4);
963
964         /* Checks for struct mds_body */
965         LASSERT((int)sizeof(struct mds_body) == 136);
966         LASSERT(offsetof(struct mds_body, fid1) == 0);
967         LASSERT((int)sizeof(((struct mds_body *)0)->fid1) == 16);
968         LASSERT(offsetof(struct mds_body, fid2) == 16);
969         LASSERT((int)sizeof(((struct mds_body *)0)->fid2) == 16);
970         LASSERT(offsetof(struct mds_body, handle) == 32);
971         LASSERT((int)sizeof(((struct mds_body *)0)->handle) == 8);
972         LASSERT(offsetof(struct mds_body, size) == 40);
973         LASSERT((int)sizeof(((struct mds_body *)0)->size) == 8);
974         LASSERT(offsetof(struct mds_body, blocks) == 48);
975         LASSERT((int)sizeof(((struct mds_body *)0)->blocks) == 8);
976         LASSERT(offsetof(struct mds_body, io_epoch) == 56);
977         LASSERT((int)sizeof(((struct mds_body *)0)->io_epoch) == 8);
978         LASSERT(offsetof(struct mds_body, ino) == 64);
979         LASSERT((int)sizeof(((struct mds_body *)0)->ino) == 4);
980         LASSERT(offsetof(struct mds_body, valid) == 68);
981         LASSERT((int)sizeof(((struct mds_body *)0)->valid) == 4);
982         LASSERT(offsetof(struct mds_body, fsuid) == 72);
983         LASSERT((int)sizeof(((struct mds_body *)0)->fsuid) == 4);
984         LASSERT(offsetof(struct mds_body, fsgid) == 76);
985         LASSERT((int)sizeof(((struct mds_body *)0)->fsgid) == 4);
986         LASSERT(offsetof(struct mds_body, capability) == 80);
987         LASSERT((int)sizeof(((struct mds_body *)0)->capability) == 4);
988         LASSERT(offsetof(struct mds_body, mode) == 84);
989         LASSERT((int)sizeof(((struct mds_body *)0)->mode) == 4);
990         LASSERT(offsetof(struct mds_body, uid) == 88);
991         LASSERT((int)sizeof(((struct mds_body *)0)->uid) == 4);
992         LASSERT(offsetof(struct mds_body, gid) == 92);
993         LASSERT((int)sizeof(((struct mds_body *)0)->gid) == 4);
994         LASSERT(offsetof(struct mds_body, mtime) == 96);
995         LASSERT((int)sizeof(((struct mds_body *)0)->mtime) == 4);
996         LASSERT(offsetof(struct mds_body, ctime) == 100);
997         LASSERT((int)sizeof(((struct mds_body *)0)->ctime) == 4);
998         LASSERT(offsetof(struct mds_body, atime) == 104);
999         LASSERT((int)sizeof(((struct mds_body *)0)->atime) == 4);
1000         LASSERT(offsetof(struct mds_body, flags) == 108);
1001         LASSERT((int)sizeof(((struct mds_body *)0)->flags) == 4);
1002         LASSERT(offsetof(struct mds_body, rdev) == 112);
1003         LASSERT((int)sizeof(((struct mds_body *)0)->rdev) == 4);
1004         LASSERT(offsetof(struct mds_body, nlink) == 116);
1005         LASSERT((int)sizeof(((struct mds_body *)0)->nlink) == 4);
1006         LASSERT(offsetof(struct mds_body, generation) == 120);
1007         LASSERT((int)sizeof(((struct mds_body *)0)->generation) == 4);
1008         LASSERT(offsetof(struct mds_body, suppgid) == 124);
1009         LASSERT((int)sizeof(((struct mds_body *)0)->suppgid) == 4);
1010         LASSERT(offsetof(struct mds_body, eadatasize) == 128);
1011         LASSERT((int)sizeof(((struct mds_body *)0)->eadatasize) == 4);
1012         LASSERT(FMODE_READ == 1);
1013         LASSERT(FMODE_WRITE == 2);
1014         LASSERT(FMODE_EXEC == 4);
1015         LASSERT(MDS_OPEN_CREAT == 64);
1016         LASSERT(MDS_OPEN_EXCL == 128);
1017         LASSERT(MDS_OPEN_TRUNC == 512);
1018         LASSERT(MDS_OPEN_APPEND == 1024);
1019         LASSERT(MDS_OPEN_SYNC == 4096);
1020         LASSERT(MDS_OPEN_DIRECTORY == 65536);
1021         LASSERT(MDS_OPEN_DELAY_CREATE == 16777216);
1022         LASSERT(MDS_OPEN_HAS_EA == 1073741824);
1023
1024         /* Checks for struct mds_rec_setattr */
1025         LASSERT((int)sizeof(struct mds_rec_setattr) == 88);
1026         LASSERT(offsetof(struct mds_rec_setattr, sa_opcode) == 0);
1027         LASSERT((int)sizeof(((struct mds_rec_setattr *)0)->sa_opcode) == 4);
1028         LASSERT(offsetof(struct mds_rec_setattr, sa_fsuid) == 4);
1029         LASSERT((int)sizeof(((struct mds_rec_setattr *)0)->sa_fsuid) == 4);
1030         LASSERT(offsetof(struct mds_rec_setattr, sa_fsgid) == 8);
1031         LASSERT((int)sizeof(((struct mds_rec_setattr *)0)->sa_fsgid) == 4);
1032         LASSERT(offsetof(struct mds_rec_setattr, sa_cap) == 12);
1033         LASSERT((int)sizeof(((struct mds_rec_setattr *)0)->sa_cap) == 4);
1034         LASSERT(offsetof(struct mds_rec_setattr, sa_suppgid) == 16);
1035         LASSERT((int)sizeof(((struct mds_rec_setattr *)0)->sa_suppgid) == 4);
1036         LASSERT(offsetof(struct mds_rec_setattr, sa_valid) == 20);
1037         LASSERT((int)sizeof(((struct mds_rec_setattr *)0)->sa_valid) == 4);
1038         LASSERT(offsetof(struct mds_rec_setattr, sa_fid) == 24);
1039         LASSERT((int)sizeof(((struct mds_rec_setattr *)0)->sa_fid) == 16);
1040         LASSERT(offsetof(struct mds_rec_setattr, sa_mode) == 40);
1041         LASSERT((int)sizeof(((struct mds_rec_setattr *)0)->sa_mode) == 4);
1042         LASSERT(offsetof(struct mds_rec_setattr, sa_uid) == 44);
1043         LASSERT((int)sizeof(((struct mds_rec_setattr *)0)->sa_uid) == 4);
1044         LASSERT(offsetof(struct mds_rec_setattr, sa_gid) == 48);
1045         LASSERT((int)sizeof(((struct mds_rec_setattr *)0)->sa_gid) == 4);
1046         LASSERT(offsetof(struct mds_rec_setattr, sa_attr_flags) == 52);
1047         LASSERT((int)sizeof(((struct mds_rec_setattr *)0)->sa_attr_flags) == 4);
1048         LASSERT(offsetof(struct mds_rec_setattr, sa_size) == 56);
1049         LASSERT((int)sizeof(((struct mds_rec_setattr *)0)->sa_size) == 8);
1050         LASSERT(offsetof(struct mds_rec_setattr, sa_atime) == 64);
1051         LASSERT((int)sizeof(((struct mds_rec_setattr *)0)->sa_atime) == 8);
1052         LASSERT(offsetof(struct mds_rec_setattr, sa_mtime) == 72);
1053         LASSERT((int)sizeof(((struct mds_rec_setattr *)0)->sa_mtime) == 8);
1054         LASSERT(offsetof(struct mds_rec_setattr, sa_ctime) == 80);
1055         LASSERT((int)sizeof(((struct mds_rec_setattr *)0)->sa_ctime) == 8);
1056
1057         /* Checks for struct mds_rec_create */
1058         LASSERT((int)sizeof(struct mds_rec_create) == 80);
1059         LASSERT(offsetof(struct mds_rec_create, cr_opcode) == 0);
1060         LASSERT((int)sizeof(((struct mds_rec_create *)0)->cr_opcode) == 4);
1061         LASSERT(offsetof(struct mds_rec_create, cr_fsuid) == 4);
1062         LASSERT((int)sizeof(((struct mds_rec_create *)0)->cr_fsuid) == 4);
1063         LASSERT(offsetof(struct mds_rec_create, cr_fsgid) == 8);
1064         LASSERT((int)sizeof(((struct mds_rec_create *)0)->cr_fsgid) == 4);
1065         LASSERT(offsetof(struct mds_rec_create, cr_cap) == 12);
1066         LASSERT((int)sizeof(((struct mds_rec_create *)0)->cr_cap) == 4);
1067         LASSERT(offsetof(struct mds_rec_create, cr_flags) == 16);
1068         LASSERT((int)sizeof(((struct mds_rec_create *)0)->cr_flags) == 4);
1069         LASSERT(offsetof(struct mds_rec_create, cr_mode) == 20);
1070         LASSERT((int)sizeof(((struct mds_rec_create *)0)->cr_mode) == 4);
1071         LASSERT(offsetof(struct mds_rec_create, cr_fid) == 24);
1072         LASSERT((int)sizeof(((struct mds_rec_create *)0)->cr_fid) == 16);
1073         LASSERT(offsetof(struct mds_rec_create, cr_replayfid) == 40);
1074         LASSERT((int)sizeof(((struct mds_rec_create *)0)->cr_replayfid) == 16);
1075         LASSERT(offsetof(struct mds_rec_create, cr_time) == 56);
1076         LASSERT((int)sizeof(((struct mds_rec_create *)0)->cr_time) == 8);
1077         LASSERT(offsetof(struct mds_rec_create, cr_rdev) == 64);
1078         LASSERT((int)sizeof(((struct mds_rec_create *)0)->cr_rdev) == 8);
1079         LASSERT(offsetof(struct mds_rec_create, cr_suppgid) == 72);
1080         LASSERT((int)sizeof(((struct mds_rec_create *)0)->cr_suppgid) == 4);
1081
1082         /* Checks for struct mds_rec_link */
1083         LASSERT((int)sizeof(struct mds_rec_link) == 64);
1084         LASSERT(offsetof(struct mds_rec_link, lk_opcode) == 0);
1085         LASSERT((int)sizeof(((struct mds_rec_link *)0)->lk_opcode) == 4);
1086         LASSERT(offsetof(struct mds_rec_link, lk_fsuid) == 4);
1087         LASSERT((int)sizeof(((struct mds_rec_link *)0)->lk_fsuid) == 4);
1088         LASSERT(offsetof(struct mds_rec_link, lk_fsgid) == 8);
1089         LASSERT((int)sizeof(((struct mds_rec_link *)0)->lk_fsgid) == 4);
1090         LASSERT(offsetof(struct mds_rec_link, lk_cap) == 12);
1091         LASSERT((int)sizeof(((struct mds_rec_link *)0)->lk_cap) == 4);
1092         LASSERT(offsetof(struct mds_rec_link, lk_suppgid1) == 16);
1093         LASSERT((int)sizeof(((struct mds_rec_link *)0)->lk_suppgid1) == 4);
1094         LASSERT(offsetof(struct mds_rec_link, lk_suppgid2) == 20);
1095         LASSERT((int)sizeof(((struct mds_rec_link *)0)->lk_suppgid2) == 4);
1096         LASSERT(offsetof(struct mds_rec_link, lk_fid1) == 24);
1097         LASSERT((int)sizeof(((struct mds_rec_link *)0)->lk_fid1) == 16);
1098         LASSERT(offsetof(struct mds_rec_link, lk_fid2) == 40);
1099         LASSERT((int)sizeof(((struct mds_rec_link *)0)->lk_fid2) == 16);
1100         LASSERT(offsetof(struct mds_rec_link, lk_time) == 56);
1101         LASSERT((int)sizeof(((struct mds_rec_link *)0)->lk_time) == 8);
1102
1103         /* Checks for struct mds_rec_unlink */
1104         LASSERT((int)sizeof(struct mds_rec_unlink) == 64);
1105         LASSERT(offsetof(struct mds_rec_unlink, ul_opcode) == 0);
1106         LASSERT((int)sizeof(((struct mds_rec_unlink *)0)->ul_opcode) == 4);
1107         LASSERT(offsetof(struct mds_rec_unlink, ul_fsuid) == 4);
1108         LASSERT((int)sizeof(((struct mds_rec_unlink *)0)->ul_fsuid) == 4);
1109         LASSERT(offsetof(struct mds_rec_unlink, ul_fsgid) == 8);
1110         LASSERT((int)sizeof(((struct mds_rec_unlink *)0)->ul_fsgid) == 4);
1111         LASSERT(offsetof(struct mds_rec_unlink, ul_cap) == 12);
1112         LASSERT((int)sizeof(((struct mds_rec_unlink *)0)->ul_cap) == 4);
1113         LASSERT(offsetof(struct mds_rec_unlink, ul_suppgid) == 16);
1114         LASSERT((int)sizeof(((struct mds_rec_unlink *)0)->ul_suppgid) == 4);
1115         LASSERT(offsetof(struct mds_rec_unlink, ul_mode) == 20);
1116         LASSERT((int)sizeof(((struct mds_rec_unlink *)0)->ul_mode) == 4);
1117         LASSERT(offsetof(struct mds_rec_unlink, ul_fid1) == 24);
1118         LASSERT((int)sizeof(((struct mds_rec_unlink *)0)->ul_fid1) == 16);
1119         LASSERT(offsetof(struct mds_rec_unlink, ul_fid2) == 40);
1120         LASSERT((int)sizeof(((struct mds_rec_unlink *)0)->ul_fid2) == 16);
1121         LASSERT(offsetof(struct mds_rec_unlink, ul_time) == 56);
1122         LASSERT((int)sizeof(((struct mds_rec_unlink *)0)->ul_time) == 8);
1123
1124         /* Checks for struct mds_rec_rename */
1125         LASSERT((int)sizeof(struct mds_rec_rename) == 64);
1126         LASSERT(offsetof(struct mds_rec_rename, rn_opcode) == 0);
1127         LASSERT((int)sizeof(((struct mds_rec_rename *)0)->rn_opcode) == 4);
1128         LASSERT(offsetof(struct mds_rec_rename, rn_fsuid) == 4);
1129         LASSERT((int)sizeof(((struct mds_rec_rename *)0)->rn_fsuid) == 4);
1130         LASSERT(offsetof(struct mds_rec_rename, rn_fsgid) == 8);
1131         LASSERT((int)sizeof(((struct mds_rec_rename *)0)->rn_fsgid) == 4);
1132         LASSERT(offsetof(struct mds_rec_rename, rn_cap) == 12);
1133         LASSERT((int)sizeof(((struct mds_rec_rename *)0)->rn_cap) == 4);
1134         LASSERT(offsetof(struct mds_rec_rename, rn_suppgid1) == 16);
1135         LASSERT((int)sizeof(((struct mds_rec_rename *)0)->rn_suppgid1) == 4);
1136         LASSERT(offsetof(struct mds_rec_rename, rn_suppgid2) == 20);
1137         LASSERT((int)sizeof(((struct mds_rec_rename *)0)->rn_suppgid2) == 4);
1138         LASSERT(offsetof(struct mds_rec_rename, rn_fid1) == 24);
1139         LASSERT((int)sizeof(((struct mds_rec_rename *)0)->rn_fid1) == 16);
1140         LASSERT(offsetof(struct mds_rec_rename, rn_fid2) == 40);
1141         LASSERT((int)sizeof(((struct mds_rec_rename *)0)->rn_fid2) == 16);
1142         LASSERT(offsetof(struct mds_rec_rename, rn_time) == 56);
1143         LASSERT((int)sizeof(((struct mds_rec_rename *)0)->rn_time) == 8);
1144
1145         /* Checks for struct lov_desc */
1146         LASSERT((int)sizeof(struct lov_desc) == 72);
1147         LASSERT(offsetof(struct lov_desc, ld_tgt_count) == 0);
1148         LASSERT((int)sizeof(((struct lov_desc *)0)->ld_tgt_count) == 4);
1149         LASSERT(offsetof(struct lov_desc, ld_active_tgt_count) == 4);
1150         LASSERT((int)sizeof(((struct lov_desc *)0)->ld_active_tgt_count) == 4);
1151         LASSERT(offsetof(struct lov_desc, ld_default_stripe_count) == 8);
1152         LASSERT((int)sizeof(((struct lov_desc *)0)->ld_default_stripe_count) == 4);
1153         LASSERT(offsetof(struct lov_desc, ld_pattern) == 12);
1154         LASSERT((int)sizeof(((struct lov_desc *)0)->ld_pattern) == 4);
1155         LASSERT(offsetof(struct lov_desc, ld_default_stripe_size) == 16);
1156         LASSERT((int)sizeof(((struct lov_desc *)0)->ld_default_stripe_size) == 8);
1157         LASSERT(offsetof(struct lov_desc, ld_default_stripe_offset) == 24);
1158         LASSERT((int)sizeof(((struct lov_desc *)0)->ld_default_stripe_offset) == 8);
1159         LASSERT(offsetof(struct lov_desc, ld_uuid) == 32);
1160         LASSERT((int)sizeof(((struct lov_desc *)0)->ld_uuid) == 40);
1161
1162         /* Checks for struct ldlm_res_id */
1163         LASSERT((int)sizeof(struct ldlm_res_id) == 32);
1164         LASSERT(offsetof(struct ldlm_res_id, name[4]) == 32);
1165         LASSERT((int)sizeof(((struct ldlm_res_id *)0)->name[4]) == 8);
1166
1167         /* Checks for struct ldlm_extent */
1168         LASSERT((int)sizeof(struct ldlm_extent) == 16);
1169         LASSERT(offsetof(struct ldlm_extent, start) == 0);
1170         LASSERT((int)sizeof(((struct ldlm_extent *)0)->start) == 8);
1171         LASSERT(offsetof(struct ldlm_extent, end) == 8);
1172         LASSERT((int)sizeof(((struct ldlm_extent *)0)->end) == 8);
1173
1174         /* Checks for struct ldlm_flock */
1175         LASSERT((int)sizeof(struct ldlm_flock) == 32);
1176         LASSERT(offsetof(struct ldlm_flock, start) == 0);
1177         LASSERT((int)sizeof(((struct ldlm_flock *)0)->start) == 8);
1178         LASSERT(offsetof(struct ldlm_flock, end) == 8);
1179         LASSERT((int)sizeof(((struct ldlm_flock *)0)->end) == 8);
1180         LASSERT(offsetof(struct ldlm_flock, blocking_export) == 16);
1181         LASSERT((int)sizeof(((struct ldlm_flock *)0)->blocking_export) == 8);
1182         LASSERT(offsetof(struct ldlm_flock, blocking_pid) == 24);
1183         LASSERT((int)sizeof(((struct ldlm_flock *)0)->blocking_pid) == 4);
1184         LASSERT(offsetof(struct ldlm_flock, pid) == 28);
1185         LASSERT((int)sizeof(((struct ldlm_flock *)0)->pid) == 4);
1186
1187         /* Checks for struct ldlm_intent */
1188         LASSERT((int)sizeof(struct ldlm_intent) == 8);
1189         LASSERT(offsetof(struct ldlm_intent, opc) == 0);
1190         LASSERT((int)sizeof(((struct ldlm_intent *)0)->opc) == 8);
1191
1192         /* Checks for struct ldlm_resource_desc */
1193         LASSERT((int)sizeof(struct ldlm_resource_desc) == 40);
1194         LASSERT(offsetof(struct ldlm_resource_desc, lr_type) == 0);
1195         LASSERT((int)sizeof(((struct ldlm_resource_desc *)0)->lr_type) == 4);
1196         LASSERT(offsetof(struct ldlm_resource_desc, lr_name) == 8);
1197         LASSERT((int)sizeof(((struct ldlm_resource_desc *)0)->lr_name) == 32);
1198
1199         /* Checks for struct ldlm_lock_desc */
1200         LASSERT((int)sizeof(struct ldlm_lock_desc) == 108);
1201         LASSERT(offsetof(struct ldlm_lock_desc, l_resource) == 0);
1202         LASSERT((int)sizeof(((struct ldlm_lock_desc *)0)->l_resource) == 52);
1203         LASSERT(offsetof(struct ldlm_lock_desc, l_req_mode) == 52);
1204         LASSERT((int)sizeof(((struct ldlm_lock_desc *)0)->l_req_mode) == 4);
1205         LASSERT(offsetof(struct ldlm_lock_desc, l_granted_mode) == 56);
1206         LASSERT((int)sizeof(((struct ldlm_lock_desc *)0)->l_granted_mode) == 4);
1207         LASSERT(offsetof(struct ldlm_lock_desc, l_policy_data) == 60);
1208         LASSERT((int)sizeof(((struct ldlm_lock_desc *)0)->l_policy_data) == 32);
1209         LASSERT(offsetof(struct ldlm_lock_desc, l_version[4]) == 108);
1210         LASSERT((int)sizeof(((struct ldlm_lock_desc *)0)->l_version[4]) == 4);
1211
1212         /* Checks for struct ldlm_request */
1213         LASSERT((int)sizeof(struct ldlm_request) == 128);
1214         LASSERT(offsetof(struct ldlm_request, lock_flags) == 0);
1215         LASSERT((int)sizeof(((struct ldlm_request *)0)->lock_flags) == 4);
1216         LASSERT(offsetof(struct ldlm_request, lock_desc) == 4);
1217         LASSERT((int)sizeof(((struct ldlm_request *)0)->lock_desc) == 108);
1218         LASSERT(offsetof(struct ldlm_request, lock_handle1) == 112);
1219         LASSERT((int)sizeof(((struct ldlm_request *)0)->lock_handle1) == 8);
1220         LASSERT(offsetof(struct ldlm_request, lock_handle2) == 120);
1221         LASSERT((int)sizeof(((struct ldlm_request *)0)->lock_handle2) == 8);
1222
1223         /* Checks for struct ldlm_reply */
1224         LASSERT((int)sizeof(struct ldlm_reply) == 96);
1225         LASSERT(offsetof(struct ldlm_reply, lock_flags) == 0);
1226         LASSERT((int)sizeof(((struct ldlm_reply *)0)->lock_flags) == 4);
1227         LASSERT(offsetof(struct ldlm_reply, lock_mode) == 4);
1228         LASSERT((int)sizeof(((struct ldlm_reply *)0)->lock_mode) == 4);
1229         LASSERT(offsetof(struct ldlm_reply, lock_resource_name) == 8);
1230         LASSERT((int)sizeof(((struct ldlm_reply *)0)->lock_resource_name) == 32);
1231         LASSERT(offsetof(struct ldlm_reply, lock_handle) == 40);
1232         LASSERT((int)sizeof(((struct ldlm_reply *)0)->lock_handle) == 8);
1233         LASSERT(offsetof(struct ldlm_reply, lock_policy_data) == 48);
1234         LASSERT((int)sizeof(((struct ldlm_reply *)0)->lock_policy_data) == 32);
1235         LASSERT(offsetof(struct ldlm_reply, lock_policy_res1) == 80);
1236         LASSERT((int)sizeof(((struct ldlm_reply *)0)->lock_policy_res1) == 8);
1237         LASSERT(offsetof(struct ldlm_reply, lock_policy_res2) == 88);
1238         LASSERT((int)sizeof(((struct ldlm_reply *)0)->lock_policy_res2) == 8);
1239
1240         /* Checks for struct ptlbd_op */
1241         LASSERT((int)sizeof(struct ptlbd_op) == 12);
1242         LASSERT(offsetof(struct ptlbd_op, op_cmd) == 0);
1243         LASSERT((int)sizeof(((struct ptlbd_op *)0)->op_cmd) == 2);
1244         LASSERT(offsetof(struct ptlbd_op, op_lun) == 2);
1245         LASSERT((int)sizeof(((struct ptlbd_op *)0)->op_lun) == 2);
1246         LASSERT(offsetof(struct ptlbd_op, op_niob_cnt) == 4);
1247         LASSERT((int)sizeof(((struct ptlbd_op *)0)->op_niob_cnt) == 2);
1248         LASSERT(offsetof(struct ptlbd_op, op__padding) == 6);
1249         LASSERT((int)sizeof(((struct ptlbd_op *)0)->op__padding) == 2);
1250         LASSERT(offsetof(struct ptlbd_op, op_block_cnt) == 8);
1251         LASSERT((int)sizeof(((struct ptlbd_op *)0)->op_block_cnt) == 4);
1252
1253         /* Checks for struct ptlbd_niob */
1254         LASSERT((int)sizeof(struct ptlbd_niob) == 24);
1255         LASSERT(offsetof(struct ptlbd_niob, n_xid) == 0);
1256         LASSERT((int)sizeof(((struct ptlbd_niob *)0)->n_xid) == 8);
1257         LASSERT(offsetof(struct ptlbd_niob, n_block_nr) == 8);
1258         LASSERT((int)sizeof(((struct ptlbd_niob *)0)->n_block_nr) == 8);
1259         LASSERT(offsetof(struct ptlbd_niob, n_offset) == 16);
1260         LASSERT((int)sizeof(((struct ptlbd_niob *)0)->n_offset) == 4);
1261         LASSERT(offsetof(struct ptlbd_niob, n_length) == 20);
1262         LASSERT((int)sizeof(((struct ptlbd_niob *)0)->n_length) == 4);
1263
1264         /* Checks for struct ptlbd_rsp */
1265         LASSERT((int)sizeof(struct ptlbd_rsp) == 4);
1266         LASSERT(offsetof(struct ptlbd_rsp, r_status) == 0);
1267         LASSERT((int)sizeof(((struct ptlbd_rsp *)0)->r_status) == 2);
1268         LASSERT(offsetof(struct ptlbd_rsp, r_error_cnt) == 2);
1269         LASSERT((int)sizeof(((struct ptlbd_rsp *)0)->r_error_cnt) == 2);
1270
1271         /* Checks for struct llog_logid */
1272         LASSERT((int)sizeof(struct llog_logid) == 20);
1273         LASSERT(offsetof(struct llog_logid, lgl_oid) == 0);
1274         LASSERT((int)sizeof(((struct llog_logid *)0)->lgl_oid) == 8);
1275         LASSERT(offsetof(struct llog_logid, lgl_ogr) == 8);
1276         LASSERT((int)sizeof(((struct llog_logid *)0)->lgl_ogr) == 8);
1277         LASSERT(offsetof(struct llog_logid, lgl_ogen) == 16);
1278         LASSERT((int)sizeof(((struct llog_logid *)0)->lgl_ogen) == 4);
1279         LASSERT(OST_SZ_REC == 274730752);
1280         LASSERT(OST_RAID1_REC == 274731008);
1281         LASSERT(MDS_UNLINK_REC == 274801668);
1282         LASSERT(OBD_CFG_REC == 274857984);
1283         LASSERT(PTL_CFG_REC == 274923520);
1284         LASSERT(LLOG_GEN_REC == 274989056);
1285         LASSERT(LLOG_HDR_MAGIC == 275010873);
1286         LASSERT(LLOG_LOGID_MAGIC == 275010874);
1287
1288         /* Checks for struct llog_rec_hdr */
1289         LASSERT((int)sizeof(struct llog_rec_hdr) == 16);
1290         LASSERT(offsetof(struct llog_rec_hdr, lrh_len) == 0);
1291         LASSERT((int)sizeof(((struct llog_rec_hdr *)0)->lrh_len) == 4);
1292         LASSERT(offsetof(struct llog_rec_hdr, lrh_index) == 4);
1293         LASSERT((int)sizeof(((struct llog_rec_hdr *)0)->lrh_index) == 4);
1294         LASSERT(offsetof(struct llog_rec_hdr, lrh_type) == 8);
1295         LASSERT((int)sizeof(((struct llog_rec_hdr *)0)->lrh_type) == 4);
1296
1297         /* Checks for struct llog_rec_tail */
1298         LASSERT((int)sizeof(struct llog_rec_tail) == 8);
1299         LASSERT(offsetof(struct llog_rec_tail, lrt_len) == 0);
1300         LASSERT((int)sizeof(((struct llog_rec_tail *)0)->lrt_len) == 4);
1301         LASSERT(offsetof(struct llog_rec_tail, lrt_index) == 4);
1302         LASSERT((int)sizeof(((struct llog_rec_tail *)0)->lrt_index) == 4);
1303
1304         /* Checks for struct llog_logid_rec */
1305         LASSERT((int)sizeof(struct llog_logid_rec) == 48);
1306         LASSERT(offsetof(struct llog_logid_rec, lid_hdr) == 0);
1307         LASSERT((int)sizeof(((struct llog_logid_rec *)0)->lid_hdr) == 16);
1308         LASSERT(offsetof(struct llog_logid_rec, lid_id) == 16);
1309         LASSERT((int)sizeof(((struct llog_logid_rec *)0)->lid_id) == 20);
1310         LASSERT(offsetof(struct llog_logid_rec, lid_tail) == 40);
1311         LASSERT((int)sizeof(((struct llog_logid_rec *)0)->lid_tail) == 8);
1312
1313         /* Checks for struct llog_create_rec */
1314         LASSERT((int)sizeof(struct llog_create_rec) == 56);
1315         LASSERT(offsetof(struct llog_create_rec, lcr_hdr) == 0);
1316         LASSERT((int)sizeof(((struct llog_create_rec *)0)->lcr_hdr) == 16);
1317         LASSERT(offsetof(struct llog_create_rec, lcr_fid) == 16);
1318         LASSERT((int)sizeof(((struct llog_create_rec *)0)->lcr_fid) == 16);
1319         LASSERT(offsetof(struct llog_create_rec, lcr_oid) == 32);
1320         LASSERT((int)sizeof(((struct llog_create_rec *)0)->lcr_oid) == 8);
1321         LASSERT(offsetof(struct llog_create_rec, lcr_ogen) == 40);
1322         LASSERT((int)sizeof(((struct llog_create_rec *)0)->lcr_ogen) == 4);
1323
1324         /* Checks for struct llog_orphan_rec */
1325         LASSERT((int)sizeof(struct llog_orphan_rec) == 40);
1326         LASSERT(offsetof(struct llog_orphan_rec, lor_hdr) == 0);
1327         LASSERT((int)sizeof(((struct llog_orphan_rec *)0)->lor_hdr) == 16);
1328         LASSERT(offsetof(struct llog_orphan_rec, lor_oid) == 16);
1329         LASSERT((int)sizeof(((struct llog_orphan_rec *)0)->lor_oid) == 8);
1330         LASSERT(offsetof(struct llog_orphan_rec, lor_ogen) == 24);
1331         LASSERT((int)sizeof(((struct llog_orphan_rec *)0)->lor_ogen) == 4);
1332         LASSERT(offsetof(struct llog_orphan_rec, lor_tail) == 32);
1333         LASSERT((int)sizeof(((struct llog_orphan_rec *)0)->lor_tail) == 8);
1334
1335         /* Checks for struct llog_unlink_rec */
1336         LASSERT((int)sizeof(struct llog_unlink_rec) == 40);
1337         LASSERT(offsetof(struct llog_unlink_rec, lur_hdr) == 0);
1338         LASSERT((int)sizeof(((struct llog_unlink_rec *)0)->lur_hdr) == 16);
1339         LASSERT(offsetof(struct llog_unlink_rec, lur_oid) == 16);
1340         LASSERT((int)sizeof(((struct llog_unlink_rec *)0)->lur_oid) == 8);
1341         LASSERT(offsetof(struct llog_unlink_rec, lur_ogen) == 24);
1342         LASSERT((int)sizeof(((struct llog_unlink_rec *)0)->lur_ogen) == 4);
1343         LASSERT(offsetof(struct llog_unlink_rec, lur_tail) == 32);
1344         LASSERT((int)sizeof(((struct llog_unlink_rec *)0)->lur_tail) == 8);
1345
1346         /* Checks for struct llog_size_change_rec */
1347         LASSERT((int)sizeof(struct llog_size_change_rec) == 48);
1348         LASSERT(offsetof(struct llog_size_change_rec, lsc_hdr) == 0);
1349         LASSERT((int)sizeof(((struct llog_size_change_rec *)0)->lsc_hdr) == 16);
1350         LASSERT(offsetof(struct llog_size_change_rec, lsc_fid) == 16);
1351         LASSERT((int)sizeof(((struct llog_size_change_rec *)0)->lsc_fid) == 16);
1352         LASSERT(offsetof(struct llog_size_change_rec, lsc_io_epoch) == 32);
1353         LASSERT((int)sizeof(((struct llog_size_change_rec *)0)->lsc_io_epoch) == 4);
1354         LASSERT(offsetof(struct llog_size_change_rec, lsc_tail) == 40);
1355         LASSERT((int)sizeof(((struct llog_size_change_rec *)0)->lsc_tail) == 8);
1356
1357         /* Checks for struct llog_gen */
1358         LASSERT((int)sizeof(struct llog_gen) == 16);
1359         LASSERT(offsetof(struct llog_gen, mnt_cnt) == 0);
1360         LASSERT((int)sizeof(((struct llog_gen *)0)->mnt_cnt) == 8);
1361         LASSERT(offsetof(struct llog_gen, conn_cnt) == 8);
1362         LASSERT((int)sizeof(((struct llog_gen *)0)->conn_cnt) == 8);
1363
1364         /* Checks for struct llog_gen_rec */
1365         LASSERT((int)sizeof(struct llog_gen_rec) == 40);
1366         LASSERT(offsetof(struct llog_gen_rec, lgr_hdr) == 0);
1367         LASSERT((int)sizeof(((struct llog_gen_rec *)0)->lgr_hdr) == 16);
1368         LASSERT(offsetof(struct llog_gen_rec, lgr_gen) == 16);
1369         LASSERT((int)sizeof(((struct llog_gen_rec *)0)->lgr_gen) == 16);
1370         LASSERT(offsetof(struct llog_gen_rec, lgr_tail) == 32);
1371         LASSERT((int)sizeof(((struct llog_gen_rec *)0)->lgr_tail) == 8);
1372
1373         /* Checks for struct llog_log_hdr */
1374         LASSERT((int)sizeof(struct llog_log_hdr) == 4096);
1375         LASSERT(offsetof(struct llog_log_hdr, llh_hdr) == 0);
1376         LASSERT((int)sizeof(((struct llog_log_hdr *)0)->llh_hdr) == 16);
1377         LASSERT(offsetof(struct llog_log_hdr, llh_timestamp) == 16);
1378         LASSERT((int)sizeof(((struct llog_log_hdr *)0)->llh_timestamp) == 8);
1379         LASSERT(offsetof(struct llog_log_hdr, llh_count) == 24);
1380         LASSERT((int)sizeof(((struct llog_log_hdr *)0)->llh_count) == 4);
1381         LASSERT(offsetof(struct llog_log_hdr, llh_bitmap_offset) == 28);
1382         LASSERT((int)sizeof(((struct llog_log_hdr *)0)->llh_bitmap_offset) == 4);
1383         LASSERT(offsetof(struct llog_log_hdr, llh_size) == 32);
1384         LASSERT((int)sizeof(((struct llog_log_hdr *)0)->llh_size) == 4);
1385         LASSERT(offsetof(struct llog_log_hdr, llh_flags) == 36);
1386         LASSERT((int)sizeof(((struct llog_log_hdr *)0)->llh_flags) == 4);
1387         LASSERT(offsetof(struct llog_log_hdr, llh_cat_idx) == 40);
1388         LASSERT((int)sizeof(((struct llog_log_hdr *)0)->llh_cat_idx) == 4);
1389         LASSERT(offsetof(struct llog_log_hdr, llh_tgtuuid) == 44);
1390         LASSERT((int)sizeof(((struct llog_log_hdr *)0)->llh_tgtuuid) == 40);
1391         LASSERT(offsetof(struct llog_log_hdr, llh_reserved) == 84);
1392         LASSERT((int)sizeof(((struct llog_log_hdr *)0)->llh_reserved) == 4);
1393         LASSERT(offsetof(struct llog_log_hdr, llh_bitmap) == 88);
1394         LASSERT((int)sizeof(((struct llog_log_hdr *)0)->llh_bitmap) == 4000);
1395         LASSERT(offsetof(struct llog_log_hdr, llh_tail) == 4088);
1396         LASSERT((int)sizeof(((struct llog_log_hdr *)0)->llh_tail) == 8);
1397
1398         /* Checks for struct llog_cookie */
1399         LASSERT((int)sizeof(struct llog_cookie) == 32);
1400         LASSERT(offsetof(struct llog_cookie, lgc_lgl) == 0);
1401         LASSERT((int)sizeof(((struct llog_cookie *)0)->lgc_lgl) == 20);
1402         LASSERT(offsetof(struct llog_cookie, lgc_subsys) == 20);
1403         LASSERT((int)sizeof(((struct llog_cookie *)0)->lgc_subsys) == 4);
1404         LASSERT(offsetof(struct llog_cookie, lgc_index) == 24);
1405         LASSERT((int)sizeof(((struct llog_cookie *)0)->lgc_index) == 4);
1406
1407         /* Checks for struct llogd_body */
1408         LASSERT((int)sizeof(struct llogd_body) == 48);
1409         LASSERT(offsetof(struct llogd_body, lgd_logid) == 0);
1410         LASSERT((int)sizeof(((struct llogd_body *)0)->lgd_logid) == 20);
1411         LASSERT(offsetof(struct llogd_body, lgd_ctxt_idx) == 20);
1412         LASSERT((int)sizeof(((struct llogd_body *)0)->lgd_ctxt_idx) == 4);
1413         LASSERT(offsetof(struct llogd_body, lgd_llh_flags) == 24);
1414         LASSERT((int)sizeof(((struct llogd_body *)0)->lgd_llh_flags) == 4);
1415         LASSERT(offsetof(struct llogd_body, lgd_index) == 28);
1416         LASSERT((int)sizeof(((struct llogd_body *)0)->lgd_index) == 4);
1417         LASSERT(offsetof(struct llogd_body, lgd_saved_index) == 32);
1418         LASSERT((int)sizeof(((struct llogd_body *)0)->lgd_saved_index) == 4);
1419         LASSERT(offsetof(struct llogd_body, lgd_len) == 36);
1420         LASSERT((int)sizeof(((struct llogd_body *)0)->lgd_len) == 4);
1421         LASSERT(offsetof(struct llogd_body, lgd_cur_offset) == 40);
1422         LASSERT((int)sizeof(((struct llogd_body *)0)->lgd_cur_offset) == 8);
1423         LASSERT(LLOG_ORIGIN_HANDLE_CREATE == 501);
1424         LASSERT(LLOG_ORIGIN_HANDLE_NEXT_BLOCK == 502);
1425         LASSERT(LLOG_ORIGIN_HANDLE_READ_HEADER == 503);
1426         LASSERT(LLOG_ORIGIN_HANDLE_WRITE_REC == 504);
1427         LASSERT(LLOG_ORIGIN_HANDLE_CLOSE == 505);
1428         LASSERT(LLOG_ORIGIN_CONNECT == 506);
1429         LASSERT(LLOG_CATINFO == 507);
1430
1431         /* Checks for struct llogd_conn_body */
1432         LASSERT((int)sizeof(struct llogd_conn_body) == 40);
1433         LASSERT(offsetof(struct llogd_conn_body, lgdc_gen) == 0);
1434         LASSERT((int)sizeof(((struct llogd_conn_body *)0)->lgdc_gen) == 16);
1435         LASSERT(offsetof(struct llogd_conn_body, lgdc_logid) == 16);
1436         LASSERT((int)sizeof(((struct llogd_conn_body *)0)->lgdc_logid) == 20);
1437         LASSERT(offsetof(struct llogd_conn_body, lgdc_ctxt_idx) == 36);
1438         LASSERT((int)sizeof(((struct llogd_conn_body *)0)->lgdc_ctxt_idx) == 4);
1439 }
1440 #else
1441 void lustre_assert_wire_constants(void)
1442 {
1443         return;
1444 }
1445 #endif
1446