Whamcloud - gitweb
Land b_hd_capa onto HEAD (20050809_1942)
authorlsy <lsy>
Tue, 9 Aug 2005 12:04:07 +0000 (12:04 +0000)
committerlsy <lsy>
Tue, 9 Aug 2005 12:04:07 +0000 (12:04 +0000)
58 files changed:
lustre/cmobd/cm_write.c
lustre/cobd/cache_obd.c
lustre/include/linux/lustre_idl.h
lustre/include/linux/lustre_lib.h
lustre/include/linux/lustre_lite.h
lustre/include/linux/lustre_mds.h
lustre/include/linux/lustre_sec.h
lustre/include/linux/obd.h
lustre/include/linux/obd_class.h
lustre/include/linux/obd_support.h
lustre/llite/Makefile.in
lustre/llite/dir.c
lustre/llite/file.c
lustre/llite/llite_capa.c [new file with mode: 0644]
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/llite_nfs.c
lustre/llite/namei.c
lustre/llite/rw.c
lustre/llite/super.c
lustre/llite/super25.c
lustre/llite/symlink.c
lustre/lmv/lmv_obd.c
lustre/lmv/lmv_objmgr.c
lustre/lov/lov_obd.c
lustre/mdc/mdc_locks.c
lustre/mdc/mdc_reint.c
lustre/mdc/mdc_request.c
lustre/mds/Makefile.in
lustre/mds/handler.c
lustre/mds/lproc_mds.c
lustre/mds/mds_capa.c [new file with mode: 0644]
lustre/mds/mds_fs.c
lustre/mds/mds_internal.h
lustre/mds/mds_lib.c
lustre/mds/mds_lmv.c
lustre/mds/mds_lov.c
lustre/mds/mds_open.c
lustre/mds/mds_reint.c
lustre/obdclass/Makefile.in
lustre/obdclass/autoMakefile.am
lustre/obdclass/capa.c [new file with mode: 0644]
lustre/obdclass/class_obd.c
lustre/obdclass/genops.c
lustre/obdecho/echo.c
lustre/obdecho/echo_client.c
lustre/obdfilter/Makefile.in
lustre/obdfilter/filter.c
lustre/obdfilter/filter_capa.c [new file with mode: 0644]
lustre/obdfilter/filter_internal.h
lustre/obdfilter/filter_io.c
lustre/obdfilter/lproc_obdfilter.c
lustre/osc/osc_request.c
lustre/ost/ost_handler.c
lustre/ptlrpc/pack_generic.c
lustre/ptlrpc/ptlrpc_module.c
lustre/utils/wirecheck.c
lustre/utils/wiretest.c

index 4f0cdca..93e2942 100644 (file)
@@ -296,7 +296,7 @@ static int cmobd_write_extent(struct obd_device *obd,
         ioo.ioo_bufcnt = oa_bufs;
 
         ret = obd_preprw(OBD_BRW_READ, cmobd->cache_exp, oa, 1, &ioo, 
-                         oa_bufs, rnb, lnb, NULL);
+                         oa_bufs, rnb, lnb, NULL, NULL);
         if (ret)
                 GOTO(out, rc = ret);
 
index dca4582..83d2a97 100644 (file)
@@ -852,7 +852,8 @@ static int cobd_dt_teardown_async_page(struct obd_export *exp,
 
 static int cobd_dt_punch(struct obd_export *exp, struct obdo *oa,
                          struct lov_stripe_md *ea, obd_size start,
-                         obd_size end, struct obd_trans_info *oti)
+                         obd_size end, struct obd_trans_info *oti,
+                         struct lustre_capa *capa)
 {
         struct obd_device *obd = class_exp2obd(exp);
         struct obd_export *cobd_exp;
@@ -865,7 +866,7 @@ static int cobd_dt_punch(struct obd_export *exp, struct obdo *oa,
                 RETURN(-EINVAL);
         }
         cobd_exp = cobd_get_exp(obd);
-        rc = obd_punch(cobd_exp, oa, ea, start, end, oti);
+        rc = obd_punch(cobd_exp, oa, ea, start, end, oti, capa);
         RETURN(rc);
 }
 
@@ -992,7 +993,8 @@ static int cobd_dt_preprw(int cmd, struct obd_export *exp,
                           struct obd_ioobj *obj, int niocount,
                           struct niobuf_remote *nb,
                           struct niobuf_local *res,
-                          struct obd_trans_info *oti)
+                          struct obd_trans_info *oti,
+                          struct lustre_capa *capa)
 {
         struct obd_device *obd = class_exp2obd(exp);
         struct obd_export *cobd_exp;
@@ -1006,7 +1008,7 @@ static int cobd_dt_preprw(int cmd, struct obd_export *exp,
         }
         cobd_exp = cobd_get_exp(obd);
         rc = obd_preprw(cmd, cobd_exp, oa, objcount, obj,
-                        niocount, nb, res, oti);
+                          niocount, nb, res, oti, capa);
         RETURN(rc);
 }
 
