Whamcloud - gitweb
LU-18936 quota: correct limits for squashed root 86/58886/5
authorSergey Cheremencev <scherementsev@ddn.com>
Fri, 18 Apr 2025 18:19:30 +0000 (21:19 +0300)
committerOleg Drokin <green@whamcloud.com>
Fri, 2 May 2025 02:22:46 +0000 (02:22 +0000)
As root doesn't have quota limits, it's limits have been always set to
zero at client side. However, qid=0 can be changed according to the
nodemap at the MDT. As clients don't know about the mapping, quota
limits must to be set to zero only on the MDT.

Signed-off-by: Sergey Cheremencev <scherementsev@ddn.com>
Change-Id: Ibdfd70d0cf4987a6e99e4ee07d7308a6865116ad
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58886
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity-quota.sh
lustre/utils/lfs.c

index b580ccd..22fe0fe 100755 (executable)
@@ -6906,6 +6906,68 @@ test_93()
 }
 run_test 93 "update projid while client write to OST"
 
+test_95() {
+       local cmd="do_facet mgs $LCTL get_param -n "
+       local squash=100
+       local off=100000
+       local lim=70000
+       local nm="nm0"
+       local ip=$(host_nids_address $HOSTNAME $NETTYPE)
+       local nid=$(h2nettype $ip)
+
+       $LFS setquota -u $off -B1025 $DIR ||
+               error "Can't setquota for uid $off"
+       stack_trap "$LFS setquota -u $off -B0 $DIR"
+       $LFS setquota -g $off -B1026 $DIR ||
+               error "Can't setquota for gid $off"
+       stack_trap "$LFS setquota -g $off -B0 $DIR"
+       $LFS setquota -p $((off + squash)) -B1027 $DIR ||
+               error "Can't setquota for project $((off + squash))"
+       stack_trap "$LFS setquota -p $((off + squash)) -B0 $DIR"
+
+       local 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"
+
+       do_facet mgs $LCTL nodemap_add $nm ||
+               error "unable to add $nm as nodemap"
+       stack_trap "do_facet mgs $LCTL nodemap_del $nm"
+
+       do_facet mgs $LCTL nodemap_add_range --name $nm --range $nid ||
+               error "Add range $nid to $nm failed"
+
+       do_facet mgs "$LCTL nodemap_modify --name $nm \
+               --property squash_uid --value $squash"
+
+       do_facet mgs "$LCTL nodemap_modify --name $nm \
+               --property squash_gid --value $squash"
+
+       do_facet mgs "$LCTL nodemap_modify --name $nm \
+               --property squash_projid --value $squash"
+
+       do_facet mgs $LCTL nodemap_add_offset --name $nm \
+               --offset $off --limit $lim ||
+                       error "cannot set offset $off-$((lim + off - 1))"
+
+       do_facet mgs $LCTL nodemap_modify --name $nm --property admin --value 1
+       wait_nm_sync $nm admin_nodemap
+
+       $LFS quota -u 0 $DIR
+       (( $($LFS quota -q -u 0 --bhardlimit $DIR) == 1025 )) ||
+               error "Wrong user limit for squashed root"
+
+       $LFS quota -g 0 $DIR
+       (( $($LFS quota -q -g 0 --bhardlimit $DIR) == 1026 )) ||
+               error "Wrong group limit for squashed root"
+
+       $LFS quota -p 0 $DIR
+       (( $($LFS quota -q -p 0 --bhardlimit $DIR) == 1027 )) ||
+               error "Wrong proj limit for squashed root"
+}
+run_test 95 "Correct limits for squashed root"
+
 quota_fini()
 {
        do_nodes $(comma_list $(nodes_list)) \
index 30ddfad..0118ed8 100755 (executable)
@@ -9660,16 +9660,6 @@ static int print_one_quota(char *mnt, char *name, struct if_quotactl *qctl,
        __u64 total_ialloc = 0, total_balloc = 0;
        int inacc;
 
-       if (!param->qp_show_default && qctl->qc_id == 0) {
-               qctl->qc_dqblk.dqb_bhardlimit = 0;
-               qctl->qc_dqblk.dqb_bsoftlimit = 0;
-               qctl->qc_dqblk.dqb_ihardlimit = 0;
-               qctl->qc_dqblk.dqb_isoftlimit = 0;
-               qctl->qc_dqblk.dqb_btime = 0;
-               qctl->qc_dqblk.dqb_itime = 0;
-               qctl->qc_dqblk.dqb_valid |= QIF_LIMITS | QIF_TIMES;
-       }
-
        if (qctl->qc_dqblk.dqb_valid & QIF_BTIME &&
            LQUOTA_FLAG(qctl->qc_dqblk.dqb_btime) & LQUOTA_FLAG_DEFAULT)
                qctl->qc_dqblk.dqb_btime &= LQUOTA_GRACE_MASK;