Whamcloud - gitweb
LU-974 security: ignore umask if acl enabled
authorLai Siyao <laisiyao@whamcloud.com>
Fri, 13 Jan 2012 10:34:33 +0000 (18:34 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 29 Nov 2012 20:36:27 +0000 (15:36 -0500)
Backport commit: Ibbb45dd79378d116eb428b76070a417fe08a8142.

* add OBD_CONNECT_UMASK to show whether MDS supports umask.
* client packs umask in create/open request, MDS will use it in
  object creation.
* client ignores umask if acl is enabled.
* client enforces umask if MDS doesn't support OBD_CONNECT_UMASK.
* don't update inode->i_mode after creation because la_mode may
  not be correct which doesn't consider umask.
* add an acl test for this.

Signed-off-by: Lai Siyao <laisiyao@whamcloud.com>
Change-Id: Ief42dd27fa500c2f13e7dc672c37744a8ecbf489
Reviewed-on: http://review.whamcloud.com/4660
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Fan Yong <yong.fan@whamcloud.com>
Reviewed-by: Bobi Jam <bobijam@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
16 files changed:
lustre/include/liblustre.h
lustre/include/lustre/lustre_idl.h
lustre/include/lustre_export.h
lustre/llite/dcache.c
lustre/llite/llite_lib.c
lustre/llite/namei.c
lustre/mdc/mdc_lib.c
lustre/mdd/mdd_dir.c
lustre/mdd/mdd_internal.h
lustre/mdt/mdt_lib.c
lustre/osd-ldiskfs/osd_handler.c
lustre/ptlrpc/wiretest.c
lustre/tests/acl/974.test [new file with mode: 0644]
lustre/tests/sanity.sh
lustre/utils/wirecheck.c
lustre/utils/wiretest.c

index f5eb5cd..c556efa 100644 (file)
@@ -276,6 +276,7 @@ typedef struct task_struct cfs_task_t;
 #define cfs_curproc_comm()      (current->comm)
 #define cfs_curproc_fsuid()     (current->fsuid)
 #define cfs_curproc_fsgid()     (current->fsgid)
+#define cfs_curproc_umask()     ({ mode_t mask = umask(0); umask(mask); mask; })
 
 extern struct task_struct *current;
 int cfs_curproc_is_in_groups(gid_t gid);
index 1db06a6..cf25f7c 100644 (file)
@@ -1138,7 +1138,7 @@ extern void lustre_swab_ptlrpc_body(struct ptlrpc_body *pb);
                                 OBD_CONNECT_FID | LRU_RESIZE_CONNECT_FLAG | \
                                 OBD_CONNECT_VBR | OBD_CONNECT_LOV_V3 | \
                                 OBD_CONNECT_SOM | OBD_CONNECT_FULL20 | \
-                                OBD_CONNECT_64BITHASH)
+                                OBD_CONNECT_64BITHASH | OBD_CONNECT_UMASK)
 #define OST_CONNECT_SUPPORTED  (OBD_CONNECT_SRVLOCK | OBD_CONNECT_GRANT | \
                                 OBD_CONNECT_REQPORTAL | OBD_CONNECT_VERSION | \
                                 OBD_CONNECT_TRUNCLOCK | OBD_CONNECT_INDEX | \
@@ -2001,7 +2001,7 @@ struct mdt_rec_create {
          * extend cr_flags size without breaking 1.8 compat */
         __u32           cr_flags_l;     /* for use with open, low  32 bits  */
         __u32           cr_flags_h;     /* for use with open, high 32 bits */
-        __u32           cr_padding_3;   /* rr_padding_3 */
+        __u32           cr_umask;       /* umask for create */
         __u32           cr_padding_4;   /* rr_padding_4 */
 };
 
index 5eeffbf..8eaaad9 100644 (file)
@@ -319,6 +319,11 @@ static inline int exp_connect_som(struct obd_export *exp)
         return !!(exp->exp_connect_flags & OBD_CONNECT_SOM);
 }
 
