Whamcloud - gitweb
Branch HEAD
authortappro <tappro>
Tue, 18 Aug 2009 08:23:13 +0000 (08:23 +0000)
committertappro <tappro>
Tue, 18 Aug 2009 08:23:13 +0000 (08:23 +0000)
b=15390
i=fanyong
i=pravin

Port permission sync functionality from 1.8 to 2.0.

lustre/include/dt_object.h
lustre/mdd/mdd_device.c
lustre/mdd/mdd_internal.h
lustre/mdd/mdd_lproc.c
lustre/mdd/mdd_object.c
lustre/mdd/mdd_trans.c
lustre/osd/osd_handler.c

index 8e4cb77..a8ec09c 100644 (file)
@@ -538,6 +538,17 @@ static inline void txn_param_init(struct txn_param *p, unsigned int credits)
         p->tp_credits = credits;
 }
 
+static inline void txn_param_credit_add(struct txn_param *p,
+                                        unsigned int credits)
+{
+        p->tp_credits += credits;
+}
+
+static inline void txn_param_sync(struct txn_param *p)
+{
+        p->tp_sync = 1;
+}
+
 /**
  * This is the general purpose transaction handle.
  * 1. Transaction Life Cycle
index 16fefbd..3ce0d5d 100644 (file)
@@ -95,6 +95,8 @@ static int mdd_device_init(const struct lu_env *env, struct lu_device *d,
         mdd->mdd_txn_cb.dtc_tag = LCT_MD_THREAD;
         CFS_INIT_LIST_HEAD(&mdd->mdd_txn_cb.dtc_linkage);
         mdd->mdd_atime_diff = MAX_ATIME_DIFF;
+        /* sync permission changes */
+        mdd->mdd_sync_permission = 1;
 
         rc = mdd_procfs_init(mdd, name);
         RETURN(rc);
