Whamcloud - gitweb
LU-15141 quota: optimize capability check for root squash
authorSebastien Buisson <sbuisson@ddn.com>
Thu, 21 Oct 2021 06:56:44 +0000 (08:56 +0200)
committerAndreas Dilger <adilger@whamcloud.com>
Wed, 10 Nov 2021 15:59:25 +0000 (15:59 +0000)
On client side, checking for owner/group quota can be directly
bypassed if this is for root and there is no root squash.

Lustre-change: https://review.whamcloud.com/45322
Lustre-commit: TBD (15aa2e9264f0604b185ce280df4b34ea5a280b3f)

Change-Id: If29eca428d8748df412a717615e4d0a4886ddd04
Fixes: 0b057b7179 ("LU-14739 quota: nodemap squashed root cannot bypass quota")
Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-on: https://review.whamcloud.com/45321
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/osc/osc_cache.c

index 1beb8ac..7cd1f56 100644 (file)
@@ -2341,7 +2341,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[LL_MAXQUOTAS];
@@ -2356,20 +2361,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);
        }