+static inline int exp_connect_umask(struct obd_export *exp)
+{
+        return !!(exp->exp_connect_flags & OBD_CONNECT_UMASK);
+}
+
 static inline int imp_connect_lru_resize(struct obd_import *imp)
 {
         struct obd_connect_data *ocd;
index 3396978..79f7e9c 100644 (file)
@@ -509,7 +509,8 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags,
                 first = ll_statahead_enter(parent, &de, 0);
 
 do_lock:
-        it->it_create_mode &= ~cfs_curproc_umask();
+        if (!IS_POSIXACL(parent) || !exp_connect_umask(exp))
+                it->it_create_mode &= ~cfs_curproc_umask();
         it->it_create_mode |= M_CHECK_STALE;
         rc = md_intent_lock(exp, op_data, NULL, 0, it,
                             lookup_flags,
index 0c14375..fe062ee 100644 (file)
@@ -225,7 +225,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
                 data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
 #endif
 #ifdef CONFIG_FS_POSIX_ACL
-        data->ocd_connect_flags |= OBD_CONNECT_ACL;
+        data->ocd_connect_flags |= OBD_CONNECT_ACL | OBD_CONNECT_UMASK;
 #endif
         data->ocd_ibits_known = MDS_INODELOCK_FULL;
         data->ocd_version = LUSTRE_VERSION_CODE;
index 81a1c9c..3c1c98d 100644 (file)
@@ -578,7 +578,9 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
         if (IS_ERR(op_data))
                 RETURN((void *)op_data);
 
-        it->it_create_mode &= ~cfs_curproc_umask();
+        /* enforce umask if acl disabled or MDS doesn't support umask */
+        if (!IS_POSIXACL(parent) || !exp_connect_umask(ll_i2mdexp(parent)))
+                it->it_create_mode &= ~cfs_curproc_umask();
 
         rc = md_intent_lock(ll_i2mdexp(parent), op_data, NULL, 0, it,
                             lookup_flags, &req, ll_md_blocking_ast, 0);
@@ -887,7 +889,8 @@ static int ll_mknod_generic(struct inode *dir, struct qstr *name, int mode,
                name->len, name->name, dir->i_ino, dir->i_generation, dir,
                mode, rdev);
 
-        mode &= ~cfs_curproc_umask();
+        if (!IS_POSIXACL(dir) || !exp_connect_umask(ll_i2mdexp(dir)))
+                mode &= ~cfs_curproc_umask();
 
         switch (mode & S_IFMT) {
         case 0:
@@ -1001,7 +1004,9 @@ static int ll_mkdir_generic(struct inode *dir, struct qstr *name,
         CDEBUG(D_VFSTRACE, "VFS Op:name=%.*s,dir=%lu/%u(%p)\n",
                name->len, name->name, dir->i_ino, dir->i_generation, dir);
 
-        mode = (mode & (S_IRWXUGO|S_ISVTX) & ~cfs_curproc_umask()) | S_IFDIR;
+        if (!IS_POSIXACL(dir) || !exp_connect_umask(ll_i2mdexp(dir)))
+                mode &= ~cfs_curproc_umask();
+        mode = (mode & (S_IRWXUGO|S_ISVTX)) | S_IFDIR;
         err = ll_new_node(dir, name, NULL, mode, 0, dchild, LUSTRE_OPC_MKDIR);
 
         RETURN(err);
index 56d3f73..86b72d0 100644 (file)
@@ -152,6 +152,7 @@ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
         rec->cr_suppgid2 = op_data->op_suppgids[1];
         set_mrc_cr_flags(rec, op_data->op_flags & MF_SOM_LOCAL_FLAGS);
         rec->cr_bias     = op_data->op_bias;
+        rec->cr_umask    = cfs_curproc_umask();
 
         mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
 
@@ -222,6 +223,7 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
         rec->cr_suppgid1 = op_data->op_suppgids[0];
         rec->cr_suppgid2 = op_data->op_suppgids[1];
         rec->cr_bias     = op_data->op_bias;
+        rec->cr_umask    = cfs_curproc_umask();
 
         mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
         /* the next buffer is child capa, which is used for replay,
index 14c0ed8..a2ba0e1 100644 (file)
@@ -1484,6 +1484,13 @@ int mdd_object_initialize(const struct lu_env *env, const struct lu_fid *pfid,
          *  (2) maybe, the child attributes should be set in OSD when creation.
          */
 
+       /*
+        * inode mode has been set in creation time, and it's based on umask,
+        * la_mode and acl, don't set here again! (which will go wrong
+        * because below function doesn't consider umask).
+        * I'd suggest set all object attributes in creation time, see above.
+        */
+       ma->ma_attr.la_valid &= ~LA_MODE;
         rc = mdd_attr_set_internal(env, child, &ma->ma_attr, handle, 0);
         if (rc != 0)
                 RETURN(rc);
index 8e50547..6eb67e3 100644 (file)
@@ -791,7 +791,22 @@ int mdo_create_obj(const struct lu_env *env, struct mdd_object *o,
                    struct thandle *handle)
 {
         struct dt_object *next = mdd_object_child(o);
-        return next->do_ops->do_create(env, next, attr, hint, dof, handle);
+       struct md_ucred *uc = md_ucred(env);
+       __u32 saved;
+       int rc;
+
+       /*
+        *  LU-974 enforce client umask in creation.
+        * TODO: CMD needs to handle this for remote object.
+        */
+        saved = xchg(&current->fs->umask, uc->mu_umask & S_IRWXUGO);
+
+       rc = next->do_ops->do_create(env, next, attr, hint, dof, handle);
+
+       /* restore previous umask value */
+       current->fs->umask = saved;
+
+       return rc;
 }
 
 static inline struct obd_capa *mdo_capa_get(const struct lu_env *env,
index 0dea2bb..9a0b556 100644 (file)
@@ -896,6 +896,7 @@ static int mdt_create_unpack(struct mdt_thread_info *info)
         uc->mu_cap   = rec->cr_cap;
         uc->mu_suppgids[0] = rec->cr_suppgid1;
         uc->mu_suppgids[1] = -1;
+        uc->mu_umask = rec->cr_umask;
 
         rr->rr_fid1 = &rec->cr_fid1;
         rr->rr_fid2 = &rec->cr_fid2;
@@ -1165,6 +1166,7 @@ static int mdt_open_unpack(struct mdt_thread_info *info)
         uc->mu_cap   = rec->cr_cap;
         uc->mu_suppgids[0] = rec->cr_suppgid1;
         uc->mu_suppgids[1] = rec->cr_suppgid2;
+        uc->mu_umask = rec->cr_umask;
 
         rr->rr_fid1   = &rec->cr_fid1;
         rr->rr_fid2   = &rec->cr_fid2;
index 1920b2a..df1cf15 100644 (file)
@@ -1708,7 +1708,6 @@ static int __osd_object_create(struct osd_thread_info *info,
                                struct dt_object_format *dof,
                                struct thandle *th)
 {
-
         int result;
 
         result = osd_create_pre(info, obj, attr, th);
@@ -1718,6 +1717,7 @@ static int __osd_object_create(struct osd_thread_info *info,
                 if (result == 0)
                         result = osd_create_post(info, obj, attr, th);
         }
+
         return result;
 }
 
index b9d6263..4e0018c 100644 (file)
@@ -68,8 +68,8 @@ void lustre_assert_wire_constants(void)
 {
         /* Wire protocol assertions generated by 'wirecheck'
          * (make -C lustre/utils newwiretest)
-         * running on Linux centos5.localhost 2.6.18-prep #3 SMP Mon Mar 22 08:28:01 EDT 2010 x86_64 
-         * with gcc version 4.1.2 20071124 (Red Hat 4.1.2-42) */
+         * running on Linux chopin 2.6.32.279.lustre #2 SMP Wed Aug 15 14:20:56 CST 2012 x86_64 x86_6
+         * with gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC)  */
 
 
         /* Constants... */
@@ -288,6 +288,12 @@ void lustre_assert_wire_constants(void)
                  (long long)MGS_TARGET_DEL);
         LASSERTF(MGS_SET_INFO == 255, " found %lld\n",
                  (long long)MGS_SET_INFO);
+        LASSERTF(LDF_EMPTY == 1, " found %lld\n",
+                 (long long)LDF_EMPTY);
+        LASSERTF(LDF_COLLIDE == 2, " found %lld\n",
+                 (long long)LDF_COLLIDE);
+        LASSERTF(LU_PAGE_SIZE == 4096, " found %lld\n",
+                 (long long)LU_PAGE_SIZE);
         /* Sizes and Offsets */
 
         /* Checks for struct obd_uuid */
@@ -490,51 +496,51 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct obd_connect_data, padding2));
         LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding2) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct obd_connect_data *)0)->padding2));
