From: Sergey Cheremencev Date: Fri, 2 Jul 2021 11:55:19 +0000 (+0300) Subject: LU-15066 utils: do not inherit limits from global pool X-Git-Tag: 2.14.57~5 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=bbecfa64fc585197246fcc443b487bec44b1f4dc LU-15066 utils: do not inherit limits from global pool lfs_setquota retrieves quota limits from the server before setting new ones. It is needed to do not overwrite already set limits. Before the patch limits were retrieved only from global pool, despite the fact that new limit should be set to a specific pool. Thus, setting only hard block limit to a specific pool, this pool could inherit soft block limit from the global pool. HPE-bug-id: LUS-10186 Change-Id: I6fdbf3265f950e39b48a5ad06b059d8aa06a6218 Signed-off-by: Sergey Cheremencev Reviewed-on: https://review.whamcloud.com/45135 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Alexander Boyko Reviewed-by: Chris Horn Reviewed-by: Oleg Drokin --- diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index d0d67de..56efc53 100755 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -4528,7 +4528,7 @@ test_69() } run_test 69 "EDQUOT at one of pools shouldn't affect DOM" -test_70() +test_70a() { local qpool="qpool1" local limit=20 # MB @@ -4563,7 +4563,31 @@ test_70() rc=$? [ $rc -eq $err ] || error "quota res $rc != $err" } -run_test 70 "check lfs setquota/quota with a pool option" +run_test 70a "check lfs setquota/quota with a pool option" + +test_70b() +{ + local glbl_hard=200 # 200M + local glbl_soft=100 # 100M + local pool_hard=10 # 10M + local qpool="qpool1" + + pool_add $qpool || error "pool_add failed" + pool_add_targets $qpool 0 1 || error "pool_add_targets failed" + + $LFS setquota -u $TSTUSR -b ${glbl_soft}M -B ${glbl_hard}M $DIR || + error "set user quota failed" + $LFS setquota -u $TSTUSR -B ${pool_hard}M --pool $qpool $DIR || + error "set user quota failed" + + local tmp=$(getquota -u $TSTUSR global bhardlimit $qpool) + [ $tmp -eq $((pool_hard * 1024)) ] || + error "wrong block hard limit $tmp for $qpool" + local tmp=$(getquota -u $TSTUSR global bsoftlimit $qpool) + # soft limit hasn't been set and should be zero + [ $tmp -eq 0 ] || error "wrong soft block limit $tmp for $qpool" +} +run_test 70b "lfs setquota pool works properly" test_71a() { diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 42d8d28..8a21d28 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -7885,33 +7885,48 @@ quota_type_def: } else if ((!(limit_mask & BHLIMIT) ^ !(limit_mask & BSLIMIT)) || (!(limit_mask & IHLIMIT) ^ !(limit_mask & ISLIMIT))) { /* sigh, we can't just set blimits/ilimits */ - struct if_quotactl tmp_qctl = {.qc_cmd = LUSTRE_Q_GETQUOTA, - .qc_type = qctl->qc_type, - .qc_id = qctl->qc_id}; + struct if_quotactl *tmp_qctl; - rc = llapi_quotactl(mnt, &tmp_qctl); - if (rc < 0) + tmp_qctl = calloc(1, sizeof(*qctl) + LOV_MAXPOOLNAME + 1); + if (!tmp_qctl) + goto out; + + if (qctl->qc_cmd == LUSTRE_Q_SETQUOTAPOOL) { + tmp_qctl->qc_cmd = LUSTRE_Q_GETQUOTAPOOL; + strncpy(tmp_qctl->qc_poolname, qctl->qc_poolname, + LOV_MAXPOOLNAME); + } else { + tmp_qctl->qc_cmd = LUSTRE_Q_GETQUOTA; + } + tmp_qctl->qc_type = qctl->qc_type; + tmp_qctl->qc_id = qctl->qc_id; + + rc = llapi_quotactl(mnt, tmp_qctl); + if (rc < 0) { + free(tmp_qctl); goto out; + } if (!(limit_mask & BHLIMIT)) - dqb->dqb_bhardlimit = tmp_qctl.qc_dqblk.dqb_bhardlimit; + dqb->dqb_bhardlimit = tmp_qctl->qc_dqblk.dqb_bhardlimit; if (!(limit_mask & BSLIMIT)) - dqb->dqb_bsoftlimit = tmp_qctl.qc_dqblk.dqb_bsoftlimit; + dqb->dqb_bsoftlimit = tmp_qctl->qc_dqblk.dqb_bsoftlimit; if (!(limit_mask & IHLIMIT)) - dqb->dqb_ihardlimit = tmp_qctl.qc_dqblk.dqb_ihardlimit; + dqb->dqb_ihardlimit = tmp_qctl->qc_dqblk.dqb_ihardlimit; if (!(limit_mask & ISLIMIT)) - dqb->dqb_isoftlimit = tmp_qctl.qc_dqblk.dqb_isoftlimit; + dqb->dqb_isoftlimit = tmp_qctl->qc_dqblk.dqb_isoftlimit; /* Keep grace times if we have got no softlimit arguments */ if ((limit_mask & BHLIMIT) && !(limit_mask & BSLIMIT)) { dqb->dqb_valid |= QIF_BTIME; - dqb->dqb_btime = tmp_qctl.qc_dqblk.dqb_btime; + dqb->dqb_btime = tmp_qctl->qc_dqblk.dqb_btime; } if ((limit_mask & IHLIMIT) && !(limit_mask & ISLIMIT)) { dqb->dqb_valid |= QIF_ITIME; - dqb->dqb_itime = tmp_qctl.qc_dqblk.dqb_itime; + dqb->dqb_itime = tmp_qctl->qc_dqblk.dqb_itime; } + free(tmp_qctl); } dqb->dqb_valid |= (limit_mask & (BHLIMIT | BSLIMIT)) ? QIF_BLIMITS : 0;