From f5fd5a363cc48e38cfd906edab3dec78d88a79e5 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Thu, 21 Oct 2021 08:56:44 +0200 Subject: [PATCH] LU-15141 quota: optimize capability check for root squash On client side, checking for owner/group quota can be directly bypassed if this is for root and there is no root squash. Change-Id: If29eca428d8748df412a717615e4d0a4886ddd04 Fixes: a4fbe7341b ("LU-14739 quota: nodemap squashed root cannot bypass quota") Signed-off-by: Sebastien Buisson Reviewed-on: https://review.whamcloud.com/45322 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Hongchao Zhang Reviewed-by: Oleg Drokin --- lustre/osc/osc_cache.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/lustre/osc/osc_cache.c b/lustre/osc/osc_cache.c index b8fa6da..fe8a56e 100644 --- a/lustre/osc/osc_cache.c +++ b/lustre/osc/osc_cache.c @@ -2315,7 +2315,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]; @@ -2330,20 +2335,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); } -- 1.8.3.1