-        CLASSERT(OBD_CONNECT_RDONLY ==                    0x1ULL);
-        CLASSERT(OBD_CONNECT_INDEX ==                     0x2ULL);
-        CLASSERT(OBD_CONNECT_MDS ==                       0x4ULL);
-        CLASSERT(OBD_CONNECT_GRANT ==                     0x8ULL);
-        CLASSERT(OBD_CONNECT_SRVLOCK ==                  0x10ULL);
-        CLASSERT(OBD_CONNECT_VERSION ==                  0x20ULL);
-        CLASSERT(OBD_CONNECT_REQPORTAL ==                0x40ULL);
-        CLASSERT(OBD_CONNECT_ACL ==                      0x80ULL);
-        CLASSERT(OBD_CONNECT_XATTR ==                   0x100ULL);
-        CLASSERT(OBD_CONNECT_CROW ==                    0x200ULL);
-        CLASSERT(OBD_CONNECT_TRUNCLOCK ==               0x400ULL);
-        CLASSERT(OBD_CONNECT_TRANSNO ==                 0x800ULL);
-        CLASSERT(OBD_CONNECT_IBITS ==                  0x1000ULL);
-        CLASSERT(OBD_CONNECT_JOIN ==                   0x2000ULL);
-        CLASSERT(OBD_CONNECT_ATTRFID ==                0x4000ULL);
-        CLASSERT(OBD_CONNECT_NODEVOH ==                0x8000ULL);
-        CLASSERT(OBD_CONNECT_RMT_CLIENT ==            0x10000ULL);
-        CLASSERT(OBD_CONNECT_RMT_CLIENT_FORCE ==      0x20000ULL);
-        CLASSERT(OBD_CONNECT_BRW_SIZE ==              0x40000ULL);
-        CLASSERT(OBD_CONNECT_QUOTA64 ==               0x80000ULL);
-        CLASSERT(OBD_CONNECT_MDS_CAPA ==             0x100000ULL);
-        CLASSERT(OBD_CONNECT_OSS_CAPA ==             0x200000ULL);
-        CLASSERT(OBD_CONNECT_CANCELSET ==            0x400000ULL);
-        CLASSERT(OBD_CONNECT_SOM ==                  0x800000ULL);
-        CLASSERT(OBD_CONNECT_AT ==                  0x1000000ULL);
-        CLASSERT(OBD_CONNECT_LRU_RESIZE ==          0x2000000ULL);
-        CLASSERT(OBD_CONNECT_MDS_MDS ==             0x4000000ULL);
-        CLASSERT(OBD_CONNECT_REAL ==                0x8000000ULL);
-        CLASSERT(OBD_CONNECT_CHANGE_QS ==          0x10000000ULL);
-        CLASSERT(OBD_CONNECT_CKSUM ==              0x20000000ULL);
-        CLASSERT(OBD_CONNECT_FID ==                0x40000000ULL);
-        CLASSERT(OBD_CONNECT_VBR ==                0x80000000ULL);
-        CLASSERT(OBD_CONNECT_LOV_V3 ==            0x100000000ULL);
-        CLASSERT(OBD_CONNECT_GRANT_SHRINK ==      0x200000000ULL);
-        CLASSERT(OBD_CONNECT_SKIP_ORPHAN ==       0x400000000ULL);
-        CLASSERT(OBD_CONNECT_MAX_EASIZE ==        0x800000000ULL);
-        CLASSERT(OBD_CONNECT_FULL20 ==           0x1000000000ULL);
-        CLASSERT(OBD_CONNECT_LAYOUTLOCK ==       0x2000000000ULL);
-        CLASSERT(OBD_CONNECT_64BITHASH ==        0x4000000000ULL);
-        CLASSERT(OBD_CONNECT_MAXBYTES ==         0x8000000000ULL);
-        CLASSERT(OBD_CONNECT_IMP_RECOV ==       0x10000000000ULL);
-        CLASSERT(OBD_CONNECT_JOBSTATS ==        0x20000000000ULL);
-        CLASSERT(OBD_CONNECT_UMASK ==           0x40000000000ULL);
-        CLASSERT(OBD_CONNECT_EINPROGRESS ==     0x80000000000ULL);
-        CLASSERT(OBD_CONNECT_GRANT_PARAM ==    0x100000000000ULL);
+        CLASSERT(OBD_CONNECT_RDONLY == 0x1ULL);
+        CLASSERT(OBD_CONNECT_INDEX == 0x2ULL);
+        CLASSERT(OBD_CONNECT_MDS == 0x4ULL);
+        CLASSERT(OBD_CONNECT_GRANT == 0x8ULL);
+        CLASSERT(OBD_CONNECT_SRVLOCK == 0x10ULL);
+        CLASSERT(OBD_CONNECT_VERSION == 0x20ULL);
+        CLASSERT(OBD_CONNECT_REQPORTAL == 0x40ULL);
+        CLASSERT(OBD_CONNECT_ACL == 0x80ULL);
+        CLASSERT(OBD_CONNECT_XATTR == 0x100ULL);
+        CLASSERT(OBD_CONNECT_CROW == 0x200ULL);
+        CLASSERT(OBD_CONNECT_TRUNCLOCK == 0x400ULL);
+        CLASSERT(OBD_CONNECT_TRANSNO == 0x800ULL);
+        CLASSERT(OBD_CONNECT_IBITS == 0x1000ULL);
+        CLASSERT(OBD_CONNECT_JOIN == 0x2000ULL);
+        CLASSERT(OBD_CONNECT_ATTRFID == 0x4000ULL);
+        CLASSERT(OBD_CONNECT_NODEVOH == 0x8000ULL);
+        CLASSERT(OBD_CONNECT_RMT_CLIENT == 0x10000ULL);
+        CLASSERT(OBD_CONNECT_RMT_CLIENT_FORCE == 0x20000ULL);
+        CLASSERT(OBD_CONNECT_BRW_SIZE == 0x40000ULL);
+        CLASSERT(OBD_CONNECT_QUOTA64 == 0x80000ULL);
+        CLASSERT(OBD_CONNECT_MDS_CAPA == 0x100000ULL);
+        CLASSERT(OBD_CONNECT_OSS_CAPA == 0x200000ULL);
+        CLASSERT(OBD_CONNECT_CANCELSET == 0x400000ULL);
+        CLASSERT(OBD_CONNECT_SOM == 0x800000ULL);
+        CLASSERT(OBD_CONNECT_AT == 0x1000000ULL);
+        CLASSERT(OBD_CONNECT_LRU_RESIZE == 0x2000000ULL);
+        CLASSERT(OBD_CONNECT_MDS_MDS == 0x4000000ULL);
+        CLASSERT(OBD_CONNECT_REAL == 0x8000000ULL);
+        CLASSERT(OBD_CONNECT_CHANGE_QS == 0x10000000ULL);
+        CLASSERT(OBD_CONNECT_CKSUM == 0x20000000ULL);
+        CLASSERT(OBD_CONNECT_FID == 0x40000000ULL);
+        CLASSERT(OBD_CONNECT_VBR == 0x80000000ULL);
+        CLASSERT(OBD_CONNECT_LOV_V3 == 0x100000000ULL);
+        CLASSERT(OBD_CONNECT_GRANT_SHRINK == 0x200000000ULL);
+        CLASSERT(OBD_CONNECT_SKIP_ORPHAN == 0x400000000ULL);
+        CLASSERT(OBD_CONNECT_MAX_EASIZE == 0x800000000ULL);
+        CLASSERT(OBD_CONNECT_FULL20 == 0x1000000000ULL);
+        CLASSERT(OBD_CONNECT_LAYOUTLOCK == 0x2000000000ULL);
+        CLASSERT(OBD_CONNECT_64BITHASH == 0x4000000000ULL);
+        CLASSERT(OBD_CONNECT_MAXBYTES == 0x8000000000ULL);
+        CLASSERT(OBD_CONNECT_IMP_RECOV == 0x10000000000ULL);
+        CLASSERT(OBD_CONNECT_JOBSTATS == 0x20000000000ULL);
+        CLASSERT(OBD_CONNECT_UMASK == 0x40000000000ULL);
+        CLASSERT(OBD_CONNECT_EINPROGRESS == 0x80000000000ULL);
+        CLASSERT(OBD_CONNECT_GRANT_PARAM == 0x100000000000ULL);
 
         /* Checks for struct obdo */
         LASSERTF((int)sizeof(struct obdo) == 208, " found %lld\n",
@@ -703,8 +709,8 @@ void lustre_assert_wire_constants(void)
         CLASSERT(OBD_FL_CKSUM_CRC32 == 4096);
         CLASSERT(OBD_FL_CKSUM_ADLER == 8192);
         CLASSERT(OBD_FL_SHRINK_GRANT == 131072);
-        CLASSERT(OBD_FL_MMAP == (0x00040000));
-        CLASSERT(OBD_FL_RECOV_RESEND == (0x00080000));
+        CLASSERT(OBD_FL_MMAP == 262144);
+        CLASSERT(OBD_FL_RECOV_RESEND == 524288);
         CLASSERT(OBD_CKSUM_CRC32 == 1);
         CLASSERT(OBD_CKSUM_ADLER == 2);
 
@@ -1412,10 +1418,10 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct mdt_rec_create, cr_flags_h));
         LASSERTF((int)sizeof(((struct mdt_rec_create *)0)->cr_flags_h) == 4, " found %lld\n",
                  (long long)(int)sizeof(((struct mdt_rec_create *)0)->cr_flags_h));
-        LASSERTF((int)offsetof(struct mdt_rec_create, cr_padding_3) == 128, " found %lld\n",
-                 (long long)(int)offsetof(struct mdt_rec_create, cr_padding_3));
-        LASSERTF((int)sizeof(((struct mdt_rec_create *)0)->cr_padding_3) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct mdt_rec_create *)0)->cr_padding_3));
+        LASSERTF((int)offsetof(struct mdt_rec_create, cr_umask) == 128, " found %lld\n",
+                 (long long)(int)offsetof(struct mdt_rec_create, cr_umask));
+        LASSERTF((int)sizeof(((struct mdt_rec_create *)0)->cr_umask) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct mdt_rec_create *)0)->cr_umask));
         LASSERTF((int)offsetof(struct mdt_rec_create, cr_padding_4) == 132, " found %lld\n",
                  (long long)(int)offsetof(struct mdt_rec_create, cr_padding_4));
         LASSERTF((int)sizeof(((struct mdt_rec_create *)0)->cr_padding_4) == 4, " found %lld\n",
@@ -2736,4 +2742,61 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct link_ea_entry, lee_name));
         LASSERTF((int)sizeof(((struct link_ea_entry *)0)->lee_name) == 0, " found %lld\n",
                  (long long)(int)sizeof(((struct link_ea_entry *)0)->lee_name));