@@ -1180,7 +1182,7 @@ static int cobd_md_getstatus(struct obd_export *exp,
 static int cobd_md_getattr(struct obd_export *exp, struct lustre_id *id,
                            __u64 valid, const char *xattr_name,
                            const void *xattr_data, unsigned int xattr_datalen,
-                           unsigned int ea_size,
+                           unsigned int ea_size, struct obd_capa *ocapa,
                            struct ptlrpc_request **request)
 {
         struct obd_device *obd = class_exp2obd(exp);
@@ -1194,8 +1196,8 @@ static int cobd_md_getattr(struct obd_export *exp, struct lustre_id *id,
                 RETURN(-EINVAL);
         }
         cobd_exp = cobd_get_exp(obd);
-        rc = md_getattr(cobd_exp, id, valid, xattr_name,
-                        xattr_data, xattr_datalen, ea_size, request);
+        rc = md_getattr(cobd_exp, id, valid, xattr_name, xattr_data,
+                          xattr_datalen, ea_size, ocapa, request);
         RETURN(rc);
 }
 
index fa924b2..2ee7cd0 100644 (file)
@@ -333,8 +333,8 @@ struct obdo {
         __u32                   o_easize;       /* epoch in ost writes */
         __u32                   o_mds;
         __u64                   o_fid;
-        __u32                   o_padding;
-        char                    o_inline[OBD_INLINESZ];
+        obd_uid                 o_fsuid;        /* fsuid, used by capability */
+        char                    o_inline[OBD_INLINESZ]; /* fid in ost writes */
 };
 
 #define o_dirty   o_blocks
@@ -426,14 +426,17 @@ struct lov_mds_md_v0 {            /* LOV EA mds/wire data (little-endian) */
 #define OBD_MD_FLRMTACL (0x0000000800000000LL)    /* remote acl */
 #define OBD_MD_FLKEY    (0x0000001000000000LL)    /* mds key extended attributes */
 #define OBD_MD_FLAUDIT  (0x0000002000000000LL)    /* audit setting */
-
-#define OBD_MD_FLNOTOBD (~(OBD_MD_FLBLOCKS | OBD_MD_LINKNAME |          \
-                           OBD_MD_FLEASIZE | OBD_MD_FLHANDLE |          \
-                           OBD_MD_FLCKSUM | OBD_MD_FLQOS |              \
-                           OBD_MD_FLOSCOPQ | OBD_MD_FLCOOKIE |          \
-                           OBD_MD_FLXATTR | OBD_MD_FLXATTRLIST |        \
-                           OBD_MD_FLACL | OBD_MD_FLKEY |                \
-                           OBD_MD_MDS | OBD_MD_FLAUDIT))
+#define OBD_MD_CAPA     (0x0000004000000000LL)    /* capability */
+#define OBD_MD_FLFSUID  (0x0000008000000000LL)    /* fsuid */
+
+#define OBD_MD_FLNOTOBD (~(OBD_MD_FLBLOCKS | OBD_MD_LINKNAME    |        \
+                           OBD_MD_FLEASIZE | OBD_MD_FLHANDLE    |        \
+                           OBD_MD_FLCKSUM  | OBD_MD_FLQOS       |        \
+                           OBD_MD_FLOSCOPQ | OBD_MD_FLCOOKIE    |        \
+                           OBD_MD_FLXATTR  | OBD_MD_FLXATTRLIST |        \
+                           OBD_MD_FLACL    | OBD_MD_MDS         |        \
+                           OBD_MD_FLKEY    | OBD_MD_FLAUDIT     |        \
+                           OBD_MD_CAPA     | OBD_MD_FLFSUID))
 
 static inline struct lustre_handle *obdo_handle(struct obdo *oa)
 {
@@ -1031,6 +1034,31 @@ struct ptlbd_rsp {
 
 extern void lustre_swab_ptlbd_rsp (struct ptlbd_rsp *r);
 
+#define CAPA_KEY_LEN           16
+#define CAPA_DIGEST_SIZE       16
+
+struct lustre_capa {
+        __u32   lc_uid;       /* uid */
+        __u32   lc_op;        /* operations allowed */
+        __u64   lc_ino;       /* inode# */
+        __u32   lc_mdsid;     /* mds# */
+        __u32   lc_keyid;     /* key used for the capability */
+        __u64   lc_expiry;    /* expiry time (sec): servers have clocks */
+        __u32   lc_flags;     /* security features for capability */
+        __u8    lc_hmac[CAPA_DIGEST_SIZE]; /* HMAC */
+} __attribute__((packed));
+
+extern void lustre_swab_lustre_capa (struct lustre_capa *c);
+
+struct lustre_capa_key {
+        __u32   lk_mdsid;     /* mds# */
+        __u32   lk_keyid;     /* key# */
+        __u64   lk_expiry;    /* expiry (sec) */
+        __u8    lk_key[CAPA_KEY_LEN];  /* key */
+};
+
+extern void lustre_swab_lustre_capa_key (struct lustre_capa_key *k);
+
 /*
  * Opcodes for management/monitoring node.
  */
index 3c9f081..f31dcc2 100644 (file)
@@ -113,6 +113,7 @@ struct obd_client_handle {
         struct lustre_handle och_fh;
         struct llog_cookie och_cookie;
         struct mdc_open_data *och_mod;
+        struct obd_capa *och_capa;
         __u32 och_magic;
 };
 #define OBD_CLIENT_HANDLE_MAGIC 0xd15ea5ed
index fa2887b..41c5bb0 100644 (file)
@@ -117,7 +117,10 @@ struct ll_inode_info {
         __u64                   lli_open_fd_exec_count;
         struct posix_acl       *lli_posix_acl;
         struct remote_acl      *lli_remote_acl;
+
         struct lustre_key      *lli_key_info;
+
+        struct lustre_capa     *lli_trunc_capa; /* capabiliity for truncate */
 };
 
 // FIXME: replace the name of this with LL_I to conform to kernel stuff
@@ -193,5 +196,6 @@ struct lustre_intent_data {
          (struct ll_async_page *)(c))
 
 #include <lustre/lustre_user.h>
+#include <linux/lustre_sec.h>
 
 #endif
index 3b413db..45602d5 100644 (file)
@@ -324,11 +324,14 @@ int mdc_enqueue(struct obd_export *exp,
 int mdc_req2lustre_md(struct obd_export *exp_lmv, struct ptlrpc_request *req, 
                       unsigned int offset, struct obd_export *exp_lov, 
                       struct lustre_md *md);
+int mdc_req2lustre_capa(struct ptlrpc_request *req, unsigned int offset,
+                        struct lustre_capa **capa);
 int mdc_getstatus(struct obd_export *exp, struct lustre_id *rootid);
 int mdc_getattr(struct obd_export *exp, struct lustre_id *id,
                 __u64 valid, const char *xattr_name,
                 const void *xattr_data, unsigned int xattr_datalen,
-                unsigned int ea_size, struct ptlrpc_request **request);
+                unsigned int ea_size, struct obd_capa *ocapa,
+                struct ptlrpc_request **request);
 int mdc_getattr_lock(struct obd_export *exp, struct lustre_id *id,
                      char *filename, int namelen, __u64 valid,
                      unsigned int ea_size, struct ptlrpc_request **request);
index 2056753..22bcffa 100644 (file)
@@ -22,6 +22,8 @@
 #ifndef __LINUX_SEC_H_
 #define __LINUX_SEC_H_
 
+//#include <linux/lustre_idl.h>
+
 enum ptlrpcs_major_flavors {
         PTLRPCS_FLVR_MAJOR_NULL         = 0,
         PTLRPCS_FLVR_MAJOR_GSS          = 1,
@@ -503,6 +505,146 @@ void svcsec_free_reply_state(struct ptlrpc_reply_state *rs);
 int svcsec_null_init(void);
 int svcsec_null_exit(void);
 
+/* capability */
+#include <linux/crypto.h>
+
+#define NR_CAPAHASH 32
+#define CAPA_TIMEOUT 1800                /* sec, == 30 min */
+#define CAPA_KEY_TIMEOUT (24 * 60 * 60)  /* sec, == 1 day */
+#define CAPA_CACHE_SIZE 1000             /* for MDS & OST */
+#define CAPA_HMAC_ALG "sha1"
+
+struct lustre_capa_data {
+        __u32   lc_uid;       /* uid */
+        __u32   lc_op;        /* operations allowed */
+        __u64   lc_ino;       /* inode# */
+        __u32   lc_mdsid;     /* mds# */
+        __u32   lc_keyid;     /* key used for the capability */
+        __u64   lc_expiry;    /* expiry time: servers have clocks */
+        __u32   lc_flags;     /* security features for capability */
+} __attribute__((packed));
+
+struct client_capa {
+        struct inode             *inode;      /* this should be always valid
+                                               * if c_refc > 0 */
+        struct lustre_handle      handle;     /* handle of mds_file_data */
+        struct list_head         *list;       /* the capa list belong to this client */
+        struct timer_list        *timer;      /* timer belong to this client */
+};
+
+struct filter_capa {
+        int                       bvalid;     /* black key here valid or not */
+        __u32                     bkeyid;     /* black key id */
+        __u8                      bhmac[CAPA_DIGEST_SIZE]; /* black key */
+};
+
+struct obd_capa {
+        struct hlist_node         c_hash;
+        struct list_head          c_list;
+
+        struct lustre_capa        c_capa;        /* capa */
+        int                       c_type;
+        atomic_t                  c_refc;
+
+        union {
+                struct client_capa       client;
+                struct filter_capa       filter;
+        } u;
+};
+
+#define c_inode   u.client.inode
+#define c_handle  u.client.handle
+#define c_bvalid  u.filter.bvalid
+#define c_bkeyid  u.filter.bkeyid
+#define c_bhmac   u.filter.bhmac
+
+enum lustre_capa_type {
+        CLIENT_CAPA = 0,
+        MDS_CAPA    = 1,
+        FILTER_CAPA = 2,
+};
+
+extern spinlock_t capa_lock;
+extern struct hlist_head *capa_hash;
+extern struct list_head capa_list[];
+extern struct timer_list ll_capa_timer;
+
+/* obdclass/capa.c */
+int capa_op(int flags);
+void __capa_get(struct obd_capa *ocapa);
+struct obd_capa *capa_get(uid_t uid, int capa_op, __u64 mdsid,
+                          unsigned long ino, int type,
+                          struct lustre_capa *capa, struct inode *inode,
+                          struct lustre_handle *handle);
+void capa_put(struct obd_capa *ocapa, int type);
+int capa_renew(struct lustre_capa *capa, int type);
+void capa_hmac(struct crypto_tfm *tfm, u8 *key, struct lustre_capa *capa);
+void capa_dup(void *dst, struct obd_capa *ocapa);
+void capa_dup2(void *dst, struct lustre_capa *capa);
+int capa_expired(struct lustre_capa *capa);
+int __capa_is_to_expire(struct obd_capa *ocapa);
+int capa_is_to_expire(struct obd_capa *ocapa);
+
+#define CAPA_EXPIRY_SHIFT 10 /* 1024 sec */
+#define CAPA_EXPIRY       (1UL << PAGE_SHIFT)
+#define CAPA_EXPIRY_MASK  (~(CAPA_EXPIRY-1))
+
+#define CAPA_PRE_EXPIRY_NOROUND 3       /* sec */
+#define CAPA_PRE_EXPIRY         300     /* sec */
+
+/* struct lustre_capa.lc_flags */
+#define CAPA_FL_NOROUND   0x001 /* capa expiry not rounded */
+
+static inline unsigned long capa_pre_expiry(struct lustre_capa *capa)
+{
+        return (capa->lc_flags & CAPA_FL_NOROUND) ? 
+                        CAPA_PRE_EXPIRY_NOROUND : CAPA_PRE_EXPIRY;
+}
+
+static inline __u64
+round_expiry(__u32 timeout)
+{
+        struct timeval tv;
+        __u64 expiry;
+
+        do_gettimeofday(&tv);
+        expiry = tv.tv_sec + timeout;
+
+        if (timeout > CAPA_EXPIRY)
+                expiry = (expiry + CAPA_EXPIRY - 1) & CAPA_EXPIRY_MASK;
+
+        return expiry;
+}
+
+static inline int
+capa_key_cmp(struct lustre_capa_key *k1, struct lustre_capa_key *k2)
+{
+        return le32_to_cpu(k1->lk_keyid) - le32_to_cpu(k2->lk_keyid);
+}
+
+static inline unsigned long
+expiry_to_jiffies(__u64 expiry)
+{
+        /* sec -> jiffies */
+        struct timeval tv;
+
+        do_gettimeofday(&tv);
+        return jiffies + ((unsigned long)expiry - tv.tv_sec) * HZ;
+}
+
 #endif /* __KERNEL__ */
 
+struct mds_capa_key {
+        struct list_head        k_list;
+
+        struct lustre_capa_key *k_key;
+        struct obd_device      *k_obd;
+};
+
+struct filter_capa_key {
+        struct list_head        k_list;
+
+        struct lustre_capa_key  k_key;
+};
+
 #endif /* __LINUX_SEC_H_ */
index 784fc49..12e67fc 100644 (file)
@@ -63,6 +63,7 @@
 #include <linux/lustre_lib.h>
 #include <linux/lustre_idl.h>
 #include <linux/lustre_export.h>
+#include <linux/lustre_sec.h>
 
 /* this is really local to the OSC */
 struct loi_oap_pages {
@@ -283,9 +284,15 @@ struct filter_obd {
         spinlock_t               fo_llog_list_lock;
 
         /* which secure flavor from remote is denied */
-        spinlock_t              fo_denylist_lock;
-        struct list_head        fo_denylist;
+        spinlock_t               fo_denylist_lock;
+        struct list_head         fo_denylist;
 
+        /* capability related */
+        int                      fo_capa_stat;
+        struct crypto_tfm       *fo_capa_hmac;
+        spinlock_t               fo_capa_lock;
+
+        struct list_head         fo_capa_keys;
 };
 
 struct mds_server_data;
@@ -446,6 +453,16 @@ struct mds_obd {
         spinlock_t                      mds_fidext_lock;
         __u64                           mds_fidext_thumb;
         int                             mds_crypto_type;
+
+        /* capability related */
+        int                              mds_capa_stat;     /* 1: on, 0: off */
+        struct crypto_tfm               *mds_capa_hmac;
+        unsigned long                    mds_capa_timeout;  /* sec */
+
+        struct mds_capa_key              mds_capa_keys[2];  /* red & black key */
+        int                              mds_capa_key_idx;  /* the red key index */
+        struct file                     *mds_capa_keys_filp;
+        unsigned long                    mds_capa_key_timeout; /* sec */
 };
 
 struct echo_obd {
@@ -859,7 +876,8 @@ struct obd_ops {
                             obd_off size, int shrink);
         int (*o_punch)(struct obd_export *exp, struct obdo *oa,
                        struct lov_stripe_md *ea, obd_size start,
-                       obd_size end, struct obd_trans_info *oti);
+                       obd_size end, struct obd_trans_info *oti,
+                       struct lustre_capa *capa);
         int (*o_sync)(struct obd_export *exp, struct obdo *oa,
                       struct lov_stripe_md *ea, obd_size start, obd_size end);
         int (*o_migrate)(struct lustre_handle *conn, struct lov_stripe_md *dst,
@@ -874,7 +892,8 @@ struct obd_ops {
         int (*o_preprw)(int cmd, struct obd_export *exp, struct obdo *oa,
                         int objcount, struct obd_ioobj *obj,
                         int niocount, struct niobuf_remote *remote,
-                        struct niobuf_local *local, struct obd_trans_info *oti);
+                        struct niobuf_local *local, struct obd_trans_info *oti,
+                        struct lustre_capa *capa);
         int (*o_commitrw)(int cmd, struct obd_export *exp, struct obdo *oa,
                           int objcount, struct obd_ioobj *obj,
                           int niocount, struct niobuf_local *local,
@@ -952,7 +971,8 @@ struct md_ops {
                          ldlm_blocking_callback, void *);
         int (*m_getattr)(struct obd_export *, struct lustre_id *,
                          __u64, const char *, const void *, unsigned int,
-                         unsigned int, struct ptlrpc_request **);
+                         unsigned int, struct obd_capa *,
+                         struct ptlrpc_request **);
         int (*m_access_check)(struct obd_export *, struct lustre_id *,
                               struct ptlrpc_request **);
         int (*m_getattr_lock)(struct obd_export *, struct lustre_id *,
index f5182dd..8866039 100644 (file)
@@ -723,7 +723,8 @@ static inline int obd_sync(struct obd_export *exp, struct obdo *oa,
 
 static inline int obd_punch(struct obd_export *exp, struct obdo *oa,
                             struct lov_stripe_md *ea, obd_size start,
-                            obd_size end, struct obd_trans_info *oti)
+                            obd_size end, struct obd_trans_info *oti,
+                            struct lustre_capa *capa)
 {
         int rc;
         ENTRY;
@@ -731,7 +732,7 @@ static inline int obd_punch(struct obd_export *exp, struct obdo *oa,
         EXP_CHECK_OP(exp, punch);
         OBD_COUNTER_INCREMENT(exp->exp_obd, punch);
 
-        rc = OBP(exp->exp_obd, punch)(exp, oa, ea, start, end, oti);
+        rc = OBP(exp->exp_obd, punch)(exp, oa, ea, start, end, oti, capa);
         RETURN(rc);
 }
 
@@ -883,7 +884,8 @@ static inline int obd_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
                              int objcount, struct obd_ioobj *obj,
                              int niocount, struct niobuf_remote *remote,
                              struct niobuf_local *local,
-                             struct obd_trans_info *oti)
+                             struct obd_trans_info *oti,
+                             struct lustre_capa *capa)
 {
         int rc;
         ENTRY;
@@ -892,7 +894,7 @@ static inline int obd_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
         OBD_COUNTER_INCREMENT(exp->exp_obd, preprw);
 
         rc = OBP(exp->exp_obd, preprw)(cmd, exp, oa, objcount, obj, niocount,
-                                       remote, local, oti);
+                                       remote, local, oti, capa);
         RETURN(rc);
 }
 
@@ -1180,7 +1182,7 @@ static inline int md_delete_inode(struct obd_export *exp,
 static inline int md_getattr(struct obd_export *exp, struct lustre_id *id,
                              __u64 valid, const char *xattr_name,
                              const void *xattr_data, unsigned int xattr_datalen,
-                             unsigned int ea_size,
+                             unsigned int ea_size, struct obd_capa *ocapa,
                              struct ptlrpc_request **request)
 {
         int rc;
@@ -1189,7 +1191,7 @@ static inline int md_getattr(struct obd_export *exp, struct lustre_id *id,
         MD_COUNTER_INCREMENT(exp->exp_obd, getattr);
         rc = MDP(exp->exp_obd, getattr)(exp, id, valid, xattr_name,
                                         xattr_data, xattr_datalen,
-                                        ea_size, request);
+                                        ea_size, ocapa, request);
         RETURN(rc);
 }
 
@@ -1307,7 +1309,8 @@ static inline int md_getattr_lock(struct obd_export *exp, struct lustre_id *id,
 static inline int md_intent_lock(struct obd_export *exp,
                                  struct lustre_id *pid, const char *name,
                                  int len, void *lmm, int lmmsize,
-                                 struct lustre_id *cid, struct lookup_intent *it,
+                                 struct lustre_id *cid,
+                                 struct lookup_intent *it,
                                  int flags, struct ptlrpc_request **reqp,
                                  ldlm_blocking_callback cb_blocking)
 {
@@ -1315,8 +1318,8 @@ static inline int md_intent_lock(struct obd_export *exp,
         ENTRY;
         EXP_CHECK_MD_OP(exp, intent_lock);
         MD_COUNTER_INCREMENT(exp->exp_obd, intent_lock);
-        rc = MDP(exp->exp_obd, intent_lock)(exp, pid, name, len,
-                                            lmm, lmmsize, cid, it, flags,
+        rc = MDP(exp->exp_obd, intent_lock)(exp, pid, name, len, lmm,
+                                            lmmsize, cid, it, flags,
                                             reqp, cb_blocking);
         RETURN(rc);
 }
index a7ec412..53d4376 100644 (file)
@@ -91,6 +91,7 @@ extern wait_queue_head_t obd_race_waitq;
 #define OBD_FAIL_MDS_OPEN_CREATE         0x12b
 #define OBD_FAIL_MDS_ACCESS_CHECK_NET    0x12c
 #define OBD_FAIL_MDS_ACCESS_CHECK_PACK   0x12d
+#define OBD_FAIL_MDS_PACK_CAPA           0x12e
 
 #define OBD_FAIL_OST                     0x200
 #define OBD_FAIL_OST_CONNECT_NET         0x201
@@ -162,6 +163,8 @@ extern wait_queue_head_t obd_race_waitq;
 
 #define OBD_FAIL_MDC_REVALIDATE_PAUSE    0x800
 
+#define OBD_FAIL_FILTER_VERIFY_CAPA      0x900
+
 /* preparation for a more advanced failure testbed (not functional yet) */
 #define OBD_FAIL_MASK_SYS    0x0000FF00
 #define OBD_FAIL_MASK_LOC    (0x000000FF | OBD_FAIL_MASK_SYS)
index 9e91583..eb55c6f 100644 (file)
@@ -1,7 +1,7 @@
 MODULES := llite
 llite-objs := dcache.o dir.o file.o llite_close.o llite_gns.o llite_lib.o llite_nfs.o 
 llite-objs += rw.o lproc_llite.o namei.o special.o symlink.o llite_mmap.o
-llite-objs += llite_gs.o llite_audit.o
+llite-objs += llite_gs.o llite_audit.o llite_capa.o
 
 ifeq ($(PATCHLEVEL),4)
 llite-objs += rw24.o super.o
index bd74819..8868604 100644 (file)
@@ -471,7 +471,7 @@ static int ll_ioctl_getfacl(struct inode *inode,
         ll_inode2id(&id, inode);
         rc = md_getattr(ll_i2sbi(inode)->ll_md_exp, &id, OBD_MD_FLXATTR,
                         XATTR_NAME_LUSTRE_ACL,
-                        cmd, ioc->cmd_len, ioc->res_len, &req);
+                        cmd, ioc->cmd_len, ioc->res_len, NULL, &req);
         if (rc < 0) {
                 CERROR("rc: %d\n", rc);
                 GOTO(out, rc);
@@ -685,7 +685,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file,
                 ll_inode2id(&id, inode);
                 rc = md_getattr(sbi->ll_md_exp, &id, valid, NULL, NULL, 0,
                                 obd_size_diskmd(sbi->ll_dt_exp, NULL),
-                                &request);
+                                NULL, &request);
                 if (rc < 0) {
                         CDEBUG(D_INFO, "md_getattr failed: rc = %d\n", rc);
                         RETURN(rc);
index eef00a3..49b38e5 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/pagemap.h>
 #include <linux/file.h>
 #include <linux/lustre_acl.h>
+#include <linux/lustre_sec.h>
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
 #include <linux/lustre_compat25.h>
 #endif
@@ -146,6 +147,8 @@ int ll_md_och_close(struct obd_export *md_exp, struct inode *inode,
         EXIT;
 out:
         mdc_clear_open_replay_data(md_exp, och);
+        if (och->och_capa)
+                capa_put(och->och_capa, CLIENT_CAPA);
         och->och_fh.cookie = DEAD_HANDLE_MAGIC;
         OBD_FREE(och, sizeof *och);
         return rc;
@@ -341,12 +344,14 @@ static int ll_intent_file_open(struct file *file, void *lmm,
         RETURN(rc);
 }
 
-void ll_och_fill(struct inode *inode, struct lookup_intent *it,
+int ll_och_fill(struct inode *inode, struct lookup_intent *it,
                  struct obd_client_handle *och)
 {
         struct ptlrpc_request *req = LUSTRE_IT(it)->it_data;
         struct ll_inode_info *lli = ll_i2info(inode);
         struct mds_body *body;
+        int rc = 0;
+        ENTRY;
         LASSERT(och);
 
         body = lustre_msg_buf (req->rq_repmsg, 1, sizeof (*body));
@@ -358,16 +363,24 @@ void ll_och_fill(struct inode *inode, struct lookup_intent *it,
         lli->lli_io_epoch = body->io_epoch;
         mdc_set_open_replay_data(ll_i2mdexp(inode), och, 
                                 LUSTRE_IT(it)->it_data);
+
+        if (S_ISREG(inode->i_mode) && (body->valid & OBD_MD_CAPA))
+                rc = ll_set_och_capa(inode, it, och);
+        RETURN(rc);
 }
 
 int ll_local_open(struct file *file, struct lookup_intent *it,
                   struct obd_client_handle *och)
 {
         struct ll_file_data *fd;
+        int rc = 0;
         ENTRY;
 
-        if (och)
-                ll_och_fill(file->f_dentry->d_inode, it, och);
+        if (och) {
+                rc = ll_och_fill(file->f_dentry->d_inode, it, och);
+                if (rc)
+                        RETURN(rc);
+        }
 
         LASSERTF(file->private_data == NULL, "file %.*s/%.*s ino %lu/%u (%o)\n",
                  file->f_dentry->d_name.len, file->f_dentry->d_name.name,
@@ -482,7 +495,12 @@ int ll_file_open(struct inode *inode, struct file *file)
                                 RETURN(-ENOMEM);
                         }
 
-                        ll_och_fill(inode, it, och);
+                        rc = ll_och_fill(inode, it, och);
+                        if (rc) {
+                                up(&lli->lli_och_sem);
+                                RETURN(rc);
+                        }
+                        
                         /* ll_md_och_close() will free och */
                         ll_md_och_close(ll_i2mdexp(inode), inode, och, 0);
                 }
@@ -534,7 +552,6 @@ int ll_file_open(struct inode *inode, struct file *file)
          * different kind of OPEN lock for this same inode gets cancelled by
          * ldlm_cancel_lru
          */
-
         if (!S_ISREG(inode->i_mode))
                 GOTO(out, rc);
 
@@ -1981,7 +1998,7 @@ int ll_getxattr_internal(struct inode *inode, const char *name,
 
         ll_inode2id(&id, inode);
         rc = md_getattr(sbi->ll_md_exp, &id, valid, name, NULL, 0,
-                        size, &request);
+                        size, NULL, &request);
         if (rc) {
                 if (rc != -ENODATA && rc != -EOPNOTSUPP)
                         CERROR("rc = %d\n", rc);
diff --git a/lustre/llite/llite_capa.c b/lustre/llite/llite_capa.c
new file mode 100644 (file)
index 0000000..40ae02a
--- /dev/null
@@ -0,0 +1,231 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2004, 2005 Cluster File Systems, Inc.
+ *
+ * Author: Lai Siyao <lsy@clusterfs.com>
+ *
+ *   This file is part of Lustre, http://www.lustre.org.
+ *
+ *   Lustre is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2 of the GNU General Public
+ *   License as published by the Free Software Foundation.
+ *
+ *   Lustre is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with Lustre; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#define DEBUG_SUBSYSTEM S_LLITE
+
+#include <linux/fs.h>
+#include <linux/version.h>
+#include <asm/uaccess.h>
+#include <linux/file.h>
+#include <linux/kmod.h>
+
+#include <linux/lustre_lite.h>
+#include "llite_internal.h"
+
+static struct ptlrpc_thread ll_capa_thread;
+static struct list_head *ll_capa_list = &capa_list[CLIENT_CAPA];
+static struct thread_ctl {
+        struct completion ctl_starting;
+        struct completion ctl_finishing;
+} ll_capa_ctl;
+
+static inline int have_expired_capa(void)
+{
+        struct obd_capa *ocapa;
+        int expired = 0;
+        ENTRY;
+
+        spin_lock(&capa_lock);
+        if (!list_empty(ll_capa_list)) {
+                ocapa = list_entry(ll_capa_list->next, struct obd_capa, c_list);
+
+                expired = __capa_is_to_expire(ocapa);
+        }
+        spin_unlock(&capa_lock);
+
+        RETURN(expired);
+}
+
+static int inline ll_capa_check_stop(void)
+{
+        return (ll_capa_thread.t_flags & SVC_STOPPING) ? 1: 0;
+}
+
+static int ll_renew_capa(struct obd_capa *ocapa)
+{
+        struct ptlrpc_request *req = NULL;
+        /* no need to lock, no one else will touch it */
+        struct inode *inode = ocapa->c_inode;
+        struct obd_export *md_exp = ll_i2mdexp(inode);
+        struct ll_inode_info *lli = ll_i2info(inode);
+        __u64 valid = 0;
+        int rc;
+        ENTRY;
+
+        valid |= OBD_MD_CAPA;
+
+        rc = md_getattr(md_exp, &lli->lli_id, valid, NULL, NULL, 0,
+                        0, ocapa, &req);
+        if (rc < 0)
+                CDEBUG(D_INFO, "md_getattr failed: rc = %d\n", rc);
+        RETURN(rc);
+}
+
+static int ll_capa_thread_main(void *arg)
+{
+        struct thread_ctl *ctl = arg;
+        unsigned long flags;
+        ENTRY;
+
+        {
+                char name[sizeof(current->comm)];
+                snprintf(name, sizeof(name) - 1, "ll_capa");
+                kportal_daemonize(name);
+        }
+
+        SIGNAL_MASK_LOCK(current, flags);
+        sigfillset(&current->blocked);
+        RECALC_SIGPENDING;
+        SIGNAL_MASK_UNLOCK(current, flags);
+
+        /*
+         * letting starting function know, that we are ready and control may be
+         * returned.
+         */
+        ll_capa_thread.t_flags = SVC_RUNNING;
+        complete(&ctl->ctl_starting);
+
+        while (1) {
+                struct l_wait_info lwi = { 0 };
+                struct obd_capa *ocapa, *next = NULL;
+                int sleep = CAPA_PRE_EXPIRY;
+
+                l_wait_event(ll_capa_thread.t_ctl_waitq,
+                             (have_expired_capa() || ll_capa_check_stop()),
+                             &lwi);
+
+                spin_lock(&capa_lock);
+                list_for_each_entry(ocapa, ll_capa_list, c_list) {
+                        if (__capa_is_to_expire(ocapa)) {
+                                /* get capa in case it's deleted */
+                                __capa_get(ocapa);
+
+                                spin_unlock(&capa_lock);
+                                ll_renew_capa(ocapa);
+                                capa_put(ocapa, CLIENT_CAPA);
+                                spin_lock(&capa_lock);
+                        } else {
+                                next = ocapa;
+                                break;
+                        }
+                }
+                if (next) {
+                        mod_timer(&ll_capa_timer,
+                                  expiry_to_jiffies(next->c_capa.lc_expiry));
+                        if (next->c_capa.lc_flags & CAPA_FL_NOROUND)
+                                sleep = CAPA_PRE_EXPIRY_NOROUND;
+                }
+                spin_unlock(&capa_lock);
+
+                if (ll_capa_check_stop())
+                        break;
+
+                /* wait ll_renew_capa finish */
+                set_current_state(TASK_INTERRUPTIBLE);
+                schedule_timeout(sleep * HZ);
+        }
+
+        ll_capa_thread.t_flags = SVC_STOPPED;
+
+        /* this is SMP-safe way to finish thread. */
+        complete_and_exit(&ctl->ctl_finishing, 0);
+        EXIT;
+}
+
+/* just wake up, others are handled by ll_capa_thread */
+void ll_capa_timer_callback(unsigned long unused)
+{
+        ENTRY;
+        wake_up(&ll_capa_thread.t_ctl_waitq);
+        EXIT;
+}
+
+int ll_capa_start_thread(void)
+{
+        int rc;
+        ENTRY;
+
+        LASSERT(ll_capa_thread.t_flags == 0);
+        init_completion(&ll_capa_ctl.ctl_starting);
+        init_completion(&ll_capa_ctl.ctl_finishing);
+        init_waitqueue_head(&ll_capa_thread.t_ctl_waitq);
+
+        rc = kernel_thread(ll_capa_thread_main, &ll_capa_ctl,
+                           (CLONE_VM | CLONE_FILES));
+        if (rc < 0) {
+                CERROR("cannot start expired capa thread, "
+                       "err = %d\n", rc);
+                RETURN(rc);
+        }
+        wait_for_completion(&ll_capa_ctl.ctl_starting);
+        LASSERT(ll_capa_thread.t_flags == SVC_RUNNING);
+        RETURN(0);
+}
+
+void ll_capa_stop_thread(void)
+{
+        ENTRY;
+
+        ll_capa_thread.t_flags = SVC_STOPPING;
+        wake_up(&ll_capa_thread.t_ctl_waitq);
+        wait_for_completion(&ll_capa_ctl.ctl_finishing);
+        LASSERT(ll_capa_thread.t_flags == SVC_STOPPED);
+        ll_capa_thread.t_flags = 0;
+
+        EXIT;
+}
+
+int ll_set_och_capa(struct inode *inode, struct lookup_intent *it,
+                           struct obd_client_handle *och)
+{
+        struct ptlrpc_request *req = LUSTRE_IT(it)->it_data;
+        struct ll_inode_info *lli = ll_i2info(inode);
+        struct mds_body *body;
+        struct lustre_capa *capa;
+        __u64 mdsid = lli->lli_id.li_fid.lf_group;
+        unsigned long ino = lli->lli_id.li_stc.u.e3s.l3s_ino;
+        int capa_op = (it->it_flags & MAY_WRITE) ? MAY_WRITE : MAY_READ;
+        unsigned long expiry;
+        int rc = 0;
+        ENTRY;
+
+        body = lustre_msg_buf(req->rq_repmsg, 1, sizeof (*body));
+        LASSERT(body != NULL);          /* reply already checked out */
+        LASSERT_REPSWABBED(req, 1);     /* and swabbed down */
+
+        capa = lustre_msg_buf(req->rq_repmsg, 7, sizeof (*capa));
+        LASSERT(capa != NULL);          /* reply already checked out */
+        LASSERT_REPSWABBED(req, 7);     /* and swabbed down */
+
+        och->och_capa = capa_get(current->uid, capa_op, mdsid, ino,
+                                 CLIENT_CAPA, capa, inode, &body->handle);
+        if (!och->och_capa)
+                rc = -ENOMEM;
+
+        expiry = expiry_to_jiffies(capa->lc_expiry - capa_pre_expiry(capa));
+        if (time_before(expiry, ll_capa_timer.expires) ||
+            !timer_pending(&ll_capa_timer))
+                mod_timer(&ll_capa_timer, expiry);
+
+        RETURN(rc);
+}
index a71ac76..6896b55 100644 (file)
@@ -111,6 +111,10 @@ struct ll_sb_info {
         /* mount object entry name */
         char                      ll_gns_oname[PATH_MAX];
         void                      *ll_crypto_info;
+
+        /* TODO: to support multi mount for capability */
+        struct list_head          ll_capa_list;
+        struct timer_list         ll_capa_timer;
 };
 
 struct ll_gns_ctl {
@@ -172,6 +176,7 @@ struct ll_readahead_state {
 
 extern kmem_cache_t *ll_file_data_slab;
 extern kmem_cache_t *ll_intent_slab;
+
 struct lustre_handle;
 
 struct ll_file_data {
@@ -212,16 +217,19 @@ struct it_cb_data {
 #define LLAP_MAGIC 98764321
 
 struct ll_async_page {
-        int             llap_magic;
+        int              llap_magic;
         void            *llap_cookie;
         struct page     *llap_page;
         struct list_head llap_pending_write;
-         /* only trust these if the page lock is providing exclusion */
+        /* only trust these if the page lock is providing exclusion */
         unsigned         llap_write_queued:1,
                          llap_defer_uptodate:1,
                          llap_origin:3,
                          llap_ra_used:1;
 
+        /* used to find proper capability */
+        uid_t            llap_fsuid;
+
         struct list_head llap_proc_item;
 };
 
@@ -333,8 +341,8 @@ int ll_md_close(struct obd_export *md_exp, struct inode *inode,
                 struct file *file);
 int ll_md_och_close(struct obd_export *md_exp, struct inode *inode,
                     struct obd_client_handle *och, int dirty);
-void ll_och_fill(struct inode *inode, struct lookup_intent *it,
-                 struct obd_client_handle *och);
+int ll_och_fill(struct inode *inode, struct lookup_intent *it,
+                struct obd_client_handle *och);
 int ll_set_audit(struct inode *, __u64);
 int ll_audit_log(struct inode *, audit_op, int);
 
@@ -346,6 +354,13 @@ int ll_getattr(struct vfsmount *mnt, struct dentry *de, struct kstat *stat);
 void ll_stime_record(struct ll_sb_info *sbi, struct timeval *start,
                      struct obd_service_time *stime);
 
+/* llite_capa.c */
+void ll_capa_timer_callback(unsigned long unused);
+int ll_capa_start_thread(void);
+void ll_capa_stop_thread(void);
+int ll_set_och_capa(struct inode *inode, struct lookup_intent *it,
+                           struct obd_client_handle *och);
+
 /* llite/dcache.c */
 void ll_intent_drop_lock(struct lookup_intent *);
 void ll_intent_release(struct lookup_intent *);
index b23522e..f033377 100644 (file)
@@ -318,7 +318,7 @@ static int lustre_init_root_inode(struct super_block *sb)
         /* make root inode */
         err = md_getattr(sbi->ll_md_exp, &sbi->ll_rootid,
                          (OBD_MD_FLNOTOBD | OBD_MD_FLBLOCKS | OBD_MD_FID),
-                         NULL, NULL, 0, 0, &request);
+                         NULL, NULL, 0, 0, NULL, &request);
         if (err) {
                 CERROR("md_getattr failed for root: rc = %d\n", err);
                 GOTO(out, err);
@@ -1177,8 +1177,12 @@ void ll_clear_inode(struct inode *inode)
                 lli->lli_remote_acl = NULL;
         }
 
-        lli->lli_inode_magic = LLI_INODE_DEAD;
+        if (lli->lli_trunc_capa) {
+                OBD_FREE(lli->lli_trunc_capa, sizeof(struct lustre_capa));
+                lli->lli_trunc_capa = NULL;
+        }
 
+        lli->lli_inode_magic = LLI_INODE_DEAD;
         EXIT;
 }
 
@@ -1202,6 +1206,7 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
         struct ll_sb_info *sbi = ll_i2sbi(inode);
         struct ptlrpc_request *request = NULL;
         struct mdc_op_data *op_data;
+        struct lustre_capa *trunc_capa = NULL;
         int ia_valid = attr->ia_valid;
         int err, rc = 0;
         ENTRY;
@@ -1244,9 +1249,6 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
                        LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime),
                        LTIME_S(CURRENT_TIME));
 
-        if (lsm)
-                attr->ia_valid &= ~ATTR_SIZE;
-
         /* If only OST attributes being set on objects, don't do MDS RPC.
          * In that case, we need to check permissions and update the local
          * inode ourselves so we can call obdo_from_inode() always. */
@@ -1284,6 +1286,24 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
                         RETURN(rc);
                 }
 
+                if (attr->ia_valid & ATTR_SIZE) {
+                        /* XXX: hack for truncate capa */
+                        rc = mdc_req2lustre_capa(request, 0, &trunc_capa);
+                        if (rc) {
+                                ptlrpc_req_finished(request);
+                                RETURN(rc);
+                        }
+
+                        spin_lock(&lli->lli_lock);
+                        if (trunc_capa) {
+                                if (lli->lli_trunc_capa)
+                                        OBD_FREE(lli->lli_trunc_capa,
+                                                 sizeof(*trunc_capa));
+                                lli->lli_trunc_capa = trunc_capa;
+                        }
+                        spin_unlock(&lli->lli_lock);
+                }
+
                 /* We call inode_setattr to adjust timestamps, but we first
                  * clear ATTR_SIZE to avoid invoking vmtruncate.
                  *
@@ -1323,6 +1343,9 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr)
                         }
                 }
 
+                if (lsm)
+                        attr->ia_valid &= ~ATTR_SIZE;
+
                 /* won't invoke vmtruncate, as we already cleared ATTR_SIZE */
                 err = inode_setattr(inode, attr);
                 /* 
@@ -2191,8 +2214,8 @@ int ll_iocontrol(struct inode *inode, struct file *file,
                 struct mds_body *body;
 
                 ll_inode2id(&id, inode);
-                rc = md_getattr(sbi->ll_md_exp, &id, valid, NULL, NULL, 0, 0,
-                                &req);
+                rc = md_getattr(sbi->ll_md_exp, &id, valid, NULL, NULL,
+                                0, 0, NULL, &req);
                 if (rc) {
                         CERROR("failure %d inode %lu\n", rc, inode->i_ino);
                         RETURN(-abs(rc));
index e7138c2..d693709 100644 (file)
@@ -79,8 +79,8 @@ static struct inode * search_inode_for_lustre(struct super_block *sb,
         id_ino(&id) = (__u64)ino;
         id_gen(&id) = generation;
 
-        rc = md_getattr(sbi->ll_md_exp, &id, valid, NULL, NULL, 0,
-                        eadatalen, &req);
+        rc = md_getattr(sbi->ll_md_exp, &id, valid, NULL, NULL, 0, 
+                        eadatalen, NULL, &req);
         if (rc) {
                 CERROR("failure %d inode %lu\n", rc, ino);
                 return ERR_PTR(rc);
index 8b50459..3428e45 100644 (file)
@@ -376,14 +376,15 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
         icbd.icbd_childp = &dentry;
         icbd.icbd_parent = parent;
         ll_inode2id(&pid, parent);
+
         /*ONLY need key for open_create file*/
         rc = ll_crypto_init_it_key(parent, it);
         if (rc != 0) 
                 GOTO(out, retval = ERR_PTR(rc)); 
         
-        rc = md_intent_lock(ll_i2mdexp(parent), &pid, (char *)dentry->d_name.name,
-                            dentry->d_name.len, NULL, 0, NULL, it, flags, &req,
+        rc = md_intent_lock(ll_i2mdexp(parent), &pid,
+                            (char *)dentry->d_name.name, dentry->d_name.len,
+                            NULL, 0, NULL, it, flags, &req,
                             ll_mdc_blocking_ast);
         if (rc < 0)
                 GOTO(out, retval = ERR_PTR(rc));
index 8375fc6..3b142fa 100644 (file)
@@ -167,7 +167,7 @@ void ll_truncate(struct inode *inode)
         up(&lli->lli_size_sem);
         
         rc = obd_punch(ll_i2dtexp(inode), oa, lsm, inode->i_size,
-                       OBD_OBJECT_EOF, NULL);
+                       OBD_OBJECT_EOF, NULL, lli->lli_trunc_capa);
         if (rc)
                 CERROR("obd_truncate fails (%d) ino %lu\n", rc, inode->i_ino);
         else
@@ -228,6 +228,9 @@ int ll_prepare_write(struct file *file, struct page *page,
         oa->o_valid = OBD_MD_FLID | OBD_MD_FLMODE |
                 OBD_MD_FLTYPE | OBD_MD_FLGROUP;
 
+        oa->o_fsuid = current->fsuid;
+        oa->o_valid |= OBD_MD_FLFSUID;
+
         rc = obd_brw(OBD_BRW_CHECK, ll_i2dtexp(inode),
                      oa, lsm, 1, &pga, NULL);
         if (rc)
@@ -384,6 +387,7 @@ static void ll_ap_fill_obdo(void *data, int cmd, struct obdo *oa)
 
         llap = LLAP_FROM_COOKIE(data);
         ll_inode_fill_obdo(llap->llap_page->mapping->host, cmd, oa);
+        oa->o_fsuid = llap->llap_fsuid;
         EXIT;
 }
 
@@ -528,6 +532,8 @@ int ll_commit_write(struct file *file, struct page *page, unsigned from,
         if (exp == NULL)
                 RETURN(-EINVAL);
 
+        llap->llap_fsuid = current->fsuid;
+
         /* queue a write for some time in the future the first time we
          * dirty the page */
         if (!PageDirty(page)) {
index 0c0c7bc..1f9a484 100644 (file)
@@ -38,6 +38,7 @@
 
 extern struct address_space_operations ll_aops;
 extern struct address_space_operations ll_dir_aops;
+extern struct timer_list ll_capa_timer;
 
 static struct super_block *ll_read_super(struct super_block *sb,
                                          void *data, int silent)
@@ -116,7 +117,6 @@ static int __init init_lustre_lite(void)
                 return -ENOMEM;
         }
 
-
         proc_lustre_fs_root = proc_lustre_root ? proc_mkdir("llite", proc_lustre_root) : NULL;
 
         rc = register_filesystem(&lustre_lite_fs_type);
@@ -132,6 +132,15 @@ static int __init init_lustre_lite(void)
         rc = ll_gns_start_thread();
         if (rc)
                 goto out;
+
+        ll_capa_timer.function = ll_capa_timer_callback;
+        ll_capa_timer.data = 0;
+        init_timer(&ll_capa_timer);        
+
+        rc = ll_capa_start_thread();
+        if (rc)
+                goto out;
+
         return 0;
 
  out:
@@ -141,6 +150,7 @@ static int __init init_lustre_lite(void)
         case 1:
                 unregister_filesystem(&lustre_lite_fs_type);
         case 0:
+                kmem_cache_destroy(ll_intent_slab);
                 kmem_cache_destroy(ll_file_data_slab);
         }
         return rc;
@@ -151,6 +161,8 @@ static void __exit exit_lustre_lite(void)
         unregister_filesystem(&lustre_lite_fs_type);
         unregister_filesystem(&lustre_fs_type);
 
+        del_timer(&ll_capa_timer);
+        ll_capa_stop_thread();
         ll_gns_stop_thread();
 
         LASSERTF(kmem_cache_destroy(ll_file_data_slab) == 0,
index 8ed5ca5..e758f21 100644 (file)
@@ -178,6 +178,15 @@ static int __init init_lustre_lite(void)
         rc = ll_gns_start_thread();
         if (rc)
                 goto out;
+
+        ll_capa_timer.function = ll_capa_timer_callback;
+        ll_capa_timer.data = 0;
+        init_timer(&ll_capa_timer);        
+
+        rc = ll_capa_start_thread();
+        if (rc)
+                goto out;
+
         return 0;
 out:
         switch (cleanup) {
@@ -196,6 +205,8 @@ static void __exit exit_lustre_lite(void)
         unregister_filesystem(&lustre_fs_type);
         unregister_filesystem(&lustre_lite_fs_type);
 
+        del_timer(&ll_capa_timer);
+        ll_capa_stop_thread();
         ll_gns_stop_thread();
         ll_destroy_inodecache();
         
index 443f782..82e9d32 100644 (file)
@@ -50,7 +50,7 @@ static int ll_readlink_internal(struct inode *inode,
 
         ll_inode2id(&id, inode);
         rc = md_getattr(sbi->ll_md_exp, &id, OBD_MD_LINKNAME, NULL, NULL, 0,
-                        symlen, request);
+                        symlen, NULL, request);
 
         if (rc) {
                 if (rc != -ENOENT)
index 994e002..c3119b4 100644 (file)
@@ -686,7 +686,8 @@ static int lmv_getstatus(struct obd_export *exp, struct lustre_id *id)
 static int lmv_getattr(struct obd_export *exp, struct lustre_id *id,
                        __u64 valid, const char *xattr_name,
                        const void *xattr_data, unsigned int xattr_datalen,
-                       unsigned int ea_size, struct ptlrpc_request **request)
+                       unsigned int ea_size, struct obd_capa *ocapa,
+                       struct ptlrpc_request **request)
 {
         struct obd_device *obd = exp->exp_obd;
         struct lmv_obd *lmv = &obd->u.lmv;
@@ -703,7 +704,7 @@ static int lmv_getattr(struct obd_export *exp, struct lustre_id *id,
 
         rc = md_getattr(lmv->tgts[i].ltd_exp, id, valid,
                         xattr_name, xattr_data, xattr_datalen,
-                        ea_size, request);
+                        ea_size, ocapa, request);
         if (rc)
                 RETURN(rc);
         
@@ -893,7 +894,7 @@ int lmv_get_mea_and_update_object(struct obd_export *exp,
 
         /* time to update mea of parent id */
         rc = md_getattr(lmv->tgts[id_group(id)].ltd_exp,
-                        id, valid, NULL, NULL, 0, mealen, &req);
+                        id, valid, NULL, NULL, 0, mealen, NULL, &req);
         if (rc) {
                 CERROR("md_getattr() failed, error %d\n", rc);
                 GOTO(cleanup, rc);
index 04595e6..adaa0e4 100644 (file)
@@ -310,7 +310,7 @@ lmv_create_obj(struct obd_export *exp, struct lustre_id *id, struct mea *mea)
                 valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA | OBD_MD_MEA;
 
                 rc = md_getattr(lmv->tgts[id_group(id)].ltd_exp,
-                                id, valid, NULL, NULL, 0, mealen, &req);
+                                id, valid, NULL, NULL, 0, mealen, NULL, &req);
                 if (rc) {
                         CERROR("md_getattr() failed, error %d\n", rc);
                         GOTO(cleanup, obj = ERR_PTR(rc));
index 1ed048b..b09283e 100644 (file)
@@ -1097,8 +1097,9 @@ static int lov_revalidate_md(struct obd_export *exp, struct obdo *src_oa,
  * we can send this 'punch' to just the authoritative node and the nodes
  * that the punch will affect. */
 static int lov_punch(struct obd_export *exp, struct obdo *oa,
-                     struct lov_stripe_md *lsm,
-                     obd_off start, obd_off end, struct obd_trans_info *oti)
+                     struct lov_stripe_md *lsm, obd_off start,
+                     obd_off end, struct obd_trans_info *oti,
+                     struct lustre_capa *capa)
 {
         struct lov_request_set *set;
         struct lov_obd *lov;
@@ -1123,7 +1124,7 @@ static int lov_punch(struct obd_export *exp, struct obdo *oa,
 
                 rc = obd_punch(lov->tgts[req->rq_idx].ltd_exp, req->rq_oa, 
                                NULL, req->rq_extent.start, 
-                               req->rq_extent.end, NULL);
+                               req->rq_extent.end, NULL, capa);
                 err = lov_update_punch_set(set, req, rc);
                 if (err) {
                         CERROR("error: punch objid "LPX64" subobj "LPX64
@@ -2207,7 +2208,8 @@ static int lov_set_info(struct obd_export *exp, obd_count keylen,
                 }
                 
                 RETURN(rc);           
-        } else if (KEY_IS("flush_cred") || KEY_IS("crypto_cb")) {
+        } else if (KEY_IS("flush_cred") || KEY_IS("crypto_cb") ||
+                   KEY_IS("capa_key")) {
                 struct lov_tgt_desc *tgt;
                 int rc = 0, i;
 
index d7c7d7c..ecb0869 100644 (file)
@@ -224,7 +224,7 @@ int mdc_enqueue(struct obd_export *exp,
         int reqsize[6] = {[MDS_REQ_SECDESC_OFF] = 0,
                           [MDS_REQ_INTENT_LOCKREQ_OFF] = sizeof(*lockreq),
                           [MDS_REQ_INTENT_IT_OFF] = sizeof(*lit)};
-        int repsize[5] = {sizeof(struct ldlm_reply),
+        int repsize[8] = {sizeof(struct ldlm_reply),
                           sizeof(struct mds_body),
                           obddev->u.cli.cl_max_mds_easize};
         int req_buffers = 3, reply_buffers = 0;
@@ -276,6 +276,7 @@ int mdc_enqueue(struct obd_export *exp,
                 repsize[reply_buffers++] = xattr_acl_size(LL_ACL_MAX_ENTRIES);
                 repsize[reply_buffers++] = sizeof(int);
                 repsize[reply_buffers++] = sizeof(struct crypto_key);
+                repsize[reply_buffers++] = sizeof(struct lustre_capa);
                 req->rq_replen = lustre_msg_size(reply_buffers, repsize);
         } else if (it->it_op & (IT_GETATTR | IT_LOOKUP | IT_CHDIR)) {
                 __u64 valid = data->valid | OBD_MD_FLNOTOBD | OBD_MD_FLEASIZE |
@@ -414,9 +415,9 @@ int mdc_enqueue(struct obd_export *exp,
                   LUSTRE_IT(it)->it_disposition, LUSTRE_IT(it)->it_status);
 
         /* We know what to expect, so we do any byte flipping required here */
-        LASSERT(reply_buffers == 5 || reply_buffers == 4 || 
-                reply_buffers == 3 || reply_buffers == 1 || 
-                reply_buffers == 6 || reply_buffers == 7);
+        LASSERT(reply_buffers == 1 || reply_buffers == 3 || 
+                reply_buffers == 5 || reply_buffers == 7 || 
+                reply_buffers == 8);
         if (reply_buffers >= 3) {
                 struct mds_body *body;
 
@@ -452,6 +453,16 @@ int mdc_enqueue(struct obd_export *exp,
                                  * have to shift other data around. */
                         }
                 }
+
+                /* just swab out capa to check here, and for future use */
+                if (body->valid & OBD_MD_CAPA) {
+                        struct lustre_capa *capa;
+
+                        LASSERT(it->it_op & IT_OPEN);
+                        capa = lustre_swab_repbuf(req, 7, sizeof(*capa),
+                                                  lustre_swab_lustre_capa);
+                        LASSERT(capa);
+                }
         }
 
         RETURN(rc);
index b349b88..6679464 100644 (file)
@@ -121,6 +121,8 @@ int mdc_setattr(struct obd_export *exp, struct mdc_op_data *data,
         if (ealen == sizeof(XATTR_NAME_LUSTRE_ACL) &&
             !strncmp((char *) ea, XATTR_NAME_LUSTRE_ACL, ealen)) {
                 size[bufcount++] = LUSTRE_ACL_SIZE_MAX;
+        } else if (iattr->ia_valid & ATTR_SIZE) {
+                size[bufcount++] = sizeof(struct lustre_capa);
         }
 
         req->rq_replen = lustre_msg_size(bufcount, size);
index 01fd020..eb7bcdf 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/lustre_sec.h>
 #include <linux/lprocfs_status.h>
 #include <linux/lustre_acl.h>
+#include <linux/lustre_lite.h>
 #include <linux/lustre_gs.h>
 #include "mdc_internal.h"
 
@@ -101,6 +102,62 @@ int mdc_getstatus(struct obd_export *exp, struct lustre_id *rootid)
                               LUSTRE_IMP_FULL, 0);
 }
 
+int
+mdc_interpret_getattr(struct ptlrpc_request *req, void *unused, int rc)
+{
+        struct mds_body *body = NULL;
+        struct lustre_capa *capa = NULL;
+        unsigned long expiry;
+        ENTRY;
+
+        if (rc) {
+                DEBUG_REQ(D_ERROR, req,
+                          "async getattr failed: rc = %d", rc);
+                RETURN(rc);
+        }
+
+        body = lustre_swab_repbuf(req, 0, sizeof (*body), lustre_swab_mds_body);
+        if (body == NULL) {
+                CERROR ("Can't unpack mds_body\n");
+                RETURN(-EPROTO);
+        }
+
+        if (!(body->valid & OBD_MD_CAPA)) {
+                CDEBUG(D_INFO, "MDS has disabled capability\n");
+                RETURN(0);
+        }
+
+        capa = lustre_swab_repbuf(req, 1, sizeof(*capa),
+                                  lustre_swab_lustre_capa);
+        if (capa == NULL && rc != 0) {
+                CERROR ("Can't unpack lustre_capa\n");
+                RETURN(-EPROTO);
+        }
+
+        rc = capa_renew(capa, CLIENT_CAPA);
+        if (rc)
+                RETURN(rc);
+
+        expiry = expiry_to_jiffies(capa->lc_expiry - capa_pre_expiry(capa));
+        if (time_before(expiry, ll_capa_timer.expires) ||
+            !timer_pending(&ll_capa_timer))
+                mod_timer(&ll_capa_timer, expiry);
+
+        RETURN(rc);
+}
+
+int mdc_getattr_async(struct obd_export *exp, struct ptlrpc_request *req)
+{
+        int repsize[2] = {sizeof(struct mds_body), sizeof(struct lustre_capa)};
+        ENTRY;
+
+        req->rq_replen = lustre_msg_size(1, repsize);
+        req->rq_interpret_reply = mdc_interpret_getattr;
+        ptlrpcd_add_req(req);
+
+        RETURN (0);
+}
+
 int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
                        struct ptlrpc_request *req)
 {
@@ -125,6 +182,9 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
         if (reqbody->valid & OBD_MD_FLKEY) {
                 repsize[bufcount++] = 5;
                 repsize[bufcount++] = sizeof(struct lustre_key);
+        } else if (reqbody->valid & OBD_MD_CAPA) {
+                LASSERT(ea_size == 0);
+                repsize[bufcount++] = sizeof(struct lustre_capa);
         }
 
         req->rq_replen = lustre_msg_size(bufcount, repsize);
@@ -175,7 +235,8 @@ static int mdc_cancel_unused(struct obd_export *exp,
 int mdc_getattr(struct obd_export *exp, struct lustre_id *id,
                 __u64 valid, const char *xattr_name,
                 const void *xattr_data, unsigned int xattr_datalen,
-                unsigned int ea_size, struct ptlrpc_request **request)
+                unsigned int ea_size, struct obd_capa *ocapa,
+                struct ptlrpc_request **request)
 {
         struct ptlrpc_request *req;
         struct mds_body *body;
@@ -194,8 +255,13 @@ int mdc_getattr(struct obd_export *exp, struct lustre_id *id,
                         LASSERT(xattr_data);
                         size[bufcount++] = xattr_datalen;
                 }
-        } else
+        } else if (valid & OBD_MD_CAPA) {
+                LASSERT(valid  == OBD_MD_CAPA);
+                LASSERT(ocapa);
+                size[bufcount++] = sizeof(*ocapa);
+        } else {
                 LASSERT(!xattr_data && !xattr_datalen);
+        }
 
         req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
                               MDS_GETATTR, bufcount, size, NULL);
@@ -217,10 +283,20 @@ int mdc_getattr(struct obd_export *exp, struct lustre_id *id,
                                xattr_data, xattr_datalen);
         }
 
-        rc = mdc_getattr_common(exp, ea_size, req);
-        if (rc != 0) {
-                ptlrpc_req_finished (req);
-                req = NULL;
+        if (valid & OBD_MD_CAPA) {
+                /* renew capability */
+                memcpy(&body->handle, &ocapa->c_handle, sizeof(body->handle));
+                memcpy(lustre_msg_buf(req->rq_reqmsg, 2, sizeof(ocapa->c_capa)),
+                       &ocapa->c_capa, sizeof(ocapa->c_capa));
+
+                rc = mdc_getattr_async(exp, req);
+                req = NULL;     /* ptlrpcd will finish request */
+        } else {
+                rc = mdc_getattr_common(exp, ea_size, req);
+                if (rc != 0) {
+                        ptlrpc_req_finished (req);
+                        req = NULL;
+                }
         }
  out:
         *request = req;
@@ -328,6 +404,34 @@ int mdc_store_inode_generation(struct obd_export *exp,
         return 0;
 }
 
+int mdc_req2lustre_capa(struct ptlrpc_request *req, unsigned int offset,
+                        struct lustre_capa **capa)
+{
+        struct mds_body *body;
+        struct lustre_capa *lcapa;
+
+        body = lustre_msg_buf(req->rq_repmsg, offset, sizeof(*body));
+        if (!body)
+                RETURN(-ENOMEM);
+
+        if (!(body->valid & OBD_MD_CAPA)) {
+                *capa = NULL;
+                RETURN(0);
+        }
+
+        lcapa = (struct lustre_capa *)lustre_swab_repbuf(req, offset + 1,
+                                        sizeof(*capa), lustre_swab_lustre_capa);
+        if (!lcapa)
+                RETURN(-ENOMEM);
+                
+        OBD_ALLOC(*capa, sizeof(**capa));
+        if (!*capa)
+                RETURN(-ENOMEM);
+        memcpy(*capa, lcapa, sizeof(**capa));
+
+        RETURN(0);
+}
+
 static int mdc_unpack_acl(struct obd_export *exp_lmv, struct ptlrpc_request *req, 
                           unsigned int *offset, struct lustre_md *md)
 {
@@ -342,7 +446,7 @@ static int mdc_unpack_acl(struct obd_export *exp_lmv, struct ptlrpc_request *req
         if (md->body->valid & OBD_MD_FLACL) {
                 acl_off = *offset;
                 if (md->body->valid & OBD_MD_FLRMTACL) {
-                        
+                        acl_off++; /* XXX: pass place where acl size is stored */
                         buf = lustre_swab_repbuf(req, acl_off++, sizeof(*perm),
                                                  lustre_swab_remote_perm);
                         if (buf == NULL) {
@@ -379,6 +483,7 @@ static int mdc_unpack_acl(struct obd_export *exp_lmv, struct ptlrpc_request *req
         }
         RETURN(rc);
 }
+
 static int mdc_unpack_gskey(struct obd_export *exp_lmv, struct ptlrpc_request *req, 
                             unsigned int *offset, struct lustre_md *md)
 { 
@@ -398,6 +503,7 @@ static int mdc_unpack_gskey(struct obd_export *exp_lmv, struct ptlrpc_request *r
         }  
         RETURN(rc);
 }
+
 int mdc_req2lustre_md(struct obd_export *exp_lmv, struct ptlrpc_request *req, 
                       unsigned int offset, struct obd_export *exp_lov, 
                       struct lustre_md *md)
@@ -1318,6 +1424,7 @@ static int mdc_llog_finish(struct obd_device *obd,
         rc = obd_llog_cleanup(llog_get_context(llogs, LLOG_CONFIG_REPL_CTXT));
         RETURN(rc);
 }
+
 static struct obd_device *mdc_get_real_obd(struct obd_export *exp,
                                            struct lustre_id *id)
 {
@@ -1673,6 +1780,7 @@ MODULE_DESCRIPTION("Lustre Metadata Client");
 MODULE_LICENSE("GPL");
 
 EXPORT_SYMBOL(mdc_req2lustre_md);
+EXPORT_SYMBOL(mdc_req2lustre_capa);
 EXPORT_SYMBOL(mdc_change_cbdata);
 EXPORT_SYMBOL(mdc_getstatus);
 EXPORT_SYMBOL(mdc_getattr);
index a3032e2..61be9dd 100644 (file)
@@ -1,6 +1,6 @@
 MODULES := mds
 mds-objs := mds_log.o mds_unlink_open.o mds_lov.o handler.o mds_reint.o
 mds-objs += mds_fs.o lproc_mds.o mds_open.o mds_lib.o mds_lmv.o mds_lsd.o
-mds-objs += mds_audit_path.o mds_audit.o mds_acl.o
+mds-objs += mds_audit_path.o mds_audit.o mds_acl.o mds_capa.o
 
 @INCLUDE_RULES@
index 089e7bc..756d671 100644 (file)
 #include <linux/lprocfs_status.h>
 #include <linux/lustre_commit_confd.h>
 #include <linux/lustre_acl.h>
-#include <linux/lustre_gs.h>
-#include "mds_internal.h"
 #include <linux/lustre_sec.h>
+#include <linux/lustre_gs.h>
 #include <linux/lustre_audit.h>
 
+#include "mds_internal.h"
+
 extern int mds_audit_auth(struct ptlrpc_request *, struct lvfs_ucred *,
                           audit_op, struct lustre_id *,
                           char *, int);
@@ -1112,6 +1113,7 @@ int mds_pack_posix_acl(struct lustre_msg *repmsg, int *offset,
 
         buflen = repmsg->buflens[pack_off];
         buf = lustre_msg_buf(repmsg, pack_off++, buflen);
+        *offset = pack_off;
 
         size = inode->i_op->getxattr(&de, XATTR_NAME_ACL_ACCESS, buf, buflen);
         if (size == -ENODATA || size == -EOPNOTSUPP)
@@ -1122,8 +1124,6 @@ int mds_pack_posix_acl(struct lustre_msg *repmsg, int *offset,
         body->valid |= OBD_MD_FLACL;
 
         *sizep = cpu_to_le32(size);
-        
-        *offset = pack_off;
         RETURN(0);
 }
 
@@ -1139,6 +1139,7 @@ int mds_pack_remote_perm(struct ptlrpc_request *req, int *reply_off,
         LASSERT(inode->i_op->permission);
         LASSERT(req->rq_export->exp_mds_data.med_remote);
 
+        pack_off++; /* XXX: ignore the place for acl count */
         perm = (struct mds_remote_perm *)
                        lustre_msg_buf(req->rq_repmsg, pack_off++, sizeof(perm));
         if (!perm)
@@ -1260,6 +1261,25 @@ static int mds_getattr_internal(struct obd_device *obd, struct dentry *dentry,
         
         mds_pack_audit(obd, inode, body);
 
+        if (reqbody->valid & OBD_MD_CAPA) {
+                struct lustre_capa *req_capa;
+
+                LASSERT(!(reqbody->valid & ~OBD_MD_CAPA));
+                LASSERT(S_ISREG(inode->i_mode));
+
+                req_capa = lustre_swab_reqbuf(req, req_off + 1,
+                                              sizeof(*req_capa),
+                                              lustre_swab_lustre_capa);
+                if (req_capa == NULL) {
+                        CERROR("Can't unpack capa\n");
+                        RETURN(-EFAULT);
+                }
+
+                offset = reply_off + 1;
+                rc = mds_pack_capa(obd, reqbody, req_capa, req->rq_repmsg,
+                                   &offset, body);
+        }
+
         if (rc == 0)
                 mds_body_do_reverse_map(med, body);
 
@@ -1386,6 +1406,9 @@ static int mds_getattr_pack_msg(struct ptlrpc_request *req, struct dentry *de,
                 size[bufcount++] = sizeof(struct crypto_key);
         }
 
+        if (body->valid & OBD_MD_CAPA)
+                size[bufcount++] = sizeof(struct lustre_capa);
+
         if (OBD_FAIL_CHECK(OBD_FAIL_MDS_GETATTR_PACK)) {
                 CERROR("failed MDS_GETATTR_PACK test\n");
                 req->rq_status = -ENOMEM;
@@ -3542,6 +3565,7 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
         struct vfsmount *mnt;
         char ns_name[48];
         unsigned long page;
+        struct crypto_tfm *tfm = NULL;
         int rc = 0;
         ENTRY;
 
@@ -3653,11 +3677,19 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
         }
         ldlm_register_intent(obd->obd_namespace, mds_intent_policy);
 
+        tfm = crypto_alloc_tfm(CAPA_HMAC_ALG, 0);
+        if (!tfm)
+                GOTO(err_ns, rc = -ENOSYS);
+
+        mds->mds_capa_hmac = tfm;
+        mds->mds_capa_timeout = CAPA_TIMEOUT;
+        mds->mds_capa_key_timeout = CAPA_KEY_TIMEOUT;
+        
         rc = mds_fs_setup(obd, mnt);
         if (rc) {
                 CERROR("%s: MDS filesystem method init failed: rc = %d\n",
                        obd->obd_name, rc);
-                GOTO(err_ns, rc);
+                GOTO(err_capa, rc);
         }
 
         rc = llog_start_commit_thread();
@@ -3714,6 +3746,8 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
 err_fs:
         /* No extra cleanup needed for llog_init_commit_thread() */
         mds_fs_cleanup(obd, 0);
+err_capa:
+        crypto_free_tfm(mds->mds_capa_hmac);
 err_ns:
         ldlm_namespace_free(obd->obd_namespace, 0);
         obd->obd_namespace = NULL;
@@ -3976,6 +4010,10 @@ static int mds_cleanup(struct obd_device *obd, int flags)
         }
         spin_unlock(&mds->mds_denylist_lock);
 
+        mds_capa_keys_cleanup(obd);
+
+        if (mds->mds_capa_hmac)
+                crypto_free_tfm(mds->mds_capa_hmac);
         RETURN(0);
 }
 
@@ -4108,25 +4146,28 @@ static int mds_intent_prepare_reply_buffers(struct ptlrpc_request *req,
 {
         struct mds_obd *mds = &req->rq_export->exp_obd->u.mds;
         int rc, reply_buffers;
-        int repsize[5] = {sizeof(struct ldlm_reply),
+        int repsize[8] = {sizeof(struct ldlm_reply),
                           sizeof(struct mds_body),
                           mds->mds_max_mdsize};
         ENTRY;       
  
         reply_buffers = 3;
         if (it->opc & ( IT_OPEN | IT_GETATTR | IT_LOOKUP | IT_CHDIR )) {
-                if (req->rq_export->exp_mds_data.med_remote) {
-                        repsize[reply_buffers++] = 
-                                sizeof(struct mds_remote_perm);
-                } else {
-                        repsize[reply_buffers++] = sizeof(int);
-                        repsize[reply_buffers++] = 
+                repsize[reply_buffers++] = sizeof(int);
+                /* XXX: mds_remote_perm is stored here too, and for it
+                 *      the 'size' is ignored */
+                repsize[reply_buffers++] = 
                                 xattr_acl_size(LL_ACL_MAX_ENTRIES);
-                }
+
                 /*FIXME: ugly here, should be optimize for there 
                  * is no crypto key*/
                 repsize[reply_buffers++] = sizeof(int);
                 repsize[reply_buffers++] = sizeof(struct crypto_key); 
+
+                /* XXX: if new buffer is to be added, capability reply
+                 *      buffer should always been reserved. */
+                if (it->opc & IT_OPEN)
+                        repsize[reply_buffers++] = sizeof(struct lustre_capa);
         }
 
         rc = lustre_pack_reply(req, reply_buffers, repsize, NULL);
@@ -4553,10 +4594,10 @@ struct lvfs_callback_ops mds_lvfs_ops = {
 };
 
 int mds_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
-               int objcount, struct obd_ioobj *obj,
-               int niocount, struct niobuf_remote *nb,
-               struct niobuf_local *res,
-               struct obd_trans_info *oti);
+                int objcount, struct obd_ioobj *obj,
+                int niocount, struct niobuf_remote *nb,
+                struct niobuf_local *res,
+                struct obd_trans_info *oti, struct lustre_capa *capa);
 
 int mds_commitrw(int cmd, struct obd_export *exp, struct obdo *oa,
                  int objcount, struct obd_ioobj *obj, int niocount,
@@ -4602,6 +4643,8 @@ static struct obd_ops mdt_obd_ops = {
 static int __init mds_init(void)
 {
         struct lprocfs_static_vars lvars;
+        int rc = 0;
+        ENTRY;
 
         mds_init_lsd_cache();
         mds_init_rmtacl_upcall_cache();
@@ -4613,11 +4656,23 @@ static int __init mds_init(void)
         class_register_type(&mdt_obd_ops, NULL, lvars.module_vars,
                             OBD_MDT_DEVICENAME);
 
-        return 0;
+        rc = mds_capa_key_start_thread();
+        if (rc) {
+                class_unregister_type(OBD_MDT_DEVICENAME);
+                class_unregister_type(OBD_MDS_DEVICENAME);
+                mds_cleanup_lsd_cache();
+        }
+                
+        mds_eck_timer.function = mds_capa_key_timer_callback;
+        mds_eck_timer.data = 0;
+        init_timer(&mds_eck_timer);
+
+        RETURN(rc);
 }
 
 static void /*__exit*/ mds_exit(void)
 {
+        mds_capa_key_stop_thread();
         mds_cleanup_rmtacl_upcall_cache();
         mds_cleanup_lsd_cache();
 
index fa8cbe6..1122d8a 100644 (file)
@@ -133,6 +133,78 @@ static int lprocfs_rd_group(char *page, char **start, off_t off,
                         (unsigned long)mds->mds_num);
 }
 
+static int lprocfs_rd_capa(char *page, char **start, off_t off,
+                           int count, int *eof, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+        LASSERT(obd != NULL);
+
+        return snprintf(page, count, "%d\n",
+                        obd->u.mds.mds_capa_stat);
+}
+
+static int lprocfs_wr_capa(struct file *file, const char *buffer,
+                           unsigned long count, void *data)
+{
+        struct obd_device *obd = data;
+        int val, rc;
+
+        rc = lprocfs_write_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        obd->u.mds.mds_capa_stat = val;
+        return count;
+}
+
+static int lprocfs_rd_capa_timeout(char *page, char **start, off_t off,
+                                       int count, int *eof, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+        LASSERT(obd != NULL);
+
+        return snprintf(page, count, "%lu\n",
+                        obd->u.mds.mds_capa_timeout);
+}
+
+static int lprocfs_wr_capa_timeout(struct file *file, const char *buffer,
+                                       unsigned long count, void *data)
+{
+        struct obd_device *obd = data;
+        int val, rc;
+
+        rc = lprocfs_write_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        obd->u.mds.mds_capa_timeout = val;
+        return count;
+}
+
+static int lprocfs_rd_capa_key_timeout(char *page, char **start, off_t off,
+                                           int count, int *eof, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+        LASSERT(obd != NULL);
+
+        return snprintf(page, count, "%lu\n",
+                        obd->u.mds.mds_capa_key_timeout);
+}
+
+static int lprocfs_wr_capa_key_timeout(struct file *file, const char *buffer,
+                                           unsigned long count, void *data)
+{
+        struct obd_device *obd = data;
+        int val, rc;
+
+        rc = lprocfs_write_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        obd->u.mds.mds_capa_key_timeout = val;
+        return count;
+}
+
 struct lprocfs_vars lprocfs_mds_obd_vars[] = {
         { "uuid",         lprocfs_rd_uuid,        0, 0 },
         { "blocksize",    lprocfs_rd_blksize,     0, 0 },
@@ -146,10 +218,16 @@ struct lprocfs_vars lprocfs_mds_obd_vars[] = {
         { "mntdev",       lprocfs_mds_rd_mntdev,  0, 0 },
         { "last_fid",     lprocfs_rd_last_fid,    0, 0 },
         { "group",        lprocfs_rd_group,       0, 0 },
-        { "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 },
-        { "evict_client", 0, lprocfs_mds_wr_evict_client, 0 },
+        { "recovery_status",  lprocfs_obd_rd_recovery_status, 0, 0 },
+        { "evict_client", 0,  lprocfs_mds_wr_evict_client, 0 },
         { "config_update", 0, lprocfs_mds_wr_config_update, 0 },
-        { "num_exports",  lprocfs_rd_num_exports, 0, 0 },
+        { "num_exports",      lprocfs_rd_num_exports, 0, 0 },
+        { "capa",             lprocfs_rd_capa,
+                              lprocfs_wr_capa, 0 },
+        { "capa_timeout",     lprocfs_rd_capa_timeout,
+                              lprocfs_wr_capa_timeout, 0 },
+        { "capa_key_timeout", lprocfs_rd_capa_key_timeout,
+                              lprocfs_wr_capa_key_timeout, 0 },
         { 0 }
 };
 
diff --git a/lustre/mds/mds_capa.c b/lustre/mds/mds_capa.c
new file mode 100644 (file)
index 0000000..63f9aec
--- /dev/null
@@ -0,0 +1,472 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2004, 2005 Cluster File Systems, Inc.
+ *
+ * Author: Lai Siyao <lsy@clusterfs.com>
+ *
+ *   This file is part of Lustre, http://www.lustre.org.
+ *
+ *   Lustre is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2 of the GNU General Public
+ *   License as published by the Free Software Foundation.
+ *
+ *   Lustre is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with Lustre; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#define DEBUG_SUBSYSTEM S_MDS
+
+#include <linux/fs.h>
+#include <linux/version.h>
+#include <asm/uaccess.h>
+#include <linux/file.h>
+#include <linux/kmod.h>
+#include <linux/random.h>
+
+#include <linux/obd.h>
+#include <linux/lustre_mds.h>
+#include <linux/lustre_fsfilt.h>
+#include <linux/lustre_sec.h>
+
+#include "mds_internal.h"
+
+static struct ptlrpc_thread mds_eck_thread;
+
+static struct thread_ctl {
+        struct completion ctl_starting;
+        struct completion ctl_finishing;
+} mds_eck_ctl;
+
+static LIST_HEAD(mds_capa_key_list);
+static LIST_HEAD(mds_expired_capa_keys);
+static spinlock_t mds_capa_lock; /* protect capa and capa key */
+struct timer_list mds_eck_timer;
+
+#define CUR_MDS_CAPA_KEY(mds) mds->mds_capa_keys[mds->mds_capa_key_idx]
+#define CUR_CAPA_KEY(mds) CUR_MDS_CAPA_KEY(mds).k_key
+#define CUR_CAPA_KEY_ID(mds) CUR_MDS_CAPA_KEY(mds).k_key->lk_keyid
+#define CUR_CAPA_KEY_EXPIRY(mds) expiry_to_jiffies(CUR_CAPA_KEY(mds)->lk_expiry)
+#define CUR_CAPA_KEY_LIST(mds) CUR_MDS_CAPA_KEY(mds).k_list
+
+static int mds_write_capa_key(struct obd_device *obd, int force_sync)
+{
+        struct mds_obd *mds = &obd->u.mds;
+        struct mds_capa_key *keys = mds->mds_capa_keys;
+        struct file *filp = mds->mds_capa_keys_filp;
+        struct lvfs_run_ctxt saved;
+        loff_t off = 0;
+        int i, rc;
+        ENTRY;
+
+        push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+        for (i = 0; i < 2 && keys[i].k_key; i++) {
+                rc = fsfilt_write_record(obd, filp, keys[i].k_key,
+                                         sizeof(*keys[i].k_key),
+                                         &off, force_sync);
+                if (rc) {
+                        CERROR("error writing MDS capa key: rc = %d\n", rc);
+                        break;
+                }
+        }
+        pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+
+        RETURN(rc);
+}
+
+static inline int
+mds_capa_key_cmp(struct mds_obd *mds)
+{
+        return capa_key_cmp(mds->mds_capa_keys[0].k_key,
+                            mds->mds_capa_keys[1].k_key);
+}
+
+static void
+do_update_capa_key(struct mds_obd *mds, struct lustre_capa_key *key)
+{
+        __u32 keyid = 1;
+        __u64 expiry_rounded;
+
+        if (CUR_CAPA_KEY(mds))
+                keyid = le32_to_cpu(CUR_CAPA_KEY(mds)->lk_keyid) + 1;
+        expiry_rounded = round_expiry(mds->mds_capa_key_timeout);
+
+        key->lk_mdsid = cpu_to_le32(mds->mds_num);
+        key->lk_keyid = cpu_to_le32(keyid);
+        key->lk_expiry = cpu_to_le64(expiry_rounded);
+        get_random_bytes(key->lk_key, sizeof(key->lk_key));
+}
+
+static void list_add_capa_key(struct mds_capa_key *key, struct list_head *head)
+{
+        struct mds_capa_key *tmp;
+
+        list_for_each_entry_reverse(tmp, head, k_list) {
+                if (key->k_key->lk_expiry > tmp->k_key->lk_expiry) {
+                        list_add(&key->k_list, &tmp->k_list);
+                        return;
+                }
+        }
+
+        list_add(&key->k_list, head);
+}
+
+int mds_read_capa_key(struct obd_device *obd, struct file *file)
+{
+        loff_t off = 0;
+        struct mds_obd *mds = &obd->u.mds;
+        struct lustre_capa_key *key;
+        unsigned long capa_keys_size = file->f_dentry->d_inode->i_size;
+        int i = 0, rc = 0;
+        ENTRY;
+
+        if (capa_keys_size == 0) {
+                CWARN("%s: initializing new %s\n", obd->obd_name,
+                      file->f_dentry->d_name.name);
+                 
+                OBD_ALLOC(key, sizeof(*key));
+                if (!key)
+                        RETURN(-ENOMEM);
+
+                do_update_capa_key(mds, key);
+
+                mds->mds_capa_keys[0].k_key = key;
+                mds->mds_capa_keys[0].k_obd = obd;
+                INIT_LIST_HEAD(&mds->mds_capa_keys[0].k_list);
+                mds->mds_capa_key_idx = 0;
+
+                rc = mds_write_capa_key(obd, 1);
+                if (rc)
+                        GOTO(out, rc);
+        } else {
+                LASSERT(capa_keys_size == sizeof(*key) ||
+                        capa_keys_size == 2 * sizeof(*key));
+
+                while (capa_keys_size > i * sizeof(*key)) {
+                        OBD_ALLOC(key, sizeof(*key));
+                        if (!key)
+                                RETURN(-ENOMEM);
+
+                        rc = fsfilt_read_record(obd, file, key, sizeof(*key),
+                                                &off);
+                        if (rc) {
+                                CERROR("error reading MDS %s capa key: %d\n",
+                                       file->f_dentry->d_name.name, rc);
+                                OBD_FREE(key, sizeof(*key));
+                                GOTO(out, rc);
+                        }
+
+                        mds->mds_capa_keys[i].k_key = key;
+                        mds->mds_capa_keys[i].k_obd = obd;
+                        INIT_LIST_HEAD(&mds->mds_capa_keys[i].k_list);
+                        i++;
+                }
+
+                mds->mds_capa_key_idx = 0;
+                if (mds->mds_capa_keys[1].k_key && mds_capa_key_cmp(mds) < 0)
+                        mds->mds_capa_key_idx = 1;
+        }
+
+        spin_lock(&mds_capa_lock);
+        if (time_before(CUR_CAPA_KEY_EXPIRY(mds), mds_eck_timer.expires)
+            || !timer_pending(&mds_eck_timer))
+                mod_timer(&mds_eck_timer, CUR_CAPA_KEY_EXPIRY(mds));
+
+        list_add_capa_key(&CUR_MDS_CAPA_KEY(mds), &mds_capa_key_list);
+        spin_unlock(&mds_capa_lock);
+out:
+        RETURN(rc);
+}
+
+void mds_capa_keys_cleanup(struct obd_device *obd)
+{
+        struct mds_obd *mds = &obd->u.mds;
+        int i;
+
+        spin_lock(&mds_capa_lock);
+        if (CUR_CAPA_KEY(mds))
+                list_del_init(&CUR_CAPA_KEY_LIST(mds));
+        spin_unlock(&mds_capa_lock);
+
+        for (i = 0; i < 2; i++)
+                if (mds->mds_capa_keys[i].k_key)
+                        OBD_FREE(mds->mds_capa_keys[i].k_key,
+                                 sizeof(struct lustre_capa_key));
+}
+
+static int mds_set_capa_key(struct obd_device *obd, struct lustre_capa_key *key)
+{
+        struct mds_obd *mds = &obd->u.mds;
+        int rc;
+        ENTRY;
+
+        rc = obd_set_info(mds->mds_dt_exp, strlen("capa_key"), "capa_key",
+                          sizeof(*key), key);
+        if (rc)
+                CERROR("obd_set_info capa_key failed: rc = %d\n", rc);
+
+        RETURN(rc);
+}
+
+static int
+mds_update_capa_key(struct obd_device *obd, struct mds_capa_key *mkey,
+                    int force_sync)
+{
+        struct mds_obd *mds = &obd->u.mds;
+        int to_update = mds->mds_capa_key_idx ^ 1;
+        struct lustre_capa_key *key = mds->mds_capa_keys[to_update].k_key;
+        __u32 keyid;
+        int rc = 0;
+        ENTRY;
+
+        LASSERT(mkey != &mds->mds_capa_keys[to_update]);
+
+        if (key == NULL) {
+                /* first update */
+                OBD_ALLOC(key, sizeof(*key));
+                if (!key)
+                        RETURN(-ENOMEM);
+                mds->mds_capa_keys[to_update].k_key = key;
+                mds->mds_capa_keys[to_update].k_obd = obd;
+        }
+
+        do_update_capa_key(mds, key);
+
+        keyid = le32_to_cpu(key->lk_keyid);
+
+        rc = mds_set_capa_key(obd, key);
+        if (rc) {
+                CERROR("error set capa key(id %u), err = %d\n", keyid, rc);
+                GOTO(out, rc);
+        }
+
+        CDEBUG(D_INFO, "MDS capa_keyid is %u\n", keyid);
+
+        rc = mds_write_capa_key(obd, 1);
+        if (rc)
+                GOTO(out, rc);
+        
+        CDEBUG(D_INFO, "wrote capa keyid %u: err = %d\n", keyid, rc);
+
+        spin_lock(&mds_capa_lock);
+        list_del_init(&CUR_CAPA_KEY_LIST(mds));
+        mds->mds_capa_key_idx = to_update;
+        list_add_capa_key(&CUR_MDS_CAPA_KEY(mds), &mds_capa_key_list);
+        spin_unlock(&mds_capa_lock);
+
+        /* TODO: update timer here */
+out:
+        RETURN(rc);
+}
+
+static inline int have_expired_capa_key(void)
+{
+        struct mds_capa_key *key;
+        int expired = 0;
+        ENTRY;
+
+        spin_lock(&mds_capa_lock);
+        if (!list_empty(&mds_capa_key_list)) {
+                key = list_entry(mds_capa_key_list.next, struct mds_capa_key,
+                                 k_list);
+                expired = time_before(expiry_to_jiffies(key->k_key->lk_expiry),
+                                      jiffies);
+        }
+        spin_unlock(&mds_capa_lock);
+
+        RETURN(expired);
+}
+
+static int inline mds_capa_key_check_stop(void)
+{
+        return (mds_eck_thread.t_flags & SVC_STOPPING) ? 1: 0;
+}
+
+static int mds_capa_key_thread_main(void *arg)
+{
+        struct thread_ctl *ctl = arg;
+        unsigned long flags;
+        ENTRY;
+
+        {
+                char name[sizeof(current->comm)];
+                snprintf(name, sizeof(name) - 1, "mds_ck");
+                kportal_daemonize(name);
+        }
+
+        SIGNAL_MASK_LOCK(current, flags);
+        sigfillset(&current->blocked);
+        RECALC_SIGPENDING;
+        SIGNAL_MASK_UNLOCK(current, flags);
+
+        /*
+         * letting starting function know, that we are ready and control may be
+         * returned.
+         */
+        mds_eck_thread.t_flags = SVC_RUNNING;
+        complete(&ctl->ctl_starting);
+
+        while (!mds_capa_key_check_stop()) {
+                struct l_wait_info lwi = { 0 };
+                struct mds_capa_key *key, *tmp, *next = NULL;
+
+                l_wait_event(mds_eck_thread.t_ctl_waitq,
+                             (have_expired_capa_key() ||
+                              mds_capa_key_check_stop()),
+                             &lwi);
+
+                spin_lock(&mds_capa_lock);
+                list_for_each_entry_safe(key, tmp, &mds_capa_key_list, k_list) {
+                        if (time_after(expiry_to_jiffies(key->k_key->lk_expiry),
+                                       jiffies)) {
+                                next = key;
+                                break;
+                        }
+
+                        spin_unlock(&mds_capa_lock);
+
+                        CDEBUG(D_INFO, "mds capa key expired, wake up updating "
+                                       "thread: mds #%u, key #%u\n",
+                               le32_to_cpu(key->k_key->lk_mdsid),
+                               le32_to_cpu(key->k_key->lk_keyid));
+
+                        mds_update_capa_key(key->k_obd, key, 1);
+                        spin_lock(&mds_capa_lock);
+                }
+
+                if (next)
+                        mod_timer(&mds_eck_timer,
+                                  expiry_to_jiffies(next->k_key->lk_expiry));
+                spin_unlock(&mds_capa_lock);
+        }
+
+        mds_eck_thread.t_flags = SVC_STOPPED;
+
+        /* this is SMP-safe way to finish thread. */
+        complete_and_exit(&ctl->ctl_finishing, 0);
+        EXIT;
+}
+
+void mds_capa_key_timer_callback(unsigned long unused)
+{
+        ENTRY;
+        wake_up(&mds_eck_thread.t_ctl_waitq);
+        EXIT;
+}
+
+int mds_capa_key_start_thread(void)
+{
+        int rc;
+        ENTRY;
+
+        LASSERT(mds_eck_thread.t_flags == 0);
+        init_completion(&mds_eck_ctl.ctl_starting);
+        init_completion(&mds_eck_ctl.ctl_finishing);
+        init_waitqueue_head(&mds_eck_thread.t_ctl_waitq);
+        spin_lock_init(&mds_capa_lock);
+
+        rc = kernel_thread(mds_capa_key_thread_main, &mds_eck_ctl,
+                           (CLONE_VM | CLONE_FILES));
+        if (rc < 0) {
+                CERROR("cannot start capa key thread, "
+                       "err = %d\n", rc);
+                RETURN(rc);
+        }
+
+        wait_for_completion(&mds_eck_ctl.ctl_starting);
+        LASSERT(mds_eck_thread.t_flags == SVC_RUNNING);
+        RETURN(0);
+}
+
+void mds_capa_key_stop_thread(void)
+{
+        ENTRY;
+        mds_eck_thread.t_flags = SVC_STOPPING;
+        wake_up(&mds_eck_thread.t_ctl_waitq);
+        wait_for_completion(&mds_eck_ctl.ctl_finishing);
+        LASSERT(mds_eck_thread.t_flags == SVC_STOPPED);
+        mds_eck_thread.t_flags = 0;
+        EXIT;
+}
+
+int mds_pack_capa(struct obd_device *obd, struct mds_body *req_body,
+                  struct lustre_capa *req_capa, struct lustre_msg *repmsg,
+                  int *offset, struct mds_body *body)
+{
+        struct mds_obd *mds = &obd->u.mds;
+        struct lustre_capa *capa;
+        struct obd_capa *ocapa;
+        __u8 key[CAPA_KEY_LEN];  /* key */
+        int expired, rc = 0;
+        ENTRY;
+
+        if (mds->mds_capa_stat == 0) {
+                (*offset)++;
+                RETURN(0); /* capability is disabled */
+        }
+
+        if (OBD_FAIL_CHECK(OBD_FAIL_MDS_PACK_CAPA))
+                RETURN(-EINVAL);
+
+        if (req_body) {
+                /* capa renewal, check capa op against open mode */
+                struct mds_file_data *mfd;
+                int mode;
+
+                mfd = mds_handle2mfd(&req_body->handle);
+                if (mfd == NULL) {
+                        CERROR("no handle for capa renewal ino "LPD64
+                               ": cookie "LPX64"\n",
+                               req_capa->lc_ino, req_body->handle.cookie);
+                        RETURN(-ESTALE);
+                }
+
+                mode = accmode(mfd->mfd_mode);
+                if (!(req_capa->lc_op & mode)) {
+                        CERROR("invalid capa to renew ino "LPD64
+                               ": op %d mismatch with mode %d\n",
+                               req_capa->lc_ino, req_capa->lc_op, mfd->mfd_mode);
+                        RETURN(-EACCES);
+                }
+        }
+
+        LASSERT(repmsg->buflens[*offset] == sizeof(*capa));
+        capa = lustre_msg_buf(repmsg, (*offset)++, sizeof(*capa));
+        LASSERT(capa != NULL);
+
+        ocapa = capa_get(req_capa->lc_uid, req_capa->lc_op, req_capa->lc_mdsid,
+                         req_capa->lc_ino, MDS_CAPA, NULL, NULL, NULL);
+        if (ocapa) {
+                expired = capa_is_to_expire(ocapa);
+                if (!expired) {
+                        capa_dup(capa, ocapa);
+                        capa_put(ocapa, MDS_CAPA);
+                        GOTO(out, rc);
+                }
+                capa_put(ocapa, MDS_CAPA);
+        }
+
+        memcpy(capa, req_capa, sizeof(*capa));
+
+        spin_lock(&mds_capa_lock);
+        capa->lc_keyid = le32_to_cpu(CUR_CAPA_KEY_ID(mds));
+        capa->lc_expiry = round_expiry(mds->mds_capa_timeout);
+        if (mds->mds_capa_timeout < CAPA_EXPIRY)
+                capa->lc_flags |= CAPA_FL_NOROUND;
+        memcpy(key, CUR_CAPA_KEY(mds)->lk_key, sizeof(key));
+        spin_unlock(&mds_capa_lock);
+
+        capa_hmac(mds->mds_capa_hmac, key, capa);
+
+        rc = capa_renew(capa, MDS_CAPA);
+out:
+        if (rc == 0)
+                body->valid |= OBD_MD_CAPA;
+        RETURN(rc);
+}
index ee59aa0..f4c2b91 100644 (file)
@@ -51,6 +51,7 @@
 #define LOV_OBJID "lov_objid"
 #define LAST_FID  "last_fid"
 #define VIRT_FID  "virt_fid"
+#define CAPA_KEYS  "capa_key"
 
 struct fidmap_entry {
         struct hlist_node fm_hash;
@@ -751,8 +752,7 @@ static int mds_update_virtid_fid(struct obd_device *obd,
         RETURN(rc);
 }
 
-static int mds_read_virtid_fid(struct obd_device *obd,
-                               struct file *file)
+static int mds_read_virtid_fid(struct obd_device *obd, struct file *file)
 {
         int rc = 0;
         loff_t off = 0;
@@ -990,7 +990,7 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
         if (IS_ERR(file)) {
                 rc = PTR_ERR(file);
                 CERROR("cannot open/create %s file: rc = %d\n", LOV_OBJID, rc);
-                GOTO(err_last_fid, rc = PTR_ERR(file));
+                GOTO(err_virtid_fid, rc = PTR_ERR(file));
         }
         mds->mds_dt_objid_filp = file;
         if (!S_ISREG(file->f_dentry->d_inode->i_mode)) {
@@ -999,19 +999,45 @@ int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
                 GOTO(err_lov_objid, rc = -ENOENT);
         }
 
+        /* open and test capa keyid file */
+        file = filp_open(CAPA_KEYS, O_RDWR | O_CREAT, 0644);
+        if (IS_ERR(file)) {
+                rc = PTR_ERR(file);
+                CERROR("cannot open/create %s file: rc = %d\n",
+                       CAPA_KEYS, rc);
+                GOTO(err_lov_objid, rc = PTR_ERR(file));
+        }
+        mds->mds_capa_keys_filp = file;
+        if (!S_ISREG(file->f_dentry->d_inode->i_mode)) {
+                CERROR("%s is not a regular file!: mode = %o\n",
+                       CAPA_KEYS, file->f_dentry->d_inode->i_mode);
+                GOTO(err_capa_keyid, rc = -ENOENT);
+        }
+
+#if 0
+        rc = mds_read_capa_key(obd, file);
+        if (rc) {
+                CERROR("cannot read %s: rc = %d\n", CAPA_KEYS, rc);
+                GOTO(err_capa_keyid, rc);
+        }
+#endif
+
         /* reint fidext thumb by last fid after root and virt are initialized */
         mds->mds_fidext_thumb = mds->mds_last_fid;
                 
         rc = mds_fidmap_init(obd, MDS_FIDMAP_SIZE);
         if (rc) {
                 CERROR("cannot init fid mapping tables, err %d\n", rc);
-                GOTO(err_lov_objid, rc);
+                GOTO(err_capa_keyid, rc);
         }
         
 err_pop:
         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         return rc;
 
+err_capa_keyid:
+        if (mds->mds_capa_keys_filp && filp_close(mds->mds_capa_keys_filp, 0))
+                CERROR("can't close %s after error\n", CAPA_KEYS);
 err_lov_objid:
         if (mds->mds_dt_objid_filp && filp_close(mds->mds_dt_objid_filp, 0))
                 CERROR("can't close %s after error\n", LOV_OBJID);
@@ -1088,6 +1114,12 @@ int mds_fs_cleanup(struct obd_device *obd, int flags)
                 if (rc)
                         CERROR("%s file won't close, rc=%d\n", LOV_OBJID, rc);
         }
+        if (mds->mds_capa_keys_filp) {
+                rc = filp_close(mds->mds_capa_keys_filp, 0);
+                mds->mds_capa_keys_filp = NULL;
+                if (rc)
+                        CERROR("%s file won't close, rc=%d\n", CAPA_KEYS, rc);
+        }
         if (mds->mds_unnamed_dir != NULL) {
                 l_dput(mds->mds_unnamed_dir);
                 mds->mds_unnamed_dir = NULL;
index f707e98..2a34fbc 100644 (file)
@@ -196,8 +196,10 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset,
                   int unlink_orphan);
 int mds_close(struct ptlrpc_request *req, int offset);
 int mds_done_writing(struct ptlrpc_request *req, int offset);
+struct mds_file_data *mds_handle2mfd(struct lustre_handle *handle);
 int mds_validate_size(struct obd_device *obd, struct inode *inode,
                       struct mds_body *body, struct iattr *iattr);
+int accmode(int flags);
 
 /* mds/mds_fs.c */
 int mds_fidmap_init(struct obd_device *obd, int size);
@@ -343,4 +345,16 @@ int mds_init_rmtacl_upcall_cache(void);
 void mds_cleanup_rmtacl_upcall_cache(void);
 void mds_do_remote_acl_upcall(struct rmtacl_upcall_desc *desc);
 
+/* mds_capa.c */
+extern struct timer_list mds_eck_timer;
+
+int mds_read_capa_key(struct obd_device *obd, struct file *file);
+void mds_capa_keys_cleanup(struct obd_device *obd);
+void mds_capa_key_timer_callback(unsigned long data);
+int mds_capa_key_start_thread(void);
+void mds_capa_key_stop_thread(void);
+int mds_pack_capa(struct obd_device *obd, struct mds_body *req_body,
+                  struct lustre_capa *req_capa, struct lustre_msg *repmsg,
+                  int *offset, struct mds_body *body);
+
 #endif /* _MDS_INTERNAL_H */
index a71bc99..a8c5868 100644 (file)
@@ -52,6 +52,7 @@
 #include <linux/lustre_ucache.h>
 #include <linux/lustre_gs.h>
 #include <linux/lustre_fsfilt.h>
+
 #include "mds_internal.h"
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,4)
@@ -245,7 +246,7 @@ int mds_pack_gskey(struct obd_device *obd, struct lustre_msg *repmsg,
         void *buf;
         int size, rc = 0;
         ENTRY;
-
         sizep = lustre_msg_buf(repmsg, (*offset)++, 4);
         if (!sizep) {
                 CERROR("can't locate returned ckey size buf\n");
@@ -264,6 +265,7 @@ int mds_pack_gskey(struct obd_device *obd, struct lustre_msg *repmsg,
                 if (size < 0) 
                         CERROR("Can not get gskey from MDS ino %lu rc %d\n",
                                 inode->i_ino, size);
+                (*offset) += 2; /* XXX: ignore crypto in case size == 0 */
                 GOTO(out, rc = size); 
         }
         if (le32_to_cpu(md_key->md_magic) != MD_KEY_MAGIC) {
@@ -1280,3 +1282,4 @@ void mds_exit_ucred(struct lvfs_ucred *ucred)
         drop_ucred_lsd(ucred);
         EXIT;
 }
+
index c7ee9cd..d1000e0 100644 (file)
@@ -791,7 +791,7 @@ int mds_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
                 int objcount, struct obd_ioobj *obj,
                 int niocount, struct niobuf_remote *nb,
                 struct niobuf_local *res,
-                struct obd_trans_info *oti)
+                struct obd_trans_info *oti, struct lustre_capa *capa)
 {
         struct niobuf_remote *rnb;
         struct niobuf_local *lnb = NULL;
index 30bd1a6..497bf5c 100644 (file)
@@ -342,8 +342,19 @@ int mds_dt_connect(struct obd_device *obd, char *lov_name)
         if (!obd->obd_recovering) {
                 CDEBUG(D_OTHER, "call mds_postrecov_common()\n");
                 rc = mds_postrecov_common(obd);
-                if (rc > 0) 
-                        rc = 0;
+                if (rc < 0)
+                        GOTO(err_reg, rc);
+                rc = 0;
+        }
+
+        for (i = 0; i < 2; i++) {
+                if (!mds->mds_capa_keys[i].k_key)
+                        break;
+                rc = obd_set_info(mds->mds_dt_exp, strlen("capa_key"),
+                                  "capa_key", sizeof(struct lustre_capa_key),
+                                  mds->mds_capa_keys[i].k_key);
+                if (rc)
+                        GOTO(err_reg, rc);
         }
         RETURN(rc);
 
@@ -615,11 +626,8 @@ int mds_dt_synchronize(void *data)
         struct obd_uuid *uuid;
         obd_id vals[2];
         unsigned long flags;
-        __u32  vallen;
-        __u32  group;
-        int old_count;
-        int count;
-        int index;
+        __u32  vallen, group;
+        int old_count, count, index, i;
         int rc;
         char name[32] = "CATLIST";
 
@@ -669,6 +677,16 @@ int mds_dt_synchronize(void *data)
         if (rc)
                 GOTO(cleanup, rc);
 
+        for (i = 0; i < 2; i++) {
+                if (!mds->mds_capa_keys[i].k_key)
+                        break;
+                rc = obd_set_info(mds->mds_dt_exp, strlen("capa_key"),
+                                  "capa_key", sizeof(struct lustre_capa_key),
+                                  mds->mds_capa_keys[i].k_key);
+                if (rc)
+                        GOTO(cleanup, rc);
+        }
+
         /* we don't set next id manually, instead OSCs will set them
          * during own recovery from DELORPHAN reply -bzzz */
 #if 0
index 3174e82..efa8f60 100644 (file)
@@ -87,7 +87,7 @@ struct mds_file_data *mds_mfd_new(void)
         return mfd;
 }
 
-static struct mds_file_data *mds_handle2mfd(struct lustre_handle *handle)
+struct mds_file_data *mds_handle2mfd(struct lustre_handle *handle)
 {
         ENTRY;
         LASSERT(handle != NULL);
@@ -678,7 +678,7 @@ static void reconstruct_open(struct mds_update_record *rec, int offset,
 }
 
 /* do NOT or the MAY_*'s, you'll get the weakest */
-static int accmode(int flags)
+int accmode(int flags)
 {
         int res = 0;
 
@@ -766,9 +766,28 @@ static int mds_finish_open(struct ptlrpc_request *req, struct dentry *dchild,
                 up(&dchild->d_inode->i_sem);
                 RETURN(rc);
         }
+
+        if (S_ISREG(mode)) {
+                struct lustre_capa capa = {
+                        .lc_uid   = rec->ur_uc.luc_uid,
+                        .lc_op    = capa_op(rec->ur_flags),
+                        .lc_ino   = dchild->d_inode->i_ino,
+                        .lc_mdsid = mds->mds_num,
+                };
+
+                rc = mds_pack_capa(obd, NULL, &capa, req->rq_repmsg,
+                                   &reply_off, body);
+                if (rc < 0) {
+                        CERROR("mds_pack_capa: rc = %d\n", rc);
+                        up(&dchild->d_inode->i_sem);
+                        RETURN(rc);
+                }
+        } else {
+                reply_off++;
+        }
+
         /* If the inode has no EA data, then MDSs hold size, mtime */
-        if (S_ISREG(dchild->d_inode->i_mode) &&
-            !(body->valid & OBD_MD_FLEASIZE)) {
+        if (S_ISREG(mode) && !(body->valid & OBD_MD_FLEASIZE)) {
                 body->valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
                                 OBD_MD_FLATIME | OBD_MD_FLMTIME);
         }
index 114a174..6e6068d 100644 (file)
@@ -488,7 +488,8 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
         void *handle = NULL;
         struct mds_logcancel_data *mlcd = NULL;
         int rc = 0, cleanup_phase = 0, err;
-        int repsize = sizeof(*body), locked = 0;
+        int repcnt = 1, repsize[2] = { sizeof(*body) };
+        int locked = 0, do_trunc = 0;
         ENTRY;
 
         LASSERT(offset == 1);
@@ -503,7 +504,12 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
                 return mds_reint_remote_setfacl(obd, med, rec, req);
         }
 
-        rc = lustre_pack_reply(req, 1, &repsize, NULL);
+        if (rec->ur_iattr.ia_valid & ATTR_SIZE) {
+                repsize[repcnt++] = sizeof(struct lustre_capa);
+                do_trunc = 1; /* XXX: ATTR_SIZE will be cleared from ia_valid */
+        }
+
+        rc = lustre_pack_reply(req, repcnt, repsize, NULL);
         if (rc)
                 RETURN(rc);
 
@@ -668,6 +674,24 @@ static int mds_reint_setattr(struct mds_update_record *rec, int offset,
         if (rec->ur_iattr.ia_valid & (ATTR_ATIME | ATTR_ATIME_SET))
                 body->valid |= OBD_MD_FLATIME;
 
+        if (do_trunc) {
+                struct lustre_capa capa = {
+                        .lc_uid   = rec->ur_uc.luc_uid,
+                        .lc_op    = MAY_WRITE,
+                        .lc_ino   = inode->i_ino,
+                        .lc_mdsid = mds->mds_num,
+                };
+                int offset = 1;
+
+                LASSERT(capa.lc_mdsid == mds->mds_num);
+                rc = mds_pack_capa(obd, NULL, &capa, req->rq_repmsg, &offset,
+                                   body);
+                if (rc < 0) {
+                        CERROR("mds_pack_capa: rc = %d\n", rc);
+                        RETURN(rc);
+                }
+        }
+
         mds_body_do_reverse_map(med, body);
 
         /* The logcookie should be no use anymore, why nobody remove
index c0f84f1..00b8a00 100644 (file)
@@ -3,7 +3,7 @@ MODULES := obdclass llog_test confobd
 obdclass-objs := llog_obd.o class_obd.o llog_swab.o
 obdclass-objs += debug.o genops.o sysctl.o uuid.o llog_ioctl.o
 obdclass-objs += lprocfs_status.o lustre_handles.o lustre_peer.o
-obdclass-objs += statfs_pack.o obdo.o obd_config.o mea.o
+obdclass-objs += statfs_pack.o obdo.o obd_config.o mea.o capa.o
 
 ifeq ($(PATCHLEVEL),6)
 
index 4622054..f474455 100644 (file)
@@ -2,7 +2,7 @@ if LIBLUSTRE
 
 noinst_LIBRARIES = liblustreclass.a
 liblustreclass_a_SOURCES = class_obd.c debug.c genops.c statfs_pack.c uuid.c 
-liblustreclass_a_SOURCES += lustre_handles.c lustre_peer.c lprocfs_status.c mea.c
+liblustreclass_a_SOURCES += lustre_handles.c lustre_peer.c lprocfs_status.c mea.c capa.c
 liblustreclass_a_SOURCES += obdo.c obd_config.c llog_swab.c llog_obd.c #llog_ioctl.c rbtree.c
 liblustreclass_a_CPPFLAGS = $(LLCPPFLAGS) -DLUSTRE_VERSION=\"32\" -DBUILD_VERSION=\"1\"
 liblustreclass_a_CFLAGS = $(LLCFLAGS)
diff --git a/lustre/obdclass/capa.c b/lustre/obdclass/capa.c
new file mode 100644 (file)
index 0000000..8d2cb21
--- /dev/null
@@ -0,0 +1,419 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ *  lustre/obdclass/capa.c
+ *  Lustre Capability Cache Management
+ *
+ *  Copyright (c) 2001-2003 Cluster File Systems, Inc.
+ *   Author: Lai Siyao<lsy@clusterfs.com>
+ *
+ *   This file is part of Lustre, http://www.lustre.org.
+ *
+ *   Lustre is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2 of the GNU General Public
+ *   License as published by the Free Software Foundation.
+ *
+ *   Lustre is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with Lustre; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#ifndef EXPORT_SYMTAB
+# define EXPORT_SYMTAB
+#endif
+
+#define DEBUG_SUBSYSTEM S_SEC
+
+#include <linux/version.h>
+#include <linux/fs.h>
+#include <asm/unistd.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+#include <linux/obd_class.h>
+#include <linux/lustre_debug.h>
+#include <linux/lustre_idl.h>
+#include <linux/lustre_sec.h>
+#include <libcfs/list.h>
+
+kmem_cache_t *capa_cachep = NULL;
+
+/* capa_lock protect capa hash, list and content. */
+spinlock_t capa_lock = SPIN_LOCK_UNLOCKED;
+struct hlist_head *capa_hash;
+struct list_head capa_list[3];
+static int capa_count[3] = { 0 };
+
+/* TODO: mdc and llite all need this, so define it here.
+ * in the future it will be moved to ll_sb_info to support multi-
+ * mount point */
+struct timer_list ll_capa_timer;
+
+EXPORT_SYMBOL(capa_lock);
+EXPORT_SYMBOL(capa_hash);
+EXPORT_SYMBOL(capa_list);
+EXPORT_SYMBOL(ll_capa_timer);
+
+static inline int const
+capa_hashfn(unsigned int uid, int capa_op, __u64 mdsid, unsigned long ino)
+{
+        return (ino ^ uid) * (unsigned long)capa_op * (unsigned long)mdsid %
+               NR_CAPAHASH;
+}
+
+int capa_op(int flags)
+{
+        if (flags & (FMODE_WRITE|MDS_OPEN_TRUNC))
+                return MAY_WRITE;
+        else if (flags & FMODE_READ)
+                return MAY_READ;
+
+        LBUG(); /* should be either MAY_READ or MAY_WRITE */
+        return 0;
+}
+
+static struct obd_capa *
+find_capa(struct hlist_head *head, uid_t uid, int capa_op, __u64 mdsid,
+          unsigned long ino, int type)
+{
+        struct hlist_node *pos;
+        struct obd_capa *ocapa;
+        ENTRY;
+
+        CDEBUG(D_CACHE, "find_capa uid %u op %u mdsid "LPU64" ino %lu "
+               "type %d\n", uid, capa_op, mdsid, ino, type);
+
+        hlist_for_each_entry(ocapa, pos, head, c_hash) {
+                if (ocapa->c_capa.lc_uid != uid)
+                        continue;
+                if (ocapa->c_capa.lc_op != capa_op)
+                        continue;
+                if (ocapa->c_capa.lc_mdsid != mdsid)
+                        continue;
+                if (ocapa->c_capa.lc_ino != ino)
+                        continue;
+                if (ocapa->c_type != type)
+                        continue;
+                RETURN(ocapa);
+        }
+
+        RETURN(NULL);
+}
+
+inline void __capa_get(struct obd_capa *ocapa)
+{
+        atomic_inc(&ocapa->c_refc);
+}
+
+static struct obd_capa *
+find_capa_locked(struct hlist_head *head, uid_t uid, int capa_op, __u64 mdsid,
+                 unsigned long ino, int type)
+{
+        struct obd_capa *ocapa;
+        ENTRY;
+
+        spin_lock(&capa_lock);
+        ocapa = find_capa(head, uid, capa_op, mdsid, ino, type);
+        if (ocapa)
+                __capa_get(ocapa);
+        spin_unlock(&capa_lock);
+
+        RETURN(ocapa);
+}
+
+static struct obd_capa *alloc_capa(void)
+{
+        struct obd_capa *ocapa;
+        ENTRY;
+
+        OBD_SLAB_ALLOC(ocapa, capa_cachep, SLAB_NOFS, sizeof(*ocapa));
+        if (ocapa) {
+                INIT_HLIST_NODE(&ocapa->c_hash);
+                INIT_LIST_HEAD(&ocapa->c_list);
+        }
+
+        RETURN(ocapa);
+}
+
+static void destroy_capa(struct obd_capa *ocapa)
+{
+        OBD_SLAB_FREE(ocapa, capa_cachep, sizeof(*ocapa));
+}
+
+int capa_cache_init(void)
+{
+        int order = 0, nr_hash, i;
+
+        capa_hash = (struct hlist_head *)
+                                __get_free_pages(GFP_ATOMIC, order);
+        if (!capa_hash)
+                panic("Cannot create capa_hash hash table");
+
+        nr_hash = (1UL << order) * PAGE_SIZE / sizeof(struct hlist_head);
+        LASSERT(nr_hash > NR_CAPAHASH);
+
+        for (i = 0; i < NR_CAPAHASH; i++)
+                INIT_HLIST_HEAD(capa_hash + i);
+
+        for (i =0; i < 3; i++)
+                INIT_LIST_HEAD(&capa_list[i]);
+
+        return 0;
+}
+
+void capa_cache_cleanup(void)
+{
+        struct obd_capa *ocapa;
+        struct hlist_node *pos, *n;
+
+        hlist_for_each_entry_safe(ocapa, pos, n, capa_hash, c_hash) {
+                hlist_del(&ocapa->c_hash);
+                list_del(&ocapa->c_list);
+                OBD_FREE(ocapa, sizeof(*ocapa));
+        }
+}
+
+
+static inline void list_add_capa(struct obd_capa *ocapa, struct list_head *head)
+{
+        struct obd_capa *tmp;
+
+        /* XXX: capa is sorted in client, this could be optimized */
+        if (ocapa->c_type == CLIENT_CAPA) {
+                list_for_each_entry_reverse(tmp, head, c_list) {
+                        if (ocapa->c_capa.lc_expiry > tmp->c_capa.lc_expiry) {
+                                list_add(&ocapa->c_list, &tmp->c_list);
+                                return;
+                        }
+                }
+        }
+
+        list_add_tail(&ocapa->c_list, head);
+}
+
+#define DEBUG_CAPA(level, ocapa, fmt, args...)                                 \
+do {                                                                           \
+CDEBUG(level, fmt " capa@%p uid %u op %u ino "LPU64" mdsid %d keyid %d "       \
+       "expiry "LPU64" flags %u type %d\n",                                    \
+       ##args, ocapa, ocapa->c_capa.lc_uid, ocapa->c_capa.lc_op,               \
+       ocapa->c_capa.lc_ino, ocapa->c_capa.lc_mdsid, ocapa->c_capa.lc_keyid,   \
+       ocapa->c_capa.lc_expiry, ocapa->c_capa.lc_flags, ocapa->c_type);        \
+} while (0)
+
+static struct obd_capa *
+get_new_capa_locked(struct hlist_head *head, uid_t uid, int capa_op,__u64 mdsid,
+                    unsigned long ino, int type, struct lustre_capa *capa,
+                    struct inode *inode, struct lustre_handle *handle)
+{
+        struct obd_capa *ocapa, *old;
+        ENTRY;
+
+        ocapa = alloc_capa();
+        if (!ocapa)
+                RETURN(NULL);
+
+        spin_lock(&capa_lock);
+        old = find_capa(head, uid, capa_op, mdsid, ino, type);
+        if (!old) {
+                memcpy(&ocapa->c_capa, capa, sizeof(*capa));
+                ocapa->c_type = type;
+                if (type == CLIENT_CAPA) {
+                        LASSERT(inode);
+                        igrab(inode);
+                        ocapa->c_inode = inode;
+                        memcpy(&ocapa->c_handle, handle, sizeof(*handle));
+                }
+                list_add_capa(ocapa, &capa_list[type]);
+                hlist_add_head(&ocapa->c_hash, capa_hash);
+                capa_count[type]++;
+                DEBUG_CAPA(D_CACHE, ocapa, "get_new_capa_locked");
+                __capa_get(ocapa);
+                if (type != CLIENT_CAPA && capa_count[type] > CAPA_CACHE_SIZE) {
+                        struct list_head *node = capa_list[type].next;
+                        struct obd_capa *tcapa;
+                        int count = 0;
+
+                        /* free 12 unused capa from head */
+                        while (node->next != &capa_list[type] && count < 12) {
+                                tcapa = list_entry(node, struct obd_capa, c_list);
+                                node = node->next;
+                                if (atomic_read(&tcapa->c_refc) > 0)
+                                        continue;
+                                list_del(&tcapa->c_list);
+                                destroy_capa(tcapa);
+                                count++;
+                        }
+                }
+                                        
+                spin_unlock(&capa_lock);
+                RETURN(ocapa);
+        }
+
+        __capa_get(old);
+        spin_unlock(&capa_lock);
+        destroy_capa(ocapa);
+        ocapa = old;
+        RETURN(ocapa);
+}
+
+static struct obd_capa *
+capa_get_locked(uid_t uid, int capa_op,__u64 mdsid, unsigned long ino,
+                int type, struct lustre_capa *capa, struct inode *inode,
+                struct lustre_handle *handle)
+{
+        struct hlist_head *head = capa_hash +
+                                  capa_hashfn(uid, capa_op, mdsid, ino);
+        struct obd_capa *ocapa;
+        ENTRY;
+
+        ocapa = find_capa_locked(head, uid, capa_op, mdsid, ino, type);
+        if (ocapa)
+                RETURN(ocapa);
+        
+        if (capa)
+                ocapa = get_new_capa_locked(head, uid, capa_op, mdsid, ino,
+                                            type, capa, inode, handle);
+        RETURN(ocapa);
+}
+
+struct obd_capa *
+capa_get(uid_t uid, int capa_op, __u64 mdsid, unsigned long ino, int type,
+         struct lustre_capa *capa, struct inode *inode,
+         struct lustre_handle *handle)
+{
+        return capa_get_locked(uid, capa_op, mdsid, ino, type, capa, inode,
+                               handle);
+}
+
+static void __capa_put(struct obd_capa *ocapa, int type)
+{
+        hlist_del_init(&ocapa->c_hash);
+        list_del_init(&ocapa->c_list);
+        capa_count[type]--;
+}
+
+void capa_put(struct obd_capa *ocapa, int type)
+{
+        ENTRY;
+
+        if (ocapa) {
+                if (atomic_dec_and_lock(&ocapa->c_refc, &capa_lock)) {
+                        if (type == CLIENT_CAPA) {
+                                iput(ocapa->c_inode);
+                                __capa_put(ocapa, type);
+                                destroy_capa(ocapa);
+                        }
+                        spin_unlock(&capa_lock);
+                }
+        }
+
+        EXIT;
+}
+
+static inline void __update_capa(struct obd_capa *ocapa, struct lustre_capa *capa)
+{
+        memcpy(&ocapa->c_capa, capa, sizeof(*capa));
+}
+
+static int update_capa_locked(struct lustre_capa *capa, int type)
+{
+        uid_t uid = capa->lc_uid;
+        int capa_op = capa->lc_op;
+        __u64 mdsid = capa->lc_mdsid;
+        unsigned long ino = capa->lc_ino;
+        struct hlist_head *head = capa_hash +
+                                  capa_hashfn(uid, capa_op, mdsid, ino);
+        struct obd_capa *ocapa;
+        ENTRY;
+
+        spin_lock(&capa_lock);
+        ocapa = find_capa(head, uid, capa_op, mdsid, ino, type);
+        if (ocapa)
+                __update_capa(ocapa, capa);
+        spin_unlock(&capa_lock);
+
+        if (ocapa == NULL && type == MDS_CAPA)
+                ocapa = get_new_capa_locked(head, uid, capa_op, mdsid, ino, type,
+                                            capa, NULL, NULL);
+
+        RETURN(ocapa ? 0 : -ENOENT);
+}
+
+int capa_renew(struct lustre_capa *capa, int type)
+{
+        return update_capa_locked(capa, type);
+}
+
+void capa_hmac(struct crypto_tfm *tfm, u8 *key, struct lustre_capa *capa)
+{
+        int keylen = CAPA_KEY_LEN;
+        struct scatterlist sl = {
+                .page   = virt_to_page(capa),
+                .offset = (unsigned long)(capa) % PAGE_SIZE,
+                .length = sizeof(struct lustre_capa_data),
+        };
+        ENTRY;
+
+        LASSERT(tfm);
+        crypto_hmac(tfm, key, &keylen, &sl, 1, capa->lc_hmac);
+        EXIT;
+}
+
+void capa_dup(void *dst, struct obd_capa *ocapa)
+{
+        spin_lock(&capa_lock);
+        memcpy(dst, &ocapa->c_capa, sizeof(ocapa->c_capa));
+        spin_unlock(&capa_lock);
+}
+
+void capa_dup2(void *dst, struct lustre_capa *capa)
+{
+        spin_lock(&capa_lock);
+        memcpy(dst, capa, sizeof(*capa));
+        spin_unlock(&capa_lock);
+}
+
+int capa_expired(struct lustre_capa *capa)
+{
+        struct timeval tv;
+
+        do_gettimeofday(&tv);
+        return (capa->lc_expiry < tv.tv_sec) ? 1 : 0;
+}
+
+int __capa_is_to_expire(struct obd_capa *ocapa)
+{
+        struct timeval tv;
+        int pre_expiry = capa_pre_expiry(&ocapa->c_capa);
+
+        do_gettimeofday(&tv);
+        return (ocapa->c_capa.lc_expiry - pre_expiry < tv.tv_sec)? 1 : 0;
+}
+
+int capa_is_to_expire(struct obd_capa *ocapa)
+{
+        int rc;
+
+        spin_lock(&capa_lock);
+        rc = __capa_is_to_expire(ocapa);
+        spin_unlock(&capa_lock);
+
+        return rc;
+}
+
+EXPORT_SYMBOL(capa_op);
+EXPORT_SYMBOL(capa_get);
+EXPORT_SYMBOL(capa_put);
+EXPORT_SYMBOL(capa_renew);
+EXPORT_SYMBOL(__capa_get);
+EXPORT_SYMBOL(capa_hmac);
+EXPORT_SYMBOL(capa_dup);
+EXPORT_SYMBOL(capa_dup2);
+EXPORT_SYMBOL(capa_expired);
+EXPORT_SYMBOL(__capa_is_to_expire);
+EXPORT_SYMBOL(capa_is_to_expire);
index 82fc52c..856db92 100644 (file)
@@ -568,6 +568,9 @@ struct file_operations obd_device_list_fops = {
 };
 #endif
 
+extern int capa_cache_init(void);
+extern void capa_cache_cleanup(void);
+
 #ifdef __KERNEL__
 static int __init init_obdclass(void)
 #else
@@ -606,6 +609,10 @@ int init_obdclass(void)
         if (err)
                 return err;
 
+        err = capa_cache_init();
+        if (err)
+                return err;
+
 #ifdef __KERNEL__
         obd_sysctl_init();
 #endif
@@ -649,6 +656,7 @@ static void cleanup_obdclass(void)
                 }
         }
 
+        capa_cache_cleanup();
         obd_cleanup_caches();
         obd_sysctl_clean();
 #ifdef LPROCFS
index 007a40d..b77f837 100644 (file)
 #include <linux/obd.h>
 #endif
 #include <linux/lprocfs_status.h>
+#include <linux/lustre_sec.h>
 
 extern struct list_head obd_types;
 static spinlock_t obd_types_lock = SPIN_LOCK_UNLOCKED;
 kmem_cache_t *obdo_cachep = NULL;
 kmem_cache_t *import_cachep = NULL;
 
+extern kmem_cache_t *capa_cachep;
+
 int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
 void (*ptlrpc_abort_inflight_superhack)(struct obd_import *imp);
 
@@ -351,6 +354,11 @@ void obd_cleanup_caches(void)
                          "Cannot destory ll_import_cache\n");
                 import_cachep = NULL;
         }
+        if (capa_cachep) {
+                LASSERTF(kmem_cache_destroy(capa_cachep) == 0,
+                         "Cannot destory capa_cache\n");
+                capa_cachep = NULL;
+        }
         EXIT;
 }
 
@@ -370,6 +378,13 @@ int obd_init_caches(void)
         if (!import_cachep)
                 GOTO(out, -ENOMEM);
 
+        LASSERT(capa_cachep == NULL);
+        capa_cachep = kmem_cache_create("capa_cache",
+                                        sizeof(struct obd_capa),
+                                        0, 0, NULL, NULL);
+        if (!capa_cachep)
+                GOTO(out, -ENOMEM);
+
         RETURN(0);
  out:
         obd_cleanup_caches();
index 11ce343..0962dd9 100644 (file)
@@ -277,7 +277,7 @@ echo_page_debug_check(struct page *page, obd_id id,
 int echo_preprw(int cmd, struct obd_export *export, struct obdo *oa,
                 int objcount, struct obd_ioobj *obj, int niocount,
                 struct niobuf_remote *nb, struct niobuf_local *res,
-                struct obd_trans_info *oti)
+                struct obd_trans_info *oti, struct lustre_capa *capa)
 {
         struct obd_device *obd;
         struct niobuf_local *r = res;
index 1af78b4..4ae0f67 100644 (file)
@@ -938,7 +938,8 @@ static int echo_client_prep_commit(struct obd_export *exp, int rw,
                 memset(oti, 0, sizeof(*oti));
                 ioo.ioo_bufcnt = npages;
 
-                ret = obd_preprw(rw, exp, oa, 1, &ioo, npages, rnb, lnb, oti);
+                ret = obd_preprw(rw, exp, oa, 1, &ioo, npages, rnb, lnb,
+                                 oti, NULL);
                 if (ret != 0)
                         GOTO(out, ret);
 
index 3e0871a..a636305 100644 (file)
@@ -1,6 +1,6 @@
 MODULES := obdfilter
 obdfilter-objs := filter.o filter_io.o filter_log.o filter_san.o
-obdfilter-objs += lproc_obdfilter.o filter_lvb.o
+obdfilter-objs += lproc_obdfilter.o filter_lvb.o filter_capa.o
 
 ifeq ($(PATCHLEVEL),4)
 obdfilter-objs += filter_io_24.o
index f2d818a..738cc7b 100644 (file)
@@ -61,7 +61,6 @@
 
 #include <linux/lustre_smfs.h>
 #include <linux/lustre_sec.h>
-#include <linux/lustre_audit.h>
 #include "filter_internal.h"
 
 /* Group 0 is no longer a legal group, to catch uninitialized IDs */
@@ -102,6 +101,7 @@ int filter_finish_transno(struct obd_export *exp, struct obd_trans_info *oti,
         if (oti->oti_transno == 0) {
                 spin_lock(&filter->fo_translock);
                 last_rcvd = le64_to_cpu(filter->fo_fsd->fsd_last_transno) + 1;
+                last_rcvd = le64_to_cpu(filter->fo_fsd->fsd_last_transno) + 1;
                 filter->fo_fsd->fsd_last_transno = cpu_to_le64(last_rcvd);
                 spin_unlock(&filter->fo_translock);
                 oti->oti_transno = last_rcvd;
@@ -927,6 +927,7 @@ static int filter_prep_groups(struct obd_device *obd)
         return rc;
 }
 
+
 /* setup the object store with correct subdirectories */
 static int filter_prep(struct obd_device *obd)
 {
@@ -1016,6 +1017,7 @@ static void filter_post(struct obd_device *obd)
 
         filter_cleanup_groups(obd);
         filter_free_server_data(filter);
+        filter_free_capa_keys(filter);
         pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
 }
 
@@ -1442,6 +1444,7 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf,
         struct filter_obd *filter = &obd->u.filter;
         struct lvfs_obd_ctxt *lvfs_ctxt = NULL;
         struct vfsmount *mnt;
+        struct crypto_tfm *tfm;
         char *str;
         char ns_name[48];
         int rc = 0, i;
@@ -1502,9 +1505,18 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf,
 
         sema_init(&filter->fo_init_lock, 1);
         filter->fo_committed_group = 0;
+
+        tfm = crypto_alloc_tfm(CAPA_HMAC_ALG, 0);
+        if (!tfm)
+                GOTO(err_mntput, rc = -ENOSYS);
+
+        filter->fo_capa_hmac = tfm;
+        INIT_LIST_HEAD(&filter->fo_capa_keys);
+        spin_lock_init(&filter->fo_capa_lock);
+
         rc = filter_prep(obd);
         if (rc)
-                GOTO(err_mntput, rc);
+                GOTO(err_capa, rc);
 
         filter->fo_destroys_in_progress = 0;
         for (i = 0; i < 32; i++)
@@ -1550,6 +1562,8 @@ int filter_common_setup(struct obd_device *obd, obd_count len, void *buf,
 
 err_post:
         filter_post(obd);
+err_capa:
+        crypto_free_tfm(filter->fo_capa_hmac);
 err_mntput:
         unlock_kernel();
         lvfs_umount_fs(filter->fo_lvfs_ctxt);
@@ -2735,9 +2749,9 @@ cleanup:
 
 /* NB start and end are used for punch, but not truncate */
 static int filter_truncate(struct obd_export *exp, struct obdo *oa,
-                           struct lov_stripe_md *lsm,
-                           obd_off start, obd_off end,
-                           struct obd_trans_info *oti)
+                           struct lov_stripe_md *lsm, obd_off start,
+                           obd_off end, struct obd_trans_info *oti,
+                           struct lustre_capa *capa)
 {
         int error;
         ENTRY;
@@ -2748,6 +2762,10 @@ static int filter_truncate(struct obd_export *exp, struct obdo *oa,
 
         CDEBUG(D_INODE, "calling truncate for object "LPU64", valid = "LPU64", "
                "o_size = "LPD64"\n", oa->o_id, oa->o_valid, start);
+        error = filter_verify_capa(OBD_BRW_WRITE, exp, capa);
+        if (error)
+                RETURN(error);
+
         oa->o_size = start;
         error = filter_setattr(exp, oa, NULL, oti);
         RETURN(error);
@@ -2844,11 +2862,14 @@ static int filter_set_info(struct obd_export *exp, __u32 keylen,
                 f_dput(dentry);
 
                 RETURN(rc);
+        } else if (keylen == 8 && memcmp(key, "capa_key", 8) == 0) {
+                struct lustre_capa_key *lkey = val;
+                rc = filter_update_capa_key(obd, lkey);
+                RETURN(rc);
         }
 
-
         if (rc)
-                CDEBUG(D_IOCTL, "invalid key\n");
+                CDEBUG(D_IOCTL, "invalid key '%s'\n", (char *)key);
         
         RETURN(rc);
 }
@@ -3109,8 +3130,8 @@ static int filter_llog_connect(struct obd_export *exp,
         RETURN(rc);
 }
 
-static struct dentry *filter_lvfs_id2dentry(__u64 id, __u32 gen, 
-                                           __u64 gr, void *data)
+static struct dentry *filter_lvfs_id2dentry(__u64 id, __u32 gen,
+                                            __u64 gr, void *data)
 {
         return filter_id2dentry(data, NULL, gr, id);
 }
diff --git a/lustre/obdfilter/filter_capa.c b/lustre/obdfilter/filter_capa.c
new file mode 100644 (file)
index 0000000..3f52db0
--- /dev/null
@@ -0,0 +1,201 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2004, 2005 Cluster File Systems, Inc.
+ *
+ * Author: Lai Siyao <lsy@clusterfs.com>
+ *
+ *   This file is part of Lustre, http://www.lustre.org.
+ *
+ *   Lustre is free software; you can redistribute it and/or
+ *   modify it under the terms of version 2 of the GNU General Public
+ *   License as published by the Free Software Foundation.
+ *
+ *   Lustre is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with Lustre; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#define DEBUG_SUBSYSTEM S_FILTER
+
+#include <linux/fs.h>
+#include <linux/version.h>
+#include <asm/uaccess.h>
+#include <linux/file.h>
+#include <linux/kmod.h>
+
+#include <linux/lustre_fsfilt.h>
+#include <linux/lustre_sec.h>
+
+#include "filter_internal.h"
+
+void filter_free_capa_keys(struct filter_obd *filter)
+{
+        struct filter_capa_key *key, *n;
+
+        list_for_each_entry_safe(key, n, &filter->fo_capa_keys, k_list) {
+                list_del(&key->k_list);
+                OBD_FREE(key, sizeof(*key));
+        }
+}
+
+int filter_update_capa_key(struct obd_device *obd, struct lustre_capa_key *key)
+{
+        struct filter_obd *filter = &obd->u.filter;
+        struct filter_capa_key *tmp = NULL, *rkey = NULL, *bkey = NULL;
+        int rc = 0;
+        ENTRY;
+
+        spin_lock(&filter->fo_capa_lock);
+        list_for_each_entry(tmp, &filter->fo_capa_keys, k_list) {
+                if (tmp->k_key.lk_mdsid == le32_to_cpu(key->lk_mdsid)) {
+                        if (rkey == NULL)
+                                rkey = tmp;
+                        else
+                                bkey = tmp;
+                }
+        }
+        spin_unlock(&filter->fo_capa_lock);
+
+        if (rkey && bkey && capa_key_cmp(&rkey->k_key, &bkey->k_key) < 0) {
+                tmp = rkey;
+                rkey = bkey;
+                bkey = tmp;
+        }
+
+        if (!bkey || !tmp) {
+                OBD_ALLOC(tmp, sizeof(*tmp));
+                if (!tmp)
+                        GOTO(out, rc = -ENOMEM);
+
+                spin_lock(&filter->fo_capa_lock);
+                list_add_tail(&tmp->k_list, &filter->fo_capa_keys);
+                spin_unlock(&filter->fo_capa_lock);
+        }
+
+        /* fields in lustre_capa_key are in cpu order */
+        tmp->k_key.lk_mdsid = le32_to_cpu(key->lk_mdsid);
+        tmp->k_key.lk_keyid = le32_to_cpu(key->lk_keyid);
+        tmp->k_key.lk_expiry = le64_to_cpu(key->lk_expiry);
+        memcpy(&tmp->k_key.lk_key, key->lk_key, sizeof(key->lk_key));
+
+out:
+        RETURN(rc);
+}
+
+int filter_verify_capa(int cmd, struct obd_export *exp,
+                       struct lustre_capa *capa)
+{
+        struct obd_device *obd = exp->exp_obd;
+        struct filter_obd *filter = &obd->u.filter;
+        struct obd_capa *ocapa;
+        struct lustre_capa tcapa;
+        struct filter_capa_key *rkey = NULL, *bkey = NULL, *tmp;
+        __u8 hmac_key[CAPA_KEY_LEN];
+        int rc = 0;
+        ENTRY;
+
+        /* capability is disabled */
+        if (filter->fo_capa_stat == 0)
+                RETURN(0);
+
+        if (capa == NULL)
+                RETURN(-EACCES);
+
+        if (cmd == OBD_BRW_WRITE && !(capa->lc_op & MAY_WRITE))
+                RETURN(-EACCES);
+        if (cmd == OBD_BRW_READ && !(capa->lc_op & (MAY_WRITE | MAY_READ)))
+                RETURN(-EACCES);
+
+        if (OBD_FAIL_CHECK(OBD_FAIL_FILTER_VERIFY_CAPA))
+                RETURN(-EACCES);
+
+        /* TODO: get fid from EA, and verify that against capa */
+
+        if (capa_expired(capa))
+                RETURN(-ESTALE);
+
+        ocapa = capa_get(capa->lc_uid, capa->lc_op, capa->lc_mdsid,
+                         capa->lc_ino, FILTER_CAPA, NULL, NULL, NULL);
+verify:
+        if (ocapa) {
+                /* fo_capa_lock protects capa too */
+                spin_lock(&filter->fo_capa_lock);
+                if (capa->lc_keyid == ocapa->c_capa.lc_keyid) {
+                        rc = memcmp(capa, &ocapa->c_capa, sizeof(*capa));
+                } else if (ocapa->c_bvalid &&
+                           capa->lc_keyid == ocapa->c_bkeyid) {
+                        rc = memcmp(capa->lc_hmac, ocapa->c_bhmac,
+                                    sizeof(capa->lc_hmac));
+                } else {
+                        /* ocapa is obsolete */
+                        capa_put(ocapa, FILTER_CAPA);
+                        spin_unlock(&filter->fo_capa_lock);
+                        goto new_capa;
+                }
+                spin_unlock(&filter->fo_capa_lock);
+
+                capa_put(ocapa, FILTER_CAPA);
+                RETURN(rc ? -EACCES : 0);
+        }
+
+new_capa:
+        spin_lock(&filter->fo_capa_lock);
+        list_for_each_entry(tmp, &filter->fo_capa_keys, k_list) {
+                if (tmp->k_key.lk_mdsid == capa->lc_mdsid) {
+                        if (rkey == NULL)
+                                rkey = tmp;
+                        else
+                                bkey = tmp;
+                }
+        }
+
+        if (rkey && bkey && capa_key_cmp(&rkey->k_key, &bkey->k_key) < 0) {
+                tmp = rkey;
+                rkey = bkey;
+                bkey = tmp;
+        }
+
+        if ((!rkey || rkey->k_key.lk_keyid != capa->lc_keyid) &&
+            (!bkey || bkey->k_key.lk_keyid != capa->lc_keyid)) {
+                spin_unlock(&filter->fo_capa_lock);
+                GOTO(out, rc = -ESTALE);
+        }
+
+        LASSERT(rkey);
+
+        memcpy(&tcapa, capa, sizeof(tcapa));
+        tcapa.lc_keyid = rkey->k_key.lk_keyid;
+        memcpy(hmac_key, rkey->k_key.lk_key, sizeof(hmac_key));
+        spin_unlock(&filter->fo_capa_lock);
+
+        capa_hmac(filter->fo_capa_hmac, hmac_key, &tcapa);
+
+        /* store in capa cache */
+        ocapa = capa_get(capa->lc_uid, capa->lc_op, capa->lc_mdsid,
+                         capa->lc_ino, FILTER_CAPA, capa, NULL, NULL);
+        if (!ocapa)
+                GOTO(out, rc = -ENOMEM);
+
+        if (bkey) {
+                spin_lock(&filter->fo_capa_lock);
+                tcapa.lc_keyid = bkey->k_key.lk_keyid;
+                memcpy(hmac_key, bkey->k_key.lk_key, sizeof(hmac_key));
+                ocapa->c_bkeyid = bkey->k_key.lk_keyid;
+                spin_unlock(&filter->fo_capa_lock);
+
+                capa_hmac(filter->fo_capa_hmac, bkey->k_key.lk_key, &tcapa);
+
+                spin_lock(&filter->fo_capa_lock);
+                memcpy(ocapa->c_bhmac, tcapa.lc_hmac, sizeof(ocapa->c_bhmac));
+                spin_unlock(&filter->fo_capa_lock);
+        }
+        goto verify;
+out:
+        RETURN(rc);
+}
index 2aa014f..7288807 100644 (file)
@@ -120,7 +120,8 @@ extern struct ldlm_valblock_ops filter_lvbo;
 /* filter_io.c */
 int filter_preprw(int cmd, struct obd_export *, struct obdo *, int objcount,
                   struct obd_ioobj *, int niocount, struct niobuf_remote *,
-                  struct niobuf_local *, struct obd_trans_info *);
+                  struct niobuf_local *, struct obd_trans_info *,
+                  struct lustre_capa *capa);
 int filter_commitrw(int cmd, struct obd_export *, struct obdo *, int objcount,
                     struct obd_ioobj *, int niocount, struct niobuf_local *,
                     struct obd_trans_info *, int rc);
@@ -194,4 +195,10 @@ static inline void  filter_tally_read(struct filter_obd *filter,
 static inline lproc_filter_attach_seqstat(struct obd_device *dev) {}
 #endif
 
+/* filter_capa.c */
+int filter_init_capa_keys(struct obd_device *obd);
+void filter_free_capa_keys(struct filter_obd *filter);
+int filter_update_capa_key(struct obd_device *obd, struct lustre_capa_key *key);
+int filter_verify_capa(int cmd, struct obd_export *exp, struct lustre_capa *capa);
+
 #endif
index 62beaa7..41659a4 100644 (file)
@@ -637,8 +637,14 @@ cleanup:
 int filter_preprw(int cmd, struct obd_export *exp, struct obdo *oa,
                   int objcount, struct obd_ioobj *obj, int niocount,
                   struct niobuf_remote *nb, struct niobuf_local *res,
-                  struct obd_trans_info *oti)
+                  struct obd_trans_info *oti, struct lustre_capa *capa)
 {
+        int rc;
+
+        rc = filter_verify_capa(cmd, exp, capa);
+        if (rc)
+                return rc;
+
         if (cmd == OBD_BRW_WRITE)
                 return filter_preprw_write(cmd, exp, oa, objcount, obj,
                                            niocount, nb, res, oti);
@@ -933,7 +939,7 @@ int filter_brw(int cmd, struct obd_export *exp, struct obdo *oa,
         obdo_to_ioobj(oa, &ioo);
         ioo.ioo_bufcnt = oa_bufs;
 
-        ret = filter_preprw(cmd, exp, oa, 1, &ioo, oa_bufs, rnb, lnb, oti);
+        ret = filter_preprw(cmd, exp, oa, 1, &ioo, oa_bufs, rnb, lnb, oti,NULL);
         if (ret != 0)
                 GOTO(out, ret);
 
index ef632a9..fa170d7 100644 (file)
@@ -134,6 +134,32 @@ int lprocfs_filter_wr_readcache(struct file *file, const char *buffer,
         return count;
 }
 
+int lprocfs_filter_rd_capa_stat(char *page, char **start, off_t off, int count,
+                                int *eof, void *data)
+{
+        struct obd_device *obd = data;
+        int rc;
+
+        rc = snprintf(page, count, "%d\n",
+                      obd->u.filter.fo_capa_stat);
+        return rc;
+}
+
+int lprocfs_filter_wr_capa_stat(struct file *file, const char *buffer,
+                                unsigned long count, void *data)
+{
+        struct obd_device *obd = data;
+        int val;
+        int rc;
+
+        rc = lprocfs_write_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        obd->u.filter.fo_capa_stat = val;
+        return count;
+}
+
 static struct lprocfs_vars lprocfs_obd_vars[] = {
         { "uuid",         lprocfs_rd_uuid,          0, 0 },
         { "blocksize",    lprocfs_rd_blksize,       0, 0 },
@@ -154,6 +180,8 @@ static struct lprocfs_vars lprocfs_obd_vars[] = {
                           lprocfs_filter_rd_readcache,
                           lprocfs_filter_wr_readcache, 0 },
         { "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 },
+        { "capa",         lprocfs_filter_rd_capa_stat,
+                          lprocfs_filter_wr_capa_stat, 0 },
         { 0 }
 };
 
index 8421c85..aeae7d0 100644 (file)
 #include <linux/lustre_ha.h>
 #include <linux/lprocfs_status.h>
 #include <linux/lustre_log.h>
+#include <linux/lustre_lite.h>
 #include <linux/lustre_audit.h>
 #include <linux/lustre_gs.h>
+
 #include "osc_internal.h"
 
 /* Pack OSC object metadata for disk storage (LE byte order). */
@@ -387,11 +389,14 @@ out:
 
 static int osc_punch(struct obd_export *exp, struct obdo *oa,
                      struct lov_stripe_md *md, obd_size start,
-                     obd_size end, struct obd_trans_info *oti)
+                     obd_size end, struct obd_trans_info *oti,
+                     struct lustre_capa *capa)
 {
         struct ptlrpc_request *request;
         struct ost_body *body;
-        int rc, size = sizeof(*body);
+        struct lustre_capa *req_capa;
+        int bufcnt = 0;
+        int rc, size[2] = { sizeof(*body), sizeof(*capa) };
         ENTRY;
 
         if (!oa) {
@@ -400,11 +405,12 @@ static int osc_punch(struct obd_export *exp, struct obdo *oa,
         }
 
         request = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
-                                  OST_PUNCH, 1, &size, NULL);
+                                  OST_PUNCH, capa ? 2 : 1, size, NULL);
         if (!request)
                 RETURN(-ENOMEM);
 
-        body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
+        body = lustre_msg_buf(request->rq_reqmsg, bufcnt++, sizeof (*body));
+
         memcpy(&body->oa, oa, sizeof(*oa));
 
         /* overload the size and blocks fields in the oa with start/end */
@@ -412,7 +418,14 @@ static int osc_punch(struct obd_export *exp, struct obdo *oa,
         body->oa.o_blocks = end;
         body->oa.o_valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS);
 
-        request->rq_replen = lustre_msg_size(1, &size);
+        if (capa) {
+                req_capa = lustre_msg_buf(request->rq_reqmsg, bufcnt++,
+                                          sizeof(*capa));
+                capa_dup2(req_capa, capa);
+                body->oa.o_valid |= OBD_MD_CAPA;
+        }
+
+        request->rq_replen = lustre_msg_size(1, size);
 
         rc = ptlrpc_queue_wait(request);
         if (rc)
@@ -764,13 +777,17 @@ static int osc_brw_prep_request(int cmd, struct obd_import *imp,struct obdo *oa,
         struct ptlrpc_bulk_desc *desc;
         struct client_obd       *cli = &imp->imp_obd->u.cli;
         struct ost_body         *body;
+        struct lustre_id        *raw_id = obdo_id(oa);
+        struct obd_capa         *ocapa;
+        struct lustre_capa      *capa;
         struct obd_ioobj        *ioobj;
         struct niobuf_remote    *niobuf;
         int                      niocount;
-        int                      size[3];
-        int                      i;
+        int                      size[4];
+        int                      i, bufcnt = 0;
         int                      requested_nob;
         int                      opc;
+        int                      capa_op;
         int                      rc;
 
         opc = ((cmd & OBD_BRW_WRITE) != 0) ? OST_WRITE : OST_READ;
@@ -779,11 +796,27 @@ static int osc_brw_prep_request(int cmd, struct obd_import *imp,struct obdo *oa,
                 if (!can_merge_pages(&pga[i - 1], &pga[i]))
                         niocount++;
 
-        size[0] = sizeof(*body);
-        size[1] = sizeof(*ioobj);
-        size[2] = niocount * sizeof(*niobuf);
+        capa_op = (opc == OST_WRITE) ? MAY_WRITE : MAY_READ;
+get_capa:
+        ocapa = capa_get(oa->o_fsuid, capa_op, raw_id->li_fid.lf_group,
+                         raw_id->li_stc.u.e3s.l3s_ino, CLIENT_CAPA,
+                         NULL, NULL, NULL);
+        if (!ocapa) {
+                if (opc == OST_READ && capa_op == MAY_READ) {
+                        /* partial write might cause read, MAY_WRITE capability
+                         * should be used here */
+                        capa_op = MAY_WRITE;
+                        goto get_capa;
+                }
+        }
+
+        size[bufcnt++] = sizeof(*body);
+        size[bufcnt++] = sizeof(*ioobj);
+        if (ocapa)
+                size[bufcnt++] = sizeof(*capa);
+        size[bufcnt++] = niocount * sizeof(*niobuf);
 
-        req = ptlrpc_prep_req(imp, LUSTRE_OBD_VERSION, opc, 3, size, NULL);
+        req = ptlrpc_prep_req(imp, LUSTRE_OBD_VERSION, opc, bufcnt, size, NULL);
         if (req == NULL)
                 return (-ENOMEM);
 
@@ -797,15 +830,25 @@ static int osc_brw_prep_request(int cmd, struct obd_import *imp,struct obdo *oa,
                 GOTO(out, rc = -ENOMEM);
         /* NB request now owns desc and will free it when it gets freed */
 
-        body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body));
-        ioobj = lustre_msg_buf(req->rq_reqmsg, 1, sizeof(*ioobj));
-        niobuf = lustre_msg_buf(req->rq_reqmsg, 2, niocount * sizeof(*niobuf));
+        bufcnt = 0;
+        body = lustre_msg_buf(req->rq_reqmsg, bufcnt++, sizeof(*body));
+        ioobj = lustre_msg_buf(req->rq_reqmsg, bufcnt++, sizeof(*ioobj));
+        if (ocapa)
+                capa = lustre_msg_buf(req->rq_reqmsg, bufcnt++, sizeof(*capa));
+        niobuf = lustre_msg_buf(req->rq_reqmsg, bufcnt++,
+                                niocount * sizeof(*niobuf));
 
         memcpy(&body->oa, oa, sizeof(*oa));
 
         obdo_to_ioobj(oa, ioobj);
         ioobj->ioo_bufcnt = niocount;
 
+        if (ocapa) {
+                capa_dup(capa, ocapa);
+                body->oa.o_valid |= OBD_MD_CAPA;
+                capa_put(ocapa, CLIENT_CAPA);
+        }
+
         LASSERT (page_count > 0);
 
         for (requested_nob = i = 0; i < page_count; i++, niobuf++) {
@@ -843,7 +886,8 @@ static int osc_brw_prep_request(int cmd, struct obd_import *imp,struct obdo *oa,
         }
 
         LASSERT((void *)(niobuf - niocount) ==
-                lustre_msg_buf(req->rq_reqmsg, 2, niocount * sizeof(*niobuf)));
+                lustre_msg_buf(req->rq_reqmsg, bufcnt - 1,
+                               niocount * sizeof(*niobuf)));
         osc_announce_cached(cli, &body->oa, opc == OST_WRITE ? requested_nob:0);
 
         /* size[0] still sizeof (*body) */
@@ -2917,6 +2961,7 @@ static int osc_set_info(struct obd_export *exp, obd_count keylen,
                 spin_unlock(&oscc->oscc_lock);
                 RETURN(0);
         }
+
         if (keylen == strlen("unrecovery") &&
             memcmp(key, "unrecovery", keylen) == 0) {
                 struct osc_creator *oscc = &obd->u.cli.cl_oscc;
@@ -2925,9 +2970,10 @@ static int osc_set_info(struct obd_export *exp, obd_count keylen,
                 spin_unlock(&oscc->oscc_lock);
                 RETURN(0);
         }
+
         if (keylen == strlen("initial_recov") &&
             memcmp(key, "initial_recov", strlen("initial_recov")) == 0) {
-                struct obd_import *imp = exp->exp_obd->u.cli.cl_import;
+                struct obd_import *imp = class_exp2cliimp(exp);
                 if (vallen != sizeof(int))
                         RETURN(-EINVAL);
                 imp->imp_initial_recov = *(int *)val;
@@ -3005,8 +3051,7 @@ static int osc_set_info(struct obd_export *exp, obd_count keylen,
                 RETURN(rc);
         }
 
-        if (keylen == strlen("sec") &&
-            memcmp(key, "sec", keylen) == 0) {
+        if (keylen == strlen("sec") && memcmp(key, "sec", keylen) == 0) {
                 struct client_obd *cli = &exp->exp_obd->u.cli;
 
                 cli->cl_sec_flavor = ptlrpcs_name2flavor(val);
@@ -3041,6 +3086,29 @@ static int osc_set_info(struct obd_export *exp, obd_count keylen,
                 RETURN(0);
         }
 
+        if (keylen == 8 && memcmp(key, "capa_key", 8) == 0) {
+                struct ptlrpc_request *req;
+                char *bufs[2] = {key, val};
+                unsigned long irqflags;
+                int rc, size[2] = {keylen, vallen};
+
+                LASSERT(vallen == sizeof(struct lustre_capa_key));
+
+                req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
+                                      OST_SET_INFO, 2, size, bufs);
+                if (req == NULL)
+                        RETURN(-ENOMEM);
+
+                spin_lock_irqsave (&req->rq_lock, irqflags);
+                req->rq_replay = 1;
+                spin_unlock_irqrestore (&req->rq_lock, irqflags);
+
+                req->rq_replen = lustre_msg_size(0, NULL);
+                rc = ptlrpc_queue_wait(req);
+                ptlrpc_req_finished(req);
+                RETURN(rc);
+        }
+
         if (keylen == strlen("setext") &&
             memcmp(key, "setext", keylen) == 0) {
                 struct client_obd *cli = &exp->exp_obd->u.cli;
@@ -3270,6 +3338,7 @@ static int osc_cleanup(struct obd_device *obd, int flags)
         RETURN(rc);
 }
 
+       
 struct obd_ops osc_obd_ops = {
         .o_owner                = THIS_MODULE,
         .o_attach               = osc_attach,
index b1fe341..0aa69d2 100644 (file)
@@ -166,6 +166,7 @@ static int ost_punch(struct obd_export *exp, struct ptlrpc_request *req,
                      struct obd_trans_info *oti)
 {
         struct ost_body *body, *repbody;
+        struct lustre_capa *capa = NULL;
         int rc, size = sizeof(*repbody);
         ENTRY;
 
@@ -177,6 +178,15 @@ static int ost_punch(struct obd_export *exp, struct ptlrpc_request *req,
             (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS))
                 RETURN(-EINVAL);
 
+        if (body->oa.o_valid & OBD_MD_CAPA) {
+                capa = lustre_swab_reqbuf(req, 1, sizeof(*capa),
+                                          lustre_swab_lustre_capa);
+                if (capa == NULL) {
+                        CERROR("Missing/short capa\n");
+                        RETURN(-EFAULT);
+                }
+        }
+
         rc = lustre_pack_reply(req, 1, &size, NULL);
         if (rc)
                 RETURN(rc);
@@ -184,7 +194,7 @@ static int ost_punch(struct obd_export *exp, struct ptlrpc_request *req,
         repbody = lustre_msg_buf(req->rq_repmsg, 0, sizeof(*repbody));
         memcpy(&repbody->oa, &body->oa, sizeof(body->oa));
         req->rq_status = obd_punch(exp, &repbody->oa, NULL, repbody->oa.o_size,
-                                   repbody->oa.o_blocks, oti);
+                                   repbody->oa.o_blocks, oti, capa);
         RETURN(0);
 }
 
@@ -389,6 +399,7 @@ static int ost_brw_read(struct ptlrpc_request *req)
         struct niobuf_local     *local_nb;
         struct obd_ioobj        *ioo;
         struct ost_body         *body, *repbody;
+        struct lustre_capa      *capa = NULL;
         struct l_wait_info       lwi;
         struct obd_trans_info    oti = { 0 };
         int                      size[1] = { sizeof(*body) };
@@ -397,7 +408,7 @@ static int ost_brw_read(struct ptlrpc_request *req)
         int                      npages;
         int                      nob = 0;
         int                      rc;
-        int                      i;
+        int                      i, bufcnt = 0;
         struct timeval           start;
         ENTRY;
 
@@ -407,20 +418,32 @@ static int ost_brw_read(struct ptlrpc_request *req)
         OBD_FAIL_TIMEOUT(OBD_FAIL_OST_BRW_PAUSE_BULK | OBD_FAIL_ONCE,
                          (obd_timeout + 1) / 4);
 
-        body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_ost_body);
+        body = lustre_swab_reqbuf(req, bufcnt++, sizeof(*body),
+                                  lustre_swab_ost_body);
         if (body == NULL) {
                 CERROR("Missing/short ost_body\n");
                 GOTO(out, rc = -EFAULT);
         }
 
-        ioo = lustre_swab_reqbuf(req, 1, sizeof(*ioo), lustre_swab_obd_ioobj);
+        ioo = lustre_swab_reqbuf(req, bufcnt++, sizeof(*ioo),
+                                 lustre_swab_obd_ioobj);
         if (ioo == NULL) {
                 CERROR("Missing/short ioobj\n");
                 GOTO(out, rc = -EFAULT);
         }
 
+        if (body->oa.o_valid & OBD_MD_CAPA) {
+                capa = lustre_swab_reqbuf(req, bufcnt++, sizeof(*capa),
+                                          lustre_swab_lustre_capa);
+                if (capa == NULL) {
+                        CERROR("Missing/short capa\n");
+                        GOTO(out, rc = -EFAULT);
+                }
+        }
+
         niocount = ioo->ioo_bufcnt;
-        remote_nb = lustre_swab_reqbuf(req, 2, niocount * sizeof(*remote_nb),
+        remote_nb = lustre_swab_reqbuf(req, bufcnt++,
+                                       niocount * sizeof(*remote_nb),
                                        lustre_swab_niobuf_remote);
         if (remote_nb == NULL) {
                 CERROR("Missing/short niobuf\n");
@@ -452,7 +475,7 @@ static int ost_brw_read(struct ptlrpc_request *req)
 
         do_gettimeofday(&start);
         rc = obd_preprw(OBD_BRW_READ, req->rq_export, &body->oa, 1,
-                        ioo, npages, pp_rnb, local_nb, &oti);
+                        ioo, npages, pp_rnb, local_nb, &oti, capa);
         ost_stime_record(req, &start, 0, 0);
         if (rc != 0)
                 GOTO(out_bulk, rc);
@@ -577,13 +600,14 @@ int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
         struct niobuf_remote    *pp_rnb;
         struct niobuf_local     *local_nb;
         struct obd_ioobj        *ioo;
+        struct lustre_capa      *capa = NULL;
         struct ost_body         *body, *repbody;
         struct l_wait_info       lwi;
         __u32                   *rcs;
         int                      size[2] = { sizeof(*body) };
         int                      objcount, niocount, npages;
         int                      comms_error = 0;
-        int                      rc, swab, i, j;
+        int                      rc, swab, i, j, bufcnt = 0;
         struct timeval           start;        
         ENTRY;
 
@@ -595,7 +619,8 @@ int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                          (obd_timeout + 1) / 4);
 
         swab = lustre_msg_swabbed(req->rq_reqmsg);
-        body = lustre_swab_reqbuf(req, 0, sizeof(*body), lustre_swab_ost_body);
+        body = lustre_swab_reqbuf(req, bufcnt++, sizeof(*body),
+                                  lustre_swab_ost_body);
         if (body == NULL) {
                 CERROR("Missing/short ost_body\n");
                 GOTO(out, rc = -EFAULT);
@@ -607,7 +632,8 @@ int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                 CERROR("Missing/short ioobj\n");
                 GOTO(out, rc = -EFAULT);
         }
-        ioo = lustre_msg_buf (req->rq_reqmsg, 1, objcount * sizeof(*ioo));
+        ioo = lustre_msg_buf(req->rq_reqmsg, bufcnt++,
+                             objcount * sizeof(*ioo));
         LASSERT (ioo != NULL);
         for (niocount = i = 0; i < objcount; i++) {
                 if (swab)
@@ -619,7 +645,17 @@ int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
                 niocount += ioo[i].ioo_bufcnt;
         }
 
-        remote_nb = lustre_swab_reqbuf(req, 2, niocount * sizeof(*remote_nb),
+        if (body->oa.o_valid & OBD_MD_CAPA) {
+                capa = lustre_swab_reqbuf(req, bufcnt++, sizeof(*capa),
+                                          lustre_swab_lustre_capa);
+                if (capa == NULL) {
+                        CERROR("Missing/short capa\n");
+                        GOTO(out, rc = -EFAULT);
+                }
+        }
+
+        remote_nb = lustre_swab_reqbuf(req, bufcnt++,
+                                       niocount * sizeof(*remote_nb),
                                        lustre_swab_niobuf_remote);
         if (remote_nb == NULL) {
                 CERROR("Missing/short niobuf\n");
@@ -660,7 +696,7 @@ int ost_brw_write(struct ptlrpc_request *req, struct obd_trans_info *oti)
 
         do_gettimeofday(&start);
         rc = obd_preprw(OBD_BRW_WRITE, req->rq_export, &body->oa, objcount,
-                        ioo, npages, pp_rnb, local_nb, oti);
+                        ioo, npages, pp_rnb, local_nb, oti, capa);
         ost_stime_record(req, &start, 1, 0);
         if (rc != 0)
                 GOTO(out_bulk, rc);
@@ -881,18 +917,23 @@ static int ost_set_info(struct obd_export *exp, struct ptlrpc_request *req)
                 RETURN(rc);
 
         val = lustre_msg_buf(req->rq_reqmsg, 1, 0);
+        if (val == NULL) {
+                CERROR("val for setinfo can't be NULL\n");
+                RETURN(-EFAULT);
+        }
         
         if (keylen == 8 && memcmp(key, "auditlog", 8) == 0) {
                 lustre_swab_reqbuf(req, 1, sizeof(struct audit_msg),
                                    lustre_swab_audit_msg);
-        }
-        else if (keylen == 5 && strcmp(key, "audit") == 0) {
+        } else if (keylen == 5 && strcmp(key, "audit") == 0) {
                 lustre_swab_reqbuf(req, 1, sizeof(struct audit_attr_msg),
                                    lustre_swab_audit_attr);
-        }
-        else if (keylen == 9 && strcmp(key, "audit_obj") == 0) {
+        } else if (keylen == 9 && strcmp(key, "audit_obj") == 0) {
                 lustre_swab_reqbuf(req, 1, sizeof(struct obdo),
                                    lustre_swab_obdo);
+        } else if (keylen == 8 && strcmp(key, "capa_key") == 0) {
+                lustre_swab_reqbuf(req, 1, sizeof(struct lustre_capa_key),
+                                   lustre_swab_lustre_capa_key);
         }
 
         rc = obd_set_info(exp, keylen, key, req->rq_reqmsg->buflens[1], val);
index 1072c8c..f319244 100644 (file)
@@ -919,6 +919,24 @@ void lustre_swab_remote_perm(struct mds_remote_perm *p)
         __swab16s(&p->mrp_perm);
 }
 
+void lustre_swab_lustre_capa(struct lustre_capa *c)
+{
+        __swab32s (&c->lc_uid);
+        __swab32s (&c->lc_op);
+        __swab64s (&c->lc_ino);
+        __swab32s (&c->lc_mdsid);
+        __swab32s (&c->lc_keyid);
+        __swab64s (&c->lc_expiry);
+        __swab32s (&c->lc_flags);
+}
+
+void lustre_swab_lustre_capa_key (struct lustre_capa_key *k)
+{
+        __swab32s (&k->lk_mdsid);
+        __swab32s (&k->lk_keyid);
+        __swab64s (&k->lk_expiry);
+}
+
 void lustre_swab_audit_msg (struct audit_msg *r)
 {
         lustre_swab_lustre_id(&r->id);
index 8367c3a..6aac960 100644 (file)
@@ -200,6 +200,8 @@ EXPORT_SYMBOL(lustre_swab_ldlm_reply);
 EXPORT_SYMBOL(lustre_swab_ptlbd_op);
 EXPORT_SYMBOL(lustre_swab_ptlbd_niob);
 EXPORT_SYMBOL(lustre_swab_ptlbd_rsp);
+EXPORT_SYMBOL(lustre_swab_lustre_capa);
+EXPORT_SYMBOL(lustre_swab_lustre_capa_key);
 EXPORT_SYMBOL(lustre_swab_key_context);
 EXPORT_SYMBOL(lustre_swab_key_perms);
 EXPORT_SYMBOL(mdc_create_pack);
index db867b6..134f822 100644 (file)
@@ -118,7 +118,7 @@ check_obdo(void)
         CHECK_MEMBER(obdo, o_easize);
         CHECK_MEMBER(obdo, o_mds);
         CHECK_MEMBER(obdo, o_mds);
-        CHECK_MEMBER(obdo, o_padding);
+        CHECK_MEMBER(obdo, o_fsuid);
         CHECK_MEMBER(obdo, o_inline);
 
         CHECK_VALUE(OBD_MD_FLID);
@@ -673,6 +673,32 @@ check_llogd_conn_body(void)
 }
 
 void
+check_lustre_capa(void)
+{
+        BLANK_LINE();
+        CHECK_STRUCT(lustre_capa);
+        CHECK_MEMBER(lustre_capa, lc_uid);
+        CHECK_MEMBER(lustre_capa, lc_op);
+        CHECK_MEMBER(lustre_capa, lc_ino);
+        CHECK_MEMBER(lustre_capa, lc_mdsid);
+        CHECK_MEMBER(lustre_capa, lc_keyid);
+        CHECK_MEMBER(lustre_capa, lc_expiry);
+        CHECK_MEMBER(lustre_capa, lc_flags);
+        CHECK_MEMBER(lustre_capa, lc_hmac);
+}
+
+void
+check_lustre_capa_key(void)
+{
+        BLANK_LINE();
+        CHECK_STRUCT(lustre_capa_key);
+        CHECK_MEMBER(lustre_capa_key, lk_mdsid);
+        CHECK_MEMBER(lustre_capa_key, lk_keyid);
+        CHECK_MEMBER(lustre_capa_key, lk_expiry);
+        CHECK_MEMBER(lustre_capa_key, lk_key);
+}
+
+void
 system_string (char *cmdline, char *str, int len)
 {
         int   fds[2];
@@ -892,6 +918,8 @@ main(int argc, char **argv)
         check_llog_cookie();
         check_llogd_body();
         check_llogd_conn_body();
+        check_lustre_capa();
+        check_lustre_capa_key();
 
         printf("}\n\n");
 
index 3563b8a..2d4f3de 100644 (file)
@@ -24,4 +24,1443 @@ int main()
 
 void lustre_assert_wire_constants(void)
 {
+        /* Wire protocol assertions generated by 'wirecheck'
+         * running on Linux localhost.localdomain 2.6.12-1.1372_FC3 #1 Fri Jul 15 00:59:10 EDT 2005 i
+         * with gcc version 3.4.3 20050227 (Red Hat 3.4.3-22.fc3) */
+
+
+        /* Constants... */
+        LASSERTF(PTLRPC_MSG_MAGIC == 0x0BD00BD0," found %lld\n",
+                 (long long)PTLRPC_MSG_MAGIC);
+        LASSERTF(PTLRPC_MSG_VERSION == 0x00000003," found %lld\n",
+                 (long long)PTLRPC_MSG_VERSION);
+        LASSERTF(PTL_RPC_MSG_REQUEST == 4711, " found %llu\n",
+                 (unsigned long long)PTL_RPC_MSG_REQUEST);
+        LASSERTF(PTL_RPC_MSG_ERR == 4712, " found %llu\n",
+                 (unsigned long long)PTL_RPC_MSG_ERR);
+        LASSERTF(PTL_RPC_MSG_REPLY == 4713, " found %llu\n",
+                 (unsigned long long)PTL_RPC_MSG_REPLY);
+        LASSERTF(MSG_LAST_REPLAY == 1, " found %llu\n",
+                 (unsigned long long)MSG_LAST_REPLAY);
+        LASSERTF(MSG_RESENT == 2, " found %llu\n",
+                 (unsigned long long)MSG_RESENT);
+        LASSERTF(MSG_REPLAY == 4, " found %llu\n",
+                 (unsigned long long)MSG_REPLAY);
+        LASSERTF(MSG_CONNECT_RECOVERING == 1, " found %llu\n",
+                 (unsigned long long)MSG_CONNECT_RECOVERING);
+        LASSERTF(MSG_CONNECT_RECONNECT == 2, " found %llu\n",
+                 (unsigned long long)MSG_CONNECT_RECONNECT);
+        LASSERTF(MSG_CONNECT_REPLAYABLE == 4, " found %llu\n",
+                 (unsigned long long)MSG_CONNECT_REPLAYABLE);
+        LASSERTF(OST_REPLY == 0, " found %llu\n",
+                 (unsigned long long)OST_REPLY);
+        LASSERTF(OST_GETATTR == 1, " found %llu\n",
+                 (unsigned long long)OST_GETATTR);
+        LASSERTF(OST_SETATTR == 2, " found %llu\n",
+                 (unsigned long long)OST_SETATTR);
+        LASSERTF(OST_READ == 3, " found %llu\n",
+                 (unsigned long long)OST_READ);
+        LASSERTF(OST_WRITE == 4, " found %llu\n",
+                 (unsigned long long)OST_WRITE);
+        LASSERTF(OST_CREATE == 5, " found %llu\n",
+                 (unsigned long long)OST_CREATE);
+        LASSERTF(OST_DESTROY == 6, " found %llu\n",
+                 (unsigned long long)OST_DESTROY);
+        LASSERTF(OST_GET_INFO == 7, " found %llu\n",
+                 (unsigned long long)OST_GET_INFO);
+        LASSERTF(OST_CONNECT == 8, " found %llu\n",
+                 (unsigned long long)OST_CONNECT);
+        LASSERTF(OST_DISCONNECT == 9, " found %llu\n",
+                 (unsigned long long)OST_DISCONNECT);
+        LASSERTF(OST_PUNCH == 10, " found %llu\n",
+                 (unsigned long long)OST_PUNCH);
+        LASSERTF(OST_OPEN == 11, " found %llu\n",
+                 (unsigned long long)OST_OPEN);
+        LASSERTF(OST_CLOSE == 12, " found %llu\n",
+                 (unsigned long long)OST_CLOSE);
+        LASSERTF(OST_STATFS == 13, " found %llu\n",
+                 (unsigned long long)OST_STATFS);
+        LASSERTF(OST_SAN_READ == 14, " found %llu\n",
+                 (unsigned long long)OST_SAN_READ);
+        LASSERTF(OST_SAN_WRITE == 15, " found %llu\n",
+                 (unsigned long long)OST_SAN_WRITE);
+        LASSERTF(OST_SYNC == 16, " found %llu\n",
+                 (unsigned long long)OST_SYNC);
+        LASSERTF(OST_LAST_OPC == 18, " found %llu\n",
+                 (unsigned long long)OST_LAST_OPC);
+        LASSERTF(OBD_OBJECT_EOF == 0xffffffffffffffffULL," found %lld\n",
+                 (long long)OBD_OBJECT_EOF);
+        LASSERTF(OST_REQ_HAS_OA1 == 1, " found %llu\n",
+                 (unsigned long long)OST_REQ_HAS_OA1);
+        LASSERTF(MDS_GETATTR == 33, " found %llu\n",
+                 (unsigned long long)MDS_GETATTR);
+        LASSERTF(MDS_GETATTR_LOCK == 34, " found %llu\n",
+                 (unsigned long long)MDS_GETATTR_LOCK);
+        LASSERTF(MDS_CLOSE == 35, " found %llu\n",
+                 (unsigned long long)MDS_CLOSE);
+        LASSERTF(MDS_REINT == 36, " found %llu\n",
+                 (unsigned long long)MDS_REINT);
+        LASSERTF(MDS_READPAGE == 37, " found %llu\n",
+                 (unsigned long long)MDS_READPAGE);
+        LASSERTF(MDS_CONNECT == 38, " found %llu\n",
+                 (unsigned long long)MDS_CONNECT);
+        LASSERTF(MDS_DISCONNECT == 39, " found %llu\n",
+                 (unsigned long long)MDS_DISCONNECT);
+        LASSERTF(MDS_GETSTATUS == 40, " found %llu\n",
+                 (unsigned long long)MDS_GETSTATUS);
+        LASSERTF(MDS_STATFS == 41, " found %llu\n",
+                 (unsigned long long)MDS_STATFS);
+        LASSERTF(MDS_PIN == 42, " found %llu\n",
+                 (unsigned long long)MDS_PIN);
+        LASSERTF(MDS_UNPIN == 43, " found %llu\n",
+                 (unsigned long long)MDS_UNPIN);
+        LASSERTF(MDS_SYNC == 44, " found %llu\n",
+                 (unsigned long long)MDS_SYNC);
+        LASSERTF(MDS_DONE_WRITING == 45, " found %llu\n",
+                 (unsigned long long)MDS_DONE_WRITING);
+        LASSERTF(MDS_ACCESS_CHECK == 46, " found %llu\n",
+                 (unsigned long long)MDS_ACCESS_CHECK);
+        LASSERTF(MDS_LAST_OPC == 48, " found %llu\n",
+                 (unsigned long long)MDS_LAST_OPC);
+        LASSERTF(REINT_SETATTR == 1, " found %llu\n",
+                 (unsigned long long)REINT_SETATTR);
+        LASSERTF(REINT_CREATE == 2, " found %llu\n",
+                 (unsigned long long)REINT_CREATE);
+        LASSERTF(REINT_LINK == 3, " found %llu\n",
+                 (unsigned long long)REINT_LINK);
+        LASSERTF(REINT_UNLINK == 4, " found %llu\n",
+                 (unsigned long long)REINT_UNLINK);
+        LASSERTF(REINT_RENAME == 5, " found %llu\n",
+                 (unsigned long long)REINT_RENAME);
+        LASSERTF(REINT_OPEN == 7, " found %llu\n",
+                 (unsigned long long)REINT_OPEN);
+        LASSERTF(REINT_MAX == 9, " found %llu\n",
+                 (unsigned long long)REINT_MAX);
+        LASSERTF(DISP_IT_EXECD == 1, " found %llu\n",
+                 (unsigned long long)DISP_IT_EXECD);
+        LASSERTF(DISP_LOOKUP_EXECD == 2, " found %llu\n",
+                 (unsigned long long)DISP_LOOKUP_EXECD);
+        LASSERTF(DISP_LOOKUP_NEG == 4, " found %llu\n",
+                 (unsigned long long)DISP_LOOKUP_NEG);
+        LASSERTF(DISP_LOOKUP_POS == 8, " found %llu\n",
+                 (unsigned long long)DISP_LOOKUP_POS);
+        LASSERTF(DISP_OPEN_CREATE == 16, " found %llu\n",
+                 (unsigned long long)DISP_OPEN_CREATE);
+        LASSERTF(DISP_OPEN_OPEN == 32, " found %llu\n",
+                 (unsigned long long)DISP_OPEN_OPEN);
+        LASSERTF(MDS_STATUS_CONN == 1, " found %llu\n",
+                 (unsigned long long)MDS_STATUS_CONN);
+        LASSERTF(MDS_STATUS_LOV == 2, " found %llu\n",
+                 (unsigned long long)MDS_STATUS_LOV);
+        LASSERTF(MDS_OPEN_HAS_EA == 1073741824, " found %llu\n",
+                 (unsigned long long)MDS_OPEN_HAS_EA);
+        LASSERTF(LDLM_ENQUEUE == 101, " found %llu\n",
+                 (unsigned long long)LDLM_ENQUEUE);
+        LASSERTF(LDLM_CONVERT == 102, " found %llu\n",
+                 (unsigned long long)LDLM_CONVERT);
+        LASSERTF(LDLM_CANCEL == 103, " found %llu\n",
+                 (unsigned long long)LDLM_CANCEL);
+        LASSERTF(LDLM_BL_CALLBACK == 104, " found %llu\n",
+                 (unsigned long long)LDLM_BL_CALLBACK);
+        LASSERTF(LDLM_CP_CALLBACK == 105, " found %llu\n",
+                 (unsigned long long)LDLM_CP_CALLBACK);
+        LASSERTF(LDLM_LAST_OPC == 107, " found %llu\n",
+                 (unsigned long long)LDLM_LAST_OPC);
+        LASSERTF(LCK_EX == 1, " found %llu\n",
+                 (unsigned long long)LCK_EX);
+        LASSERTF(LCK_PW == 2, " found %llu\n",
+                 (unsigned long long)LCK_PW);
+        LASSERTF(LCK_PR == 4, " found %llu\n",
+                 (unsigned long long)LCK_PR);
+        LASSERTF(LCK_CW == 8, " found %llu\n",
+                 (unsigned long long)LCK_CW);
+        LASSERTF(LCK_CR == 16, " found %llu\n",
+                 (unsigned long long)LCK_CR);
+        LASSERTF(LCK_NL == 32, " found %llu\n",
+                 (unsigned long long)LCK_NL);
+        LASSERTF(PTLBD_QUERY == 200, " found %llu\n",
+                 (unsigned long long)PTLBD_QUERY);
+        LASSERTF(PTLBD_READ == 201, " found %llu\n",
+                 (unsigned long long)PTLBD_READ);
+        LASSERTF(PTLBD_WRITE == 202, " found %llu\n",
+                 (unsigned long long)PTLBD_WRITE);
+        LASSERTF(PTLBD_FLUSH == 203, " found %llu\n",
+                 (unsigned long long)PTLBD_FLUSH);
+        LASSERTF(PTLBD_CONNECT == 204, " found %llu\n",
+                 (unsigned long long)PTLBD_CONNECT);
+        LASSERTF(PTLBD_DISCONNECT == 205, " found %llu\n",
+                 (unsigned long long)PTLBD_DISCONNECT);
+        LASSERTF(PTLBD_LAST_OPC == 206, " found %llu\n",
+                 (unsigned long long)PTLBD_LAST_OPC);
+        LASSERTF(MGMT_CONNECT == 250, " found %llu\n",
+                 (unsigned long long)MGMT_CONNECT);
+        LASSERTF(MGMT_DISCONNECT == 251, " found %llu\n",
+                 (unsigned long long)MGMT_DISCONNECT);
+        LASSERTF(MGMT_EXCEPTION == 252, " found %llu\n",
+                 (unsigned long long)MGMT_EXCEPTION);
+        LASSERTF(OBD_PING == 400, " found %llu\n",
+                 (unsigned long long)OBD_PING);
+        LASSERTF(OBD_LOG_CANCEL == 401, " found %llu\n",
+                 (unsigned long long)OBD_LOG_CANCEL);
+        LASSERTF(OBD_LAST_OPC == 402, " found %llu\n",
+                 (unsigned long long)OBD_LAST_OPC);
+        /* Sizes and Offsets */
+
+
+        /* Checks for struct lustre_handle */
+        LASSERTF((int)sizeof(struct lustre_handle) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct lustre_handle));
+        LASSERTF((int)offsetof(struct lustre_handle, cookie) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_handle, cookie));
+        LASSERTF((int)sizeof(((struct lustre_handle *)0)->cookie) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_handle *)0)->cookie));
+
+        /* Checks for struct lustre_msg */
+        LASSERTF((int)sizeof(struct lustre_msg) == 64, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct lustre_msg));
+        LASSERTF((int)offsetof(struct lustre_msg, handle) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_msg, handle));
+        LASSERTF((int)sizeof(((struct lustre_msg *)0)->handle) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_msg *)0)->handle));
+        LASSERTF((int)offsetof(struct lustre_msg, magic) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_msg, magic));
+        LASSERTF((int)sizeof(((struct lustre_msg *)0)->magic) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_msg *)0)->magic));
+        LASSERTF((int)offsetof(struct lustre_msg, type) == 12, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_msg, type));
+        LASSERTF((int)sizeof(((struct lustre_msg *)0)->type) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_msg *)0)->type));
+        LASSERTF((int)offsetof(struct lustre_msg, version) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_msg, version));
+        LASSERTF((int)sizeof(((struct lustre_msg *)0)->version) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_msg *)0)->version));
+        LASSERTF((int)offsetof(struct lustre_msg, opc) == 20, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_msg, opc));
+        LASSERTF((int)sizeof(((struct lustre_msg *)0)->opc) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_msg *)0)->opc));
+        LASSERTF((int)offsetof(struct lustre_msg, last_xid) == 24, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_msg, last_xid));
+        LASSERTF((int)sizeof(((struct lustre_msg *)0)->last_xid) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_msg *)0)->last_xid));
+        LASSERTF((int)offsetof(struct lustre_msg, last_committed) == 32, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_msg, last_committed));
+        LASSERTF((int)sizeof(((struct lustre_msg *)0)->last_committed) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_msg *)0)->last_committed));
+        LASSERTF((int)offsetof(struct lustre_msg, transno) == 40, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_msg, transno));
+        LASSERTF((int)sizeof(((struct lustre_msg *)0)->transno) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_msg *)0)->transno));
+        LASSERTF((int)offsetof(struct lustre_msg, status) == 48, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_msg, status));
+        LASSERTF((int)sizeof(((struct lustre_msg *)0)->status) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_msg *)0)->status));
+        LASSERTF((int)offsetof(struct lustre_msg, flags) == 52, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_msg, flags));
+        LASSERTF((int)sizeof(((struct lustre_msg *)0)->flags) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_msg *)0)->flags));
+        LASSERTF((int)offsetof(struct lustre_msg, bufcount) == 60, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_msg, bufcount));
+        LASSERTF((int)sizeof(((struct lustre_msg *)0)->bufcount) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_msg *)0)->bufcount));
+        LASSERTF((int)offsetof(struct lustre_msg, buflens[7]) == 92, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_msg, buflens[7]));
+        LASSERTF((int)sizeof(((struct lustre_msg *)0)->buflens[7]) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_msg *)0)->buflens[7]));
+
+        /* Checks for struct obdo */
+        LASSERTF((int)sizeof(struct obdo) == 204, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct obdo));
+        LASSERTF((int)offsetof(struct obdo, o_id) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_id));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_id) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_id));
+        LASSERTF((int)offsetof(struct obdo, o_gr) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_gr));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_gr) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_gr));
+        LASSERTF((int)offsetof(struct obdo, o_atime) == 32, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_atime));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_atime) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_atime));
+        LASSERTF((int)offsetof(struct obdo, o_mtime) == 24, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_mtime));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_mtime) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_mtime));
+        LASSERTF((int)offsetof(struct obdo, o_ctime) == 40, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_ctime));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_ctime) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_ctime));
+        LASSERTF((int)offsetof(struct obdo, o_size) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_size));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_size) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_size));
+        LASSERTF((int)offsetof(struct obdo, o_blocks) == 48, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_blocks));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_blocks) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_blocks));
+        LASSERTF((int)offsetof(struct obdo, o_grant) == 56, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_grant));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_grant) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_grant));
+        LASSERTF((int)offsetof(struct obdo, o_blksize) == 64, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_blksize));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_blksize) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_blksize));
+        LASSERTF((int)offsetof(struct obdo, o_mode) == 68, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_mode));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_mode) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_mode));
+        LASSERTF((int)offsetof(struct obdo, o_uid) == 72, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_uid));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_uid) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_uid));
+        LASSERTF((int)offsetof(struct obdo, o_gid) == 76, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_gid));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_gid) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_gid));
+        LASSERTF((int)offsetof(struct obdo, o_flags) == 80, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_flags));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_flags) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_flags));
+        LASSERTF((int)offsetof(struct obdo, o_nlink) == 84, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_nlink));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_nlink) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_nlink));
+        LASSERTF((int)offsetof(struct obdo, o_generation) == 88, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_generation));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_generation) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_generation));
+        LASSERTF((int)offsetof(struct obdo, o_valid) == 92, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_valid));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_valid) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_valid));
+        LASSERTF((int)offsetof(struct obdo, o_misc) == 100, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_misc));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_misc) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_misc));
+        LASSERTF((int)offsetof(struct obdo, o_easize) == 104, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_easize));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_easize) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_easize));
+        LASSERTF((int)offsetof(struct obdo, o_mds) == 108, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_mds));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_mds) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_mds));
+        LASSERTF((int)offsetof(struct obdo, o_mds) == 108, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_mds));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_mds) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_mds));
+        LASSERTF((int)offsetof(struct obdo, o_fsuid) == 120, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_fsuid));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_fsuid) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_fsuid));
+        LASSERTF((int)offsetof(struct obdo, o_inline) == 124, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obdo, o_inline));
+        LASSERTF((int)sizeof(((struct obdo *)0)->o_inline) == 80, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obdo *)0)->o_inline));
+        LASSERTF(OBD_MD_FLID == 1, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLID);
+        LASSERTF(OBD_MD_FLATIME == 2, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLATIME);
+        LASSERTF(OBD_MD_FLMTIME == 4, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLMTIME);
+        LASSERTF(OBD_MD_FLCTIME == 8, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLCTIME);
+        LASSERTF(OBD_MD_FLSIZE == 16, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLSIZE);
+        LASSERTF(OBD_MD_FLBLOCKS == 32, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLBLOCKS);
+        LASSERTF(OBD_MD_FLBLKSZ == 64, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLBLKSZ);
+        LASSERTF(OBD_MD_FLMODE == 128, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLMODE);
+        LASSERTF(OBD_MD_FLTYPE == 256, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLTYPE);
+        LASSERTF(OBD_MD_FLUID == 512, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLUID);
+        LASSERTF(OBD_MD_FLGID == 1024, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLGID);
+        LASSERTF(OBD_MD_FLFLAGS == 2048, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLFLAGS);
+        LASSERTF(OBD_MD_FLNLINK == 8192, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLNLINK);
+        LASSERTF(OBD_MD_FLGENER == 16384, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLGENER);
+        LASSERTF(OBD_MD_FLINLINE == 32768, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLINLINE);
+        LASSERTF(OBD_MD_FLRDEV == 65536, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLRDEV);
+        LASSERTF(OBD_MD_FLEASIZE == 131072, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLEASIZE);
+        LASSERTF(OBD_MD_LINKNAME == 262144, " found %llu\n",
+                 (unsigned long long)OBD_MD_LINKNAME);
+        LASSERTF(OBD_MD_FLHANDLE == 524288, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLHANDLE);
+        LASSERTF(OBD_MD_FLCKSUM == 1048576, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLCKSUM);
+        LASSERTF(OBD_MD_FLQOS == 2097152, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLQOS);
+        LASSERTF(OBD_MD_FLOSCOPQ == 4194304, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLOSCOPQ);
+        LASSERTF(OBD_MD_FLCOOKIE == 8388608, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLCOOKIE);
+        LASSERTF(OBD_MD_FLGROUP == 16777216, " found %llu\n",
+                 (unsigned long long)OBD_MD_FLGROUP);
+        LASSERTF(OBD_FL_INLINEDATA == 1, " found %llu\n",
+                 (unsigned long long)OBD_FL_INLINEDATA);
+        LASSERTF(OBD_FL_OBDMDEXISTS == 2, " found %llu\n",
+                 (unsigned long long)OBD_FL_OBDMDEXISTS);
+        LASSERTF(OBD_FL_DELORPHAN == 4, " found %llu\n",
+                 (unsigned long long)OBD_FL_DELORPHAN);
+        LASSERTF(OBD_FL_NORPC == 8, " found %llu\n",
+                 (unsigned long long)OBD_FL_NORPC);
+        LASSERTF(OBD_FL_IDONLY == 16, " found %llu\n",
+                 (unsigned long long)OBD_FL_IDONLY);
+        LASSERTF(OBD_FL_RECREATE_OBJS == 32, " found %llu\n",
+                 (unsigned long long)OBD_FL_RECREATE_OBJS);
+
+        /* Checks for struct lov_mds_md_v1 */
+        LASSERTF((int)sizeof(struct lov_mds_md_v1) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct lov_mds_md_v1));
+        LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_magic) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_mds_md_v1, lmm_magic));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_magic) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_magic));
+        LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_pattern) == 4, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_mds_md_v1, lmm_pattern));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_pattern) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_pattern));
+        LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_object_id) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_mds_md_v1, lmm_object_id));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_object_id) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_object_id));
+        LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_object_gr) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_mds_md_v1, lmm_object_gr));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_object_gr) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_object_gr));
+        LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_stripe_size) == 24, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_mds_md_v1, lmm_stripe_size));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_stripe_size) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_stripe_size));
+        LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_stripe_count) == 28, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_mds_md_v1, lmm_stripe_count));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_stripe_count) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_stripe_count));
+        LASSERTF((int)offsetof(struct lov_mds_md_v1, lmm_objects) == 32, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_mds_md_v1, lmm_objects));
+        LASSERTF((int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_objects) == 0, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_mds_md_v1 *)0)->lmm_objects));
+
+        /* Checks for struct lov_ost_data_v1 */
+        LASSERTF((int)sizeof(struct lov_ost_data_v1) == 24, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct lov_ost_data_v1));
+        LASSERTF((int)offsetof(struct lov_ost_data_v1, l_object_id) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_ost_data_v1, l_object_id));
+        LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_id) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_id));
+        LASSERTF((int)offsetof(struct lov_ost_data_v1, l_object_gr) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_ost_data_v1, l_object_gr));
+        LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_gr) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_object_gr));
+        LASSERTF((int)offsetof(struct lov_ost_data_v1, l_ost_gen) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_ost_data_v1, l_ost_gen));
+        LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_gen) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_gen));
+        LASSERTF((int)offsetof(struct lov_ost_data_v1, l_ost_idx) == 20, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_ost_data_v1, l_ost_idx));
+        LASSERTF((int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_idx) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_ost_data_v1 *)0)->l_ost_idx));
+        LASSERTF(LOV_MAGIC_V0 == 198183888, " found %llu\n",
+                 (unsigned long long)LOV_MAGIC_V0);
+        LASSERTF(LOV_MAGIC_V1 == 198249424, " found %llu\n",
+                 (unsigned long long)LOV_MAGIC_V1);
+        LASSERTF(LOV_PATTERN_RAID0 == 1, " found %llu\n",
+                 (unsigned long long)LOV_PATTERN_RAID0);
+        LASSERTF(LOV_PATTERN_RAID1 == 2, " found %llu\n",
+                 (unsigned long long)LOV_PATTERN_RAID1);
+
+        /* Checks for struct obd_statfs */
+        LASSERTF((int)sizeof(struct obd_statfs) == 144, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct obd_statfs));
+        LASSERTF((int)offsetof(struct obd_statfs, os_type) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obd_statfs, os_type));
+        LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_type) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obd_statfs *)0)->os_type));
+        LASSERTF((int)offsetof(struct obd_statfs, os_blocks) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obd_statfs, os_blocks));
+        LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_blocks) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obd_statfs *)0)->os_blocks));
+        LASSERTF((int)offsetof(struct obd_statfs, os_bfree) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obd_statfs, os_bfree));
+        LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_bfree) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obd_statfs *)0)->os_bfree));
+        LASSERTF((int)offsetof(struct obd_statfs, os_bavail) == 24, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obd_statfs, os_bavail));
+        LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_bavail) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obd_statfs *)0)->os_bavail));
+        LASSERTF((int)offsetof(struct obd_statfs, os_ffree) == 40, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obd_statfs, os_ffree));
+        LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_ffree) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obd_statfs *)0)->os_ffree));
+        LASSERTF((int)offsetof(struct obd_statfs, os_fsid) == 48, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obd_statfs, os_fsid));
+        LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_fsid) == 40, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obd_statfs *)0)->os_fsid));
+        LASSERTF((int)offsetof(struct obd_statfs, os_bsize) == 88, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obd_statfs, os_bsize));
+        LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_bsize) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obd_statfs *)0)->os_bsize));
+        LASSERTF((int)offsetof(struct obd_statfs, os_namelen) == 92, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obd_statfs, os_namelen));
+        LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_namelen) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obd_statfs *)0)->os_namelen));
+        LASSERTF((int)offsetof(struct obd_statfs, os_spare) == 104, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obd_statfs, os_spare));
+        LASSERTF((int)sizeof(((struct obd_statfs *)0)->os_spare) == 40, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obd_statfs *)0)->os_spare));
+
+        /* Checks for struct obd_ioobj */
+        LASSERTF((int)sizeof(struct obd_ioobj) == 24, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct obd_ioobj));
+        LASSERTF((int)offsetof(struct obd_ioobj, ioo_id) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obd_ioobj, ioo_id));
+        LASSERTF((int)sizeof(((struct obd_ioobj *)0)->ioo_id) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obd_ioobj *)0)->ioo_id));
+        LASSERTF((int)offsetof(struct obd_ioobj, ioo_gr) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obd_ioobj, ioo_gr));
+        LASSERTF((int)sizeof(((struct obd_ioobj *)0)->ioo_gr) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obd_ioobj *)0)->ioo_gr));
+        LASSERTF((int)offsetof(struct obd_ioobj, ioo_type) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obd_ioobj, ioo_type));
+        LASSERTF((int)sizeof(((struct obd_ioobj *)0)->ioo_type) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obd_ioobj *)0)->ioo_type));
+        LASSERTF((int)offsetof(struct obd_ioobj, ioo_bufcnt) == 20, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct obd_ioobj, ioo_bufcnt));
+        LASSERTF((int)sizeof(((struct obd_ioobj *)0)->ioo_bufcnt) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct obd_ioobj *)0)->ioo_bufcnt));
+
+        /* Checks for struct niobuf_remote */
+        LASSERTF((int)sizeof(struct niobuf_remote) == 16, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct niobuf_remote));
+        LASSERTF((int)offsetof(struct niobuf_remote, offset) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct niobuf_remote, offset));
+        LASSERTF((int)sizeof(((struct niobuf_remote *)0)->offset) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct niobuf_remote *)0)->offset));
+        LASSERTF((int)offsetof(struct niobuf_remote, len) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct niobuf_remote, len));
+        LASSERTF((int)sizeof(((struct niobuf_remote *)0)->len) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct niobuf_remote *)0)->len));
+        LASSERTF((int)offsetof(struct niobuf_remote, flags) == 12, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct niobuf_remote, flags));
+        LASSERTF((int)sizeof(((struct niobuf_remote *)0)->flags) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct niobuf_remote *)0)->flags));
+        LASSERTF(OBD_BRW_READ == 1, " found %llu\n",
+                 (unsigned long long)OBD_BRW_READ);
+        LASSERTF(OBD_BRW_WRITE == 2, " found %llu\n",
+                 (unsigned long long)OBD_BRW_WRITE);
+        LASSERTF(OBD_BRW_SYNC == 8, " found %llu\n",
+                 (unsigned long long)OBD_BRW_SYNC);
+        LASSERTF(OBD_BRW_FROM_GRANT == 32, " found %llu\n",
+                 (unsigned long long)OBD_BRW_FROM_GRANT);
+
+        /* Checks for struct ost_body */
+        LASSERTF((int)sizeof(struct ost_body) == 204, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct ost_body));
+        LASSERTF((int)offsetof(struct ost_body, oa) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ost_body, oa));
+        LASSERTF((int)sizeof(((struct ost_body *)0)->oa) == 204, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ost_body *)0)->oa));
+
+        /* Checks for struct lustre_stc */
+        LASSERTF((int)sizeof(struct lustre_stc) == 16, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct lustre_stc));
+        LASSERTF((int)offsetof(struct lustre_stc, u.e3s.l3s_ino) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_stc, u.e3s.l3s_ino));
+        LASSERTF((int)sizeof(((struct lustre_stc *)0)->u.e3s.l3s_ino) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_stc *)0)->u.e3s.l3s_ino));
+        LASSERTF((int)offsetof(struct lustre_stc, u.e3s.l3s_gen) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_stc, u.e3s.l3s_gen));
+        LASSERTF((int)sizeof(((struct lustre_stc *)0)->u.e3s.l3s_gen) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_stc *)0)->u.e3s.l3s_gen));
+        LASSERTF((int)offsetof(struct lustre_stc, u.e3s.l3s_type) == 12, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_stc, u.e3s.l3s_type));
+        LASSERTF((int)sizeof(((struct lustre_stc *)0)->u.e3s.l3s_type) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_stc *)0)->u.e3s.l3s_type));
+
+        /* Checks for struct mds_status_req */
+        LASSERTF((int)sizeof(struct mds_status_req) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct mds_status_req));
+        LASSERTF((int)offsetof(struct mds_status_req, flags) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_status_req, flags));
+        LASSERTF((int)sizeof(((struct mds_status_req *)0)->flags) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_status_req *)0)->flags));
+        LASSERTF((int)offsetof(struct mds_status_req, repbuf) == 4, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_status_req, repbuf));
+        LASSERTF((int)sizeof(((struct mds_status_req *)0)->repbuf) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_status_req *)0)->repbuf));
+
+        /* Checks for struct mds_body */
+        LASSERTF((int)sizeof(struct mds_body) == 152, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct mds_body));
+        LASSERTF((int)offsetof(struct mds_body, id1) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, id1));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->id1) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->id1));
+        LASSERTF((int)offsetof(struct mds_body, id2) == 32, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, id2));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->id2) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->id2));
+        LASSERTF((int)offsetof(struct mds_body, handle) == 64, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, handle));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->handle) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->handle));
+        LASSERTF((int)offsetof(struct mds_body, size) == 72, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, size));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->size) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->size));
+        LASSERTF((int)offsetof(struct mds_body, blocks) == 80, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, blocks));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->blocks) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->blocks));
+        LASSERTF((int)offsetof(struct mds_body, io_epoch) == 88, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, io_epoch));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->io_epoch) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->io_epoch));
+        LASSERTF((int)offsetof(struct mds_body, valid) == 96, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, valid));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->valid) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->valid));
+        LASSERTF((int)offsetof(struct mds_body, mode) == 112, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, mode));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->mode) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->mode));
+        LASSERTF((int)offsetof(struct mds_body, uid) == 116, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, uid));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->uid) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->uid));
+        LASSERTF((int)offsetof(struct mds_body, gid) == 120, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, gid));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->gid) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->gid));
+        LASSERTF((int)offsetof(struct mds_body, mtime) == 124, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, mtime));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->mtime) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->mtime));
+        LASSERTF((int)offsetof(struct mds_body, ctime) == 128, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, ctime));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->ctime) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->ctime));
+        LASSERTF((int)offsetof(struct mds_body, atime) == 132, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, atime));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->atime) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->atime));
+        LASSERTF((int)offsetof(struct mds_body, flags) == 136, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, flags));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->flags) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->flags));
+        LASSERTF((int)offsetof(struct mds_body, rdev) == 140, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, rdev));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->rdev) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->rdev));
+        LASSERTF((int)offsetof(struct mds_body, nlink) == 144, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, nlink));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->nlink) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->nlink));
+        LASSERTF((int)offsetof(struct mds_body, eadatasize) == 148, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_body, eadatasize));
+        LASSERTF((int)sizeof(((struct mds_body *)0)->eadatasize) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_body *)0)->eadatasize));
+        LASSERTF(FMODE_READ == 1, " found %llu\n",
+                 (unsigned long long)FMODE_READ);
+        LASSERTF(FMODE_WRITE == 2, " found %llu\n",
+                 (unsigned long long)FMODE_WRITE);
+        LASSERTF(FMODE_EXEC == 4, " found %llu\n",
+                 (unsigned long long)FMODE_EXEC);
+        LASSERTF(MDS_OPEN_CREAT == 64, " found %llu\n",
+                 (unsigned long long)MDS_OPEN_CREAT);
+        LASSERTF(MDS_OPEN_EXCL == 128, " found %llu\n",
+                 (unsigned long long)MDS_OPEN_EXCL);
+        LASSERTF(MDS_OPEN_TRUNC == 512, " found %llu\n",
+                 (unsigned long long)MDS_OPEN_TRUNC);
+        LASSERTF(MDS_OPEN_APPEND == 1024, " found %llu\n",
+                 (unsigned long long)MDS_OPEN_APPEND);
+        LASSERTF(MDS_OPEN_SYNC == 4096, " found %llu\n",
+                 (unsigned long long)MDS_OPEN_SYNC);
+        LASSERTF(MDS_OPEN_DIRECTORY == 65536, " found %llu\n",
+                 (unsigned long long)MDS_OPEN_DIRECTORY);
+        LASSERTF(MDS_OPEN_DELAY_CREATE == 16777216, " found %llu\n",
+                 (unsigned long long)MDS_OPEN_DELAY_CREATE);
+        LASSERTF(MDS_OPEN_HAS_EA == 1073741824, " found %llu\n",
+                 (unsigned long long)MDS_OPEN_HAS_EA);
+
+        /* Checks for struct mds_rec_setattr */
+        LASSERTF((int)sizeof(struct mds_rec_setattr) == 92, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct mds_rec_setattr));
+        LASSERTF((int)offsetof(struct mds_rec_setattr, sa_opcode) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_setattr, sa_opcode));
+        LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_opcode) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_opcode));
+        LASSERTF((int)offsetof(struct mds_rec_setattr, sa_valid) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_setattr, sa_valid));
+        LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_valid) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_valid));
+        LASSERTF((int)offsetof(struct mds_rec_setattr, sa_id) == 12, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_setattr, sa_id));
+        LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_id) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_id));
+        LASSERTF((int)offsetof(struct mds_rec_setattr, sa_mode) == 44, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_setattr, sa_mode));
+        LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_mode) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_mode));
+        LASSERTF((int)offsetof(struct mds_rec_setattr, sa_uid) == 48, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_setattr, sa_uid));
+        LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_uid) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_uid));
+        LASSERTF((int)offsetof(struct mds_rec_setattr, sa_gid) == 52, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_setattr, sa_gid));
+        LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_gid) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_gid));
+        LASSERTF((int)offsetof(struct mds_rec_setattr, sa_attr_flags) == 56, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_setattr, sa_attr_flags));
+        LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_attr_flags) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_attr_flags));
+        LASSERTF((int)offsetof(struct mds_rec_setattr, sa_size) == 60, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_setattr, sa_size));
+        LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_size) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_size));
+        LASSERTF((int)offsetof(struct mds_rec_setattr, sa_atime) == 68, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_setattr, sa_atime));
+        LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_atime) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_atime));
+        LASSERTF((int)offsetof(struct mds_rec_setattr, sa_mtime) == 76, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_setattr, sa_mtime));
+        LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_mtime) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_mtime));
+        LASSERTF((int)offsetof(struct mds_rec_setattr, sa_ctime) == 84, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_setattr, sa_ctime));
+        LASSERTF((int)sizeof(((struct mds_rec_setattr *)0)->sa_ctime) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_setattr *)0)->sa_ctime));
+
+        /* Checks for struct mds_rec_create */
+        LASSERTF((int)sizeof(struct mds_rec_create) == 112, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct mds_rec_create));
+        LASSERTF((int)offsetof(struct mds_rec_create, cr_opcode) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_create, cr_opcode));
+        LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_opcode) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_create *)0)->cr_opcode));
+        LASSERTF((int)offsetof(struct mds_rec_create, cr_flags) == 4, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_create, cr_flags));
+        LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_flags) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_create *)0)->cr_flags));
+        LASSERTF((int)offsetof(struct mds_rec_create, cr_mode) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_create, cr_mode));
+        LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_mode) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_create *)0)->cr_mode));
+        LASSERTF((int)offsetof(struct mds_rec_create, cr_padding) == 12, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_create, cr_padding));
+        LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_padding) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_create *)0)->cr_padding));
+        LASSERTF((int)offsetof(struct mds_rec_create, cr_id) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_create, cr_id));
+        LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_id) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_create *)0)->cr_id));
+        LASSERTF((int)offsetof(struct mds_rec_create, cr_replayid) == 48, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_create, cr_replayid));
+        LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_replayid) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_create *)0)->cr_replayid));
+        LASSERTF((int)offsetof(struct mds_rec_create, cr_time) == 80, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_create, cr_time));
+        LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_time) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_create *)0)->cr_time));
+        LASSERTF((int)offsetof(struct mds_rec_create, cr_rdev) == 88, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_create, cr_rdev));
+        LASSERTF((int)sizeof(((struct mds_rec_create *)0)->cr_rdev) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_create *)0)->cr_rdev));
+
+        /* Checks for struct mds_rec_link */
+        LASSERTF((int)sizeof(struct mds_rec_link) == 84, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct mds_rec_link));
+        LASSERTF((int)offsetof(struct mds_rec_link, lk_opcode) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_link, lk_opcode));
+        LASSERTF((int)sizeof(((struct mds_rec_link *)0)->lk_opcode) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_link *)0)->lk_opcode));
+        LASSERTF((int)offsetof(struct mds_rec_link, lk_padding) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_link, lk_padding));
+        LASSERTF((int)sizeof(((struct mds_rec_link *)0)->lk_padding) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_link *)0)->lk_padding));
+        LASSERTF((int)offsetof(struct mds_rec_link, lk_id1) == 12, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_link, lk_id1));
+        LASSERTF((int)sizeof(((struct mds_rec_link *)0)->lk_id1) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_link *)0)->lk_id1));
+        LASSERTF((int)offsetof(struct mds_rec_link, lk_id2) == 44, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_link, lk_id2));
+        LASSERTF((int)sizeof(((struct mds_rec_link *)0)->lk_id2) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_link *)0)->lk_id2));
+        LASSERTF((int)offsetof(struct mds_rec_link, lk_time) == 76, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_link, lk_time));
+        LASSERTF((int)sizeof(((struct mds_rec_link *)0)->lk_time) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_link *)0)->lk_time));
+
+        /* Checks for struct mds_rec_unlink */
+        LASSERTF((int)sizeof(struct mds_rec_unlink) == 84, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct mds_rec_unlink));
+        LASSERTF((int)offsetof(struct mds_rec_unlink, ul_opcode) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_unlink, ul_opcode));
+        LASSERTF((int)sizeof(((struct mds_rec_unlink *)0)->ul_opcode) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_unlink *)0)->ul_opcode));
+        LASSERTF((int)offsetof(struct mds_rec_unlink, ul_mode) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_unlink, ul_mode));
+        LASSERTF((int)sizeof(((struct mds_rec_unlink *)0)->ul_mode) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_unlink *)0)->ul_mode));
+        LASSERTF((int)offsetof(struct mds_rec_unlink, ul_id1) == 12, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_unlink, ul_id1));
+        LASSERTF((int)sizeof(((struct mds_rec_unlink *)0)->ul_id1) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_unlink *)0)->ul_id1));
+        LASSERTF((int)offsetof(struct mds_rec_unlink, ul_id2) == 44, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_unlink, ul_id2));
+        LASSERTF((int)sizeof(((struct mds_rec_unlink *)0)->ul_id2) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_unlink *)0)->ul_id2));
+        LASSERTF((int)offsetof(struct mds_rec_unlink, ul_time) == 76, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_unlink, ul_time));
+        LASSERTF((int)sizeof(((struct mds_rec_unlink *)0)->ul_time) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_unlink *)0)->ul_time));
+
+        /* Checks for struct mds_rec_rename */
+        LASSERTF((int)sizeof(struct mds_rec_rename) == 84, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct mds_rec_rename));
+        LASSERTF((int)offsetof(struct mds_rec_rename, rn_opcode) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_rename, rn_opcode));
+        LASSERTF((int)sizeof(((struct mds_rec_rename *)0)->rn_opcode) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_rename *)0)->rn_opcode));
+        LASSERTF((int)offsetof(struct mds_rec_rename, rn_padding) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_rename, rn_padding));
+        LASSERTF((int)sizeof(((struct mds_rec_rename *)0)->rn_padding) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_rename *)0)->rn_padding));
+        LASSERTF((int)offsetof(struct mds_rec_rename, rn_id1) == 12, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_rename, rn_id1));
+        LASSERTF((int)sizeof(((struct mds_rec_rename *)0)->rn_id1) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_rename *)0)->rn_id1));
+        LASSERTF((int)offsetof(struct mds_rec_rename, rn_id2) == 44, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_rename, rn_id2));
+        LASSERTF((int)sizeof(((struct mds_rec_rename *)0)->rn_id2) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_rename *)0)->rn_id2));
+        LASSERTF((int)offsetof(struct mds_rec_rename, rn_time) == 76, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct mds_rec_rename, rn_time));
+        LASSERTF((int)sizeof(((struct mds_rec_rename *)0)->rn_time) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct mds_rec_rename *)0)->rn_time));
+
+        /* Checks for struct lov_desc */
+        LASSERTF((int)sizeof(struct lov_desc) == 72, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct lov_desc));
+        LASSERTF((int)offsetof(struct lov_desc, ld_tgt_count) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_desc, ld_tgt_count));
+        LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_tgt_count) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_desc *)0)->ld_tgt_count));
+        LASSERTF((int)offsetof(struct lov_desc, ld_active_tgt_count) == 4, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_desc, ld_active_tgt_count));
+        LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_active_tgt_count) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_desc *)0)->ld_active_tgt_count));
+        LASSERTF((int)offsetof(struct lov_desc, ld_default_stripe_count) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_desc, ld_default_stripe_count));
+        LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_default_stripe_count) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_desc *)0)->ld_default_stripe_count));
+        LASSERTF((int)offsetof(struct lov_desc, ld_pattern) == 12, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_desc, ld_pattern));
+        LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_pattern) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_desc *)0)->ld_pattern));
+        LASSERTF((int)offsetof(struct lov_desc, ld_default_stripe_size) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_desc, ld_default_stripe_size));
+        LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_default_stripe_size) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_desc *)0)->ld_default_stripe_size));
+        LASSERTF((int)offsetof(struct lov_desc, ld_default_stripe_offset) == 24, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_desc, ld_default_stripe_offset));
+        LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_default_stripe_offset) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_desc *)0)->ld_default_stripe_offset));
+        LASSERTF((int)offsetof(struct lov_desc, ld_uuid) == 32, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lov_desc, ld_uuid));
+        LASSERTF((int)sizeof(((struct lov_desc *)0)->ld_uuid) == 40, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lov_desc *)0)->ld_uuid));
+
+        /* Checks for struct ldlm_res_id */
+        LASSERTF((int)sizeof(struct ldlm_res_id) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct ldlm_res_id));
+        LASSERTF((int)offsetof(struct ldlm_res_id, name[4]) == 32, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_res_id, name[4]));
+        LASSERTF((int)sizeof(((struct ldlm_res_id *)0)->name[4]) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_res_id *)0)->name[4]));
+
+        /* Checks for struct ldlm_extent */
+        LASSERTF((int)sizeof(struct ldlm_extent) == 24, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct ldlm_extent));
+        LASSERTF((int)offsetof(struct ldlm_extent, start) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_extent, start));
+        LASSERTF((int)sizeof(((struct ldlm_extent *)0)->start) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_extent *)0)->start));
+        LASSERTF((int)offsetof(struct ldlm_extent, end) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_extent, end));
+        LASSERTF((int)sizeof(((struct ldlm_extent *)0)->end) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_extent *)0)->end));
+        LASSERTF((int)offsetof(struct ldlm_extent, gid) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_extent, gid));
+        LASSERTF((int)sizeof(((struct ldlm_extent *)0)->gid) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_extent *)0)->gid));
+
+        /* Checks for struct ldlm_flock */
+        LASSERTF((int)sizeof(struct ldlm_flock) == 40, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct ldlm_flock));
+        LASSERTF((int)offsetof(struct ldlm_flock, start) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_flock, start));
+        LASSERTF((int)sizeof(((struct ldlm_flock *)0)->start) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_flock *)0)->start));
+        LASSERTF((int)offsetof(struct ldlm_flock, end) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_flock, end));
+        LASSERTF((int)sizeof(((struct ldlm_flock *)0)->end) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_flock *)0)->end));
+        LASSERTF((int)offsetof(struct ldlm_flock, pid) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_flock, pid));
+        LASSERTF((int)sizeof(((struct ldlm_flock *)0)->pid) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_flock *)0)->pid));
+        LASSERTF((int)offsetof(struct ldlm_flock, blocking_pid) == 24, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_flock, blocking_pid));
+        LASSERTF((int)sizeof(((struct ldlm_flock *)0)->blocking_pid) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_flock *)0)->blocking_pid));
+        LASSERTF((int)offsetof(struct ldlm_flock, blocking_export) == 32, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_flock, blocking_export));
+        LASSERTF((int)sizeof(((struct ldlm_flock *)0)->blocking_export) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_flock *)0)->blocking_export));
+
+        /* Checks for struct ldlm_intent */
+        LASSERTF((int)sizeof(struct ldlm_intent) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct ldlm_intent));
+        LASSERTF((int)offsetof(struct ldlm_intent, opc) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_intent, opc));
+        LASSERTF((int)sizeof(((struct ldlm_intent *)0)->opc) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_intent *)0)->opc));
+
+        /* Checks for struct ldlm_resource_desc */
+        LASSERTF((int)sizeof(struct ldlm_resource_desc) == 40, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct ldlm_resource_desc));
+        LASSERTF((int)offsetof(struct ldlm_resource_desc, lr_type) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_resource_desc, lr_type));
+        LASSERTF((int)sizeof(((struct ldlm_resource_desc *)0)->lr_type) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_resource_desc *)0)->lr_type));
+        LASSERTF((int)offsetof(struct ldlm_resource_desc, lr_name) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_resource_desc, lr_name));
+        LASSERTF((int)sizeof(((struct ldlm_resource_desc *)0)->lr_name) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_resource_desc *)0)->lr_name));
+
+        /* Checks for struct ldlm_lock_desc */
+        LASSERTF((int)sizeof(struct ldlm_lock_desc) == 88, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct ldlm_lock_desc));
+        LASSERTF((int)offsetof(struct ldlm_lock_desc, l_resource) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_lock_desc, l_resource));
+        LASSERTF((int)sizeof(((struct ldlm_lock_desc *)0)->l_resource) == 40, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_lock_desc *)0)->l_resource));
+        LASSERTF((int)offsetof(struct ldlm_lock_desc, l_req_mode) == 40, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_lock_desc, l_req_mode));
+        LASSERTF((int)sizeof(((struct ldlm_lock_desc *)0)->l_req_mode) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_lock_desc *)0)->l_req_mode));
+        LASSERTF((int)offsetof(struct ldlm_lock_desc, l_granted_mode) == 44, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_lock_desc, l_granted_mode));
+        LASSERTF((int)sizeof(((struct ldlm_lock_desc *)0)->l_granted_mode) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_lock_desc *)0)->l_granted_mode));
+        LASSERTF((int)offsetof(struct ldlm_lock_desc, l_policy_data) == 48, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_lock_desc, l_policy_data));
+        LASSERTF((int)sizeof(((struct ldlm_lock_desc *)0)->l_policy_data) == 40, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_lock_desc *)0)->l_policy_data));
+
+        /* Checks for struct ldlm_request */
+        LASSERTF((int)sizeof(struct ldlm_request) == 112, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct ldlm_request));
+        LASSERTF((int)offsetof(struct ldlm_request, lock_flags) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_request, lock_flags));
+        LASSERTF((int)sizeof(((struct ldlm_request *)0)->lock_flags) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_request *)0)->lock_flags));
+        LASSERTF((int)offsetof(struct ldlm_request, lock_desc) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_request, lock_desc));
+        LASSERTF((int)sizeof(((struct ldlm_request *)0)->lock_desc) == 88, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_request *)0)->lock_desc));
+        LASSERTF((int)offsetof(struct ldlm_request, lock_handle1) == 96, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_request, lock_handle1));
+        LASSERTF((int)sizeof(((struct ldlm_request *)0)->lock_handle1) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_request *)0)->lock_handle1));
+        LASSERTF((int)offsetof(struct ldlm_request, lock_handle2) == 104, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_request, lock_handle2));
+        LASSERTF((int)sizeof(((struct ldlm_request *)0)->lock_handle2) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_request *)0)->lock_handle2));
+
+        /* Checks for struct ldlm_reply */
+        LASSERTF((int)sizeof(struct ldlm_reply) == 120, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct ldlm_reply));
+        LASSERTF((int)offsetof(struct ldlm_reply, lock_flags) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_reply, lock_flags));
+        LASSERTF((int)sizeof(((struct ldlm_reply *)0)->lock_flags) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_reply *)0)->lock_flags));
+        LASSERTF((int)offsetof(struct ldlm_request, lock_desc) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_request, lock_desc));
+        LASSERTF((int)sizeof(((struct ldlm_request *)0)->lock_desc) == 88, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_request *)0)->lock_desc));
+        LASSERTF((int)offsetof(struct ldlm_reply, lock_handle) == 96, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_reply, lock_handle));
+        LASSERTF((int)sizeof(((struct ldlm_reply *)0)->lock_handle) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_reply *)0)->lock_handle));
+        LASSERTF((int)offsetof(struct ldlm_reply, lock_policy_res1) == 104, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_reply, lock_policy_res1));
+        LASSERTF((int)sizeof(((struct ldlm_reply *)0)->lock_policy_res1) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_reply *)0)->lock_policy_res1));
+        LASSERTF((int)offsetof(struct ldlm_reply, lock_policy_res2) == 112, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ldlm_reply, lock_policy_res2));
+        LASSERTF((int)sizeof(((struct ldlm_reply *)0)->lock_policy_res2) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ldlm_reply *)0)->lock_policy_res2));
+
+        /* Checks for struct ost_lvb */
+        LASSERTF((int)sizeof(struct ost_lvb) == 40, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct ost_lvb));
+        LASSERTF((int)offsetof(struct ost_lvb, lvb_size) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ost_lvb, lvb_size));
+        LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_size) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ost_lvb *)0)->lvb_size));
+        LASSERTF((int)offsetof(struct ost_lvb, lvb_mtime) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ost_lvb, lvb_mtime));
+        LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_mtime) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ost_lvb *)0)->lvb_mtime));
+        LASSERTF((int)offsetof(struct ost_lvb, lvb_atime) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ost_lvb, lvb_atime));
+        LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_atime) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ost_lvb *)0)->lvb_atime));
+        LASSERTF((int)offsetof(struct ost_lvb, lvb_ctime) == 24, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ost_lvb, lvb_ctime));
+        LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_ctime) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ost_lvb *)0)->lvb_ctime));
+        LASSERTF((int)offsetof(struct ost_lvb, lvb_blocks) == 32, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ost_lvb, lvb_blocks));
+        LASSERTF((int)sizeof(((struct ost_lvb *)0)->lvb_blocks) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ost_lvb *)0)->lvb_blocks));
+
+        /* Checks for struct ptlbd_op */
+        LASSERTF((int)sizeof(struct ptlbd_op) == 12, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct ptlbd_op));
+        LASSERTF((int)offsetof(struct ptlbd_op, op_cmd) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ptlbd_op, op_cmd));
+        LASSERTF((int)sizeof(((struct ptlbd_op *)0)->op_cmd) == 2, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ptlbd_op *)0)->op_cmd));
+        LASSERTF((int)offsetof(struct ptlbd_op, op_lun) == 2, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ptlbd_op, op_lun));
+        LASSERTF((int)sizeof(((struct ptlbd_op *)0)->op_lun) == 2, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ptlbd_op *)0)->op_lun));
+        LASSERTF((int)offsetof(struct ptlbd_op, op_niob_cnt) == 4, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ptlbd_op, op_niob_cnt));
+        LASSERTF((int)sizeof(((struct ptlbd_op *)0)->op_niob_cnt) == 2, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ptlbd_op *)0)->op_niob_cnt));
+        LASSERTF((int)offsetof(struct ptlbd_op, op__padding) == 6, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ptlbd_op, op__padding));
+        LASSERTF((int)sizeof(((struct ptlbd_op *)0)->op__padding) == 2, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ptlbd_op *)0)->op__padding));
+        LASSERTF((int)offsetof(struct ptlbd_op, op_block_cnt) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ptlbd_op, op_block_cnt));
+        LASSERTF((int)sizeof(((struct ptlbd_op *)0)->op_block_cnt) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ptlbd_op *)0)->op_block_cnt));
+
+        /* Checks for struct ptlbd_niob */
+        LASSERTF((int)sizeof(struct ptlbd_niob) == 24, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct ptlbd_niob));
+        LASSERTF((int)offsetof(struct ptlbd_niob, n_xid) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ptlbd_niob, n_xid));
+        LASSERTF((int)sizeof(((struct ptlbd_niob *)0)->n_xid) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ptlbd_niob *)0)->n_xid));
+        LASSERTF((int)offsetof(struct ptlbd_niob, n_block_nr) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ptlbd_niob, n_block_nr));
+        LASSERTF((int)sizeof(((struct ptlbd_niob *)0)->n_block_nr) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ptlbd_niob *)0)->n_block_nr));
+        LASSERTF((int)offsetof(struct ptlbd_niob, n_offset) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ptlbd_niob, n_offset));
+        LASSERTF((int)sizeof(((struct ptlbd_niob *)0)->n_offset) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ptlbd_niob *)0)->n_offset));
+        LASSERTF((int)offsetof(struct ptlbd_niob, n_length) == 20, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ptlbd_niob, n_length));
+        LASSERTF((int)sizeof(((struct ptlbd_niob *)0)->n_length) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ptlbd_niob *)0)->n_length));
+
+        /* Checks for struct ptlbd_rsp */
+        LASSERTF((int)sizeof(struct ptlbd_rsp) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct ptlbd_rsp));
+        LASSERTF((int)offsetof(struct ptlbd_rsp, r_status) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ptlbd_rsp, r_status));
+        LASSERTF((int)sizeof(((struct ptlbd_rsp *)0)->r_status) == 2, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ptlbd_rsp *)0)->r_status));
+        LASSERTF((int)offsetof(struct ptlbd_rsp, r_error_cnt) == 2, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct ptlbd_rsp, r_error_cnt));
+        LASSERTF((int)sizeof(((struct ptlbd_rsp *)0)->r_error_cnt) == 2, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct ptlbd_rsp *)0)->r_error_cnt));
+
+        /* Checks for struct llog_logid */
+        LASSERTF((int)sizeof(struct llog_logid) == 20, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct llog_logid));
+        LASSERTF((int)offsetof(struct llog_logid, lgl_oid) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_logid, lgl_oid));
+        LASSERTF((int)sizeof(((struct llog_logid *)0)->lgl_oid) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_logid *)0)->lgl_oid));
+        LASSERTF((int)offsetof(struct llog_logid, lgl_ogr) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_logid, lgl_ogr));
+        LASSERTF((int)sizeof(((struct llog_logid *)0)->lgl_ogr) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_logid *)0)->lgl_ogr));
+        LASSERTF((int)offsetof(struct llog_logid, lgl_ogen) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_logid, lgl_ogen));
+        LASSERTF((int)sizeof(((struct llog_logid *)0)->lgl_ogen) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_logid *)0)->lgl_ogen));
+        LASSERTF(OST_SZ_REC == 274730752, " found %llu\n",
+                 (unsigned long long)OST_SZ_REC);
+        LASSERTF(OST_RAID1_REC == 274731008, " found %llu\n",
+                 (unsigned long long)OST_RAID1_REC);
+        LASSERTF(MDS_UNLINK_REC == 274801668, " found %llu\n",
+                 (unsigned long long)MDS_UNLINK_REC);
+        LASSERTF(OBD_CFG_REC == 274857984, " found %llu\n",
+                 (unsigned long long)OBD_CFG_REC);
+        LASSERTF(PTL_CFG_REC == 274923520, " found %llu\n",
+                 (unsigned long long)PTL_CFG_REC);
+        LASSERTF(LLOG_GEN_REC == 274989056, " found %llu\n",
+                 (unsigned long long)LLOG_GEN_REC);
+        LASSERTF(LLOG_HDR_MAGIC == 275010873, " found %llu\n",
+                 (unsigned long long)LLOG_HDR_MAGIC);
+        LASSERTF(LLOG_LOGID_MAGIC == 275010875, " found %llu\n",
+                 (unsigned long long)LLOG_LOGID_MAGIC);
+
+        /* Checks for struct llog_catid */
+        LASSERTF((int)sizeof(struct llog_catid) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct llog_catid));
+        LASSERTF((int)offsetof(struct llog_catid, lci_logid) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_catid, lci_logid));
+        LASSERTF((int)sizeof(((struct llog_catid *)0)->lci_logid) == 20, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_catid *)0)->lci_logid));
+
+        /* Checks for struct llog_rec_hdr */
+        LASSERTF((int)sizeof(struct llog_rec_hdr) == 16, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct llog_rec_hdr));
+        LASSERTF((int)offsetof(struct llog_rec_hdr, lrh_len) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_rec_hdr, lrh_len));
+        LASSERTF((int)sizeof(((struct llog_rec_hdr *)0)->lrh_len) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_rec_hdr *)0)->lrh_len));
+        LASSERTF((int)offsetof(struct llog_rec_hdr, lrh_index) == 4, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_rec_hdr, lrh_index));
+        LASSERTF((int)sizeof(((struct llog_rec_hdr *)0)->lrh_index) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_rec_hdr *)0)->lrh_index));
+        LASSERTF((int)offsetof(struct llog_rec_hdr, lrh_type) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_rec_hdr, lrh_type));
+        LASSERTF((int)sizeof(((struct llog_rec_hdr *)0)->lrh_type) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_rec_hdr *)0)->lrh_type));
+
+        /* Checks for struct llog_rec_tail */
+        LASSERTF((int)sizeof(struct llog_rec_tail) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct llog_rec_tail));
+        LASSERTF((int)offsetof(struct llog_rec_tail, lrt_len) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_rec_tail, lrt_len));
+        LASSERTF((int)sizeof(((struct llog_rec_tail *)0)->lrt_len) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_rec_tail *)0)->lrt_len));
+        LASSERTF((int)offsetof(struct llog_rec_tail, lrt_index) == 4, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_rec_tail, lrt_index));
+        LASSERTF((int)sizeof(((struct llog_rec_tail *)0)->lrt_index) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_rec_tail *)0)->lrt_index));
+
+        /* Checks for struct llog_logid_rec */
+        LASSERTF((int)sizeof(struct llog_logid_rec) == 64, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct llog_logid_rec));
+        LASSERTF((int)offsetof(struct llog_logid_rec, lid_hdr) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_logid_rec, lid_hdr));
+        LASSERTF((int)sizeof(((struct llog_logid_rec *)0)->lid_hdr) == 16, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_logid_rec *)0)->lid_hdr));
+        LASSERTF((int)offsetof(struct llog_logid_rec, lid_id) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_logid_rec, lid_id));
+        LASSERTF((int)sizeof(((struct llog_logid_rec *)0)->lid_id) == 20, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_logid_rec *)0)->lid_id));
+        LASSERTF((int)offsetof(struct llog_logid_rec, lid_tail) == 56, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_logid_rec, lid_tail));
+        LASSERTF((int)sizeof(((struct llog_logid_rec *)0)->lid_tail) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_logid_rec *)0)->lid_tail));
+
+        /* Checks for struct llog_create_rec */
+        LASSERTF((int)sizeof(struct llog_create_rec) == 72, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct llog_create_rec));
+        LASSERTF((int)offsetof(struct llog_create_rec, lcr_hdr) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_create_rec, lcr_hdr));
+        LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_hdr) == 16, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_hdr));
+        LASSERTF((int)offsetof(struct llog_create_rec, lcr_id) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_create_rec, lcr_id));
+        LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_id) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_id));
+        LASSERTF((int)offsetof(struct llog_create_rec, lcr_oid) == 48, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_create_rec, lcr_oid));
+        LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_oid) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_oid));
+        LASSERTF((int)offsetof(struct llog_create_rec, lcr_ogen) == 56, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_create_rec, lcr_ogen));
+        LASSERTF((int)sizeof(((struct llog_create_rec *)0)->lcr_ogen) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_create_rec *)0)->lcr_ogen));
+
+        /* Checks for struct llog_orphan_rec */
+        LASSERTF((int)sizeof(struct llog_orphan_rec) == 40, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct llog_orphan_rec));
+        LASSERTF((int)offsetof(struct llog_orphan_rec, lor_hdr) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_orphan_rec, lor_hdr));
+        LASSERTF((int)sizeof(((struct llog_orphan_rec *)0)->lor_hdr) == 16, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_orphan_rec *)0)->lor_hdr));
+        LASSERTF((int)offsetof(struct llog_orphan_rec, lor_oid) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_orphan_rec, lor_oid));
+        LASSERTF((int)sizeof(((struct llog_orphan_rec *)0)->lor_oid) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_orphan_rec *)0)->lor_oid));
+        LASSERTF((int)offsetof(struct llog_orphan_rec, lor_ogen) == 24, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_orphan_rec, lor_ogen));
+        LASSERTF((int)sizeof(((struct llog_orphan_rec *)0)->lor_ogen) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_orphan_rec *)0)->lor_ogen));
+        LASSERTF((int)offsetof(struct llog_orphan_rec, lor_tail) == 32, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_orphan_rec, lor_tail));
+        LASSERTF((int)sizeof(((struct llog_orphan_rec *)0)->lor_tail) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_orphan_rec *)0)->lor_tail));
+
+        /* Checks for struct llog_unlink_rec */
+        LASSERTF((int)sizeof(struct llog_unlink_rec) == 40, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct llog_unlink_rec));
+        LASSERTF((int)offsetof(struct llog_unlink_rec, lur_hdr) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_unlink_rec, lur_hdr));
+        LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_hdr) == 16, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_hdr));
+        LASSERTF((int)offsetof(struct llog_unlink_rec, lur_oid) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_unlink_rec, lur_oid));
+        LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_oid) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_oid));
+        LASSERTF((int)offsetof(struct llog_unlink_rec, lur_ogen) == 24, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_unlink_rec, lur_ogen));
+        LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_ogen) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_ogen));
+        LASSERTF((int)offsetof(struct llog_unlink_rec, lur_tail) == 32, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_unlink_rec, lur_tail));
+        LASSERTF((int)sizeof(((struct llog_unlink_rec *)0)->lur_tail) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_unlink_rec *)0)->lur_tail));
+
+        /* Checks for struct llog_size_change_rec */
+        LASSERTF((int)sizeof(struct llog_size_change_rec) == 64, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct llog_size_change_rec));
+        LASSERTF((int)offsetof(struct llog_size_change_rec, lsc_hdr) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_size_change_rec, lsc_hdr));
+        LASSERTF((int)sizeof(((struct llog_size_change_rec *)0)->lsc_hdr) == 16, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_size_change_rec *)0)->lsc_hdr));
+        LASSERTF((int)offsetof(struct llog_size_change_rec, lsc_id) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_size_change_rec, lsc_id));
+        LASSERTF((int)sizeof(((struct llog_size_change_rec *)0)->lsc_id) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_size_change_rec *)0)->lsc_id));
+        LASSERTF((int)offsetof(struct llog_size_change_rec, lsc_io_epoch) == 48, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_size_change_rec, lsc_io_epoch));
+        LASSERTF((int)sizeof(((struct llog_size_change_rec *)0)->lsc_io_epoch) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_size_change_rec *)0)->lsc_io_epoch));
+        LASSERTF((int)offsetof(struct llog_size_change_rec, lsc_tail) == 56, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_size_change_rec, lsc_tail));
+        LASSERTF((int)sizeof(((struct llog_size_change_rec *)0)->lsc_tail) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_size_change_rec *)0)->lsc_tail));
+
+        /* Checks for struct llog_gen */
+        LASSERTF((int)sizeof(struct llog_gen) == 16, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct llog_gen));
+        LASSERTF((int)offsetof(struct llog_gen, mnt_cnt) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_gen, mnt_cnt));
+        LASSERTF((int)sizeof(((struct llog_gen *)0)->mnt_cnt) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_gen *)0)->mnt_cnt));
+        LASSERTF((int)offsetof(struct llog_gen, conn_cnt) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_gen, conn_cnt));
+        LASSERTF((int)sizeof(((struct llog_gen *)0)->conn_cnt) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_gen *)0)->conn_cnt));
+
+        /* Checks for struct llog_gen_rec */
+        LASSERTF((int)sizeof(struct llog_gen_rec) == 40, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct llog_gen_rec));
+        LASSERTF((int)offsetof(struct llog_gen_rec, lgr_hdr) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_gen_rec, lgr_hdr));
+        LASSERTF((int)sizeof(((struct llog_gen_rec *)0)->lgr_hdr) == 16, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_gen_rec *)0)->lgr_hdr));
+        LASSERTF((int)offsetof(struct llog_gen_rec, lgr_gen) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_gen_rec, lgr_gen));
+        LASSERTF((int)sizeof(((struct llog_gen_rec *)0)->lgr_gen) == 16, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_gen_rec *)0)->lgr_gen));
+        LASSERTF((int)offsetof(struct llog_gen_rec, lgr_tail) == 32, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_gen_rec, lgr_tail));
+        LASSERTF((int)sizeof(((struct llog_gen_rec *)0)->lgr_tail) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_gen_rec *)0)->lgr_tail));
+
+        /* Checks for struct llog_log_hdr */
+        LASSERTF((int)sizeof(struct llog_log_hdr) == 8192, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct llog_log_hdr));
+        LASSERTF((int)offsetof(struct llog_log_hdr, llh_hdr) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_log_hdr, llh_hdr));
+        LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_hdr) == 16, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_hdr));
+        LASSERTF((int)offsetof(struct llog_log_hdr, llh_timestamp) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_log_hdr, llh_timestamp));
+        LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_timestamp) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_timestamp));
+        LASSERTF((int)offsetof(struct llog_log_hdr, llh_count) == 24, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_log_hdr, llh_count));
+        LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_count) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_count));
+        LASSERTF((int)offsetof(struct llog_log_hdr, llh_bitmap_offset) == 28, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_log_hdr, llh_bitmap_offset));
+        LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_bitmap_offset) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_bitmap_offset));
+        LASSERTF((int)offsetof(struct llog_log_hdr, llh_size) == 32, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_log_hdr, llh_size));
+        LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_size) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_size));
+        LASSERTF((int)offsetof(struct llog_log_hdr, llh_flags) == 36, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_log_hdr, llh_flags));
+        LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_flags) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_flags));
+        LASSERTF((int)offsetof(struct llog_log_hdr, llh_cat_idx) == 40, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_log_hdr, llh_cat_idx));
+        LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_cat_idx) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_cat_idx));
+        LASSERTF((int)offsetof(struct llog_log_hdr, llh_tgtuuid) == 44, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_log_hdr, llh_tgtuuid));
+        LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_tgtuuid) == 40, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_tgtuuid));
+        LASSERTF((int)offsetof(struct llog_log_hdr, llh_bitmap) == 88, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_log_hdr, llh_bitmap));
+        LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_bitmap) == 8096, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_bitmap));
+        LASSERTF((int)offsetof(struct llog_log_hdr, llh_tail) == 8184, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_log_hdr, llh_tail));
+        LASSERTF((int)sizeof(((struct llog_log_hdr *)0)->llh_tail) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_log_hdr *)0)->llh_tail));
+
+        /* Checks for struct llog_cookie */
+        LASSERTF((int)sizeof(struct llog_cookie) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct llog_cookie));
+        LASSERTF((int)offsetof(struct llog_cookie, lgc_lgl) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_cookie, lgc_lgl));
+        LASSERTF((int)sizeof(((struct llog_cookie *)0)->lgc_lgl) == 20, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_cookie *)0)->lgc_lgl));
+        LASSERTF((int)offsetof(struct llog_cookie, lgc_subsys) == 20, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_cookie, lgc_subsys));
+        LASSERTF((int)sizeof(((struct llog_cookie *)0)->lgc_subsys) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_cookie *)0)->lgc_subsys));
+        LASSERTF((int)offsetof(struct llog_cookie, lgc_index) == 24, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llog_cookie, lgc_index));
+        LASSERTF((int)sizeof(((struct llog_cookie *)0)->lgc_index) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llog_cookie *)0)->lgc_index));
+
+        /* Checks for struct llogd_body */
+        LASSERTF((int)sizeof(struct llogd_body) == 48, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct llogd_body));
+        LASSERTF((int)offsetof(struct llogd_body, lgd_logid) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llogd_body, lgd_logid));
+        LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_logid) == 20, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llogd_body *)0)->lgd_logid));
+        LASSERTF((int)offsetof(struct llogd_body, lgd_ctxt_idx) == 20, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llogd_body, lgd_ctxt_idx));
+        LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_ctxt_idx) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llogd_body *)0)->lgd_ctxt_idx));
+        LASSERTF((int)offsetof(struct llogd_body, lgd_llh_flags) == 24, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llogd_body, lgd_llh_flags));
+        LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_llh_flags) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llogd_body *)0)->lgd_llh_flags));
+        LASSERTF((int)offsetof(struct llogd_body, lgd_index) == 28, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llogd_body, lgd_index));
+        LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_index) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llogd_body *)0)->lgd_index));
+        LASSERTF((int)offsetof(struct llogd_body, lgd_saved_index) == 32, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llogd_body, lgd_saved_index));
+        LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_saved_index) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llogd_body *)0)->lgd_saved_index));
+        LASSERTF((int)offsetof(struct llogd_body, lgd_len) == 36, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llogd_body, lgd_len));
+        LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_len) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llogd_body *)0)->lgd_len));
+        LASSERTF((int)offsetof(struct llogd_body, lgd_cur_offset) == 40, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llogd_body, lgd_cur_offset));
+        LASSERTF((int)sizeof(((struct llogd_body *)0)->lgd_cur_offset) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llogd_body *)0)->lgd_cur_offset));
+        LASSERTF(LLOG_ORIGIN_HANDLE_OPEN == 501, " found %llu\n",
+                 (unsigned long long)LLOG_ORIGIN_HANDLE_OPEN);
+        LASSERTF(LLOG_ORIGIN_HANDLE_NEXT_BLOCK == 502, " found %llu\n",
+                 (unsigned long long)LLOG_ORIGIN_HANDLE_NEXT_BLOCK);
+        LASSERTF(LLOG_ORIGIN_HANDLE_READ_HEADER == 503, " found %llu\n",
+                 (unsigned long long)LLOG_ORIGIN_HANDLE_READ_HEADER);
+        LASSERTF(LLOG_ORIGIN_HANDLE_WRITE_REC == 504, " found %llu\n",
+                 (unsigned long long)LLOG_ORIGIN_HANDLE_WRITE_REC);
+        LASSERTF(LLOG_ORIGIN_HANDLE_CLOSE == 505, " found %llu\n",
+                 (unsigned long long)LLOG_ORIGIN_HANDLE_CLOSE);
+        LASSERTF(LLOG_ORIGIN_CONNECT == 506, " found %llu\n",
+                 (unsigned long long)LLOG_ORIGIN_CONNECT);
+        LASSERTF(LLOG_CATINFO == 507, " found %llu\n",
+                 (unsigned long long)LLOG_CATINFO);
+
+        /* Checks for struct llogd_conn_body */
+        LASSERTF((int)sizeof(struct llogd_conn_body) == 40, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct llogd_conn_body));
+        LASSERTF((int)offsetof(struct llogd_conn_body, lgdc_gen) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llogd_conn_body, lgdc_gen));
+        LASSERTF((int)sizeof(((struct llogd_conn_body *)0)->lgdc_gen) == 16, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llogd_conn_body *)0)->lgdc_gen));
+        LASSERTF((int)offsetof(struct llogd_conn_body, lgdc_logid) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llogd_conn_body, lgdc_logid));
+        LASSERTF((int)sizeof(((struct llogd_conn_body *)0)->lgdc_logid) == 20, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llogd_conn_body *)0)->lgdc_logid));
+        LASSERTF((int)offsetof(struct llogd_conn_body, lgdc_ctxt_idx) == 36, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct llogd_conn_body, lgdc_ctxt_idx));
+        LASSERTF((int)sizeof(((struct llogd_conn_body *)0)->lgdc_ctxt_idx) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct llogd_conn_body *)0)->lgdc_ctxt_idx));
+
+        /* Checks for struct lustre_capa */
+        LASSERTF((int)sizeof(struct lustre_capa) == 52, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct lustre_capa));
+        LASSERTF((int)offsetof(struct lustre_capa, lc_uid) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_capa, lc_uid));
+        LASSERTF((int)sizeof(((struct lustre_capa *)0)->lc_uid) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_capa *)0)->lc_uid));
+        LASSERTF((int)offsetof(struct lustre_capa, lc_op) == 4, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_capa, lc_op));
+        LASSERTF((int)sizeof(((struct lustre_capa *)0)->lc_op) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_capa *)0)->lc_op));
+        LASSERTF((int)offsetof(struct lustre_capa, lc_ino) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_capa, lc_ino));
+        LASSERTF((int)sizeof(((struct lustre_capa *)0)->lc_ino) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_capa *)0)->lc_ino));
+        LASSERTF((int)offsetof(struct lustre_capa, lc_mdsid) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_capa, lc_mdsid));
+        LASSERTF((int)sizeof(((struct lustre_capa *)0)->lc_mdsid) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_capa *)0)->lc_mdsid));
+        LASSERTF((int)offsetof(struct lustre_capa, lc_keyid) == 20, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_capa, lc_keyid));
+        LASSERTF((int)sizeof(((struct lustre_capa *)0)->lc_keyid) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_capa *)0)->lc_keyid));
+        LASSERTF((int)offsetof(struct lustre_capa, lc_expiry) == 24, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_capa, lc_expiry));
+        LASSERTF((int)sizeof(((struct lustre_capa *)0)->lc_expiry) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_capa *)0)->lc_expiry));
+        LASSERTF((int)offsetof(struct lustre_capa, lc_flags) == 32, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_capa, lc_flags));
+        LASSERTF((int)sizeof(((struct lustre_capa *)0)->lc_flags) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_capa *)0)->lc_flags));
+        LASSERTF((int)offsetof(struct lustre_capa, lc_hmac) == 36, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_capa, lc_hmac));
+        LASSERTF((int)sizeof(((struct lustre_capa *)0)->lc_hmac) == 16, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_capa *)0)->lc_hmac));
+
+        /* Checks for struct lustre_capa_key */
+        LASSERTF((int)sizeof(struct lustre_capa_key) == 32, " found %llu\n",
+                 (unsigned long long)(int)sizeof(struct lustre_capa_key));
+        LASSERTF((int)offsetof(struct lustre_capa_key, lk_mdsid) == 0, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_capa_key, lk_mdsid));
+        LASSERTF((int)sizeof(((struct lustre_capa_key *)0)->lk_mdsid) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_capa_key *)0)->lk_mdsid));
+        LASSERTF((int)offsetof(struct lustre_capa_key, lk_keyid) == 4, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_capa_key, lk_keyid));
+        LASSERTF((int)sizeof(((struct lustre_capa_key *)0)->lk_keyid) == 4, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_capa_key *)0)->lk_keyid));
+        LASSERTF((int)offsetof(struct lustre_capa_key, lk_expiry) == 8, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_capa_key, lk_expiry));
+        LASSERTF((int)sizeof(((struct lustre_capa_key *)0)->lk_expiry) == 8, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_capa_key *)0)->lk_expiry));
+        LASSERTF((int)offsetof(struct lustre_capa_key, lk_key) == 16, " found %llu\n",
+                 (unsigned long long)(int)offsetof(struct lustre_capa_key, lk_key));
+        LASSERTF((int)sizeof(((struct lustre_capa_key *)0)->lk_key) == 16, " found %llu\n",
+                 (unsigned long long)(int)sizeof(((struct lustre_capa_key *)0)->lk_key));
 }
+