index 51ca3e4..65ee175 100644 (file)
@@ -132,6 +132,7 @@ struct mdd_device {
         unsigned long                    mdd_atime_diff;
         struct mdd_object               *mdd_dot_lustre;
         struct mdd_dot_lustre_objs       mdd_dot_lustre_objs;
+        unsigned int                     mdd_sync_permission;
 };
 
 enum mod_flags {
index 3784927..d37229a 100644 (file)
@@ -422,6 +422,30 @@ static int mdd_lprocfs_quota_wr_type(struct file *file, const char *buffer,
 }
 #endif
 
+static int lprocfs_rd_sync_perm(char *page, char **start, off_t off,
+                                int count, int *eof, void *data)
+{
+        struct mdd_device *mdd = data;
+
+        LASSERT(mdd != NULL);
+        return snprintf(page, count, "%d\n", mdd->mdd_sync_permission);
+}
+
+static int lprocfs_wr_sync_perm(struct file *file, const char *buffer,
+                                unsigned long count, void *data)
+{
+        struct mdd_device *mdd = data;
+        int val, rc;
+
+        LASSERT(mdd != NULL);
+        rc = lprocfs_write_helper(buffer, count, &val);
+        if (rc)
+                return rc;
+
+        mdd->mdd_sync_permission = !!val;
+        return count;
+}
+
 static struct lprocfs_vars lprocfs_mdd_obd_vars[] = {
         { "atime_diff",      lprocfs_rd_atime_diff, lprocfs_wr_atime_diff, 0 },
         { "changelog_mask",  lprocfs_rd_changelog_mask,
@@ -432,6 +456,7 @@ static struct lprocfs_vars lprocfs_mdd_obd_vars[] = {
         { "quota_type",      mdd_lprocfs_quota_rd_type,
                              mdd_lprocfs_quota_wr_type, 0 },
 #endif
+        { "sync_permission", lprocfs_rd_sync_perm, lprocfs_wr_sync_perm, 0 },
         { 0 }
 };
 
index 070847e..29a6d79 100644 (file)
@@ -1410,6 +1410,11 @@ static int mdd_xattr_set(const struct lu_env *env, struct md_object *obj,
                 RETURN(rc);
 
         mdd_txn_param_build(env, mdd, MDD_TXN_XATTR_SET_OP);
+        /* security-replated changes may require sync */
+        if (!strcmp(name, XATTR_NAME_ACL_ACCESS) &&
+            mdd->mdd_sync_permission == 1)
+                txn_param_sync(&mdd_env_info(env)->mti_param);
+
         handle = mdd_trans_start(env, mdd);
         if (IS_ERR(handle))
                 RETURN(PTR_ERR(handle));
index 8a40869..95774a2 100644 (file)
@@ -139,7 +139,7 @@ int mdd_log_txn_param_build(const struct lu_env *env, struct md_object *obj,
                 stripe = le32_to_cpu(ma->ma_lmm->lmm_stripe_count);
 
         log_credits = stripe * dto_txn_credits[DTO_LOG_REC];
-        mdd_env_info(env)->mti_param.tp_credits += log_credits;
+        txn_param_credit_add(&mdd_env_info(env)->mti_param, log_credits);
         RETURN(rc);
 }
 
@@ -151,8 +151,13 @@ int mdd_setattr_txn_param_build(const struct lu_env *env, struct md_object *obj,
 
         mdd_txn_param_build(env, mdd, op);
         if (ma->ma_attr.la_valid & (LA_UID | LA_GID))
-                mdd_env_info(env)->mti_param.tp_credits =
-                                        dto_txn_credits[DTO_ATTR_SET_CHOWN];
+                txn_param_credit_add(&mdd_env_info(env)->mti_param,
+                                     dto_txn_credits[DTO_ATTR_SET_CHOWN]);
+
+        /* permission changes may require sync operation */
+        if (ma->ma_attr.la_valid & (LA_MODE|LA_UID|LA_GID) &&
+            mdd->mdd_sync_permission == 1)
+                txn_param_sync(&mdd_env_info(env)->mti_param);
 
         RETURN(0);
 }
@@ -258,7 +263,7 @@ struct thandle* mdd_trans_start(const struct lu_env *env,
 {
         struct txn_param *p = &mdd_env_info(env)->mti_param;
         struct thandle *th;
-        
+
         th = mdd_child_ops(mdd)->dt_trans_start(env, mdd->mdd_child, p);
         return th;
 }
index 7fc790f..5ac3cc2 100644 (file)
@@ -907,8 +907,8 @@ static const int osd_dto_credits_noquota[DTO_NR] = {
         /**
          * Xattr set. The same as xattr of EXT3.
          * DATA_TRANS_BLOCKS(14)
-         * XXX Note: in original MDS implmentation INDEX_EXTRA_TRANS_BLOCKS are
-         *           also counted in. Do not know why?
+         * XXX Note: in original MDS implmentation INDEX_EXTRA_TRANS_BLOCKS
+         * are also counted in. Do not know why?
          */
         [DTO_XATTR_SET]     = 14,
         [DTO_LOG_REC]       = 14,
@@ -922,9 +922,9 @@ static const int osd_dto_credits_noquota[DTO_NR] = {
         [DTO_WRITE_BLOCK]   = 14,
         /**
          * Attr set credits for chown.
-         * 3 (inode bit, group, GDT)
+         * This is extra credits for setattr, and it is null without quota
          */
-        [DTO_ATTR_SET_CHOWN]= 3
+        [DTO_ATTR_SET_CHOWN]= 0
 };
 
 /**
@@ -987,11 +987,11 @@ static const int osd_dto_credits_quota[DTO_NR] = {
         [DTO_WRITE_BLOCK]   = 16,
         /**
          * Attr set credits for chown.
-         * 3 (inode bit, group, GDT) +
+         * It is added to already set setattr credits
          * 2 * QUOTA_INIT_BLOCKS(25) +
          * 2 * QUOTA_DEL_BLOCKS(9)
          */
-        [DTO_ATTR_SET_CHOWN]= 71
+        [DTO_ATTR_SET_CHOWN]= 68,
 };
 
 static int osd_credit_get(const struct lu_env *env, struct dt_device *d,