+
+        /* Checks for struct hsm_user_item */
+        LASSERTF((int)sizeof(struct hsm_user_item) == 32, " found %lld\n",
+                 (long long)(int)sizeof(struct hsm_user_item));
+        LASSERTF((int)offsetof(struct hsm_user_item, hui_fid) == 0, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_item, hui_fid));
+        LASSERTF((int)sizeof(((struct hsm_user_item *)0)->hui_fid) == 16, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_item *)0)->hui_fid));
+        LASSERTF((int)offsetof(struct hsm_user_item, hui_extent) == 16, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_item, hui_extent));
+        LASSERTF((int)sizeof(((struct hsm_user_item *)0)->hui_extent) == 16, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_item *)0)->hui_extent));
+
+        /* Checks for struct hsm_user_request */
+        LASSERTF((int)sizeof(struct hsm_user_request) == 16, " found %lld\n",
+                 (long long)(int)sizeof(struct hsm_user_request));
+        LASSERTF((int)offsetof(struct hsm_user_request, hur_action) == 0, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_request, hur_action));
+        LASSERTF((int)sizeof(((struct hsm_user_request *)0)->hur_action) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_request *)0)->hur_action));
+        LASSERTF((int)offsetof(struct hsm_user_request, hur_archive_num) == 4, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_request, hur_archive_num));
+        LASSERTF((int)sizeof(((struct hsm_user_request *)0)->hur_archive_num) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_request *)0)->hur_archive_num));
+        LASSERTF((int)offsetof(struct hsm_user_request, hur_itemcount) == 8, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_request, hur_itemcount));
+        LASSERTF((int)sizeof(((struct hsm_user_request *)0)->hur_itemcount) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_request *)0)->hur_itemcount));
+        LASSERTF((int)offsetof(struct hsm_user_request, hur_data_len) == 12, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_request, hur_data_len));
+        LASSERTF((int)sizeof(((struct hsm_user_request *)0)->hur_data_len) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_request *)0)->hur_data_len));
+
+        /* Checks for struct hsm_user_state */
+        LASSERTF((int)sizeof(struct hsm_user_state) == 32, " found %lld\n",
+                 (long long)(int)sizeof(struct hsm_user_state));
+        LASSERTF((int)offsetof(struct hsm_user_state, hus_states) == 0, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_state, hus_states));
+        LASSERTF((int)sizeof(((struct hsm_user_state *)0)->hus_states) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_state *)0)->hus_states));
+        LASSERTF((int)offsetof(struct hsm_user_state, hus_archive_num) == 4, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_state, hus_archive_num));
+        LASSERTF((int)sizeof(((struct hsm_user_state *)0)->hus_archive_num) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_state *)0)->hus_archive_num));
+        LASSERTF((int)offsetof(struct hsm_user_state, hus_in_progress_state) == 8, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_state, hus_in_progress_state));
+        LASSERTF((int)sizeof(((struct hsm_user_state *)0)->hus_in_progress_state) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_state *)0)->hus_in_progress_state));
+        LASSERTF((int)offsetof(struct hsm_user_state, hus_in_progress_action) == 12, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_state, hus_in_progress_action));
+        LASSERTF((int)sizeof(((struct hsm_user_state *)0)->hus_in_progress_action) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_state *)0)->hus_in_progress_action));
+        LASSERTF((int)offsetof(struct hsm_user_state, hus_in_progress_location) == 16, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_state, hus_in_progress_location));
+        LASSERTF((int)sizeof(((struct hsm_user_state *)0)->hus_in_progress_location) == 16, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_state *)0)->hus_in_progress_location));
 }
+
diff --git a/lustre/tests/acl/974.test b/lustre/tests/acl/974.test
new file mode 100644 (file)
index 0000000..2026681
--- /dev/null
@@ -0,0 +1,18 @@
+LU-974 ignore umask when default acl with mask is set
+
+       $ umask 022
+       $ mkdir d
+
+       $ touch d/f1
+       $ ls -dl d/f1 | awk '{ print $1 }'
+       > -rw-r--r--
+
+       $ setfacl -R -d -m mask:007 d
+       $ touch d/f2
+       $ ls -dl d/f2 | awk '{ print $1 }'
+       > -rw-rw-r--+
+
+       $ umask 077
+       $ touch f3
+       $ ls -dl f3 | awk '{ print $1 }'
+       > -rw-------
index bc1c1b9..6aa83f0 100644 (file)
@@ -5269,6 +5269,12 @@ test_103 () {
     run_acl_subtest inheritance || error "inheritance test failed"
     rm -f make-tree
 
+    echo "LU-974 ignore umask when acl is enabled..."
+    mkdir $DIR/974
+    cd $DIR/974
+    run_acl_subtest 974 || error "LU-974 test failed"
+    rm -rf $DIR/974
+
     cd $SAVE_PWD
     umask $SAVE_UMASK
 
index 36e7928..19c917d 100644 (file)
@@ -628,7 +628,7 @@ check_mdt_rec_create(void)
         CHECK_MEMBER(mdt_rec_create, cr_bias);
         CHECK_MEMBER(mdt_rec_create, cr_flags_l);
         CHECK_MEMBER(mdt_rec_create, cr_flags_h);
-        CHECK_MEMBER(mdt_rec_create, cr_padding_3);
+        CHECK_MEMBER(mdt_rec_create, cr_umask);
         CHECK_MEMBER(mdt_rec_create, cr_padding_4);
 }
 
