Whamcloud - gitweb
LU-12324 mdd: Do not record xattr size get in changelogs
[fs/lustre-release.git] / lustre / mdd / mdd_object.c
index 4b81988..e94118e 100644 (file)
@@ -235,8 +235,7 @@ int mdd_la_get(const struct lu_env *env, struct mdd_object *obj,
                return rc;
        }
 
-       if (la->la_valid & LA_FLAGS &&
-           la->la_flags & LUSTRE_ORPHAN_FL)
+       if (la->la_valid & LA_FLAGS && la->la_flags & LUSTRE_ORPHAN_FL)
                obj->mod_flags |= ORPHAN_OBJ | DEAD_OBJ;
 
        return 0;
@@ -429,7 +428,7 @@ static int mdd_xattr_get(const struct lu_env *env,
        mdd = mdo2mdd(obj);
 
        /* record only getting user xattrs and acls */
-       if (rc >= 0 &&
+       if (rc >= 0 && buf->lb_buf &&
            mdd_changelog_enabled(env, mdd, CL_GETXATTR) &&
            (has_prefix(name, XATTR_USER_PREFIX) ||
             has_prefix(name, XATTR_NAME_POSIX_ACL_ACCESS) ||
@@ -1099,6 +1098,7 @@ static int mdd_declare_attr_set(const struct lu_env *env,
 
 /*
  * LU-3671
+ * LU-7239
  *
  * permission changes may require sync operation, to mitigate performance
  * impact, only do this for dir and when permission is reduced.
@@ -1113,17 +1113,24 @@ static inline bool permission_needs_sync(const struct lu_attr *old,
        if (!S_ISDIR(old->la_mode))
                return false;
 
-       if (new->la_valid & (LA_UID | LA_GID))
+       if (new->la_valid & LA_UID && old->la_uid != new->la_uid)
                return true;
 
-       if (new->la_valid & LA_MODE &&
-           new->la_mode & (S_ISUID | S_ISGID | S_ISVTX))
+       if (new->la_valid & LA_GID && old->la_gid != new->la_gid)
                return true;
 
-       if ((new->la_valid & LA_MODE) &&
-           ((new->la_mode & old->la_mode) & S_IRWXUGO) !=
-            (old->la_mode & S_IRWXUGO))
-               return true;
+       if (new->la_valid & LA_MODE) {
+               /* turned on sticky bit */
+               if (!(old->la_mode & S_ISVTX) && (new->la_mode & S_ISVTX))
+                       return true;
+
+               /* set-GID has no impact on what is allowed, not checked */
+
+               /* turned off setuid bit, or one of rwx for someone */
+               if (((new->la_mode & old->la_mode) & (0777 | S_ISUID)) !=
+                    (old->la_mode & (0777 | S_ISUID)))
+                       return true;
+       }
 
        return false;
 }
@@ -1163,6 +1170,7 @@ int mdd_attr_set(const struct lu_env *env, struct md_object *obj,
        struct lu_attr *attr = MDD_ENV_VAR(env, cattr);
        const struct lu_attr *la = &ma->ma_attr;
        struct lu_ucred  *uc;
+       bool chrgrp_by_unprivileged_user = false;
        int rc;
        ENTRY;
 
@@ -1194,15 +1202,23 @@ int mdd_attr_set(const struct lu_env *env, struct md_object *obj,
        uc = lu_ucred_check(env);
        if (S_ISREG(attr->la_mode) && la->la_valid & LA_GID &&
            la->la_gid != attr->la_gid && uc != NULL && uc->uc_fsuid != 0) {
+               /* LU-10048: disable synchronous chgrp operation for it will
+                * cause deadlock between MDT and OST.
                la_copy->la_valid |= LA_FLAGS;
                la_copy->la_flags |= LUSTRE_SET_SYNC_FL;
+                */
+               chrgrp_by_unprivileged_user = true;
 
-               /* Flush the possible existing sync requests to OSTs to
-                * keep the order of sync for the current setattr operation
+               /* Flush the possible existing client setattr requests to OSTs
+                * to keep the order with the current setattr operation that
                 * will be sent directly to OSTs. see LU-5152 */
+               /* LU-11303 disable sync as this is too heavyweight.
+                * This should be replaced with a sync only for the object
+                * being modified here, not the whole filesystem.
                rc = dt_sync(env, mdd->mdd_child);
                if (rc)
                        GOTO(out, rc);
+                */
        }
 
        handle = mdd_trans_create(env, mdd);
@@ -1221,7 +1237,8 @@ int mdd_attr_set(const struct lu_env *env, struct md_object *obj,
        if (rc)
                GOTO(out, rc);
 
-       if (mdd->mdd_sync_permission && permission_needs_sync(attr, la))
+       if (!chrgrp_by_unprivileged_user && mdd->mdd_sync_permission &&
+           permission_needs_sync(attr, la))
                handle->th_sync = 1;
 
        if (la->la_valid & (LA_MTIME | LA_CTIME))
@@ -1396,7 +1413,8 @@ static int mdd_hsm_update_locked(const struct lu_env *env,
 
        /* Read HSM attrs from disk */
        current_buf = lu_buf_check_and_alloc(&info->mti_xattr_buf,
-                               mdo2mdd(obj)->mdd_dt_conf.ddp_max_ea_size);
+                       MIN(mdd_obj2mdd_dev(mdd_obj)->mdd_dt_conf.ddp_max_ea_size,
+                           XATTR_SIZE_MAX));
        rc = mdo_xattr_get(env, mdd_obj, current_buf, XATTR_NAME_HSM);
        rc = lustre_buf2hsm(current_buf->lb_buf, rc, current_mh);
        if (rc < 0 && rc != -ENODATA)