From a6e97440de408a092376cc8f65a3eba4a97bdf80 Mon Sep 17 00:00:00 2001 From: Sergey Cheremencev Date: Thu, 22 May 2025 04:57:02 +0300 Subject: [PATCH] LU-19058 llite: ll_statfs_project for projid 0 df should take into account project quota limits for squashed project id. Otherwhise it shows system wide size. Signed-off-by: Sergey Cheremencev Change-Id: Ieae5d8503829e2de859b60ed259bc0ee4d1274ca Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/59435 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin Reviewed-by: Sebastien Buisson Reviewed-by: Andreas Dilger --- lustre/llite/llite_lib.c | 3 +-- lustre/tests/sanity-quota.sh | 46 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 68627d4..5771bfd 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -2773,8 +2773,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs) sfs->f_fsid.val[0] = (__u32)fsid; sfs->f_fsid.val[1] = (__u32)(fsid >> 32); sfs->f_namelen = sbi->ll_namelen; - if (ll_i2info(de->d_inode)->lli_projid && - test_bit(LL_SBI_STATFS_PROJECT, sbi->ll_flags) && + if (test_bit(LL_SBI_STATFS_PROJECT, sbi->ll_flags) && test_bit(LLIF_PROJECT_INHERIT, &ll_i2info(de->d_inode)->lli_flags)) return ll_statfs_project(de->d_inode, sfs); diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index 78704e2..498d651 100755 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -7092,7 +7092,7 @@ test_94() } run_test 94 "lfs quota all respects nodemap offset" -test_95() { +test_95a() { local cmd="do_facet mgs $LCTL get_param -n " local squash=100 local off=100000 @@ -7155,7 +7155,49 @@ test_95() { (( $($LFS quota -q -p 0 --bhardlimit $DIR) == 1027 )) || error "Wrong proj limit for squashed root" } -run_test 95 "Correct limits for squashed root" +run_test 95a "Correct limits for squashed root" + +test_95b() +{ + local cmd="do_facet mgs $LCTL get_param -n " + local trusted + local projid + local act + local size + + is_project_quota_supported || skip "project is not supported" + setup_quota_test || error "setup quota failed with $?" + + trusted=$($cmd nodemap.default.trusted_nodemap) + do_facet mgs "$LCTL nodemap_modify --name default \ + --property trusted --value 0" + stack_trap "do_facet mgs $LCTL nodemap_modify --name default \ + --property trusted --value $trusted" + + projid=$($cmd nodemap.default.squash_projid) + do_facet mgs "$LCTL nodemap_modify --name default \ + --property squash_projid --value $TSTPRJID" + stack_trap "do_facet mgs $LCTL nodemap_modify --name default \ + --property squash_projid --value $projid" + + $LFS setquota -p $TSTPRJID -B10M $MOUNT || + error "Set default quotas with squashed uid" + + $LFS project -p 0 -sr $DIR + stack_trap "$LFS project -C -r $DIR" + $LFS project $DIR + + act=$($cmd nodemap.active) + do_facet mgs $LCTL nodemap_activate 1 + wait_nm_sync active + stack_trap "do_facet mgs $LCTL nodemap_activate $act; \ + wait_nm_sync active" + + size=$(df -h --output=size $DIR | awk 'NR > 1 {print $1}') + echo "size :$size" + [[ $size == "10M" ]] || error "Wrong df size:$size, expect:10M" +} +run_test 95b "df respects squashed project id" quota_fini() { -- 1.8.3.1