index 57ae36a..53786a5 100644 (file)
@@ -65,8 +65,8 @@ void lustre_assert_wire_constants(void)
 {
         /* Wire protocol assertions generated by 'wirecheck'
          * (make -C lustre/utils newwiretest)
-         * running on Linux centos5.localhost 2.6.18-prep #3 SMP Mon Mar 22 08:28:01 EDT 2010 x86_64 
-         * with gcc version 4.1.2 20071124 (Red Hat 4.1.2-42) */
+         * running on Linux chopin 2.6.32.279.lustre #2 SMP Wed Aug 15 14:20:56 CST 2012 x86_64 x86_6
+         * with gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC)  */
 
 
         /* Constants... */
@@ -285,6 +285,12 @@ void lustre_assert_wire_constants(void)
                  (long long)MGS_TARGET_DEL);
         LASSERTF(MGS_SET_INFO == 255, " found %lld\n",
                  (long long)MGS_SET_INFO);
+        LASSERTF(LDF_EMPTY == 1, " found %lld\n",
+                 (long long)LDF_EMPTY);
+        LASSERTF(LDF_COLLIDE == 2, " found %lld\n",
+                 (long long)LDF_COLLIDE);
+        LASSERTF(LU_PAGE_SIZE == 4096, " found %lld\n",
+                 (long long)LU_PAGE_SIZE);
         /* Sizes and Offsets */
 
         /* Checks for struct obd_uuid */
@@ -487,51 +493,51 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct obd_connect_data, padding2));
         LASSERTF((int)sizeof(((struct obd_connect_data *)0)->padding2) == 8, " found %lld\n",
                  (long long)(int)sizeof(((struct obd_connect_data *)0)->padding2));
