quota_scan() {
local local_ugp=$1
local local_id=$2
+ local count
if [ "$local_ugp" == "a" -o "$local_ugp" == "u" ]; then
$LFS quota -v -u $local_id $DIR
- log "Files for user ($local_id):"
+ count=$($LFS find --user $local_id $DIR | wc -l)
+ log "Files for user ($local_id), count=$count:"
($LFS find --user $local_id $DIR | head -n 4 |
xargs stat 2>/dev/null)
fi
if [ "$local_ugp" == "a" -o "$local_ugp" == "g" ]; then
$LFS quota -v -g $local_id $DIR
- log "Files for group ($local_id):"
+ count=$($LFS find --group $local_id $DIR | wc -l)
+ log "Files for group ($local_id), count=$count:"
($LFS find --group $local_id $DIR | head -n 4 |
xargs stat 2>/dev/null)
fi
is_project_quota_supported || return 0
if [ "$local_ugp" == "a" -o "$local_ugp" == "p" ]; then
$LFS quota -v -p $TSTPRJID $DIR
- log "Files for project ($TSTPRJID):"
+ count=$($LFS find --projid $TSTPRJID $DIR | wc -l)
+ log "Files for project ($TSTPRJID), count=$count:"
($LFS find --projid $TSTPRJID $DIR | head -n 4 |
xargs stat 2>/dev/null)
fi
pool_add_targets $qpool 0 $(($OSTCOUNT - 1)) ||
error "pool_add_targets failed"
+ # check qmt_pool_add dmesg error
+ local msg_rgx="QMT0000: can't add to $FSNAME-OST0000.*pool.*$qpool"
+ local dmesg_err
+ dmesg_err=$(do_facet mds1 dmesg | grep "$msg_rgx" | tail -1)
+ [[ -z "$dmesg_err" ]] || error "found qmt_pool_add error: $dmesg_err"
+
$LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool $DIR ||
error "set user quota failed"
local testfile="$DIR/$tdir/$tfile-0"
local least_qunit=$(do_facet mds1 $LCTL get_param -n \
qmt.$FSNAME-QMT0000.md-0x0.info |
- awk '/least qunit/{ print $3 }')
+ sed -e 's/least qunit/least_qunit/' |
+ awk '/least_qunit/{ print $2 }')
local limit
[ "$SLOW" = "no" ] && limit=$((least_qunit * 2)) ||
limit=$((least_qunit * 1024))
+ echo "least_qunit: '$least_qunit', limit: '$limit'"
local free_inodes=$(mdt_free_inodes 0)
echo "$free_inodes free inodes on master MDT"
local TESTFILE=$DIR/$tdir/$tfile-0
local GRACE=12
+ [ "$mds1_FSTYPE" = zfs ] && GRACE=20
set_mdt_qtype $QTYPE || error "enable mdt quota failed"
echo "User quota (soft limit:$LIMIT files grace:$GRACE seconds)"
$LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
error "set user quota failed"
- [ "$mds1_FSTYPE" = zfs ] && GRACE=20
-
test_file_soft $TESTFILE $LIMIT $GRACE "u"
echo "Group quota (soft limit:$LIMIT files grace:$GRACE seconds)"
quota_error a $TSTUSR "dbench failed!"
is_project_quota_supported && change_project -C $DIR/$tdir
+ return 0
}
run_test 8 "Run dbench with quota enabled"
}
run_test 15 "Set over 4T block quota"
+test_16a()
+{
+ (( $CLIENT_VERSION < $(version_code 2.14.55) )) &&
+ skip "Not supported Lustre client before 2.14.55"
+
+ setup_quota_test || error "setup quota failed with $?"
+
+ $LFS setquota -u $TSTUSR -B 500M -I 10K $MOUNT ||
+ error "failed to set quota for user $TSTUSR"
+ $LFS setquota -g $TSTUSR -B 500M -I 10K $MOUNT ||
+ error "failed to set quota for group $TSTUSR"
+
+ $RUNAS $DD of=$DIR/$tdir/$tfile bs=1M count=50 ||
+ quota_error u $TSTUSR "write failure"
+
+ $LFS quota -u $TSTUSR $MOUNT ||
+ quota_error u $TSTUSR "failed to get quota"
+
+ local OSC=$($LCTL dl | grep OST0000-osc-[^M] | awk '{print $4}')
+
+ $LCTL --device %$OSC deactivate
+ stack_trap "$LCTL --device %$OSC activate"
+
+ $LFS quota -v -u $TSTUSR $MOUNT ||
+ quota_error u $TSTUSR "failed to get quota after deactivate OSC"
+ $LFS quota -v -g $TSTUSR $MOUNT ||
+ quota_error g $TSTUSR "failed to get quota after deactivate OSC"
+
+ (( $MDSCOUNT > 1 )) || return 0
+
+ local MDC=$($LCTL dl | grep MDT0001-mdc-[^M] | awk '{print $4}')
+
+ $LCTL --device %$MDC deactivate
+ stack_trap "$LCTL --device %$MDC activate"
+
+ $LFS quota -v -u $TSTUSR $MOUNT ||
+ quota_error u $TSTUSR "failed to get quota after deactivate MDC"
+ $LFS quota -v -g $TSTUSR $MOUNT ||
+ quota_error g $TSTUSR "failed to get quota after deactivate OSC"
+}
+run_test 16a "lfs quota should skip the inactive MDT/OST"
+
+cleanup_16b()
+{
+ stopall
+ formatall
+ setupall
+}
+
+test_16b()
+{
+ (( $CLIENT_VERSION < $(version_code 2.14.55) )) &&
+ skip "Not supported Lustre client before 2.14.55"
+
+ (( $MDSCOUNT >= 3 )) || skip "needs >= 3 MDTs"
+
+ stopall
+ if ! combined_mgs_mds ; then
+ format_mgs
+ start_mgs
+ fi
+
+ add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) --index=0 --reformat \
+ $(mdsdevname 1) $(mdsvdevname 1)
+ add mds2 $(mkfs_opts mds2 $(mdsdevname 2)) --index=1 --reformat \
+ $(mdsdevname 2) $(mdsvdevname 2)
+ add mds3 $(mkfs_opts mds3 $(mdsdevname 3)) --index=100 --reformat \
+ $(mdsdevname 3) $(mdsvdevname 3)
+
+ add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=0 --reformat \
+ $(ostdevname 1) $(ostvdevname 1)
+ add ost2 $(mkfs_opts ost2 $(ostdevname 2)) --index=100 --reformat \
+ $(ostdevname 2) $(ostvdevname 2)
+
+ stack_trap cleanup_16b
+
+ start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "MDT1 start failed"
+ start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS || error "MDT2 start failed"
+ start mds3 $(mdsdevname 3) $MDS_MOUNT_OPTS || error "MDT3 start failed"
+ start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "OST1 start failed"
+ start ost2 $(ostdevname 2) $OST_MOUNT_OPTS || error "OST2 start failed"
+
+ mount_client $MOUNT || error "Unable to mount client"
+
+ setup_quota_test || error "setup quota failed with $?"
+ stack_trap cleanup_quota_test EXIT
+
+ $LFS setquota -u $TSTUSR -B 100M -I 10K $MOUNT ||
+ error "failed to set quota for user $TSTUSR"
+ $LFS setquota -g $TSTUSR -B 100M -I 10K $MOUNT ||
+ error "failed to set quota for group $TSTUSR"
+
+ $RUNAS $DD of=$DIR/$tdir/$tfile bs=1M count=10 ||
+ quota_error u $TSTUSR "write failure"
+
+ cnt=$($LFS quota -v -u $TSTUSR $MOUNT | grep -ce "^$FSNAME-[MD|OS]T*")
+ [ $cnt -le 5 ] || quota_error u $TSTUSR "failed to get user quota"
+ cnt=$($LFS quota -v -g $TSTUSR $MOUNT | grep -ce "^$FSNAME-[MD|OS]T*")
+ [ $cnt -le 5 ] || quota_error g $TSTUSR "failed to get group quota"
+}
+run_test 16b "lfs quota should skip the nonexistent MDT/OST"
+
test_17sub() {
local err_code=$1
local BLKS=1 # 1M less than limit
local qtype=$2
local nr
+ wait_update_facet mds1 \
+ "$LCTL get_param -n qmt.$FSNAME-QMT0000.dt-$pool.info \
+ >/dev/null 2>&1 || echo foo" "" ||
+ error "mds1: failed to create quota pool $pool"
+
do_facet mds1 $LCTL get_param -n qmt.$FSNAME-QMT0000.dt-$pool.info |
awk '/usr/ {getline; print $2}'
}
}
run_test 81 "Race qmt_start_pool_recalc with qmt_pool_free"
+test_82()
+{
+ (( $MDS1_VERSION >= $(version_code 2.14.55) )) ||
+ skip "need MDS 2.14.55 or later"
+ is_project_quota_supported ||
+ skip "skip project quota unsupported"
+
+ setup_quota_test || error "setup quota failed with $?"
+ stack_trap cleanup_quota_test
+ quota_init
+
+ local parent_dir="$DIR/$tdir.parent"
+ local child_dir="$parent_dir/child"
+
+ mkdir -p $child_dir
+ stack_trap "chown -R 0:0 $parent_dir"
+
+ chown $TSTUSR:$TSTUSR $parent_dir ||
+ error "failed to chown on $parent_dir"
+ chown $TSTUSR2:$TSTUSRS2 $child_dir ||
+ error "failed to chown on $parent_dir"
+
+ $LFS project -p 1000 $parent_dir ||
+ error "failed to set project id on $parent_dir"
+ $LFS project -p 1001 $child_dir ||
+ error "failed to set project id on $child_dir"
+
+ rmdir $child_dir || error "cannot remove child dir, test failed"
+}
+run_test 82 "verify more than 8 qids for single operation"
+
quota_fini()
{
do_nodes $(comma_list $(nodes_list)) \