Whamcloud - gitweb
LU-3671 mdd: sync perm for dir and perm reduction only 57/7257/5
authorLai Siyao <lai.siyao@intel.com>
Wed, 7 Aug 2013 10:42:31 +0000 (18:42 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 27 Aug 2013 02:13:43 +0000 (02:13 +0000)
To mitigate performance impact for sync permission, do it for dir
and when permission is reduced only.

Remove extra sync permission check in mdd_xattr_set() because ACL
change is all handled in mdd_acl_set().

Signed-off-by: Lai Siyao <lai.siyao@intel.com>
Change-Id: I64fc720a380aafdaf858d83fbb85f29a1063e07f
Reviewed-on: http://review.whamcloud.com/7257
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
lustre/mdd/mdd_object.c
lustre/mdd/mdd_permission.c

index 824c92f..5d688cc 100644 (file)
@@ -829,6 +829,13 @@ static int mdd_declare_attr_set(const struct lu_env *env,
        return rc;
 }
 
+static inline bool permission_is_reduced(const struct lu_attr *old,
+                                        const struct lu_attr *new)
+{
+       return ((new->la_mode & old->la_mode) & S_IRWXUGO) !=
+              (old->la_mode & S_IRWXUGO);
+}
+
 /* set attr and LOV EA at once, return updated attr */
 int mdd_attr_set(const struct lu_env *env, struct md_object *obj,
                 const struct md_attr *ma)
@@ -838,6 +845,7 @@ int mdd_attr_set(const struct lu_env *env, struct md_object *obj,
         struct thandle *handle;
         struct lu_attr *la_copy = &mdd_env_info(env)->mti_la_for_fix;
        const struct lu_attr *la = &ma->ma_attr;
+       bool sync_perm = false;
        int rc;
         ENTRY;
 
@@ -867,9 +875,38 @@ int mdd_attr_set(const struct lu_env *env, struct md_object *obj,
         if (rc)
                 GOTO(stop, rc);
 
-        /* permission changes may require sync operation */
-       if (ma->ma_attr.la_valid & (LA_MODE|LA_UID|LA_GID))
-                handle->th_sync |= !!mdd->mdd_sync_permission;
+       /*
+        * LU-3671
+        *
+        * permission changes may require sync operation, to mitigate
+        * performance impact, only do this for dir and when permission is
+        * reduced.
+        *
+        * For regular files, version is updated with permission change
+        * (see VBR), async permission won't cause any issue, while missing
+        * permission change on directory may affect accessibility of other
+        * objects.
+        */
+       if (S_ISDIR(mdd_object_type(mdd_obj))) {
+               if (la->la_valid & (LA_UID | LA_GID)) {
+                       sync_perm = true;
+               } else if (la->la_valid & LA_MODE &&
+                          la->la_mode & (S_ISUID | S_ISGID | S_ISVTX)) {
+                       sync_perm = true;
+               } else if (la->la_valid & LA_MODE) {
+                       struct lu_attr *tmp_la = &mdd_env_info(env)->mti_la;
+
+                       rc = mdd_la_get(env, mdd_obj, tmp_la, BYPASS_CAPA);
+                       if (rc)
+                               GOTO(stop, rc);
+
+                       if (permission_is_reduced(tmp_la, la))
+                               sync_perm = true;
+               }
+       }
+
+       if (sync_perm)
+               handle->th_sync |= !!mdd->mdd_sync_permission;
 
        if (la->la_valid & (LA_MTIME | LA_CTIME))
                 CDEBUG(D_INODE, "setting mtime "LPU64", ctime "LPU64"\n",
@@ -1045,10 +1082,6 @@ static int mdd_xattr_set(const struct lu_env *env, struct md_object *obj,
        if (rc)
                GOTO(stop, rc);
 
-       /* security-replated changes may require sync */
-       if (!strcmp(name, XATTR_NAME_ACL_ACCESS))
-               handle->th_sync |= !!mdd->mdd_sync_permission;
-
        mdd_write_lock(env, mdd_obj, MOR_TGT_CHILD);
 
        if (strncmp(XATTR_NAME_HSM, name, sizeof(XATTR_NAME_HSM) - 1) == 0) {
index b18232e..f52d617 100644 (file)
@@ -164,7 +164,8 @@ int mdd_acl_set(const struct lu_env *env, struct mdd_object *obj,
                                mdd_object_capa(env, obj));
 
        /* security-replated changes may require sync */
-       handle->th_sync |= !!mdd->mdd_sync_permission;
+       if (S_ISDIR(mdd_object_type(obj)))
+               handle->th_sync |= !!mdd->mdd_sync_permission;
 unlock:
        mdd_write_unlock(env, obj);
 stop: