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