diff mbox series

[13/19] lustre: quota: optimize capability check for root squash

Message ID 1638142074-5945-14-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: update to OpenSFS tree Nov 28, 2021 | expand

Commit Message

James Simmons Nov. 28, 2021, 11:27 p.m. UTC
From: Sebastien Buisson <sbuisson@ddn.com>

On client side, checking for owner/group quota can be directly
bypassed if this is for root and there is no root squash.

Fixes: cd633cfc96 ("lustre: quota: nodemap squashed root cannot bypass quota")
WC-bug-id: https://jira.whamcloud.com/browse/LU-15141
Lustre-commit: f5fd5a363cc48e38c ("LU-15141 quota: optimize capability check for root squash")
Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-on: https://review.whamcloud.com/45322
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/osc/osc_cache.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/fs/lustre/osc/osc_cache.c b/fs/lustre/osc/osc_cache.c
index 1211438..7b7b49f 100644
--- a/fs/lustre/osc/osc_cache.c
+++ b/fs/lustre/osc/osc_cache.c
@@ -2385,7 +2385,12 @@  int osc_queue_async_io(const struct lu_env *env, struct cl_io *io,
 	}
 
 	/* check if the file's owner/group is over quota */
-	if (!io->ci_noquota) {
+	/* do not check for root without root squash, because in this case
+	 * we should bypass quota
+	 */
+	if ((!oio->oi_cap_sys_resource ||
+	     cli->cl_root_squash) &&
+	    !io->ci_noquota) {
 		struct cl_object *obj;
 		struct cl_attr *attr;
 		unsigned int qid[MAXQUOTAS];
@@ -2400,20 +2405,8 @@  int osc_queue_async_io(const struct lu_env *env, struct cl_io *io,
 		qid[USRQUOTA] = attr->cat_uid;
 		qid[GRPQUOTA] = attr->cat_gid;
 		qid[PRJQUOTA] = attr->cat_projid;
-		/*
-		 * if EDQUOT returned for root, we double check
-		 * if root squash enabled or not updated from server side.
-		 * without root squash, we should bypass quota for root.
-		 */
-		if (rc == 0 && osc_quota_chkdq(cli, qid) == -EDQUOT) {
-			if (oio->oi_cap_sys_resource &&
-			    !cli->cl_root_squash) {
-				io->ci_noquota = 1;
-				rc = 0;
-			} else {
-				rc = -EDQUOT;
-			}
-		}
+		if (rc == 0 && osc_quota_chkdq(cli, qid) == -EDQUOT)
+			rc = -EDQUOT;
 		if (rc)
 			return rc;
 	}