Whamcloud - gitweb
land v0.9.1 on HEAD, in preparation for a 1.0.x branch
[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_rdev);
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_obdflags);
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 void lustre_assert_wire_constants (void)
615 {
616 #if BUG_1343
617         /* Wire protocol assertions generated by 'wirecheck' */
618
619         /* Constants... */
620         LASSERT (PTLRPC_MSG_MAGIC == 0x0BD00BD0);
621         LASSERT (PTLRPC_MSG_VERSION == 0x00040002);
622         LASSERT (PTL_RPC_MSG_REQUEST == 4711);
623         LASSERT (PTL_RPC_MSG_ERR == 4712);
624         LASSERT (PTL_RPC_MSG_REPLY == 4713);
625         LASSERT (MSG_LAST_REPLAY == 1);
626         LASSERT (MSG_RESENT == 2);
627         LASSERT (MSG_CONNECT_RECOVERING == 1);
628         LASSERT (MSG_CONNECT_RECONNECT == 2);
629         LASSERT (MSG_CONNECT_REPLAYABLE == 4);
630         LASSERT (OST_REPLY == 0);
631         LASSERT (OST_GETATTR == 1);
632         LASSERT (OST_SETATTR == 2);
633         LASSERT (OST_READ == 3);
634         LASSERT (OST_WRITE == 4);
635         LASSERT (OST_CREATE == 5);
636         LASSERT (OST_DESTROY == 6);
637         LASSERT (OST_GET_INFO == 7);
638         LASSERT (OST_CONNECT == 8);
639         LASSERT (OST_DISCONNECT == 9);
640         LASSERT (OST_PUNCH == 10);
641         LASSERT (OST_OPEN == 11);
642         LASSERT (OST_CLOSE == 12);
643         LASSERT (OST_STATFS == 13);
644         LASSERT (OST_SAN_READ == 14);
645         LASSERT (OST_SAN_WRITE == 15);
646         LASSERT (OST_SYNC == 16);
647         LASSERT (OST_LAST_OPC == 17);
648         LASSERT (OST_FIRST_OPC == 0);
649         LASSERT (OBD_FL_INLINEDATA == 1);
650         LASSERT (OBD_FL_OBDMDEXISTS == 2);
651         LASSERT (LOV_MAGIC == 198183888);
652         LASSERT (OBD_MD_FLALL == -1);
653         LASSERT (OBD_MD_FLID == 1);
654         LASSERT (OBD_MD_FLATIME == 2);
655         LASSERT (OBD_MD_FLMTIME == 4);
656         LASSERT (OBD_MD_FLCTIME == 8);
657         LASSERT (OBD_MD_FLSIZE == 16);
658         LASSERT (OBD_MD_FLBLOCKS == 32);
659         LASSERT (OBD_MD_FLBLKSZ == 64);
660         LASSERT (OBD_MD_FLMODE == 128);
661         LASSERT (OBD_MD_FLTYPE == 256);
662         LASSERT (OBD_MD_FLUID == 512);
663         LASSERT (OBD_MD_FLGID == 1024);
664         LASSERT (OBD_MD_FLFLAGS == 2048);
665         LASSERT (OBD_MD_FLOBDFLG == 4096);
666         LASSERT (OBD_MD_FLNLINK == 8192);
667         LASSERT (OBD_MD_FLGENER == 16384);
668         LASSERT (OBD_MD_FLINLINE == 32768);
669         LASSERT (OBD_MD_FLRDEV == 65536);
670         LASSERT (OBD_MD_FLEASIZE == 131072);
671         LASSERT (OBD_MD_LINKNAME == 262144);
672         LASSERT (OBD_MD_FLHANDLE == 524288);
673         LASSERT (OBD_MD_FLCKSUM == 1048576);
674         LASSERT (OBD_BRW_READ == 1);
675         LASSERT (OBD_BRW_WRITE == 2);
676         LASSERT (OBD_BRW_CREATE == 4);
677         LASSERT (OBD_BRW_SYNC == 8);
678         LASSERT (OBD_OBJECT_EOF == 0xffffffffffffffffULL);
679         LASSERT (OST_REQ_HAS_OA1 == 1);
680         LASSERT (MDS_GETATTR == 33);
681         LASSERT (MDS_GETATTR_NAME == 34);
682         LASSERT (MDS_CLOSE == 35);
683         LASSERT (MDS_REINT == 36);
684         LASSERT (MDS_READPAGE == 37);
685         LASSERT (MDS_CONNECT == 38);
686         LASSERT (MDS_DISCONNECT == 39);
687         LASSERT (MDS_GETSTATUS == 40);
688         LASSERT (MDS_STATFS == 41);
689         LASSERT (MDS_GETLOVINFO == 42);
690         LASSERT (MDS_LAST_OPC == 43);
691         LASSERT (MDS_FIRST_OPC == 33);
692         LASSERT (REINT_SETATTR == 1);
693         LASSERT (REINT_CREATE == 2);
694         LASSERT (REINT_LINK == 3);
695         LASSERT (REINT_UNLINK == 4);
696         LASSERT (REINT_RENAME == 5);
697         LASSERT (REINT_OPEN == 6);
698         LASSERT (REINT_MAX == 6);
699         LASSERT (DISP_IT_EXECD == 1);
700         LASSERT (DISP_LOOKUP_EXECD == 2);
701         LASSERT (DISP_LOOKUP_NEG == 4);
702         LASSERT (DISP_LOOKUP_POS == 8);
703         LASSERT (DISP_OPEN_CREATE == 16);
704         LASSERT (DISP_OPEN_OPEN == 32);
705         LASSERT (MDS_STATUS_CONN == 1);
706         LASSERT (MDS_STATUS_LOV == 2);
707         LASSERT (MDS_OPEN_HAS_EA == (1 << 30));
708         LASSERT (LOV_RAID0 == 0);
709         LASSERT (LOV_RAIDRR == 1);
710         LASSERT (LDLM_ENQUEUE == 101);
711         LASSERT (LDLM_CONVERT == 102);
712         LASSERT (LDLM_CANCEL == 103);
713         LASSERT (LDLM_BL_CALLBACK == 104);
714         LASSERT (LDLM_CP_CALLBACK == 105);
715         LASSERT (LDLM_LAST_OPC == 106);
716         LASSERT (LDLM_FIRST_OPC == 101);
717         LASSERT (PTLBD_QUERY == 200);
718         LASSERT (PTLBD_READ == 201);
719         LASSERT (PTLBD_WRITE == 202);
720         LASSERT (PTLBD_FLUSH == 203);
721         LASSERT (PTLBD_CONNECT == 204);
722         LASSERT (PTLBD_DISCONNECT == 205);
723         LASSERT (PTLBD_LAST_OPC == 204);
724         LASSERT (PTLBD_FIRST_OPC == 200);
725         LASSERT (OBD_PING == 400);
726         /* Sizes and Offsets */
727
728
729         /* Checks for struct lustre_handle */
730         LASSERT (sizeof (struct lustre_handle) == 8);
731         LASSERT (offsetof (struct lustre_handle, cookie) == 0);
732         LASSERT (sizeof (((struct lustre_handle *)0)->cookie) == 8);
733
734         /* Checks for struct lustre_msg */
735         LASSERT (sizeof (struct lustre_msg) == 60);
736         LASSERT (offsetof (struct lustre_msg, handle) == 0);
737         LASSERT (sizeof (((struct lustre_msg *)0)->handle) == 8);
738         LASSERT (offsetof (struct lustre_msg, magic) == 8);
739         LASSERT (sizeof (((struct lustre_msg *)0)->magic) == 4);
740         LASSERT (offsetof (struct lustre_msg, type) == 12);
741         LASSERT (sizeof (((struct lustre_msg *)0)->type) == 4);
742         LASSERT (offsetof (struct lustre_msg, version) == 16);
743         LASSERT (sizeof (((struct lustre_msg *)0)->version) == 4);
744         LASSERT (offsetof (struct lustre_msg, opc) == 20);
745         LASSERT (sizeof (((struct lustre_msg *)0)->opc) == 4);
746         LASSERT (offsetof (struct lustre_msg, last_xid) == 24);
747         LASSERT (sizeof (((struct lustre_msg *)0)->last_xid) == 8);
748         LASSERT (offsetof (struct lustre_msg, last_committed) == 32);
749         LASSERT (sizeof (((struct lustre_msg *)0)->last_committed) == 8);
750         LASSERT (offsetof (struct lustre_msg, transno) == 40);
751         LASSERT (sizeof (((struct lustre_msg *)0)->transno) == 8);
752         LASSERT (offsetof (struct lustre_msg, status) == 48);
753         LASSERT (sizeof (((struct lustre_msg *)0)->status) == 4);
754         LASSERT (offsetof (struct lustre_msg, flags) == 52);
755         LASSERT (sizeof (((struct lustre_msg *)0)->flags) == 4);
756         LASSERT (offsetof (struct lustre_msg, bufcount) == 56);
757         LASSERT (sizeof (((struct lustre_msg *)0)->bufcount) == 4);
758         LASSERT (offsetof (struct lustre_msg, buflens[7]) == 88);
759         LASSERT (sizeof (((struct lustre_msg *)0)->buflens[7]) == 4);
760
761         /* Checks for struct obdo */
762         LASSERT (sizeof (struct obdo) == 164);
763         LASSERT (offsetof (struct obdo, o_id) == 0);
764         LASSERT (sizeof (((struct obdo *)0)->o_id) == 8);
765         LASSERT (offsetof (struct obdo, o_gr) == 8);
766         LASSERT (sizeof (((struct obdo *)0)->o_gr) == 8);
767         LASSERT (offsetof (struct obdo, o_atime) == 16);
768         LASSERT (sizeof (((struct obdo *)0)->o_atime) == 8);
769         LASSERT (offsetof (struct obdo, o_mtime) == 24);
770         LASSERT (sizeof (((struct obdo *)0)->o_mtime) == 8);
771         LASSERT (offsetof (struct obdo, o_ctime) == 32);
772         LASSERT (sizeof (((struct obdo *)0)->o_ctime) == 8);
773         LASSERT (offsetof (struct obdo, o_size) == 40);
774         LASSERT (sizeof (((struct obdo *)0)->o_size) == 8);
775         LASSERT (offsetof (struct obdo, o_blocks) == 48);
776         LASSERT (sizeof (((struct obdo *)0)->o_blocks) == 8);
777         LASSERT (offsetof (struct obdo, o_rdev) == 56);
778         LASSERT (sizeof (((struct obdo *)0)->o_rdev) == 8);
779         LASSERT (offsetof (struct obdo, o_blksize) == 64);
780         LASSERT (sizeof (((struct obdo *)0)->o_blksize) == 4);
781         LASSERT (offsetof (struct obdo, o_mode) == 68);
782         LASSERT (sizeof (((struct obdo *)0)->o_mode) == 4);
783         LASSERT (offsetof (struct obdo, o_uid) == 72);
784         LASSERT (sizeof (((struct obdo *)0)->o_uid) == 4);
785         LASSERT (offsetof (struct obdo, o_gid) == 76);
786         LASSERT (sizeof (((struct obdo *)0)->o_gid) == 4);
787         LASSERT (offsetof (struct obdo, o_flags) == 80);
788         LASSERT (sizeof (((struct obdo *)0)->o_flags) == 4);
789         LASSERT (offsetof (struct obdo, o_nlink) == 84);
790         LASSERT (sizeof (((struct obdo *)0)->o_nlink) == 4);
791         LASSERT (offsetof (struct obdo, o_generation) == 88);
792         LASSERT (sizeof (((struct obdo *)0)->o_generation) == 4);
793         LASSERT (offsetof (struct obdo, o_valid) == 92);
794         LASSERT (sizeof (((struct obdo *)0)->o_valid) == 4);
795         LASSERT (offsetof (struct obdo, o_obdflags) == 96);
796         LASSERT (sizeof (((struct obdo *)0)->o_obdflags) == 4);
797         LASSERT (offsetof (struct obdo, o_easize) == 100);
798         LASSERT (sizeof (((struct obdo *)0)->o_easize) == 4);
799         LASSERT (offsetof (struct obdo, o_inline) == 104);
800         LASSERT (sizeof (((struct obdo *)0)->o_inline) == 60);
801
802         /* Checks for struct obd_statfs */
803         LASSERT (sizeof (struct obd_statfs) == 144);
804         LASSERT (offsetof (struct obd_statfs, os_type) == 0);
805         LASSERT (sizeof (((struct obd_statfs *)0)->os_type) == 8);
806         LASSERT (offsetof (struct obd_statfs, os_blocks) == 8);
807         LASSERT (sizeof (((struct obd_statfs *)0)->os_blocks) == 8);
808         LASSERT (offsetof (struct obd_statfs, os_bfree) == 16);
809         LASSERT (sizeof (((struct obd_statfs *)0)->os_bfree) == 8);
810         LASSERT (offsetof (struct obd_statfs, os_bavail) == 24);
811         LASSERT (sizeof (((struct obd_statfs *)0)->os_bavail) == 8);
812         LASSERT (offsetof (struct obd_statfs, os_ffree) == 40);
813         LASSERT (sizeof (((struct obd_statfs *)0)->os_ffree) == 8);
814         LASSERT (offsetof (struct obd_statfs, os_fsid) == 48);
815         LASSERT (sizeof (((struct obd_statfs *)0)->os_fsid) == 40);
816         LASSERT (offsetof (struct obd_statfs, os_bsize) == 88);
817         LASSERT (sizeof (((struct obd_statfs *)0)->os_bsize) == 4);
818         LASSERT (offsetof (struct obd_statfs, os_namelen) == 92);
819         LASSERT (sizeof (((struct obd_statfs *)0)->os_namelen) == 4);
820
821         /* Checks for struct obd_ioobj */
822         LASSERT (sizeof (struct obd_ioobj) == 24);
823         LASSERT (offsetof (struct obd_ioobj, ioo_id) == 0);
824         LASSERT (sizeof (((struct obd_ioobj *)0)->ioo_id) == 8);
825         LASSERT (offsetof (struct obd_ioobj, ioo_gr) == 8);
826         LASSERT (sizeof (((struct obd_ioobj *)0)->ioo_gr) == 8);
827         LASSERT (offsetof (struct obd_ioobj, ioo_type) == 16);
828         LASSERT (sizeof (((struct obd_ioobj *)0)->ioo_type) == 4);
829         LASSERT (offsetof (struct obd_ioobj, ioo_bufcnt) == 20);
830         LASSERT (sizeof (((struct obd_ioobj *)0)->ioo_bufcnt) == 4);
831
832         /* Checks for struct niobuf_remote */
833         LASSERT (sizeof (struct niobuf_remote) == 16);
834         LASSERT (offsetof (struct niobuf_remote, offset) == 0);
835         LASSERT (sizeof (((struct niobuf_remote *)0)->offset) == 8);
836         LASSERT (offsetof (struct niobuf_remote, len) == 8);
837         LASSERT (sizeof (((struct niobuf_remote *)0)->len) == 4);
838         LASSERT (offsetof (struct niobuf_remote, flags) == 12);
839         LASSERT (sizeof (((struct niobuf_remote *)0)->flags) == 4);
840
841         /* Checks for struct ost_body */
842         LASSERT (sizeof (struct ost_body) == 164);
843         LASSERT (offsetof (struct ost_body, oa) == 0);
844         LASSERT (sizeof (((struct ost_body *)0)->oa) == 164);
845
846         /* Checks for struct ll_fid */
847         LASSERT (sizeof (struct ll_fid) == 16);
848         LASSERT (offsetof (struct ll_fid, id) == 0);
849         LASSERT (sizeof (((struct ll_fid *)0)->id) == 8);
850         LASSERT (offsetof (struct ll_fid, generation) == 8);
851         LASSERT (sizeof (((struct ll_fid *)0)->generation) == 4);
852         LASSERT (offsetof (struct ll_fid, f_type) == 12);
853         LASSERT (sizeof (((struct ll_fid *)0)->f_type) == 4);
854
855         /* Checks for struct mds_status_req */
856         LASSERT (sizeof (struct mds_status_req) == 8);
857         LASSERT (offsetof (struct mds_status_req, flags) == 0);
858         LASSERT (sizeof (((struct mds_status_req *)0)->flags) == 4);
859         LASSERT (offsetof (struct mds_status_req, repbuf) == 4);
860         LASSERT (sizeof (((struct mds_status_req *)0)->repbuf) == 4);
861
862         /* Checks for struct mds_body */
863         LASSERT (sizeof (struct mds_body) == 124);
864         LASSERT (offsetof (struct mds_body, fid1) == 0);
865         LASSERT (sizeof (((struct mds_body *)0)->fid1) == 16);
866         LASSERT (offsetof (struct mds_body, fid2) == 16);
867         LASSERT (sizeof (((struct mds_body *)0)->fid2) == 16);
868         LASSERT (offsetof (struct mds_body, handle) == 32);
869         LASSERT (sizeof (((struct mds_body *)0)->handle) == 8);
870         LASSERT (offsetof (struct mds_body, size) == 40);
871         LASSERT (sizeof (((struct mds_body *)0)->size) == 8);
872         LASSERT (offsetof (struct mds_body, blocks) == 48);
873         LASSERT (sizeof (((struct mds_body *)0)->blocks) == 8);
874         LASSERT (offsetof (struct mds_body, ino) == 56);
875         LASSERT (sizeof (((struct mds_body *)0)->ino) == 4);
876         LASSERT (offsetof (struct mds_body, valid) == 60);
877         LASSERT (sizeof (((struct mds_body *)0)->valid) == 4);
878         LASSERT (offsetof (struct mds_body, fsuid) == 64);
879         LASSERT (sizeof (((struct mds_body *)0)->fsuid) == 4);
880         LASSERT (offsetof (struct mds_body, fsgid) == 68);
881         LASSERT (sizeof (((struct mds_body *)0)->fsgid) == 4);
882         LASSERT (offsetof (struct mds_body, capability) == 72);
883         LASSERT (sizeof (((struct mds_body *)0)->capability) == 4);
884         LASSERT (offsetof (struct mds_body, mode) == 76);
885         LASSERT (sizeof (((struct mds_body *)0)->mode) == 4);
886         LASSERT (offsetof (struct mds_body, uid) == 80);
887         LASSERT (sizeof (((struct mds_body *)0)->uid) == 4);
888         LASSERT (offsetof (struct mds_body, gid) == 84);
889         LASSERT (sizeof (((struct mds_body *)0)->gid) == 4);
890         LASSERT (offsetof (struct mds_body, mtime) == 88);
891         LASSERT (sizeof (((struct mds_body *)0)->mtime) == 4);
892         LASSERT (offsetof (struct mds_body, ctime) == 92);
893         LASSERT (sizeof (((struct mds_body *)0)->ctime) == 4);
894         LASSERT (offsetof (struct mds_body, atime) == 96);
895         LASSERT (sizeof (((struct mds_body *)0)->atime) == 4);
896         LASSERT (offsetof (struct mds_body, flags) == 100);
897         LASSERT (sizeof (((struct mds_body *)0)->flags) == 4);
898         LASSERT (offsetof (struct mds_body, rdev) == 104);
899         LASSERT (sizeof (((struct mds_body *)0)->rdev) == 4);
900         LASSERT (offsetof (struct mds_body, nlink) == 108);
901         LASSERT (sizeof (((struct mds_body *)0)->nlink) == 4);
902         LASSERT (offsetof (struct mds_body, generation) == 112);
903         LASSERT (sizeof (((struct mds_body *)0)->generation) == 4);
904         LASSERT (offsetof (struct mds_body, suppgid) == 116);
905         LASSERT (sizeof (((struct mds_body *)0)->suppgid) == 4);
906
907         /* Checks for struct mds_rec_setattr */
908         LASSERT (sizeof (struct mds_rec_setattr) == 92);
909         LASSERT (offsetof (struct mds_rec_setattr, sa_opcode) == 0);
910         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_opcode) == 4);
911         LASSERT (offsetof (struct mds_rec_setattr, sa_fsuid) == 4);
912         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_fsuid) == 4);
913         LASSERT (offsetof (struct mds_rec_setattr, sa_fsgid) == 8);
914         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_fsgid) == 4);
915         LASSERT (offsetof (struct mds_rec_setattr, sa_cap) == 12);
916         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_cap) == 4);
917         LASSERT (offsetof (struct mds_rec_setattr, sa_reserved) == 16);
918         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_reserved) == 4);
919         LASSERT (offsetof (struct mds_rec_setattr, sa_valid) == 20);
920         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_valid) == 4);
921         LASSERT (offsetof (struct mds_rec_setattr, sa_fid) == 24);
922         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_fid) == 16);
923         LASSERT (offsetof (struct mds_rec_setattr, sa_mode) == 40);
924         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_mode) == 4);
925         LASSERT (offsetof (struct mds_rec_setattr, sa_uid) == 44);
926         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_uid) == 4);
927         LASSERT (offsetof (struct mds_rec_setattr, sa_gid) == 48);
928         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_gid) == 4);
929         LASSERT (offsetof (struct mds_rec_setattr, sa_attr_flags) == 52);
930         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_attr_flags) == 4);
931         LASSERT (offsetof (struct mds_rec_setattr, sa_size) == 56);
932         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_size) == 8);
933         LASSERT (offsetof (struct mds_rec_setattr, sa_atime) == 64);
934         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_atime) == 8);
935         LASSERT (offsetof (struct mds_rec_setattr, sa_mtime) == 72);
936         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_mtime) == 8);
937         LASSERT (offsetof (struct mds_rec_setattr, sa_ctime) == 80);
938         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_ctime) == 8);
939         LASSERT (offsetof (struct mds_rec_setattr, sa_suppgid) == 88);
940         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_suppgid) == 4);
941
942         /* Checks for struct mds_rec_create */
943         LASSERT (sizeof (struct mds_rec_create) == 84);
944         LASSERT (offsetof (struct mds_rec_create, cr_opcode) == 0);
945         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_opcode) == 4);
946         LASSERT (offsetof (struct mds_rec_create, cr_fsuid) == 4);
947         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_fsuid) == 4);
948         LASSERT (offsetof (struct mds_rec_create, cr_fsgid) == 8);
949         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_fsgid) == 4);
950         LASSERT (offsetof (struct mds_rec_create, cr_cap) == 12);
951         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_cap) == 4);
952         LASSERT (offsetof (struct mds_rec_create, cr_flags) == 16);
953         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_flags) == 4);
954         LASSERT (offsetof (struct mds_rec_create, cr_mode) == 20);
955         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_mode) == 4);
956         LASSERT (offsetof (struct mds_rec_create, cr_fid) == 24);
957         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_fid) == 16);
958         LASSERT (offsetof (struct mds_rec_create, cr_replayfid) == 40);
959         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_replayfid) == 16);
960         LASSERT (offsetof (struct mds_rec_create, cr_uid) == 56);
961         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_uid) == 4);
962         LASSERT (offsetof (struct mds_rec_create, cr_gid) == 60);
963         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_gid) == 4);
964         LASSERT (offsetof (struct mds_rec_create, cr_time) == 64);
965         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_time) == 8);
966         LASSERT (offsetof (struct mds_rec_create, cr_rdev) == 72);
967         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_rdev) == 8);
968         LASSERT (offsetof (struct mds_rec_create, cr_suppgid) == 80);
969         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_suppgid) == 4);
970
971         /* Checks for struct mds_rec_link */
972         LASSERT (sizeof (struct mds_rec_link) == 56);
973         LASSERT (offsetof (struct mds_rec_link, lk_opcode) == 0);
974         LASSERT (sizeof (((struct mds_rec_link *)0)->lk_opcode) == 4);
975         LASSERT (offsetof (struct mds_rec_link, lk_fsuid) == 4);
976         LASSERT (sizeof (((struct mds_rec_link *)0)->lk_fsuid) == 4);
977         LASSERT (offsetof (struct mds_rec_link, lk_fsgid) == 8);
978         LASSERT (sizeof (((struct mds_rec_link *)0)->lk_fsgid) == 4);
979         LASSERT (offsetof (struct mds_rec_link, lk_cap) == 12);
980         LASSERT (sizeof (((struct mds_rec_link *)0)->lk_cap) == 4);
981         LASSERT (offsetof (struct mds_rec_link, lk_suppgid1) == 16);
982         LASSERT (sizeof (((struct mds_rec_link *)0)->lk_suppgid1) == 4);
983         LASSERT (offsetof (struct mds_rec_link, lk_suppgid2) == 20);
984         LASSERT (sizeof (((struct mds_rec_link *)0)->lk_suppgid2) == 4);
985         LASSERT (offsetof (struct mds_rec_link, lk_fid1) == 24);
986         LASSERT (sizeof (((struct mds_rec_link *)0)->lk_fid1) == 16);
987         LASSERT (offsetof (struct mds_rec_link, lk_fid2) == 40);
988         LASSERT (sizeof (((struct mds_rec_link *)0)->lk_fid2) == 16);
989
990         /* Checks for struct mds_rec_unlink */
991         LASSERT (sizeof (struct mds_rec_unlink) == 60);
992         LASSERT (offsetof (struct mds_rec_unlink, ul_opcode) == 0);
993         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_opcode) == 4);
994         LASSERT (offsetof (struct mds_rec_unlink, ul_fsuid) == 4);
995         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_fsuid) == 4);
996         LASSERT (offsetof (struct mds_rec_unlink, ul_fsgid) == 8);
997         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_fsgid) == 4);
998         LASSERT (offsetof (struct mds_rec_unlink, ul_cap) == 12);
999         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_cap) == 4);
1000         LASSERT (offsetof (struct mds_rec_unlink, ul_reserved) == 16);
1001         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_reserved) == 4);
1002         LASSERT (offsetof (struct mds_rec_unlink, ul_mode) == 20);
1003         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_mode) == 4);
1004         LASSERT (offsetof (struct mds_rec_unlink, ul_suppgid) == 24);
1005         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_suppgid) == 4);
1006         LASSERT (offsetof (struct mds_rec_unlink, ul_fid1) == 28);
1007         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_fid1) == 16);
1008         LASSERT (offsetof (struct mds_rec_unlink, ul_fid2) == 44);
1009         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_fid2) == 16);
1010
1011         /* Checks for struct mds_rec_rename */
1012         LASSERT (sizeof (struct mds_rec_rename) == 56);
1013         LASSERT (offsetof (struct mds_rec_rename, rn_opcode) == 0);
1014         LASSERT (sizeof (((struct mds_rec_rename *)0)->rn_opcode) == 4);
1015         LASSERT (offsetof (struct mds_rec_rename, rn_fsuid) == 4);
1016         LASSERT (sizeof (((struct mds_rec_rename *)0)->rn_fsuid) == 4);
1017         LASSERT (offsetof (struct mds_rec_rename, rn_fsgid) == 8);
1018         LASSERT (sizeof (((struct mds_rec_rename *)0)->rn_fsgid) == 4);
1019         LASSERT (offsetof (struct mds_rec_rename, rn_cap) == 12);
1020         LASSERT (sizeof (((struct mds_rec_rename *)0)->rn_cap) == 4);
1021         LASSERT (offsetof (struct mds_rec_rename, rn_suppgid1) == 16);
1022         LASSERT (sizeof (((struct mds_rec_rename *)0)->rn_suppgid1) == 4);
1023         LASSERT (offsetof (struct mds_rec_rename, rn_suppgid2) == 20);
1024         LASSERT (sizeof (((struct mds_rec_rename *)0)->rn_suppgid2) == 4);
1025         LASSERT (offsetof (struct mds_rec_rename, rn_fid1) == 24);
1026         LASSERT (sizeof (((struct mds_rec_rename *)0)->rn_fid1) == 16);
1027         LASSERT (offsetof (struct mds_rec_rename, rn_fid2) == 40);
1028         LASSERT (sizeof (((struct mds_rec_rename *)0)->rn_fid2) == 16);
1029
1030         /* Checks for struct lov_desc */
1031         LASSERT (sizeof (struct lov_desc) == 72);
1032         LASSERT (offsetof (struct lov_desc, ld_tgt_count) == 0);
1033         LASSERT (sizeof (((struct lov_desc *)0)->ld_tgt_count) == 4);
1034         LASSERT (offsetof (struct lov_desc, ld_active_tgt_count) == 4);
1035         LASSERT (sizeof (((struct lov_desc *)0)->ld_active_tgt_count) == 4);
1036         LASSERT (offsetof (struct lov_desc, ld_default_stripe_count) == 8);
1037         LASSERT (sizeof (((struct lov_desc *)0)->ld_default_stripe_count) == 4);
1038         LASSERT (offsetof (struct lov_desc, ld_default_stripe_size) == 12);
1039         LASSERT (sizeof (((struct lov_desc *)0)->ld_default_stripe_size) == 8);
1040         LASSERT (offsetof (struct lov_desc, ld_default_stripe_offset) == 20);
1041         LASSERT (sizeof (((struct lov_desc *)0)->ld_default_stripe_offset) == 8);
1042         LASSERT (offsetof (struct lov_desc, ld_pattern) == 28);
1043         LASSERT (sizeof (((struct lov_desc *)0)->ld_pattern) == 4);
1044         LASSERT (offsetof (struct lov_desc, ld_uuid) == 32);
1045         LASSERT (sizeof (((struct lov_desc *)0)->ld_uuid) == 37);
1046
1047         /* Checks for struct ldlm_res_id */
1048         LASSERT (sizeof (struct ldlm_res_id) == 24);
1049         LASSERT (offsetof (struct ldlm_res_id, name[3]) == 24);
1050         LASSERT (sizeof (((struct ldlm_res_id *)0)->name[3]) == 8);
1051
1052         /* Checks for struct ldlm_data */
1053         LASSERT (sizeof (struct ldlm_data) == 16);
1054         LASSERT (offsetof (struct ldlm_data, l_extent.start) == 0);
1055         LASSERT (sizeof (((struct ldlm_data *)0)->l_extent.start) == 8);
1056         LASSERT (offsetof (struct ldlm_data, l_extent.end) == 8);
1057         LASSERT (sizeof (((struct ldlm_data *)0)->l_extent.end) == 8);
1058         LASSERT (sizeof (((struct ldlm_data *)0)->l_flock.pid) == 4);
1059         LASSERT (offsetof (struct ldlm_data, l_flock.pid) == 16);
1060
1061         /* Checks for struct ldlm_intent */
1062         LASSERT (sizeof (struct ldlm_intent) == 8);
1063         LASSERT (offsetof (struct ldlm_intent, opc) == 0);
1064         LASSERT (sizeof (((struct ldlm_intent *)0)->opc) == 8);
1065
1066         /* Checks for struct ldlm_resource_desc */
1067         LASSERT (sizeof (struct ldlm_resource_desc) == 44);
1068         LASSERT (offsetof (struct ldlm_resource_desc, lr_type) == 0);
1069         LASSERT (sizeof (((struct ldlm_resource_desc *)0)->lr_type) == 4);
1070         LASSERT (offsetof (struct ldlm_resource_desc, lr_name) == 4);
1071         LASSERT (sizeof (((struct ldlm_resource_desc *)0)->lr_name) == 24);
1072         LASSERT (offsetof (struct ldlm_resource_desc, lr_version[4]) == 44);
1073         LASSERT (sizeof (((struct ldlm_resource_desc *)0)->lr_version[4]) == 4);
1074
1075         /* Checks for struct ldlm_lock_desc */
1076         LASSERT (sizeof (struct ldlm_lock_desc) == 84);
1077         LASSERT (offsetof (struct ldlm_lock_desc, l_resource) == 0);
1078         LASSERT (sizeof (((struct ldlm_lock_desc *)0)->l_resource) == 44);
1079         LASSERT (offsetof (struct ldlm_lock_desc, l_req_mode) == 44);
1080         LASSERT (sizeof (((struct ldlm_lock_desc *)0)->l_req_mode) == 4);
1081         LASSERT (offsetof (struct ldlm_lock_desc, l_granted_mode) == 48);
1082         LASSERT (sizeof (((struct ldlm_lock_desc *)0)->l_granted_mode) == 4);
1083         LASSERT (offsetof (struct ldlm_lock_desc, l_extent) == 52);
1084         LASSERT (sizeof (((struct ldlm_lock_desc *)0)->l_extent) == 16);
1085         LASSERT (offsetof (struct ldlm_lock_desc, l_version[4]) == 84);
1086         LASSERT (sizeof (((struct ldlm_lock_desc *)0)->l_version[4]) == 4);
1087
1088         /* Checks for struct ldlm_request */
1089         LASSERT (sizeof (struct ldlm_request) == 104);
1090         LASSERT (offsetof (struct ldlm_request, lock_flags) == 0);
1091         LASSERT (sizeof (((struct ldlm_request *)0)->lock_flags) == 4);
1092         LASSERT (offsetof (struct ldlm_request, lock_desc) == 4);
1093         LASSERT (sizeof (((struct ldlm_request *)0)->lock_desc) == 84);
1094         LASSERT (offsetof (struct ldlm_request, lock_handle1) == 88);
1095         LASSERT (sizeof (((struct ldlm_request *)0)->lock_handle1) == 8);
1096         LASSERT (offsetof (struct ldlm_request, lock_handle2) == 96);
1097         LASSERT (sizeof (((struct ldlm_request *)0)->lock_handle2) == 8);
1098
1099         /* Checks for struct ldlm_reply */
1100         LASSERT (sizeof (struct ldlm_reply) == 72);
1101         LASSERT (offsetof (struct ldlm_reply, lock_flags) == 0);
1102         LASSERT (sizeof (((struct ldlm_reply *)0)->lock_flags) == 4);
1103         LASSERT (offsetof (struct ldlm_reply, lock_mode) == 4);
1104         LASSERT (sizeof (((struct ldlm_reply *)0)->lock_mode) == 4);
1105         LASSERT (offsetof (struct ldlm_reply, lock_resource_name) == 8);
1106         LASSERT (sizeof (((struct ldlm_reply *)0)->lock_resource_name) == 24);
1107         LASSERT (offsetof (struct ldlm_reply, lock_handle) == 32);
1108         LASSERT (sizeof (((struct ldlm_reply *)0)->lock_handle) == 8);
1109         LASSERT (offsetof (struct ldlm_reply, lock_extent) == 40);
1110         LASSERT (sizeof (((struct ldlm_reply *)0)->lock_extent) == 16);
1111         LASSERT (offsetof (struct ldlm_reply, lock_policy_res1) == 56);
1112         LASSERT (sizeof (((struct ldlm_reply *)0)->lock_policy_res1) == 8);
1113         LASSERT (offsetof (struct ldlm_reply, lock_policy_res2) == 64);
1114         LASSERT (sizeof (((struct ldlm_reply *)0)->lock_policy_res2) == 8);
1115
1116         /* Checks for struct ptlbd_op */
1117         LASSERT (sizeof (struct ptlbd_op) == 12);
1118         LASSERT (offsetof (struct ptlbd_op, op_cmd) == 0);
1119         LASSERT (sizeof (((struct ptlbd_op *)0)->op_cmd) == 2);
1120         LASSERT (offsetof (struct ptlbd_op, op_lun) == 2);
1121         LASSERT (sizeof (((struct ptlbd_op *)0)->op_lun) == 2);
1122         LASSERT (offsetof (struct ptlbd_op, op_niob_cnt) == 4);
1123         LASSERT (sizeof (((struct ptlbd_op *)0)->op_niob_cnt) == 2);
1124         LASSERT (offsetof (struct ptlbd_op, op__padding) == 6);
1125         LASSERT (sizeof (((struct ptlbd_op *)0)->op__padding) == 2);
1126         LASSERT (offsetof (struct ptlbd_op, op_block_cnt) == 8);
1127         LASSERT (sizeof (((struct ptlbd_op *)0)->op_block_cnt) == 4);
1128
1129         /* Checks for struct ptlbd_niob */
1130         LASSERT (sizeof (struct ptlbd_niob) == 24);
1131         LASSERT (offsetof (struct ptlbd_niob, n_xid) == 0);
1132         LASSERT (sizeof (((struct ptlbd_niob *)0)->n_xid) == 8);
1133         LASSERT (offsetof (struct ptlbd_niob, n_block_nr) == 8);
1134         LASSERT (sizeof (((struct ptlbd_niob *)0)->n_block_nr) == 8);
1135         LASSERT (offsetof (struct ptlbd_niob, n_offset) == 16);
1136         LASSERT (sizeof (((struct ptlbd_niob *)0)->n_offset) == 4);
1137         LASSERT (offsetof (struct ptlbd_niob, n_length) == 20);
1138         LASSERT (sizeof (((struct ptlbd_niob *)0)->n_length) == 4);
1139
1140         /* Checks for struct ptlbd_rsp */
1141         LASSERT (sizeof (struct ptlbd_rsp) == 4);
1142         LASSERT (offsetof (struct ptlbd_rsp, r_status) == 0);
1143         LASSERT (sizeof (((struct ptlbd_rsp *)0)->r_status) == 2);
1144         LASSERT (offsetof (struct ptlbd_rsp, r_error_cnt) == 2);
1145         LASSERT (sizeof (((struct ptlbd_rsp *)0)->r_error_cnt) == 2);
1146 #endif
1147 }