X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Ftests%2Fsanity.sh;h=4be9bc0a83139188bb31dedb0de1d692cc68997c;hp=ac3f1aa7bc78c5e4b359be11b648194d23c2aca4;hb=219cbfc7665a9260f3d5c8ceee823506a89df42f;hpb=986fe589f9727d52cfa2350ffbaeea0cae94f3d5 diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index ac3f1aa..4be9bc0 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -2612,6 +2612,7 @@ test_27G() { #LU-10629 local ostrange="0 0 1" test_mkdir $DIR/$tdir + touch $DIR/$tdir/$tfile.nopool pool_add $POOL || error "pool_add failed" pool_add_targets $POOL $ostrange || error "pool_add_targets failed" $LFS setstripe -p $POOL $DIR/$tdir @@ -2619,14 +2620,18 @@ test_27G() { #LU-10629 local pool=$($LFS getstripe -p $DIR/$tdir) [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'" + touch $DIR/$tdir/$tfile.default + $LFS setstripe -E 1M --pool $POOL -c 1 -E eof -c 1 $DIR/$tdir/$tfile.pfl + $LFS find $DIR/$tdir -type f --pool $POOL + local found=$($LFS find $DIR/$tdir -type f --pool $POOL | wc -l) + [[ "$found" == "2" ]] || + error "found $found != 2 files in '$DIR/$tdir' in '$POOL'" $LFS setstripe -d $DIR/$tdir - pool=$($LFS getstripe -p $DIR/$tdir) + pool=$($LFS getstripe -p -d $DIR/$tdir) - rmdir $DIR/$tdir - - [ -z "$pool" ] || error "'$pool' is not empty" + [[ "$pool" != "$POOL" ]] || error "$DIR/$tdir is still '$pool'" } run_test 27G "Clear OST pool from stripe" @@ -6263,14 +6268,15 @@ test_56rb() { test_mkdir -p $dir || error "failed to mkdir $dir" $LFS setstripe -c 1 -i 0 $dir/$tfile || error "failed to setstripe $dir/$tfile" + mdt_idx=$($LFS getdirstripe -i $dir) dd if=/dev/zero of=$dir/$tfile bs=1M count=1 stack_trap "rm -f $tmp" EXIT - $LFS find --size +100K --ost 0 $dir 2>&1 | tee $tmp - [ -z "$(cat $tmp | grep "obd_uuid: ")" ] || + $LFS find --size +100K --ost 0 $dir |& tee $tmp + ! grep -q obd_uuid $tmp || error "failed to find --size +100K --ost 0 $dir" - $LFS find --size +100K --mdt $mdt_idx $dir 2>&1 | tee $tmp - [ -z "$(cat $tmp | grep "obd_uuid: ")" ] || + $LFS find --size +100K --mdt $mdt_idx $dir |& tee $tmp + ! grep -q obd_uuid $tmp || error "failed to find --size +100K --mdt $mdt_idx $dir" } run_test 56rb "check lfs find --size --ost/--mdt works" @@ -7834,18 +7840,25 @@ test_64c() { } run_test 64c "verify grant shrink" +import_param() { + local tgt=$1 + local param=$2 + + $LCTL get_param osc.$tgt.import | awk "/$param/ { print \$2 }" +} + # this does exactly what osc_request.c:osc_announce_cached() does in # order to calculate max amount of grants to ask from server want_grant() { local tgt=$1 - local nrpages=$($LCTL get_param -n osc.${tgt}.max_pages_per_rpc) - local rpc_in_flight=$($LCTL get_param -n osc.${tgt}.max_rpcs_in_flight) + local nrpages=$($LCTL get_param -n osc.$tgt.max_pages_per_rpc) + local rpc_in_flight=$($LCTL get_param -n osc.$tgt.max_rpcs_in_flight) - ((rpc_in_flight ++)); + ((rpc_in_flight++)); nrpages=$((nrpages * rpc_in_flight)) - local dirty_max_pages=$($LCTL get_param -n osc.${tgt}.max_dirty_mb) + local dirty_max_pages=$($LCTL get_param -n osc.$tgt.max_dirty_mb) dirty_max_pages=$((dirty_max_pages * 1024 * 1024 / PAGE_SIZE)) @@ -7853,13 +7866,11 @@ want_grant() { local undirty=$((nrpages * PAGE_SIZE)) local max_extent_pages - max_extent_pages=$($LCTL get_param osc.${tgt}.import | - grep grant_max_extent_size | awk '{print $2}') + max_extent_pages=$(import_param $tgt grant_max_extent_size) max_extent_pages=$((max_extent_pages / PAGE_SIZE)) local nrextents=$(((nrpages + max_extent_pages - 1) / max_extent_pages)) local grant_extent_tax - grant_extent_tax=$($LCTL get_param osc.${tgt}.import | - grep grant_extent_tax | awk '{print $2}') + grant_extent_tax=$(import_param $tgt grant_extent_tax) undirty=$((undirty + nrextents * grant_extent_tax)) @@ -7873,56 +7884,171 @@ grant_chunk() { local max_brw_size local grant_extent_tax - max_brw_size=$($LCTL get_param osc.${tgt}.import | - grep max_brw_size | awk '{print $2}') + max_brw_size=$(import_param $tgt max_brw_size) - grant_extent_tax=$($LCTL get_param osc.${tgt}.import | - grep grant_extent_tax | awk '{print $2}') + grant_extent_tax=$(import_param $tgt grant_extent_tax) echo $(((max_brw_size + grant_extent_tax) * 2)) } test_64d() { - [ $OST1_VERSION -lt $(version_code 2.10.56) ] && + [ $OST1_VERSION -ge $(version_code 2.10.56) ] || skip "OST < 2.10.55 doesn't limit grants enough" - local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}') - local file=$DIR/$tfile + local tgt=$($LCTL dl | awk '/OST0000-osc-[^mM]/ { print $4 }') - [[ $($LCTL get_param osc.${tgt}.import | - grep "connect_flags:.*grant_param") ]] || + [[ "$($LCTL get_param osc.${tgt}.import)" =~ "grant_param" ]] || skip "no grant_param connect flag" - local olddebug=$($LCTL get_param -n debug 2> /dev/null) + local olddebug="$($LCTL get_param -n debug 2> /dev/null)" + + $LCTL set_param -n -n debug="$OLDDEBUG" || true + stack_trap "$LCTL set_param -n debug='$olddebug'" EXIT - $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt))) - stack_trap "rm -f $file" EXIT + stack_trap "rm -f $DIR/$tfile && wait_delete_completed" EXIT - $LFS setstripe $file -i 0 -c 1 - dd if=/dev/zero of=$file bs=1M count=1000 & + $LFS setstripe $DIR/$tfile -i 0 -c 1 + dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 & ddpid=$! - while true - do - local cur_grant=$($LCTL get_param -n osc.${tgt}.cur_grant_bytes) - if [[ $cur_grant -gt $max_cur_granted ]] - then + while kill -0 $ddpid; do + local cur_grant=$($LCTL get_param -n osc.$tgt.cur_grant_bytes) + + if [[ $cur_grant -gt $max_cur_granted ]]; then kill $ddpid error "cur_grant $cur_grant > $max_cur_granted" fi - kill -0 $ddpid - [[ $? -ne 0 ]] && break; - sleep 2 - done - rm -f $DIR/$tfile - wait_delete_completed - $LCTL set_param debug="$olddebug" 2> /dev/null || true + sleep 1 + done } run_test 64d "check grant limit exceed" +check_grants() { + local tgt=$1 + local expected=$2 + local msg=$3 + local cur_grants=$($LCTL get_param -n osc.$tgt.cur_grant_bytes) + + ((cur_grants == expected)) || + error "$msg: grants mismatch: $cur_grants, expected $expected" +} + +round_up_p2() { + echo $((($1 + $2 - 1) & ~($2 - 1))) +} + +test_64e() { + [ $PARALLEL == "yes" ] && skip "skip parallel run" + [ $OST1_VERSION -ge $(version_code 2.11.56) ] || + skip "Need OSS version at least 2.11.56" + + # Remount client to reset grant + remount_client $MOUNT || error "failed to remount client" + local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)" + + local init_grants=$(import_param $osc_tgt initial_grant) + + check_grants $osc_tgt $init_grants "init grants" + + local extent_tax=$(import_param $osc_tgt grant_extent_tax) + local max_brw_size=$(import_param $osc_tgt max_brw_size) + local gbs=$(import_param $osc_tgt grant_block_size) + + # write random number of bytes from max_brw_size / 4 to max_brw_size + local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1) + # align for direct io + write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE) + # round to grant consumption unit + local wb_round_up=$(round_up_p2 $write_bytes gbs) + + local grants=$((wb_round_up + extent_tax)) + + $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed" + + # define OBD_FAIL_TGT_NO_GRANT 0x725 + # make the server not grant more back + do_facet ost1 $LCTL set_param fail_loc=0x725 + dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct + + do_facet ost1 $LCTL set_param fail_loc=0 + + check_grants $osc_tgt $((init_grants - grants)) "dio w/o grant alloc" + + rm -f $DIR/$tfile || error "rm failed" + + # Remount client to reset grant + remount_client $MOUNT || error "failed to remount client" + osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)" + + $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed" + + # define OBD_FAIL_TGT_NO_GRANT 0x725 + # make the server not grant more back + do_facet ost1 $LCTL set_param fail_loc=0x725 + $MULTIOP $DIR/$tfile "oO_WRONLY:w${write_bytes}yc" + do_facet ost1 $LCTL set_param fail_loc=0 + + check_grants $osc_tgt $((init_grants - grants)) "buf io w/o grant alloc" +} +run_test 64e "check grant consumption (no grant allocation)" + +test_64f() { + [ $PARALLEL == "yes" ] && skip "skip parallel run" + + # Remount client to reset grant + remount_client $MOUNT || error "failed to remount client" + local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)" + + local init_grants=$(import_param $osc_tgt initial_grant) + local extent_tax=$(import_param $osc_tgt grant_extent_tax) + local max_brw_size=$(import_param $osc_tgt max_brw_size) + local gbs=$(import_param $osc_tgt grant_block_size) + local chunk=$(grant_chunk $osc_tgt) + + # write random number of bytes from max_brw_size / 4 to max_brw_size + local write_bytes=$(shuf -i $((max_brw_size / 4))-$max_brw_size -n 1) + # align for direct io + write_bytes=$(round_up_p2 $write_bytes PAGE_SIZE) + # round to grant consumption unit + local wb_round_up=$(round_up_p2 $write_bytes gbs) + + local grants=$((wb_round_up + extent_tax)) + + $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed" + dd if=/dev/zero of=$DIR/$tfile bs=$write_bytes count=1 oflag=direct || + error "error writing to $DIR/$tfile" + + check_grants $osc_tgt $((init_grants - grants + chunk)) \ + "direct io with grant allocation" + + rm -f $DIR/$tfile || error "rm failed" + + # Remount client to reset grant + remount_client $MOUNT || error "failed to remount client" + osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)" + + $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "lfs setstripe failed" + + local cmd="oO_WRONLY:w${write_bytes}_yc" + + $MULTIOP $DIR/$tfile $cmd & + MULTIPID=$! + sleep 1 + + check_grants $osc_tgt $((init_grants - grants)) \ + "buffered io, not write rpc" + + kill -USR1 $MULTIPID + wait + + check_grants $osc_tgt $((init_grants - grants + chunk)) \ + "buffered io, one RPC" +} +run_test 64f "check grant consumption (with grant allocation)" + # bug 1414 - set/get directories' stripe info test_65a() { [ $PARALLEL == "yes" ] && skip "skip parallel run" @@ -8764,9 +8890,8 @@ test_77k() { # LU-10906 local i [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum) - stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT - stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \ - EXIT + stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM || true" + stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" for i in 0 1; do do_facet mgs $LCTL set_param -P $cksum_param=$i || @@ -16353,16 +16478,20 @@ test_205a() { # Job stats } run_test 205a "Verify job stats" -# LU-13117 +# LU-13117, LU-13597 test_205b() { + job_stats="mdt.*.job_stats" + $LCTL set_param $job_stats=clear $LCTL set_param jobid_var=USER jobid_name="%e.%u" env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1 - do_facet $SINGLEMDS $LCTL get_param mdt.*.job_stats | - grep job_id: | grep foolish && + do_facet $SINGLEMDS $LCTL get_param $job_stats | + grep "job_id:.*foolish" && error "Unexpected jobid found" - true + do_facet $SINGLEMDS $LCTL get_param $job_stats | + grep "open:.*min.*max.*sum" || + error "wrong job_stats format found" } -run_test 205b "Verify job stats jobid parsing" +run_test 205b "Verify job stats jobid and output format" # LU-1480, LU-1773 and LU-1657 test_206() { @@ -16487,6 +16616,27 @@ test_209() { } run_test 209 "read-only open/close requests should be freed promptly" +test_210() { + local pid + + $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eW_E+eUc & + pid=$! + sleep 1 + + $LFS getstripe $DIR/$tfile + kill -USR1 $pid + wait $pid || error "multiop failed" + + $MULTIOP $DIR/$tfile oO_RDONLY:eR_E+eUc & + pid=$! + sleep 1 + + $LFS getstripe $DIR/$tfile + kill -USR1 $pid + wait $pid || error "multiop failed" +} +run_test 210 "lfs getstripe does not break leases" + test_212() { size=`date +%s` size=$((size % 8192 + 1)) @@ -19791,6 +19941,36 @@ test_270g() { } run_test 270g "DoM: default DoM stripe size depends on free space" +test_270h() { + [[ $MDS1_VERSION -ge $(version_code 2.13.53) ]] || + skip "Need MDS version at least 2.13.53" + + local mdtname=${FSNAME}-MDT0000-mdtlov + local dom=$DIR/$tdir/$tfile + local save="$TMP/$TESTSUITE-$TESTNAME.parameters" + + save_lustre_params mds1 "lod.*.dom_stripesize" > $save + stack_trap "restore_lustre_params < $save; rm -f $save" EXIT + + $LFS mkdir -i 0 -c 1 $DIR/$tdir + $LFS setstripe -E 1M -c1 -E -1 -c2 ${dom}_1 || + error "can't create OST file" + # mirrored file with DOM entry in the second mirror + $LFS mirror extend -N -E 1M -L mdt -E eof -c2 ${dom}_1 || + error "can't create mirror with DoM component" + + do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0 + + # DOM component in the middle and has other enries in the same mirror, + # should succeed but lost DoM component + $LFS setstripe --copy=${dom}_1 $dom || + error "Can't create file from OST|DOM mirror layout" + # check new file has no DoM layout after all + [[ $($LFS getstripe -L $dom) != "mdt" ]] || + error "File has DoM component while DoM is disabled" +} +run_test 270h "DoM: DoM stripe removal when disabled on server" + test_271a() { [ $MDS1_VERSION -lt $(version_code 2.10.55) ] && skip "Need MDS version at least 2.10.55"