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