-        CLASSERT(OBD_CONNECT_RDONLY ==                    0x1ULL);
-        CLASSERT(OBD_CONNECT_INDEX ==                     0x2ULL);
-        CLASSERT(OBD_CONNECT_MDS ==                       0x4ULL);
-        CLASSERT(OBD_CONNECT_GRANT ==                     0x8ULL);
-        CLASSERT(OBD_CONNECT_SRVLOCK ==                  0x10ULL);
-        CLASSERT(OBD_CONNECT_VERSION ==                  0x20ULL);
-        CLASSERT(OBD_CONNECT_REQPORTAL ==                0x40ULL);
-        CLASSERT(OBD_CONNECT_ACL ==                      0x80ULL);
-        CLASSERT(OBD_CONNECT_XATTR ==                   0x100ULL);
-        CLASSERT(OBD_CONNECT_CROW ==                    0x200ULL);
-        CLASSERT(OBD_CONNECT_TRUNCLOCK ==               0x400ULL);
-        CLASSERT(OBD_CONNECT_TRANSNO ==                 0x800ULL);
-        CLASSERT(OBD_CONNECT_IBITS ==                  0x1000ULL);
-        CLASSERT(OBD_CONNECT_JOIN ==                   0x2000ULL);
-        CLASSERT(OBD_CONNECT_ATTRFID ==                0x4000ULL);
-        CLASSERT(OBD_CONNECT_NODEVOH ==                0x8000ULL);
-        CLASSERT(OBD_CONNECT_RMT_CLIENT ==            0x10000ULL);
-        CLASSERT(OBD_CONNECT_RMT_CLIENT_FORCE ==      0x20000ULL);
-        CLASSERT(OBD_CONNECT_BRW_SIZE ==              0x40000ULL);
-        CLASSERT(OBD_CONNECT_QUOTA64 ==               0x80000ULL);
-        CLASSERT(OBD_CONNECT_MDS_CAPA ==             0x100000ULL);
-        CLASSERT(OBD_CONNECT_OSS_CAPA ==             0x200000ULL);
-        CLASSERT(OBD_CONNECT_CANCELSET ==            0x400000ULL);
-        CLASSERT(OBD_CONNECT_SOM ==                  0x800000ULL);
-        CLASSERT(OBD_CONNECT_AT ==                  0x1000000ULL);
-        CLASSERT(OBD_CONNECT_LRU_RESIZE ==          0x2000000ULL);
-        CLASSERT(OBD_CONNECT_MDS_MDS ==             0x4000000ULL);
-        CLASSERT(OBD_CONNECT_REAL ==                0x8000000ULL);
-        CLASSERT(OBD_CONNECT_CHANGE_QS ==          0x10000000ULL);
-        CLASSERT(OBD_CONNECT_CKSUM ==              0x20000000ULL);
-        CLASSERT(OBD_CONNECT_FID ==                0x40000000ULL);
-        CLASSERT(OBD_CONNECT_VBR ==                0x80000000ULL);
-        CLASSERT(OBD_CONNECT_LOV_V3 ==            0x100000000ULL);
-        CLASSERT(OBD_CONNECT_GRANT_SHRINK ==      0x200000000ULL);
-        CLASSERT(OBD_CONNECT_SKIP_ORPHAN ==       0x400000000ULL);
-        CLASSERT(OBD_CONNECT_MAX_EASIZE ==        0x800000000ULL);
-        CLASSERT(OBD_CONNECT_FULL20 ==           0x1000000000ULL);
-        CLASSERT(OBD_CONNECT_LAYOUTLOCK ==       0x2000000000ULL);
-        CLASSERT(OBD_CONNECT_64BITHASH ==        0x4000000000ULL);
-        CLASSERT(OBD_CONNECT_MAXBYTES ==         0x8000000000ULL);
-        CLASSERT(OBD_CONNECT_IMP_RECOV ==       0x10000000000ULL);
-        CLASSERT(OBD_CONNECT_JOBSTATS ==        0x20000000000ULL);
-        CLASSERT(OBD_CONNECT_UMASK ==           0x40000000000ULL);
-        CLASSERT(OBD_CONNECT_EINPROGRESS ==     0x80000000000ULL);
-        CLASSERT(OBD_CONNECT_GRANT_PARAM ==    0x100000000000ULL);
+        CLASSERT(OBD_CONNECT_RDONLY == 0x1ULL);
+        CLASSERT(OBD_CONNECT_INDEX == 0x2ULL);
+        CLASSERT(OBD_CONNECT_MDS == 0x4ULL);
+        CLASSERT(OBD_CONNECT_GRANT == 0x8ULL);
+        CLASSERT(OBD_CONNECT_SRVLOCK == 0x10ULL);
+        CLASSERT(OBD_CONNECT_VERSION == 0x20ULL);
+        CLASSERT(OBD_CONNECT_REQPORTAL == 0x40ULL);
+        CLASSERT(OBD_CONNECT_ACL == 0x80ULL);
+        CLASSERT(OBD_CONNECT_XATTR == 0x100ULL);
+        CLASSERT(OBD_CONNECT_CROW == 0x200ULL);
+        CLASSERT(OBD_CONNECT_TRUNCLOCK == 0x400ULL);
+        CLASSERT(OBD_CONNECT_TRANSNO == 0x800ULL);
+        CLASSERT(OBD_CONNECT_IBITS == 0x1000ULL);
+        CLASSERT(OBD_CONNECT_JOIN == 0x2000ULL);
+        CLASSERT(OBD_CONNECT_ATTRFID == 0x4000ULL);
+        CLASSERT(OBD_CONNECT_NODEVOH == 0x8000ULL);
+        CLASSERT(OBD_CONNECT_RMT_CLIENT == 0x10000ULL);
+        CLASSERT(OBD_CONNECT_RMT_CLIENT_FORCE == 0x20000ULL);
+        CLASSERT(OBD_CONNECT_BRW_SIZE == 0x40000ULL);
+        CLASSERT(OBD_CONNECT_QUOTA64 == 0x80000ULL);
+        CLASSERT(OBD_CONNECT_MDS_CAPA == 0x100000ULL);
+        CLASSERT(OBD_CONNECT_OSS_CAPA == 0x200000ULL);
+        CLASSERT(OBD_CONNECT_CANCELSET == 0x400000ULL);
+        CLASSERT(OBD_CONNECT_SOM == 0x800000ULL);
+        CLASSERT(OBD_CONNECT_AT == 0x1000000ULL);
+        CLASSERT(OBD_CONNECT_LRU_RESIZE == 0x2000000ULL);
+        CLASSERT(OBD_CONNECT_MDS_MDS == 0x4000000ULL);
+        CLASSERT(OBD_CONNECT_REAL == 0x8000000ULL);
+        CLASSERT(OBD_CONNECT_CHANGE_QS == 0x10000000ULL);
+        CLASSERT(OBD_CONNECT_CKSUM == 0x20000000ULL);
+        CLASSERT(OBD_CONNECT_FID == 0x40000000ULL);
+        CLASSERT(OBD_CONNECT_VBR == 0x80000000ULL);
+        CLASSERT(OBD_CONNECT_LOV_V3 == 0x100000000ULL);
+        CLASSERT(OBD_CONNECT_GRANT_SHRINK == 0x200000000ULL);
+        CLASSERT(OBD_CONNECT_SKIP_ORPHAN == 0x400000000ULL);
+        CLASSERT(OBD_CONNECT_MAX_EASIZE == 0x800000000ULL);
+        CLASSERT(OBD_CONNECT_FULL20 == 0x1000000000ULL);
+        CLASSERT(OBD_CONNECT_LAYOUTLOCK == 0x2000000000ULL);
+        CLASSERT(OBD_CONNECT_64BITHASH == 0x4000000000ULL);
+        CLASSERT(OBD_CONNECT_MAXBYTES == 0x8000000000ULL);
+        CLASSERT(OBD_CONNECT_IMP_RECOV == 0x10000000000ULL);
+        CLASSERT(OBD_CONNECT_JOBSTATS == 0x20000000000ULL);
+        CLASSERT(OBD_CONNECT_UMASK == 0x40000000000ULL);
+        CLASSERT(OBD_CONNECT_EINPROGRESS == 0x80000000000ULL);
+        CLASSERT(OBD_CONNECT_GRANT_PARAM == 0x100000000000ULL);
 
         /* Checks for struct obdo */
         LASSERTF((int)sizeof(struct obdo) == 208, " found %lld\n",
@@ -700,8 +706,8 @@ void lustre_assert_wire_constants(void)
         CLASSERT(OBD_FL_CKSUM_CRC32 == 4096);
         CLASSERT(OBD_FL_CKSUM_ADLER == 8192);
         CLASSERT(OBD_FL_SHRINK_GRANT == 131072);
-        CLASSERT(OBD_FL_MMAP == (0x00040000));
-        CLASSERT(OBD_FL_RECOV_RESEND == (0x00080000));
+        CLASSERT(OBD_FL_MMAP == 262144);
+        CLASSERT(OBD_FL_RECOV_RESEND == 524288);
         CLASSERT(OBD_CKSUM_CRC32 == 1);
         CLASSERT(OBD_CKSUM_ADLER == 2);
 
@@ -1409,10 +1415,10 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct mdt_rec_create, cr_flags_h));
         LASSERTF((int)sizeof(((struct mdt_rec_create *)0)->cr_flags_h) == 4, " found %lld\n",
                  (long long)(int)sizeof(((struct mdt_rec_create *)0)->cr_flags_h));
