Whamcloud - gitweb
merge b_devel into HEAD, which will become 0.7.3
[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_pack_msg(int count, int *lens, char **bufs, int *len,
41                     struct lustre_msg **msg)
42 {
43         char *ptr;
44         struct lustre_msg *m;
45         int size = 0, i;
46
47         size = HDR_SIZE (count);
48         for (i = 0; i < count; i++)
49                 size += size_round(lens[i]);
50
51         *len = size;
52
53         OBD_ALLOC(*msg, *len);
54         if (!*msg)
55                 RETURN(-ENOMEM);
56
57         m = *msg;
58         m->magic = PTLRPC_MSG_MAGIC;
59         m->version = PTLRPC_MSG_VERSION;
60         m->bufcount = count;
61         for (i = 0; i < count; i++)
62                 m->buflens[i] = lens[i];
63
64         ptr = (char *)m + HDR_SIZE(count);
65         for (i = 0; i < count; i++) {
66                 char *tmp = NULL;
67                 if (bufs)
68                         tmp = bufs[i];
69                 LOGL(tmp, lens[i], ptr);
70
71         }
72
73         return 0;
74 }
75
76 /* This returns the size of the buffer that is required to hold a lustre_msg
77  * with the given sub-buffer lengths. */
78 int lustre_msg_size(int count, int *lengths)
79 {
80         int size;
81         int i;
82
83         size = HDR_SIZE (count);
84         for (i = 0; i < count; i++)
85                 size += size_round(lengths[i]);
86
87         return size;
88 }
89
90 int lustre_unpack_msg(struct lustre_msg *m, int len)
91 {
92         int   flipped;
93         int   required_len;
94         int   i;
95         ENTRY;
96
97         /* We can provide a slightly better error log, if we check the
98          * message magic and version first.  In the future, struct
99          * lustre_msg may grow, and we'd like to log a version mismatch,
100          * rather than a short message.
101          *
102          */
103         required_len = MAX (offsetof (struct lustre_msg, version) +
104                             sizeof (m->version),
105                             offsetof (struct lustre_msg, magic) +
106                             sizeof (m->magic));
107         if (len < required_len) {
108                 /* can't even look inside the message */
109                 CERROR ("message length %d too small for magic/version check\n",
110                         len);
111                 RETURN (-EINVAL);
112         }
113
114         flipped = lustre_msg_swabbed(m);
115         if (flipped)
116                 __swab32s (&m->version);
117         else if (m->magic != PTLRPC_MSG_MAGIC) {
118                 CERROR("wrong lustre_msg magic %#08x\n", m->magic);
119                 RETURN (-EINVAL);
120         }
121
122         if (m->version != PTLRPC_MSG_VERSION) {
123                 CERROR("wrong lustre_msg version %#08x\n", m->version);
124                 RETURN (-EINVAL);
125         }
126
127         /* Now we know the sender speaks my language (but possibly flipped)...*/
128         required_len = HDR_SIZE(0);
129         if (len < required_len) {
130                 /* can't even look inside the message */
131                 CERROR ("message length %d too small for lustre_msg\n", len);
132                 RETURN (-EINVAL);
133         }
134
135         if (flipped) {
136                 __swab32s (&m->type);
137                 __swab32s (&m->opc);
138                 __swab64s (&m->last_xid);
139                 __swab64s (&m->last_committed);
140                 __swab64s (&m->transno);
141                 __swab32s (&m->status);
142                 __swab32s (&m->bufcount);
143                 __swab32s (&m->flags);
144         }
145
146         required_len = HDR_SIZE(m->bufcount);
147
148         if (len < required_len) {
149                 /* didn't receive all the buffer lengths */
150                 CERROR ("message length %d too small for %d buflens\n",
151                         len, m->bufcount);
152                 RETURN(-EINVAL);
153         }
154
155         for (i = 0; i < m->bufcount; i++) {
156                 if (flipped)
157                         __swab32s (&m->buflens[i]);
158                 required_len += size_round(m->buflens[i]);
159         }
160
161         if (len < required_len) {
162                 CERROR("len: %d, required_len %d\n", len, required_len);
163                 CERROR("bufcount: %d\n", m->bufcount);
164                 for (i = 0; i < m->bufcount; i++)
165                         CERROR("buffer %d length %d\n", i, m->buflens[i]);
166                 RETURN(-EINVAL);
167         }
168
169         RETURN(0);
170 }
171
172 void *lustre_msg_buf(struct lustre_msg *m, int n, int min_size)
173 {
174         int i;
175         int offset;
176         int buflen;
177         int bufcount;
178
179         LASSERT (m != NULL);
180         LASSERT (n >= 0);
181
182         bufcount = m->bufcount;
183         if (n >= bufcount) {
184                 CDEBUG(D_INFO, "msg %p buffer[%d] not present (count %d)\n",
185                        m, n, bufcount);
186                 return NULL;
187         }
188
189         buflen = m->buflens[n];
190         if (buflen < min_size) {
191                 CERROR("msg %p buffer[%d] size %d too small (required %d)\n",
192                        m, n, buflen, min_size);
193                 return NULL;
194         }
195
196         offset = HDR_SIZE(bufcount);
197         for (i = 0; i < n; i++)
198                 offset += size_round(m->buflens[i]);
199
200         return (char *)m + offset;
201 }
202
203 char *lustre_msg_string (struct lustre_msg *m, int index, int max_len)
204 {
205         /* max_len == 0 means the string should fill the buffer */
206         char *str = lustre_msg_buf (m, index, 0);
207         int   slen;
208         int   blen;
209
210         if (str == NULL) {
211                 CERROR ("can't unpack string in msg %p buffer[%d]\n", m, index);
212                 return (NULL);
213         }
214
215         blen = m->buflens[index];
216         slen = strnlen (str, blen);
217
218         if (slen == blen) {                     /* not NULL terminated */
219                 CERROR ("can't unpack non-NULL terminated string in "
220                         "msg %p buffer[%d] len %d\n", m, index, blen);
221                 return (NULL);
222         }
223
224         if (max_len == 0) {
225                 if (slen != blen - 1) {
226                         CERROR ("can't unpack short string in msg %p "
227                                 "buffer[%d] len %d: strlen %d\n",
228                                 m, index, blen, slen);
229                         return (NULL);
230                 }
231         } else if (slen > max_len) {
232                 CERROR ("can't unpack oversized string in msg %p "
233                         "buffer[%d] len %d strlen %d: max %d expected\n",
234                         m, index, blen, slen, max_len);
235                 return (NULL);
236         }
237
238         return (str);
239 }
240
241 /* Wrap up the normal fixed length case */
242 void *lustre_swab_reqbuf (struct ptlrpc_request *req, int index, int min_size,
243                           void *swabber)
244 {
245         void *ptr;
246
247         LASSERT_REQSWAB(req, index);
248
249         ptr = lustre_msg_buf(req->rq_reqmsg, index, min_size);
250         if (ptr == NULL)
251                 return NULL;
252
253         if (swabber != NULL && lustre_msg_swabbed(req->rq_reqmsg))
254                 ((void (*)(void *))swabber)(ptr);
255
256         return ptr;
257 }
258
259 /* Wrap up the normal fixed length case */
260 void *lustre_swab_repbuf (struct ptlrpc_request *req, int index, int min_size,
261                           void *swabber)
262 {
263         void *ptr;
264
265         LASSERT_REPSWAB(req, index);
266
267         ptr = lustre_msg_buf(req->rq_repmsg, index, min_size);
268         if (ptr == NULL)
269                 return NULL;
270
271         if (swabber != NULL && lustre_msg_swabbed(req->rq_repmsg))
272                 ((void (*)(void *))swabber)(ptr);
273
274         return ptr;
275 }
276
277 /* byte flipping routines for all wire types declared in
278  * lustre_idl.h implemented here.
279  */
280
281 void lustre_swab_obdo (struct obdo  *o)
282 {
283         __swab64s (&o->o_id);
284         __swab64s (&o->o_gr);
285         __swab64s (&o->o_atime);
286         __swab64s (&o->o_mtime);
287         __swab64s (&o->o_ctime);
288         __swab64s (&o->o_size);
289         __swab64s (&o->o_blocks);
290         __swab64s (&o->o_rdev);
291         __swab32s (&o->o_blksize);
292         __swab32s (&o->o_mode);
293         __swab32s (&o->o_uid);
294         __swab32s (&o->o_gid);
295         __swab32s (&o->o_flags);
296         __swab32s (&o->o_nlink);
297         __swab32s (&o->o_generation);
298         __swab32s (&o->o_valid);
299         __swab32s (&o->o_obdflags);
300         __swab32s (&o->o_easize);
301         /* o_inline is opaque */
302 }
303
304 void lustre_swab_obd_statfs (struct obd_statfs *os)
305 {
306         __swab64s (&os->os_type);
307         __swab64s (&os->os_blocks);
308         __swab64s (&os->os_bfree);
309         __swab64s (&os->os_bavail);
310         __swab64s (&os->os_ffree);
311         /* no need to swap os_fsid */
312         __swab32s (&os->os_bsize);
313         __swab32s (&os->os_namelen);
314         /* no need to swap os_spare */
315 }
316
317 void lustre_swab_obd_ioobj (struct obd_ioobj *ioo)
318 {
319         __swab64s (&ioo->ioo_id);
320         __swab64s (&ioo->ioo_gr);
321         __swab32s (&ioo->ioo_type);
322         __swab32s (&ioo->ioo_bufcnt);
323 }
324
325 void lustre_swab_niobuf_remote (struct niobuf_remote *nbr)
326 {
327         __swab64s (&nbr->offset);
328         __swab32s (&nbr->len);
329         __swab32s (&nbr->flags);
330 }
331
332 void lustre_swab_ost_body (struct ost_body *b)
333 {
334         lustre_swab_obdo (&b->oa);
335 }
336
337 void lustre_swab_ll_fid (struct ll_fid *fid)
338 {
339         __swab64s (&fid->id);
340         __swab32s (&fid->generation);
341         __swab32s (&fid->f_type);
342 }
343
344 void lustre_swab_mds_status_req (struct mds_status_req *r)
345 {
346         __swab32s (&r->flags);
347         __swab32s (&r->repbuf);
348 }
349
350 void lustre_swab_mds_fileh_body (struct mds_fileh_body *f)
351 {
352         lustre_swab_ll_fid (&f->f_fid);
353 }
354
355 void lustre_swab_mds_body (struct mds_body *b)
356 {
357         lustre_swab_ll_fid (&b->fid1);
358         lustre_swab_ll_fid (&b->fid2);
359         /* handle is opaque */
360         __swab64s (&b->size);
361         __swab64s (&b->blocks);
362         __swab32s (&b->ino);
363         __swab32s (&b->valid);
364         __swab32s (&b->fsuid);
365         __swab32s (&b->fsgid);
366         __swab32s (&b->capability);
367         __swab32s (&b->mode);
368         __swab32s (&b->uid);
369         __swab32s (&b->gid);
370         __swab32s (&b->mtime);
371         __swab32s (&b->ctime);
372         __swab32s (&b->atime);
373         __swab32s (&b->flags);
374         __swab32s (&b->rdev);
375         __swab32s (&b->nlink);
376         __swab32s (&b->generation);
377         __swab32s (&b->suppgid);
378         __swab32s (&b->eadatasize);
379 }
380
381 void lustre_swab_mds_rec_setattr (struct mds_rec_setattr *sa)
382 {
383         __swab32s (&sa->sa_opcode);
384         __swab32s (&sa->sa_fsuid);
385         __swab32s (&sa->sa_fsgid);
386         __swab32s (&sa->sa_cap);
387         __swab32s (&sa->sa_reserved);
388         __swab32s (&sa->sa_valid);
389         lustre_swab_ll_fid (&sa->sa_fid);
390         __swab32s (&sa->sa_mode);
391         __swab32s (&sa->sa_uid);
392         __swab32s (&sa->sa_gid);
393         __swab32s (&sa->sa_attr_flags);
394         __swab64s (&sa->sa_size);
395         __swab64s (&sa->sa_atime);
396         __swab64s (&sa->sa_mtime);
397         __swab64s (&sa->sa_ctime);
398         __swab32s (&sa->sa_suppgid);
399 }
400
401 void lustre_swab_mds_rec_create (struct mds_rec_create *cr)
402 {
403         __swab32s (&cr->cr_opcode);
404         __swab32s (&cr->cr_fsuid);
405         __swab32s (&cr->cr_fsgid);
406         __swab32s (&cr->cr_cap);
407         __swab32s (&cr->cr_flags); /* for use with open */
408         __swab32s (&cr->cr_mode);
409         lustre_swab_ll_fid (&cr->cr_fid);
410         lustre_swab_ll_fid (&cr->cr_replayfid);
411         __swab32s (&cr->cr_uid);
412         __swab32s (&cr->cr_gid);
413         __swab64s (&cr->cr_time);
414         __swab64s (&cr->cr_rdev);
415         __swab32s (&cr->cr_suppgid);
416 }
417
418 void lustre_swab_mds_rec_link (struct mds_rec_link *lk)
419 {
420         __swab32s (&lk->lk_opcode);
421         __swab32s (&lk->lk_fsuid);
422         __swab32s (&lk->lk_fsgid);
423         __swab32s (&lk->lk_cap);
424         __swab32s (&lk->lk_suppgid1);
425         __swab32s (&lk->lk_suppgid2);
426         lustre_swab_ll_fid (&lk->lk_fid1);
427         lustre_swab_ll_fid (&lk->lk_fid2);
428 }
429
430 void lustre_swab_mds_rec_unlink (struct mds_rec_unlink *ul)
431 {
432         __swab32s (&ul->ul_opcode);
433         __swab32s (&ul->ul_fsuid);
434         __swab32s (&ul->ul_fsgid);
435         __swab32s (&ul->ul_cap);
436         __swab32s (&ul->ul_reserved);
437         __swab32s (&ul->ul_mode);
438         __swab32s (&ul->ul_suppgid);
439         lustre_swab_ll_fid (&ul->ul_fid1);
440         lustre_swab_ll_fid (&ul->ul_fid2);
441 }
442
443 void lustre_swab_mds_rec_rename (struct mds_rec_rename *rn)
444 {
445         __swab32s (&rn->rn_opcode);
446         __swab32s (&rn->rn_fsuid);
447         __swab32s (&rn->rn_fsgid);
448         __swab32s (&rn->rn_cap);
449         __swab32s (&rn->rn_suppgid1);
450         __swab32s (&rn->rn_suppgid2);
451         lustre_swab_ll_fid (&rn->rn_fid1);
452         lustre_swab_ll_fid (&rn->rn_fid2);
453 }
454
455 void lustre_swab_lov_desc (struct lov_desc *ld)
456 {
457         __swab32s (&ld->ld_tgt_count);
458         __swab32s (&ld->ld_active_tgt_count);
459         __swab32s (&ld->ld_default_stripe_count);
460         __swab64s (&ld->ld_default_stripe_size);
461         __swab64s (&ld->ld_default_stripe_offset);
462         __swab32s (&ld->ld_pattern);
463         /* uuid endian insensitive */
464 }
465
466 void lustre_swab_ldlm_res_id (struct ldlm_res_id *id)
467 {
468         int  i;
469
470         for (i = 0; i < RES_NAME_SIZE; i++)
471                 __swab64s (&id->name[i]);
472 }
473
474 void lustre_swab_ldlm_extent (struct ldlm_extent *e)
475 {
476         __swab64s (&e->start);
477         __swab64s (&e->end);
478 }
479
480 void lustre_swab_ldlm_intent (struct ldlm_intent *i)
481 {
482         __swab64s (&i->opc);
483 }
484
485 void lustre_swab_ldlm_resource_desc (struct ldlm_resource_desc *r)
486 {
487         int   i;
488
489         __swab32s (&r->lr_type);
490         lustre_swab_ldlm_res_id (&r->lr_name);
491         for (i = 0; i < RES_VERSION_SIZE; i++)
492                 __swab32s (&r->lr_version[i]);
493 }
494
495 void lustre_swab_ldlm_lock_desc (struct ldlm_lock_desc *l)
496 {
497         int   i;
498
499         lustre_swab_ldlm_resource_desc (&l->l_resource);
500         __swab32s (&l->l_req_mode);
501         __swab32s (&l->l_granted_mode);
502         lustre_swab_ldlm_extent (&l->l_extent);
503         for (i = 0; i < RES_VERSION_SIZE; i++)
504                 __swab32s (&l->l_version[i]);
505 }
506
507 void lustre_swab_ldlm_request (struct ldlm_request *rq)
508 {
509         __swab32s (&rq->lock_flags);
510         lustre_swab_ldlm_lock_desc (&rq->lock_desc);
511         /* lock_handle1 opaque */
512         /* lock_handle2 opaque */
513 }
514
515 void lustre_swab_ldlm_reply (struct ldlm_reply *r)
516 {
517         __swab32s (&r->lock_flags);
518         __swab32s (&r->lock_mode);
519         lustre_swab_ldlm_res_id (&r->lock_resource_name);
520         /* lock_handle opaque */
521         lustre_swab_ldlm_extent (&r->lock_extent);
522         __swab64s (&r->lock_policy_res1);
523         __swab64s (&r->lock_policy_res2);
524 }
525
526 void lustre_swab_ptlbd_op (struct ptlbd_op *op)
527 {
528         __swab16s (&op->op_cmd);
529         __swab16s (&op->op_lun);
530         __swab16s (&op->op_niob_cnt);
531         /* ignore op__padding */
532         __swab32s (&op->op_block_cnt);
533 }
534
535 void lustre_swab_ptlbd_niob (struct ptlbd_niob *n)
536 {
537         __swab64s (&n->n_xid);
538         __swab64s (&n->n_block_nr);
539         __swab32s (&n->n_offset);
540         __swab32s (&n->n_length);
541 }
542
543 void lustre_swab_ptlbd_rsp (struct ptlbd_rsp *r)
544 {
545         __swab16s (&r->r_status);
546         __swab16s (&r->r_error_cnt);
547 }
548
549 void lustre_assert_wire_constants (void)
550 {
551 #if BUG_1343
552         /* Wire protocol assertions generated by 'wirecheck' */
553
554         /* Constants... */
555         LASSERT (PTLRPC_MSG_MAGIC == 0x0BD00BD0);
556         LASSERT (PTLRPC_MSG_VERSION == 0x00040002);
557         LASSERT (PTL_RPC_MSG_REQUEST == 4711);
558         LASSERT (PTL_RPC_MSG_ERR == 4712);
559         LASSERT (PTL_RPC_MSG_REPLY == 4713);
560         LASSERT (MSG_LAST_REPLAY == 1);
561         LASSERT (MSG_RESENT == 2);
562         LASSERT (MSG_CONNECT_RECOVERING == 1);
563         LASSERT (MSG_CONNECT_RECONNECT == 2);
564         LASSERT (MSG_CONNECT_REPLAYABLE == 4);
565         LASSERT (OST_REPLY == 0);
566         LASSERT (OST_GETATTR == 1);
567         LASSERT (OST_SETATTR == 2);
568         LASSERT (OST_READ == 3);
569         LASSERT (OST_WRITE == 4);
570         LASSERT (OST_CREATE == 5);
571         LASSERT (OST_DESTROY == 6);
572         LASSERT (OST_GET_INFO == 7);
573         LASSERT (OST_CONNECT == 8);
574         LASSERT (OST_DISCONNECT == 9);
575         LASSERT (OST_PUNCH == 10);
576         LASSERT (OST_OPEN == 11);
577         LASSERT (OST_CLOSE == 12);
578         LASSERT (OST_STATFS == 13);
579         LASSERT (OST_SAN_READ == 14);
580         LASSERT (OST_SAN_WRITE == 15);
581         LASSERT (OST_SYNCFS == 16);
582         LASSERT (OST_LAST_OPC == 17);
583         LASSERT (OST_FIRST_OPC == 0);
584         LASSERT (OBD_FL_INLINEDATA == 1);
585         LASSERT (OBD_FL_OBDMDEXISTS == 2);
586         LASSERT (LOV_MAGIC == 198183888);
587         LASSERT (OBD_MD_FLALL == -1);
588         LASSERT (OBD_MD_FLID == 1);
589         LASSERT (OBD_MD_FLATIME == 2);
590         LASSERT (OBD_MD_FLMTIME == 4);
591         LASSERT (OBD_MD_FLCTIME == 8);
592         LASSERT (OBD_MD_FLSIZE == 16);
593         LASSERT (OBD_MD_FLBLOCKS == 32);
594         LASSERT (OBD_MD_FLBLKSZ == 64);
595         LASSERT (OBD_MD_FLMODE == 128);
596         LASSERT (OBD_MD_FLTYPE == 256);
597         LASSERT (OBD_MD_FLUID == 512);
598         LASSERT (OBD_MD_FLGID == 1024);
599         LASSERT (OBD_MD_FLFLAGS == 2048);
600         LASSERT (OBD_MD_FLOBDFLG == 4096);
601         LASSERT (OBD_MD_FLNLINK == 8192);
602         LASSERT (OBD_MD_FLGENER == 16384);
603         LASSERT (OBD_MD_FLINLINE == 32768);
604         LASSERT (OBD_MD_FLRDEV == 65536);
605         LASSERT (OBD_MD_FLEASIZE == 131072);
606         LASSERT (OBD_MD_LINKNAME == 262144);
607         LASSERT (OBD_MD_FLHANDLE == 524288);
608         LASSERT (OBD_MD_FLCKSUM == 1048576);
609         LASSERT (OBD_BRW_READ == 1);
610         LASSERT (OBD_BRW_WRITE == 2);
611         LASSERT (OBD_BRW_CREATE == 4);
612         LASSERT (OBD_BRW_SYNC == 8);
613         LASSERT (OBD_OBJECT_EOF == 0xffffffffffffffffULL);
614         LASSERT (OST_REQ_HAS_OA1 == 1);
615         LASSERT (MDS_GETATTR == 33);
616         LASSERT (MDS_GETATTR_NAME == 34);
617         LASSERT (MDS_CLOSE == 35);
618         LASSERT (MDS_REINT == 36);
619         LASSERT (MDS_READPAGE == 37);
620         LASSERT (MDS_CONNECT == 38);
621         LASSERT (MDS_DISCONNECT == 39);
622         LASSERT (MDS_GETSTATUS == 40);
623         LASSERT (MDS_STATFS == 41);
624         LASSERT (MDS_GETLOVINFO == 42);
625         LASSERT (MDS_LAST_OPC == 43);
626         LASSERT (MDS_FIRST_OPC == 33);
627         LASSERT (REINT_SETATTR == 1);
628         LASSERT (REINT_CREATE == 2);
629         LASSERT (REINT_LINK == 3);
630         LASSERT (REINT_UNLINK == 4);
631         LASSERT (REINT_RENAME == 5);
632         LASSERT (REINT_OPEN == 6);
633         LASSERT (REINT_MAX == 6);
634         LASSERT (DISP_IT_EXECD == 1);
635         LASSERT (DISP_LOOKUP_EXECD == 2);
636         LASSERT (DISP_LOOKUP_NEG == 4);
637         LASSERT (DISP_LOOKUP_POS == 8);
638         LASSERT (DISP_OPEN_CREATE == 16);
639         LASSERT (DISP_OPEN_OPEN == 32);
640         LASSERT (MDS_STATUS_CONN == 1);
641         LASSERT (MDS_STATUS_LOV == 2);
642         LASSERT (MDS_OPEN_HAS_EA == 1);
643         LASSERT (LOV_RAID0 == 0);
644         LASSERT (LOV_RAIDRR == 1);
645         LASSERT (LDLM_ENQUEUE == 101);
646         LASSERT (LDLM_CONVERT == 102);
647         LASSERT (LDLM_CANCEL == 103);
648         LASSERT (LDLM_BL_CALLBACK == 104);
649         LASSERT (LDLM_CP_CALLBACK == 105);
650         LASSERT (LDLM_LAST_OPC == 106);
651         LASSERT (LDLM_FIRST_OPC == 101);
652         LASSERT (PTLBD_QUERY == 200);
653         LASSERT (PTLBD_READ == 201);
654         LASSERT (PTLBD_WRITE == 202);
655         LASSERT (PTLBD_FLUSH == 203);
656         LASSERT (PTLBD_CONNECT == 204);
657         LASSERT (PTLBD_DISCONNECT == 205);
658         LASSERT (PTLBD_LAST_OPC == 204);
659         LASSERT (PTLBD_FIRST_OPC == 200);
660         LASSERT (OBD_PING == 400);
661         /* Sizes and Offsets */
662
663
664         /* Checks for struct lustre_handle */
665         LASSERT (sizeof (struct lustre_handle) == 8);
666         LASSERT (offsetof (struct lustre_handle, cookie) == 0);
667         LASSERT (sizeof (((struct lustre_handle *)0)->cookie) == 8);
668
669         /* Checks for struct lustre_msg */
670         LASSERT (sizeof (struct lustre_msg) == 60);
671         LASSERT (offsetof (struct lustre_msg, handle) == 0);
672         LASSERT (sizeof (((struct lustre_msg *)0)->handle) == 8);
673         LASSERT (offsetof (struct lustre_msg, magic) == 8);
674         LASSERT (sizeof (((struct lustre_msg *)0)->magic) == 4);
675         LASSERT (offsetof (struct lustre_msg, type) == 12);
676         LASSERT (sizeof (((struct lustre_msg *)0)->type) == 4);
677         LASSERT (offsetof (struct lustre_msg, version) == 16);
678         LASSERT (sizeof (((struct lustre_msg *)0)->version) == 4);
679         LASSERT (offsetof (struct lustre_msg, opc) == 20);
680         LASSERT (sizeof (((struct lustre_msg *)0)->opc) == 4);
681         LASSERT (offsetof (struct lustre_msg, last_xid) == 24);
682         LASSERT (sizeof (((struct lustre_msg *)0)->last_xid) == 8);
683         LASSERT (offsetof (struct lustre_msg, last_committed) == 32);
684         LASSERT (sizeof (((struct lustre_msg *)0)->last_committed) == 8);
685         LASSERT (offsetof (struct lustre_msg, transno) == 40);
686         LASSERT (sizeof (((struct lustre_msg *)0)->transno) == 8);
687         LASSERT (offsetof (struct lustre_msg, status) == 48);
688         LASSERT (sizeof (((struct lustre_msg *)0)->status) == 4);
689         LASSERT (offsetof (struct lustre_msg, flags) == 52);
690         LASSERT (sizeof (((struct lustre_msg *)0)->flags) == 4);
691         LASSERT (offsetof (struct lustre_msg, bufcount) == 56);
692         LASSERT (sizeof (((struct lustre_msg *)0)->bufcount) == 4);
693         LASSERT (offsetof (struct lustre_msg, buflens[7]) == 88);
694         LASSERT (sizeof (((struct lustre_msg *)0)->buflens[7]) == 4);
695
696         /* Checks for struct obdo */
697         LASSERT (sizeof (struct obdo) == 164);
698         LASSERT (offsetof (struct obdo, o_id) == 0);
699         LASSERT (sizeof (((struct obdo *)0)->o_id) == 8);
700         LASSERT (offsetof (struct obdo, o_gr) == 8);
701         LASSERT (sizeof (((struct obdo *)0)->o_gr) == 8);
702         LASSERT (offsetof (struct obdo, o_atime) == 16);
703         LASSERT (sizeof (((struct obdo *)0)->o_atime) == 8);
704         LASSERT (offsetof (struct obdo, o_mtime) == 24);
705         LASSERT (sizeof (((struct obdo *)0)->o_mtime) == 8);
706         LASSERT (offsetof (struct obdo, o_ctime) == 32);
707         LASSERT (sizeof (((struct obdo *)0)->o_ctime) == 8);
708         LASSERT (offsetof (struct obdo, o_size) == 40);
709         LASSERT (sizeof (((struct obdo *)0)->o_size) == 8);
710         LASSERT (offsetof (struct obdo, o_blocks) == 48);
711         LASSERT (sizeof (((struct obdo *)0)->o_blocks) == 8);
712         LASSERT (offsetof (struct obdo, o_rdev) == 56);
713         LASSERT (sizeof (((struct obdo *)0)->o_rdev) == 8);
714         LASSERT (offsetof (struct obdo, o_blksize) == 64);
715         LASSERT (sizeof (((struct obdo *)0)->o_blksize) == 4);
716         LASSERT (offsetof (struct obdo, o_mode) == 68);
717         LASSERT (sizeof (((struct obdo *)0)->o_mode) == 4);
718         LASSERT (offsetof (struct obdo, o_uid) == 72);
719         LASSERT (sizeof (((struct obdo *)0)->o_uid) == 4);
720         LASSERT (offsetof (struct obdo, o_gid) == 76);
721         LASSERT (sizeof (((struct obdo *)0)->o_gid) == 4);
722         LASSERT (offsetof (struct obdo, o_flags) == 80);
723         LASSERT (sizeof (((struct obdo *)0)->o_flags) == 4);
724         LASSERT (offsetof (struct obdo, o_nlink) == 84);
725         LASSERT (sizeof (((struct obdo *)0)->o_nlink) == 4);
726         LASSERT (offsetof (struct obdo, o_generation) == 88);
727         LASSERT (sizeof (((struct obdo *)0)->o_generation) == 4);
728         LASSERT (offsetof (struct obdo, o_valid) == 92);
729         LASSERT (sizeof (((struct obdo *)0)->o_valid) == 4);
730         LASSERT (offsetof (struct obdo, o_obdflags) == 96);
731         LASSERT (sizeof (((struct obdo *)0)->o_obdflags) == 4);
732         LASSERT (offsetof (struct obdo, o_easize) == 100);
733         LASSERT (sizeof (((struct obdo *)0)->o_easize) == 4);
734         LASSERT (offsetof (struct obdo, o_inline) == 104);
735         LASSERT (sizeof (((struct obdo *)0)->o_inline) == 60);
736
737         /* Checks for struct obd_statfs */
738         LASSERT (sizeof (struct obd_statfs) == 144);
739         LASSERT (offsetof (struct obd_statfs, os_type) == 0);
740         LASSERT (sizeof (((struct obd_statfs *)0)->os_type) == 8);
741         LASSERT (offsetof (struct obd_statfs, os_blocks) == 8);
742         LASSERT (sizeof (((struct obd_statfs *)0)->os_blocks) == 8);
743         LASSERT (offsetof (struct obd_statfs, os_bfree) == 16);
744         LASSERT (sizeof (((struct obd_statfs *)0)->os_bfree) == 8);
745         LASSERT (offsetof (struct obd_statfs, os_bavail) == 24);
746         LASSERT (sizeof (((struct obd_statfs *)0)->os_bavail) == 8);
747         LASSERT (offsetof (struct obd_statfs, os_ffree) == 40);
748         LASSERT (sizeof (((struct obd_statfs *)0)->os_ffree) == 8);
749         LASSERT (offsetof (struct obd_statfs, os_fsid) == 48);
750         LASSERT (sizeof (((struct obd_statfs *)0)->os_fsid) == 40);
751         LASSERT (offsetof (struct obd_statfs, os_bsize) == 88);
752         LASSERT (sizeof (((struct obd_statfs *)0)->os_bsize) == 4);
753         LASSERT (offsetof (struct obd_statfs, os_namelen) == 92);
754         LASSERT (sizeof (((struct obd_statfs *)0)->os_namelen) == 4);
755
756         /* Checks for struct obd_ioobj */
757         LASSERT (sizeof (struct obd_ioobj) == 24);
758         LASSERT (offsetof (struct obd_ioobj, ioo_id) == 0);
759         LASSERT (sizeof (((struct obd_ioobj *)0)->ioo_id) == 8);
760         LASSERT (offsetof (struct obd_ioobj, ioo_gr) == 8);
761         LASSERT (sizeof (((struct obd_ioobj *)0)->ioo_gr) == 8);
762         LASSERT (offsetof (struct obd_ioobj, ioo_type) == 16);
763         LASSERT (sizeof (((struct obd_ioobj *)0)->ioo_type) == 4);
764         LASSERT (offsetof (struct obd_ioobj, ioo_bufcnt) == 20);
765         LASSERT (sizeof (((struct obd_ioobj *)0)->ioo_bufcnt) == 4);
766
767         /* Checks for struct niobuf_remote */
768         LASSERT (sizeof (struct niobuf_remote) == 16);
769         LASSERT (offsetof (struct niobuf_remote, offset) == 0);
770         LASSERT (sizeof (((struct niobuf_remote *)0)->offset) == 8);
771         LASSERT (offsetof (struct niobuf_remote, len) == 8);
772         LASSERT (sizeof (((struct niobuf_remote *)0)->len) == 4);
773         LASSERT (offsetof (struct niobuf_remote, flags) == 12);
774         LASSERT (sizeof (((struct niobuf_remote *)0)->flags) == 4);
775
776         /* Checks for struct ost_body */
777         LASSERT (sizeof (struct ost_body) == 164);
778         LASSERT (offsetof (struct ost_body, oa) == 0);
779         LASSERT (sizeof (((struct ost_body *)0)->oa) == 164);
780
781         /* Checks for struct ll_fid */
782         LASSERT (sizeof (struct ll_fid) == 16);
783         LASSERT (offsetof (struct ll_fid, id) == 0);
784         LASSERT (sizeof (((struct ll_fid *)0)->id) == 8);
785         LASSERT (offsetof (struct ll_fid, generation) == 8);
786         LASSERT (sizeof (((struct ll_fid *)0)->generation) == 4);
787         LASSERT (offsetof (struct ll_fid, f_type) == 12);
788         LASSERT (sizeof (((struct ll_fid *)0)->f_type) == 4);
789
790         /* Checks for struct mds_status_req */
791         LASSERT (sizeof (struct mds_status_req) == 8);
792         LASSERT (offsetof (struct mds_status_req, flags) == 0);
793         LASSERT (sizeof (((struct mds_status_req *)0)->flags) == 4);
794         LASSERT (offsetof (struct mds_status_req, repbuf) == 4);
795         LASSERT (sizeof (((struct mds_status_req *)0)->repbuf) == 4);
796
797         /* Checks for struct mds_fileh_body */
798         LASSERT (sizeof (struct mds_fileh_body) == 24);
799         LASSERT (offsetof (struct mds_fileh_body, f_fid) == 0);
800         LASSERT (sizeof (((struct mds_fileh_body *)0)->f_fid) == 16);
801
802         /* Checks for struct mds_body */
803         LASSERT (sizeof (struct mds_body) == 124);
804         LASSERT (offsetof (struct mds_body, fid1) == 0);
805         LASSERT (sizeof (((struct mds_body *)0)->fid1) == 16);
806         LASSERT (offsetof (struct mds_body, fid2) == 16);
807         LASSERT (sizeof (((struct mds_body *)0)->fid2) == 16);
808         LASSERT (offsetof (struct mds_body, handle) == 32);
809         LASSERT (sizeof (((struct mds_body *)0)->handle) == 8);
810         LASSERT (offsetof (struct mds_body, size) == 40);
811         LASSERT (sizeof (((struct mds_body *)0)->size) == 8);
812         LASSERT (offsetof (struct mds_body, blocks) == 48);
813         LASSERT (sizeof (((struct mds_body *)0)->blocks) == 8);
814         LASSERT (offsetof (struct mds_body, ino) == 56);
815         LASSERT (sizeof (((struct mds_body *)0)->ino) == 4);
816         LASSERT (offsetof (struct mds_body, valid) == 60);
817         LASSERT (sizeof (((struct mds_body *)0)->valid) == 4);
818         LASSERT (offsetof (struct mds_body, fsuid) == 64);
819         LASSERT (sizeof (((struct mds_body *)0)->fsuid) == 4);
820         LASSERT (offsetof (struct mds_body, fsgid) == 68);
821         LASSERT (sizeof (((struct mds_body *)0)->fsgid) == 4);
822         LASSERT (offsetof (struct mds_body, capability) == 72);
823         LASSERT (sizeof (((struct mds_body *)0)->capability) == 4);
824         LASSERT (offsetof (struct mds_body, mode) == 76);
825         LASSERT (sizeof (((struct mds_body *)0)->mode) == 4);
826         LASSERT (offsetof (struct mds_body, uid) == 80);
827         LASSERT (sizeof (((struct mds_body *)0)->uid) == 4);
828         LASSERT (offsetof (struct mds_body, gid) == 84);
829         LASSERT (sizeof (((struct mds_body *)0)->gid) == 4);
830         LASSERT (offsetof (struct mds_body, mtime) == 88);
831         LASSERT (sizeof (((struct mds_body *)0)->mtime) == 4);
832         LASSERT (offsetof (struct mds_body, ctime) == 92);
833         LASSERT (sizeof (((struct mds_body *)0)->ctime) == 4);
834         LASSERT (offsetof (struct mds_body, atime) == 96);
835         LASSERT (sizeof (((struct mds_body *)0)->atime) == 4);
836         LASSERT (offsetof (struct mds_body, flags) == 100);
837         LASSERT (sizeof (((struct mds_body *)0)->flags) == 4);
838         LASSERT (offsetof (struct mds_body, rdev) == 104);
839         LASSERT (sizeof (((struct mds_body *)0)->rdev) == 4);
840         LASSERT (offsetof (struct mds_body, nlink) == 108);
841         LASSERT (sizeof (((struct mds_body *)0)->nlink) == 4);
842         LASSERT (offsetof (struct mds_body, generation) == 112);
843         LASSERT (sizeof (((struct mds_body *)0)->generation) == 4);
844         LASSERT (offsetof (struct mds_body, suppgid) == 116);
845         LASSERT (sizeof (((struct mds_body *)0)->suppgid) == 4);
846
847         /* Checks for struct mds_rec_setattr */
848         LASSERT (sizeof (struct mds_rec_setattr) == 92);
849         LASSERT (offsetof (struct mds_rec_setattr, sa_opcode) == 0);
850         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_opcode) == 4);
851         LASSERT (offsetof (struct mds_rec_setattr, sa_fsuid) == 4);
852         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_fsuid) == 4);
853         LASSERT (offsetof (struct mds_rec_setattr, sa_fsgid) == 8);
854         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_fsgid) == 4);
855         LASSERT (offsetof (struct mds_rec_setattr, sa_cap) == 12);
856         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_cap) == 4);
857         LASSERT (offsetof (struct mds_rec_setattr, sa_reserved) == 16);
858         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_reserved) == 4);
859         LASSERT (offsetof (struct mds_rec_setattr, sa_valid) == 20);
860         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_valid) == 4);
861         LASSERT (offsetof (struct mds_rec_setattr, sa_fid) == 24);
862         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_fid) == 16);
863         LASSERT (offsetof (struct mds_rec_setattr, sa_mode) == 40);
864         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_mode) == 4);
865         LASSERT (offsetof (struct mds_rec_setattr, sa_uid) == 44);
866         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_uid) == 4);
867         LASSERT (offsetof (struct mds_rec_setattr, sa_gid) == 48);
868         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_gid) == 4);
869         LASSERT (offsetof (struct mds_rec_setattr, sa_attr_flags) == 52);
870         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_attr_flags) == 4);
871         LASSERT (offsetof (struct mds_rec_setattr, sa_size) == 56);
872         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_size) == 8);
873         LASSERT (offsetof (struct mds_rec_setattr, sa_atime) == 64);
874         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_atime) == 8);
875         LASSERT (offsetof (struct mds_rec_setattr, sa_mtime) == 72);
876         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_mtime) == 8);
877         LASSERT (offsetof (struct mds_rec_setattr, sa_ctime) == 80);
878         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_ctime) == 8);
879         LASSERT (offsetof (struct mds_rec_setattr, sa_suppgid) == 88);
880         LASSERT (sizeof (((struct mds_rec_setattr *)0)->sa_suppgid) == 4);
881
882         /* Checks for struct mds_rec_create */
883         LASSERT (sizeof (struct mds_rec_create) == 84);
884         LASSERT (offsetof (struct mds_rec_create, cr_opcode) == 0);
885         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_opcode) == 4);
886         LASSERT (offsetof (struct mds_rec_create, cr_fsuid) == 4);
887         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_fsuid) == 4);
888         LASSERT (offsetof (struct mds_rec_create, cr_fsgid) == 8);
889         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_fsgid) == 4);
890         LASSERT (offsetof (struct mds_rec_create, cr_cap) == 12);
891         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_cap) == 4);
892         LASSERT (offsetof (struct mds_rec_create, cr_flags) == 16);
893         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_flags) == 4);
894         LASSERT (offsetof (struct mds_rec_create, cr_mode) == 20);
895         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_mode) == 4);
896         LASSERT (offsetof (struct mds_rec_create, cr_fid) == 24);
897         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_fid) == 16);
898         LASSERT (offsetof (struct mds_rec_create, cr_replayfid) == 40);
899         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_replayfid) == 16);
900         LASSERT (offsetof (struct mds_rec_create, cr_uid) == 56);
901         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_uid) == 4);
902         LASSERT (offsetof (struct mds_rec_create, cr_gid) == 60);
903         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_gid) == 4);
904         LASSERT (offsetof (struct mds_rec_create, cr_time) == 64);
905         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_time) == 8);
906         LASSERT (offsetof (struct mds_rec_create, cr_rdev) == 72);
907         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_rdev) == 8);
908         LASSERT (offsetof (struct mds_rec_create, cr_suppgid) == 80);
909         LASSERT (sizeof (((struct mds_rec_create *)0)->cr_suppgid) == 4);
910
911         /* Checks for struct mds_rec_link */
912         LASSERT (sizeof (struct mds_rec_link) == 56);
913         LASSERT (offsetof (struct mds_rec_link, lk_opcode) == 0);
914         LASSERT (sizeof (((struct mds_rec_link *)0)->lk_opcode) == 4);
915         LASSERT (offsetof (struct mds_rec_link, lk_fsuid) == 4);
916         LASSERT (sizeof (((struct mds_rec_link *)0)->lk_fsuid) == 4);
917         LASSERT (offsetof (struct mds_rec_link, lk_fsgid) == 8);
918         LASSERT (sizeof (((struct mds_rec_link *)0)->lk_fsgid) == 4);
919         LASSERT (offsetof (struct mds_rec_link, lk_cap) == 12);
920         LASSERT (sizeof (((struct mds_rec_link *)0)->lk_cap) == 4);
921         LASSERT (offsetof (struct mds_rec_link, lk_suppgid1) == 16);
922         LASSERT (sizeof (((struct mds_rec_link *)0)->lk_suppgid1) == 4);
923         LASSERT (offsetof (struct mds_rec_link, lk_suppgid2) == 20);
924         LASSERT (sizeof (((struct mds_rec_link *)0)->lk_suppgid2) == 4);
925         LASSERT (offsetof (struct mds_rec_link, lk_fid1) == 24);
926         LASSERT (sizeof (((struct mds_rec_link *)0)->lk_fid1) == 16);
927         LASSERT (offsetof (struct mds_rec_link, lk_fid2) == 40);
928         LASSERT (sizeof (((struct mds_rec_link *)0)->lk_fid2) == 16);
929
930         /* Checks for struct mds_rec_unlink */
931         LASSERT (sizeof (struct mds_rec_unlink) == 60);
932         LASSERT (offsetof (struct mds_rec_unlink, ul_opcode) == 0);
933         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_opcode) == 4);
934         LASSERT (offsetof (struct mds_rec_unlink, ul_fsuid) == 4);
935         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_fsuid) == 4);
936         LASSERT (offsetof (struct mds_rec_unlink, ul_fsgid) == 8);
937         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_fsgid) == 4);
938         LASSERT (offsetof (struct mds_rec_unlink, ul_cap) == 12);
939         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_cap) == 4);
940         LASSERT (offsetof (struct mds_rec_unlink, ul_reserved) == 16);
941         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_reserved) == 4);
942         LASSERT (offsetof (struct mds_rec_unlink, ul_mode) == 20);
943         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_mode) == 4);
944         LASSERT (offsetof (struct mds_rec_unlink, ul_suppgid) == 24);
945         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_suppgid) == 4);
946         LASSERT (offsetof (struct mds_rec_unlink, ul_fid1) == 28);
947         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_fid1) == 16);
948         LASSERT (offsetof (struct mds_rec_unlink, ul_fid2) == 44);
949         LASSERT (sizeof (((struct mds_rec_unlink *)0)->ul_fid2) == 16);
950
951         /* Checks for struct mds_rec_rename */
952         LASSERT (sizeof (struct mds_rec_rename) == 56);
953         LASSERT (offsetof (struct mds_rec_rename, rn_opcode) == 0);
954         LASSERT (sizeof (((struct mds_rec_rename *)0)->rn_opcode) == 4);
955         LASSERT (offsetof (struct mds_rec_rename, rn_fsuid) == 4);
956         LASSERT (sizeof (((struct mds_rec_rename *)0)->rn_fsuid) == 4);
957         LASSERT (offsetof (struct mds_rec_rename, rn_fsgid) == 8);
958         LASSERT (sizeof (((struct mds_rec_rename *)0)->rn_fsgid) == 4);
959         LASSERT (offsetof (struct mds_rec_rename, rn_cap) == 12);
960         LASSERT (sizeof (((struct mds_rec_rename *)0)->rn_cap) == 4);
961         LASSERT (offsetof (struct mds_rec_rename, rn_suppgid1) == 16);
962         LASSERT (sizeof (((struct mds_rec_rename *)0)->rn_suppgid1) == 4);
963         LASSERT (offsetof (struct mds_rec_rename, rn_suppgid2) == 20);
964         LASSERT (sizeof (((struct mds_rec_rename *)0)->rn_suppgid2) == 4);
965         LASSERT (offsetof (struct mds_rec_rename, rn_fid1) == 24);
966         LASSERT (sizeof (((struct mds_rec_rename *)0)->rn_fid1) == 16);
967         LASSERT (offsetof (struct mds_rec_rename, rn_fid2) == 40);
968         LASSERT (sizeof (((struct mds_rec_rename *)0)->rn_fid2) == 16);
969
970         /* Checks for struct lov_desc */
971         LASSERT (sizeof (struct lov_desc) == 72);
972         LASSERT (offsetof (struct lov_desc, ld_tgt_count) == 0);
973         LASSERT (sizeof (((struct lov_desc *)0)->ld_tgt_count) == 4);
974         LASSERT (offsetof (struct lov_desc, ld_active_tgt_count) == 4);
975         LASSERT (sizeof (((struct lov_desc *)0)->ld_active_tgt_count) == 4);
976         LASSERT (offsetof (struct lov_desc, ld_default_stripe_count) == 8);
977         LASSERT (sizeof (((struct lov_desc *)0)->ld_default_stripe_count) == 4);
978         LASSERT (offsetof (struct lov_desc, ld_default_stripe_size) == 12);
979         LASSERT (sizeof (((struct lov_desc *)0)->ld_default_stripe_size) == 8);
980         LASSERT (offsetof (struct lov_desc, ld_default_stripe_offset) == 20);
981         LASSERT (sizeof (((struct lov_desc *)0)->ld_default_stripe_offset) == 8);
982         LASSERT (offsetof (struct lov_desc, ld_pattern) == 28);
983         LASSERT (sizeof (((struct lov_desc *)0)->ld_pattern) == 4);
984         LASSERT (offsetof (struct lov_desc, ld_uuid) == 32);
985         LASSERT (sizeof (((struct lov_desc *)0)->ld_uuid) == 37);
986
987         /* Checks for struct ldlm_res_id */
988         LASSERT (sizeof (struct ldlm_res_id) == 24);
989         LASSERT (offsetof (struct ldlm_res_id, name[3]) == 24);
990         LASSERT (sizeof (((struct ldlm_res_id *)0)->name[3]) == 8);
991
992         /* Checks for struct ldlm_extent */
993         LASSERT (sizeof (struct ldlm_extent) == 16);
994         LASSERT (offsetof (struct ldlm_extent, start) == 0);
995         LASSERT (sizeof (((struct ldlm_extent *)0)->start) == 8);
996         LASSERT (offsetof (struct ldlm_extent, end) == 8);
997         LASSERT (sizeof (((struct ldlm_extent *)0)->end) == 8);
998
999         /* Checks for struct ldlm_intent */
1000         LASSERT (sizeof (struct ldlm_intent) == 8);
1001         LASSERT (offsetof (struct ldlm_intent, opc) == 0);
1002         LASSERT (sizeof (((struct ldlm_intent *)0)->opc) == 8);
1003
1004         /* Checks for struct ldlm_resource_desc */
1005         LASSERT (sizeof (struct ldlm_resource_desc) == 44);
1006         LASSERT (offsetof (struct ldlm_resource_desc, lr_type) == 0);
1007         LASSERT (sizeof (((struct ldlm_resource_desc *)0)->lr_type) == 4);
1008         LASSERT (offsetof (struct ldlm_resource_desc, lr_name) == 4);
1009         LASSERT (sizeof (((struct ldlm_resource_desc *)0)->lr_name) == 24);
1010         LASSERT (offsetof (struct ldlm_resource_desc, lr_version[4]) == 44);
1011         LASSERT (sizeof (((struct ldlm_resource_desc *)0)->lr_version[4]) == 4);
1012
1013         /* Checks for struct ldlm_lock_desc */
1014         LASSERT (sizeof (struct ldlm_lock_desc) == 84);
1015         LASSERT (offsetof (struct ldlm_lock_desc, l_resource) == 0);
1016         LASSERT (sizeof (((struct ldlm_lock_desc *)0)->l_resource) == 44);
1017         LASSERT (offsetof (struct ldlm_lock_desc, l_req_mode) == 44);
1018         LASSERT (sizeof (((struct ldlm_lock_desc *)0)->l_req_mode) == 4);
1019         LASSERT (offsetof (struct ldlm_lock_desc, l_granted_mode) == 48);
1020         LASSERT (sizeof (((struct ldlm_lock_desc *)0)->l_granted_mode) == 4);
1021         LASSERT (offsetof (struct ldlm_lock_desc, l_extent) == 52);
1022         LASSERT (sizeof (((struct ldlm_lock_desc *)0)->l_extent) == 16);
1023         LASSERT (offsetof (struct ldlm_lock_desc, l_version[4]) == 84);
1024         LASSERT (sizeof (((struct ldlm_lock_desc *)0)->l_version[4]) == 4);
1025
1026         /* Checks for struct ldlm_request */
1027         LASSERT (sizeof (struct ldlm_request) == 104);
1028         LASSERT (offsetof (struct ldlm_request, lock_flags) == 0);
1029         LASSERT (sizeof (((struct ldlm_request *)0)->lock_flags) == 4);
1030         LASSERT (offsetof (struct ldlm_request, lock_desc) == 4);
1031         LASSERT (sizeof (((struct ldlm_request *)0)->lock_desc) == 84);
1032         LASSERT (offsetof (struct ldlm_request, lock_handle1) == 88);
1033         LASSERT (sizeof (((struct ldlm_request *)0)->lock_handle1) == 8);
1034         LASSERT (offsetof (struct ldlm_request, lock_handle2) == 96);
1035         LASSERT (sizeof (((struct ldlm_request *)0)->lock_handle2) == 8);
1036
1037         /* Checks for struct ldlm_reply */
1038         LASSERT (sizeof (struct ldlm_reply) == 72);
1039         LASSERT (offsetof (struct ldlm_reply, lock_flags) == 0);
1040         LASSERT (sizeof (((struct ldlm_reply *)0)->lock_flags) == 4);
1041         LASSERT (offsetof (struct ldlm_reply, lock_mode) == 4);
1042         LASSERT (sizeof (((struct ldlm_reply *)0)->lock_mode) == 4);
1043         LASSERT (offsetof (struct ldlm_reply, lock_resource_name) == 8);
1044         LASSERT (sizeof (((struct ldlm_reply *)0)->lock_resource_name) == 24);
1045         LASSERT (offsetof (struct ldlm_reply, lock_handle) == 32);
1046         LASSERT (sizeof (((struct ldlm_reply *)0)->lock_handle) == 8);
1047         LASSERT (offsetof (struct ldlm_reply, lock_extent) == 40);
1048         LASSERT (sizeof (((struct ldlm_reply *)0)->lock_extent) == 16);
1049         LASSERT (offsetof (struct ldlm_reply, lock_policy_res1) == 56);
1050         LASSERT (sizeof (((struct ldlm_reply *)0)->lock_policy_res1) == 8);
1051         LASSERT (offsetof (struct ldlm_reply, lock_policy_res2) == 64);
1052         LASSERT (sizeof (((struct ldlm_reply *)0)->lock_policy_res2) == 8);
1053
1054         /* Checks for struct ptlbd_op */
1055         LASSERT (sizeof (struct ptlbd_op) == 12);
1056         LASSERT (offsetof (struct ptlbd_op, op_cmd) == 0);
1057         LASSERT (sizeof (((struct ptlbd_op *)0)->op_cmd) == 2);
1058         LASSERT (offsetof (struct ptlbd_op, op_lun) == 2);
1059         LASSERT (sizeof (((struct ptlbd_op *)0)->op_lun) == 2);
1060         LASSERT (offsetof (struct ptlbd_op, op_niob_cnt) == 4);
1061         LASSERT (sizeof (((struct ptlbd_op *)0)->op_niob_cnt) == 2);
1062         LASSERT (offsetof (struct ptlbd_op, op__padding) == 6);
1063         LASSERT (sizeof (((struct ptlbd_op *)0)->op__padding) == 2);
1064         LASSERT (offsetof (struct ptlbd_op, op_block_cnt) == 8);
1065         LASSERT (sizeof (((struct ptlbd_op *)0)->op_block_cnt) == 4);
1066
1067         /* Checks for struct ptlbd_niob */
1068         LASSERT (sizeof (struct ptlbd_niob) == 24);
1069         LASSERT (offsetof (struct ptlbd_niob, n_xid) == 0);
1070         LASSERT (sizeof (((struct ptlbd_niob *)0)->n_xid) == 8);
1071         LASSERT (offsetof (struct ptlbd_niob, n_block_nr) == 8);
1072         LASSERT (sizeof (((struct ptlbd_niob *)0)->n_block_nr) == 8);
1073         LASSERT (offsetof (struct ptlbd_niob, n_offset) == 16);
1074         LASSERT (sizeof (((struct ptlbd_niob *)0)->n_offset) == 4);
1075         LASSERT (offsetof (struct ptlbd_niob, n_length) == 20);
1076         LASSERT (sizeof (((struct ptlbd_niob *)0)->n_length) == 4);
1077
1078         /* Checks for struct ptlbd_rsp */
1079         LASSERT (sizeof (struct ptlbd_rsp) == 4);
1080         LASSERT (offsetof (struct ptlbd_rsp, r_status) == 0);
1081         LASSERT (sizeof (((struct ptlbd_rsp *)0)->r_status) == 2);
1082         LASSERT (offsetof (struct ptlbd_rsp, r_error_cnt) == 2);
1083         LASSERT (sizeof (((struct ptlbd_rsp *)0)->r_error_cnt) == 2);
1084 #endif
1085 }