In patch LU-11303, chgrp was modified to be asynchronous
and updates the quotas. However, this resulted in chgrp
calls failing for file owners with read-only permissions.
This commit relaxes the permission requirements for quota updates
for chgrp calls to allow read-only permissions.
Fixes:
83f5544d8518 ("LU-11303 quota: enforce block quota for chgrp")
Test-Parameters: testlist=pjdfstest
Signed-off-by: Max Wang <wamax@amazon.com>
Change-Id: I6c4b73d1d48cb2ffc4866ab2e03a86a6c723e960
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57717
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
if (!((flags & MDS_OWNEROVERRIDE) &&
(uc->uc_fsuid == oattr->la_uid)) &&
!(flags & MDS_PERM_BYPASS)) {
+ int mask = MAY_WRITE;
+
+ /* for chgrp, allow the update with
+ * read-only permissions
+ */
+ if (S_ISREG(oattr->la_mode) && la->la_valid & LA_GID &&
+ la->la_gid != oattr->la_gid)
+ mask = MAY_READ;
rc = mdd_permission_internal(env, obj, oattr,
- MAY_WRITE);
+ mask);
if (rc != 0)
RETURN(rc);
}
}
run_test 6h "$RUNAS chown RUNAS_ID.0 .../$tfile (should return error)"
+test_6i() {
+ (( MDS1_VERSION >= $(version_code 2.16.51) )) ||
+ skip "Need MDS version at least 2.16.51"
+ (( $RUNAS_ID != $UID )) || skip_env "RUNAS_ID = UID = $UID"
+
+ touch $DIR/$tfile
+ chmod 444 $DIR/$tfile
+ chown $RUNAS_ID $DIR/$tfile || error "initial chown failed"
+ $RUNAS -u $RUNAS_ID -g $RUNAS_ID chgrp $RUNAS_ID $DIR/$tfile ||
+ error "chgrp $RUNAS_ID $file failed"
+ $CHECKSTAT -t file -u \#$RUNAS_ID -g \#$RUNAS_ID $DIR/$tfile ||
+ error "$tfile should be owned by GID $RUNAS_ID"
+}
+run_test 6i "touch+chmod+chgrp $tfile; chgrp read-only file should succeed"
+
test_7a() {
test_mkdir $DIR/$tdir
$MCREATE $DIR/$tdir/$tfile