-        LASSERTF((int)offsetof(struct mdt_rec_create, cr_padding_3) == 128, " found %lld\n",
-                 (long long)(int)offsetof(struct mdt_rec_create, cr_padding_3));
-        LASSERTF((int)sizeof(((struct mdt_rec_create *)0)->cr_padding_3) == 4, " found %lld\n",
-                 (long long)(int)sizeof(((struct mdt_rec_create *)0)->cr_padding_3));
+        LASSERTF((int)offsetof(struct mdt_rec_create, cr_umask) == 128, " found %lld\n",
+                 (long long)(int)offsetof(struct mdt_rec_create, cr_umask));
+        LASSERTF((int)sizeof(((struct mdt_rec_create *)0)->cr_umask) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct mdt_rec_create *)0)->cr_umask));
         LASSERTF((int)offsetof(struct mdt_rec_create, cr_padding_4) == 132, " found %lld\n",
                  (long long)(int)offsetof(struct mdt_rec_create, cr_padding_4));
         LASSERTF((int)sizeof(((struct mdt_rec_create *)0)->cr_padding_4) == 4, " found %lld\n",
@@ -2733,4 +2739,61 @@ void lustre_assert_wire_constants(void)
                  (long long)(int)offsetof(struct link_ea_entry, lee_name));
         LASSERTF((int)sizeof(((struct link_ea_entry *)0)->lee_name) == 0, " found %lld\n",
                  (long long)(int)sizeof(((struct link_ea_entry *)0)->lee_name));
+
+        /* Checks for struct hsm_user_item */
+        LASSERTF((int)sizeof(struct hsm_user_item) == 32, " found %lld\n",
+                 (long long)(int)sizeof(struct hsm_user_item));
+        LASSERTF((int)offsetof(struct hsm_user_item, hui_fid) == 0, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_item, hui_fid));
+        LASSERTF((int)sizeof(((struct hsm_user_item *)0)->hui_fid) == 16, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_item *)0)->hui_fid));
+        LASSERTF((int)offsetof(struct hsm_user_item, hui_extent) == 16, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_item, hui_extent));
+        LASSERTF((int)sizeof(((struct hsm_user_item *)0)->hui_extent) == 16, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_item *)0)->hui_extent));
+
+        /* Checks for struct hsm_user_request */
+        LASSERTF((int)sizeof(struct hsm_user_request) == 16, " found %lld\n",
+                 (long long)(int)sizeof(struct hsm_user_request));
+        LASSERTF((int)offsetof(struct hsm_user_request, hur_action) == 0, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_request, hur_action));
+        LASSERTF((int)sizeof(((struct hsm_user_request *)0)->hur_action) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_request *)0)->hur_action));
+        LASSERTF((int)offsetof(struct hsm_user_request, hur_archive_num) == 4, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_request, hur_archive_num));
+        LASSERTF((int)sizeof(((struct hsm_user_request *)0)->hur_archive_num) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_request *)0)->hur_archive_num));
+        LASSERTF((int)offsetof(struct hsm_user_request, hur_itemcount) == 8, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_request, hur_itemcount));
+        LASSERTF((int)sizeof(((struct hsm_user_request *)0)->hur_itemcount) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_request *)0)->hur_itemcount));
+        LASSERTF((int)offsetof(struct hsm_user_request, hur_data_len) == 12, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_request, hur_data_len));
+        LASSERTF((int)sizeof(((struct hsm_user_request *)0)->hur_data_len) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_request *)0)->hur_data_len));
+
+        /* Checks for struct hsm_user_state */
+        LASSERTF((int)sizeof(struct hsm_user_state) == 32, " found %lld\n",
+                 (long long)(int)sizeof(struct hsm_user_state));
+        LASSERTF((int)offsetof(struct hsm_user_state, hus_states) == 0, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_state, hus_states));
+        LASSERTF((int)sizeof(((struct hsm_user_state *)0)->hus_states) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_state *)0)->hus_states));
+        LASSERTF((int)offsetof(struct hsm_user_state, hus_archive_num) == 4, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_state, hus_archive_num));
+        LASSERTF((int)sizeof(((struct hsm_user_state *)0)->hus_archive_num) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_state *)0)->hus_archive_num));
+        LASSERTF((int)offsetof(struct hsm_user_state, hus_in_progress_state) == 8, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_state, hus_in_progress_state));
+        LASSERTF((int)sizeof(((struct hsm_user_state *)0)->hus_in_progress_state) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_state *)0)->hus_in_progress_state));
+        LASSERTF((int)offsetof(struct hsm_user_state, hus_in_progress_action) == 12, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_state, hus_in_progress_action));
+        LASSERTF((int)sizeof(((struct hsm_user_state *)0)->hus_in_progress_action) == 4, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_state *)0)->hus_in_progress_action));
+        LASSERTF((int)offsetof(struct hsm_user_state, hus_in_progress_location) == 16, " found %lld\n",
+                 (long long)(int)offsetof(struct hsm_user_state, hus_in_progress_location));
+        LASSERTF((int)sizeof(((struct hsm_user_state *)0)->hus_in_progress_location) == 16, " found %lld\n",
+                 (long long)(int)sizeof(((struct hsm_user_state *)0)->hus_in_progress_location));
 }
+