X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Ftests%2Fsanity.sh;h=e63d910542d83ec8548d5106312752d7d38c9c2f;hp=9e3a268f8fdbed105eab7b4807b9334cd9c24a7a;hb=083d62ee6de5ac6cee95c1d2f86b62b75034093b;hpb=cf29a5e7bfa254ccfcea023028fe7da80503c512 diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 9e3a268..e63d910 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -12,8 +12,10 @@ ONLY=${ONLY:-"$*"} ALWAYS_EXCEPT="$SANITY_EXCEPT 42a 42b 42c 77k" # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! -# skipped tests: LU-8411 LU-9096 LU-9054 LU-10734 .. -ALWAYS_EXCEPT=" 407 253 312 160g $ALWAYS_EXCEPT" +# skipped tests: LU-8411 LU-9096 LU-9054 .. +ALWAYS_EXCEPT=" 407 253 312 $ALWAYS_EXCEPT" +# skipped tests: LU-4684 +ALWAYS_EXCEPT=" 17n 160d 230 316 $ALWAYS_EXCEPT" # Check Grants after these tests GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c" @@ -59,6 +61,11 @@ init_test_env $@ . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh} init_logging +if [[ $MDSCOUNT -gt 1 ]]; then + # bug number: LU-11161 + ALWAYS_EXCEPT+=" 160g" +fi + # 5 12 (min)" [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o" @@ -2290,6 +2297,25 @@ test_27G() { #LU-10629 } run_test 27G "Clear OST pool from stripe" +test_27H() { + [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.11.53) ]] && + skip "Need MDS version newer than 2.11.53" + [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" + test_mkdir $DIR/$tdir + $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed" + touch $DIR/$tdir/$tfile + $LFS getstripe -c $DIR/$tdir/$tfile + [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] || + error "two-stripe file doesn't have two stripes" + + dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed" + $LFS getstripe -y $DIR/$tdir/$tfile + (( $($LFS getstripe -y $DIR/$tdir/$tfile | + egrep -c "l_ost_idx: [02]$") == "2" )) || + error "expected l_ost_idx: [02]$ not matched" +} +run_test 27H "Set specific OSTs stripe" + # createtest also checks that device nodes are created and # then visible correctly (#2091) test_28() { # bug 2091 @@ -8361,6 +8387,56 @@ test_102r() { } run_test 102r "set EAs with empty values" +test_102s() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.52) ] && + skip "MDS needs to be at least 2.11.52" + + local save="$TMP/$TESTSUITE-$TESTNAME.parameters" + + save_lustre_params client "llite.*.xattr_cache" > $save + + for cache in 0 1; do + lctl set_param llite.*.xattr_cache=$cache + + rm -f $DIR/$tfile + touch $DIR/$tfile || error "touch" + for prefix in lustre security system trusted user; do + # Note getxattr() may fail with 'Operation not + # supported' or 'No such attribute' depending + # on prefix and cache. + getfattr -n $prefix.n102s $DIR/$tfile && + error "getxattr '$prefix.n102s' should fail (cache = $cache)" + done + done + + restore_lustre_params < $save +} +run_test 102s "getting nonexistent xattrs should fail" + +test_102t() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.52) ] && + skip "MDS needs to be at least 2.11.52" + + local save="$TMP/$TESTSUITE-$TESTNAME.parameters" + + save_lustre_params client "llite.*.xattr_cache" > $save + + for cache in 0 1; do + lctl set_param llite.*.xattr_cache=$cache + + for buf_size in 0 256; do + rm -f $DIR/$tfile + touch $DIR/$tfile || error "touch" + setfattr -n user.multiop $DIR/$tfile + $MULTIOP $DIR/$tfile oa$buf_size || + error "cannot get zero length xattr value (buf_size = $buf_size)" + done + done + + restore_lustre_params < $save +} +run_test 102t "zero length xattr values handled correctly" + run_acl_subtest() { $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test @@ -10680,6 +10756,9 @@ test_133b() { ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed" check_stats $SINGLEMDS "getattr" 1 fi + # Sleep to avoid a cached response. + #define OBD_STATFS_CACHE_SECONDS 1 + sleep 2 $LFS df || error "lfs failed" check_stats $SINGLEMDS "statfs" 1 @@ -10904,6 +10983,18 @@ run_test 133e "Verifying OST {read,write}_bytes nid stats =================" proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/" +# Some versions of find (4.5.11, 4.5.14) included in CentOS 7.3-7.5 do +# not honor the -ignore_readdir_race option correctly. So we call +# error_ignore() rather than error() in these cases. See LU-11152. +error_133() { + if (find --version; do_facet mds1 find --version) | + grep -q '\b4\.5\.1[1-4]\b'; then + error_ignore LU-11152 "$@" + else + error "$@" + fi +} + test_133f() { # First without trusting modes. local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null) @@ -10921,7 +11012,7 @@ test_133f() { -not -name force_lbug \ -not -name changelog_mask \ -exec badarea_io '{}' \; || - error "find $proc_dirs failed" + error_133 "find $proc_dirs failed" } run_test 133f "Check reads/writes of client lustre proc files with bad area io" @@ -10955,7 +11046,7 @@ test_133g() { -not -name force_lbug \ -not -name changelog_mask \ -exec badarea_io '{}' \\\; || - error "$facet find $facet_proc_dirs failed" + error_133 "$facet find $facet_proc_dirs failed" done # remount the FS in case writes/reads /proc break the FS @@ -12357,9 +12448,12 @@ test_160g() { # Create a user changelog_register || error "first changelog_register failed" changelog_register || error "second changelog_register failed" - local cl_users=(${CL_USERS[$SINGLEMDS]}) - local cl_user1="${cl_users[0]}" - local cl_user2="${cl_users[1]}" + local cl_users + declare -A cl_user1 + declare -A cl_user2 + local user_rec1 + local user_rec2 + local i # generate some changelog records to accumulate on each MDT test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed" @@ -12367,11 +12461,11 @@ test_160g() { error "create $DIR/$tdir/$tfile failed" # check changelogs have been generated - nbcl=$(changelog_dump | wc -l) + local nbcl=$(changelog_dump | wc -l) [[ $nbcl -eq 0 ]] && error "no changelogs found" - # changelog_gc=1 should be set by default for param in "changelog_max_idle_indexes=$((nbcl / 2))" \ + "changelog_gc=1" \ "changelog_min_gc_interval=2" \ "changelog_min_free_cat_entries=3"; do local MDT0=$(facet_svc $SINGLEMDS) @@ -12387,37 +12481,71 @@ test_160g() { #define OBD_FAIL_CAT_FREE_RECORDS 0x1313 do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3 - local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user1) + for i in $(seq $MDSCOUNT); do + cl_users=(${CL_USERS[mds$i]}) + cl_user1[mds$i]="${cl_users[0]}" + cl_user2[mds$i]="${cl_users[1]}" - __changelog_clear $SINGLEMDS $cl_user1 +3 + [ -n "${cl_user1[mds$i]}" ] || + error "mds$i: no user registered" + [ -n "${cl_user2[mds$i]}" ] || + error "mds$i: only ${cl_user1[mds$i]} is registered" - local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user1) + user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]}) + [ -n "$user_rec1" ] || + error "mds$i: User ${cl_user1[mds$i]} not registered" + __changelog_clear mds$i ${cl_user1[mds$i]} +2 + user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]}) + [ -n "$user_rec2" ] || + error "mds$i: User ${cl_user1[mds$i]} not registered" + echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \ + "$user_rec1 + 2 == $user_rec2" + [ $((user_rec1 + 2)) == $user_rec2 ] || + error "mds$i: user ${cl_user1[mds$i]} index expected " \ + "$user_rec1 + 2, but is $user_rec2" + user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]}) + [ -n "$user_rec2" ] || + error "mds$i: User ${cl_user2[mds$i]} not registered" + [ $user_rec1 == $user_rec2 ] || + error "mds$i: user ${cl_user2[mds$i]} index expected " \ + "$user_rec1, but is $user_rec2" + done - echo "verifying user clear: $user_rec1 + 3 == $user_rec2" - [ $((user_rec1 + 3)) == $user_rec2 ] || - error "user index expected $user_rec1 + 3, but is $user_rec2" + # ensure we are past the previous changelog_min_gc_interval set above + sleep 2 # generate one more changelog to trigger fail_loc - rm -rf $DIR/$tdir || error "rm -rf $tdir failed" + createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) || + error "create $DIR/$tdir/${tfile}bis failed" # ensure gc thread is done - wait_update_facet $SINGLEMDS \ - "ps -e -o comm= | grep chlg_gc_thread" "" 20 + for i in $(mdts_nodes); do + wait_update $i \ + "ps -e -o comm= | grep chlg_gc_thread" "" 20 || + error "$i: GC-thread not done" + done - # check user still registered - [ -n "$(changelog_user_rec $SINGLEMDS $cl_user1)" ] || - error "User $cl_user1 not found in changelog_users" - # check user2 unregistered - [ -z "$(changelog_user_rec $SINGLEMDS $cl_user2)" ] || - error "User $cl_user2 still found in changelog_users" + local first_rec + for i in $(seq $MDSCOUNT); do + # check cl_user1 still registered + changelog_users mds$i | grep -q "${cl_user1[mds$i]}" || + error "mds$i: User ${cl_user1[mds$i]} not registered" + # check cl_user2 unregistered + changelog_users mds$i | grep -q "${cl_user2[mds$i]}" && + error "mds$i: User ${cl_user2[mds$i]} still registered" - # check changelogs are present and starting at $user_rec2 + 1 - local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) | - awk '{ print $1; exit; }') + # check changelogs are present and starting at $user_rec1 + 1 + user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]}) + [ -n "$user_rec1" ] || + error "mds$i: User ${cl_user1[mds$i]} not registered" + first_rec=$($LFS changelog $(facet_svc mds$i) | + awk '{ print $1; exit; }') - echo "verifying min purge: $user_rec2 + 1 == $first_rec" - [ $((user_rec2 + 1)) == $first_rec ] || - error "first index should be $user_rec2 + 1, but is $first_rec" + echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec" + [ $((user_rec1 + 1)) == $first_rec ] || + error "mds$i: first index should be $user_rec1 + 1, " \ + "but is $first_rec" + done } run_test 160g "changelog garbage collect (old users)" @@ -16203,6 +16331,9 @@ test_255b() { dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb || error "dd to $DIR/$tfile failed" + #force write to complete before dropping OST cache & checking memory + sync + local total=$(facet_meminfo ost1 MemTotal) echo "Total memory: $total KiB" @@ -16892,6 +17023,197 @@ test_271c() { } run_test 271c "DoM: IO lock at open saves enqueue RPCs" +cleanup_271def_tests() { + trap 0 + rm -f $1 +} + +test_271d() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.57) ] && + skip "Need MDS version at least 2.10.57" && return + + local dom=$DIR/$tdir/dom + local tmp=$TMP/$tfile + trap "cleanup_271def_tests $tmp" EXIT + + mkdir -p $DIR/$tdir + + $LFS setstripe -E 1024K -L mdt $DIR/$tdir + + local mdtidx=$($GETSTRIPE -M $DIR/$tdir) + local facet=mds$((mdtidx + 1)) + + cancel_lru_locks mdc + dd if=/dev/urandom of=$tmp bs=1000 count=1 + dd if=$tmp of=$dom bs=1000 count=1 + cancel_lru_locks mdc + + cat /etc/hosts >> $tmp + lctl set_param -n mdc.*.stats=clear + + # append data to the same file it should update local page + echo "Append to the same page" + cat /etc/hosts >> $dom + local num=$(lctl get_param -n mdc.*.stats | + awk '/ost_read/ {print $2}') + local ra=$(lctl get_param -n mdc.*.stats | + awk '/req_active/ {print $2}') + local rw=$(lctl get_param -n mdc.*.stats | + awk '/req_waittime/ {print $2}') + + [ -z $num ] || error "$num READ RPC occured" + [ $ra == $rw ] || error "$((ra - rw)) resend occured" + echo "... DONE" + + # compare content + cmp $tmp $dom || error "file miscompare" + + cancel_lru_locks mdc + lctl set_param -n mdc.*.stats=clear + + echo "Open and read file" + cat $dom > /dev/null + local num=$(lctl get_param -n mdc.*.stats | + awk '/ost_read/ {print $2}') + local ra=$(lctl get_param -n mdc.*.stats | + awk '/req_active/ {print $2}') + local rw=$(lctl get_param -n mdc.*.stats | + awk '/req_waittime/ {print $2}') + + [ -z $num ] || error "$num READ RPC occured" + [ $ra == $rw ] || error "$((ra - rw)) resend occured" + echo "... DONE" + + # compare content + cmp $tmp $dom || error "file miscompare" + + return 0 +} +run_test 271d "DoM: read on open (1K file in reply buffer)" + +test_271e() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.57) ] && + skip "Need MDS version at least 2.10.57" && return + + local dom=$DIR/$tdir/dom + local tmp=$TMP/${tfile}.data + trap "cleanup_271def_tests $tmp" EXIT + + mkdir -p $DIR/$tdir + + $LFS setstripe -E 1024K -L mdt $DIR/$tdir + + local mdtidx=$($GETSTRIPE -M $DIR/$tdir) + local facet=mds$((mdtidx + 1)) + + cancel_lru_locks mdc + dd if=/dev/urandom of=$tmp bs=30K count=1 + dd if=$tmp of=$dom bs=30K count=1 + cancel_lru_locks mdc + cat /etc/hosts >> $tmp + lctl set_param -n mdc.*.stats=clear + + echo "Append to the same page" + cat /etc/hosts >> $dom + + local num=$(lctl get_param -n mdc.*.stats | \ + awk '/ost_read/ {print $2}') + local ra=$(lctl get_param -n mdc.*.stats | \ + awk '/req_active/ {print $2}') + local rw=$(lctl get_param -n mdc.*.stats | \ + awk '/req_waittime/ {print $2}') + + [ -z $num ] || error "$num READ RPC occured" + # Reply buffer can be adjusted for larger buffer by resend + echo "... DONE with $((ra - rw)) resends" + + # compare content + cmp $tmp $dom || error "file miscompare" + + cancel_lru_locks mdc + lctl set_param -n mdc.*.stats=clear + + echo "Open and read file" + cat $dom > /dev/null + local num=$(lctl get_param -n mdc.*.stats | \ + awk '/ost_read/ {print $2}') + local ra=$(lctl get_param -n mdc.*.stats | \ + awk '/req_active/ {print $2}') + local rw=$(lctl get_param -n mdc.*.stats | \ + awk '/req_waittime/ {print $2}') + + [ -z $num ] || error "$num READ RPC occured" + # Reply buffer can be adjusted for larger buffer by resend + echo "... DONE with $((ra - rw)) resends" + + # compare content + cmp $tmp $dom || error "file miscompare" + + return 0 +} +run_test 271e "DoM: read on open (30K file with reply buffer adjusting)" + +test_271f() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.57) ] && + skip "Need MDS version at least 2.10.57" && return + + local dom=$DIR/$tdir/dom + local tmp=$TMP/$tfile + trap "cleanup_271def_tests $tmp" EXIT + + mkdir -p $DIR/$tdir + + $LFS setstripe -E 1024K -L mdt $DIR/$tdir + + local mdtidx=$($GETSTRIPE -M $DIR/$tdir) + local facet=mds$((mdtidx + 1)) + + cancel_lru_locks mdc + dd if=/dev/urandom of=$tmp bs=200000 count=1 + dd if=$tmp of=$dom bs=200000 count=1 + cancel_lru_locks mdc + cat /etc/hosts >> $tmp + lctl set_param -n mdc.*.stats=clear + + echo "Append to the same page" + cat /etc/hosts >> $dom + local num=$(lctl get_param -n mdc.*.stats | \ + awk '/ost_read/ {print $2}') + local ra=$(lctl get_param -n mdc.*.stats | \ + awk '/req_active/ {print $2}') + local rw=$(lctl get_param -n mdc.*.stats | \ + awk '/req_waittime/ {print $2}') + + [ -z $num ] || error "$num READ RPC occured" + [ $ra == $rw ] || error "$((ra - rw)) resend occured" + echo "... DONE" + + # compare content + cmp $tmp $dom || error "file miscompare" + + cancel_lru_locks mdc + lctl set_param -n mdc.*.stats=clear + + echo "Open and read file" + cat $dom > /dev/null + local num=$(lctl get_param -n mdc.*.stats | \ + awk '/ost_read/ {print $2}') + local ra=$(lctl get_param -n mdc.*.stats | \ + awk '/req_active/ {print $2}') + local rw=$(lctl get_param -n mdc.*.stats | \ + awk '/req_waittime/ {print $2}') + + [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured" + [ $ra == $rw ] || error "$((ra - rw)) resend occured" + echo "... DONE" + + # compare content + cmp $tmp $dom || error "file miscompare" + + return 0 +} +run_test 271f "DoM: read on open (200K file and read tail)" + test_275() { remote_ost_nodsh && skip "remote OST with nodsh" [ $(lustre_version_code ost1) -lt $(version_code 2.10.57) ] && @@ -17920,6 +18242,73 @@ test_316() { } run_test 316 "lfs mv" +test_317() { + local trunc_sz + local grant_blk_size + + if [ "$(facet_fstype $facet)" == "zfs" ]; then + skip "LU-10370: no implementation for ZFS" && return + fi + + stack_trap "rm -f $DIR/$tfile" EXIT + grant_blk_size=$($LCTL get_param osc.$FSNAME*.import | + awk '/grant_block_size:/ { print $2; exit; }') + # + # Create File of size 5M. Truncate it to below size's and verify + # blocks count. + # + dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync || + error "Create file : $DIR/$tfile" + + for trunc_sz in 2097152 4097 4000 509 0; do + $TRUNCATE $DIR/$tfile $trunc_sz || + error "truncate $tfile to $trunc_sz failed" + local sz=$(stat --format=%s $DIR/$tfile) + local blk=$(stat --format=%b $DIR/$tfile) + local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) / + grant_blk_size) * 8)) + + if [[ $blk -ne $trunc_blk ]]; then + $(which stat) $DIR/$tfile + error "Expected Block $trunc_blk got $blk for $tfile" + fi + + $CHECKSTAT -s $trunc_sz $DIR/$tfile || + error "Expected Size $trunc_sz got $sz for $tfile" + done + + # + # sparse file test + # Create file with a hole and write actual two blocks. Block count + # must be 16. + # + dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \ + conv=fsync || error "Create file : $DIR/$tfile" + + # Calculate the final truncate size. + trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1))) + + # + # truncate to size $trunc_sz bytes. Strip the last block + # The block count must drop to 8 + # + $TRUNCATE $DIR/$tfile $trunc_sz || + error "truncate $tfile to $trunc_sz failed" + + local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile))) + sz=$(stat --format=%s $DIR/$tfile) + blk=$(stat --format=%b $DIR/$tfile) + + if [[ $blk -ne $trunc_bsz ]]; then + $(which stat) $DIR/$tfile + error "Expected Block $trunc_bsz got $blk for $tfile" + fi + + $CHECKSTAT -s $trunc_sz $DIR/$tfile || + error "Expected Size $trunc_sz got $sz for $tfile" +} +run_test 317 "Verify blocks get correctly update after truncate" + test_fake_rw() { local read_write=$1 if [ "$read_write" = "write" ]; then @@ -18500,6 +18889,49 @@ test_414() { } run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()" +test_415() { + [ $PARALLEL == "yes" ] && skip "skip parallel run" + [ $(lustre_version_code mds1) -lt $(version_code 2.11.52) ] && + skip "Need server version at least 2.11.52" + + # LU-11102 + local total + local setattr_pid + local start_time + local end_time + local duration + + total=500 + # this test may be slow on ZFS + [ "$(facet_fstype mds1)" == "zfs" ] && total=100 + + # though this test is designed for striped directory, let's test normal + # directory too since lock is always saved as CoS lock. + test_mkdir $DIR/$tdir || error "mkdir $tdir" + createmany -o $DIR/$tdir/$tfile. $total || error "createmany" + + ( + while true; do + touch $DIR/$tdir + done + ) & + setattr_pid=$! + + start_time=$(date +%s) + for i in $(seq $total); do + mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \ + > /dev/null + done + end_time=$(date +%s) + duration=$((end_time - start_time)) + + kill -9 $setattr_pid + + echo "rename $total files took $duration sec" + [ $duration -lt 100 ] || error "rename took $duration sec" +} +run_test 415 "lock revoke is not missing" + prep_801() { [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] || [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] && @@ -18731,6 +19163,8 @@ test_802() { [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] && skip "Need server version at least 2.9.55" + [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test" + mkdir $DIR/$tdir || error "(1) fail to mkdir" cp $LUSTRE/tests/test-framework.sh $DIR/$tdir/ || @@ -18946,6 +19380,182 @@ test_805() { } run_test 805 "ZFS can remove from full fs" +# Size-on-MDS test +check_lsom_data() +{ + local file=$1 + local size=$($LFS getsom -s $file) + local expect=$(stat -c %s $file) + + [[ $size == $expect ]] || + error "$file expected size: $expect, got: $size" + + local blocks=$($LFS getsom -b $file) + expect=$(stat -c %b $file) + [[ $blocks == $expect ]] || + error "$file expected blocks: $expect, got: $blocks" +} + +check_lsom_size() +{ + local size=$($LFS getsom -s $1) + local expect=$2 + + [[ $size == $expect ]] || + error "$file expected size: $expect, got: $size" +} + +test_806() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.52) ] && + skip "Need MDS version at least 2.11.52" && return + + local bs=1048576 + + touch $DIR/$tfile || error "touch $tfile failed" + + local save="$TMP/$TESTSUITE-$TESTNAME.parameters" + save_lustre_params client "llite.*.xattr_cache" > $save + lctl set_param llite.*.xattr_cache=0 + stack_trap "restore_lustre_params < $save" EXIT + + # single-threaded write + echo "Test SOM for single-threaded write" + dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 || + error "write $tfile failed" + check_lsom_size $DIR/$tfile $bs + + local num=32 + local size=$(($num * $bs)) + local offset=0 + local i + + echo "Test SOM for single client muti-threaded($num) write" + $TRUNCATE $DIR/$tfile 0 + for ((i = 0; i < $num; i++)); do + $MULTIOP $DIR/$tfile Oz${offset}w${bs}c & + local pids[$i]=$! + offset=$((offset + $bs)) + done + for (( i=0; i < $num; i++ )); do + wait ${pids[$i]} + done + check_lsom_size $DIR/$tfile $size + + $TRUNCATE $DIR/$tfile 0 + for ((i = 0; i < $num; i++)); do + offset=$((offset - $bs)) + $MULTIOP $DIR/$tfile Oz${offset}w${bs}c & + local pids[$i]=$! + done + for (( i=0; i < $num; i++ )); do + wait ${pids[$i]} + done + check_lsom_size $DIR/$tfile $size + + # multi-client wirtes + num=$(get_node_count ${CLIENTS//,/ }) + size=$(($num * $bs)) + offset=0 + i=0 + + echo "Test SOM for muti-client ($num) writes" + $TRUNCATE $DIR/$tfile 0 + for client in ${CLIENTS//,/ }; do + do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c & + local pids[$i]=$! + i=$((i + 1)) + offset=$((offset + $bs)) + done + for (( i=0; i < $num; i++ )); do + wait ${pids[$i]} + done + check_lsom_size $DIR/$tfile $offset + + i=0 + $TRUNCATE $DIR/$tfile 0 + for client in ${CLIENTS//,/ }; do + offset=$((offset - $bs)) + do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c & + local pids[$i]=$! + i=$((i + 1)) + done + for (( i=0; i < $num; i++ )); do + wait ${pids[$i]} + done + check_lsom_size $DIR/$tfile $size + + # verify truncate + echo "Test SOM for truncate" + $TRUNCATE $DIR/$tfile 1048576 + check_lsom_size $DIR/$tfile 1048576 + $TRUNCATE $DIR/$tfile 1234 + check_lsom_size $DIR/$tfile 1234 + + # verify SOM blocks count + echo "Verify SOM block count" + $TRUNCATE $DIR/$tfile 0 + $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc || + error "failed to write file $tfile" + check_lsom_data $DIR/$tfile +} +run_test 806 "Verify Lazy Size on MDS" + +test_807() { + [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.52) ] && + skip "Need MDS version at least 2.11.52" && return + + # Registration step + changelog_register || error "changelog_register failed" + local cl_user="${CL_USERS[$SINGLEMDS]%% *}" + changelog_users $SINGLEMDS | grep -q $cl_user || + error "User $cl_user not found in changelog_users" + + local save="$TMP/$TESTSUITE-$TESTNAME.parameters" + save_lustre_params client "llite.*.xattr_cache" > $save + lctl set_param llite.*.xattr_cache=0 + stack_trap "restore_lustre_params < $save" EXIT + + rm -rf $DIR/$tdir || error "rm $tdir failed" + mkdir -p $DIR/$tdir || error "mkdir $tdir failed" + touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed" + $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed" + $TRUNCATE $DIR/$tdir/trunc 1048576 || + error "truncate $tdir/trunc failed" + + local bs=1048576 + dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 || + error "write $tfile failed" + + # multi-client wirtes + local num=$(get_node_count ${CLIENTS//,/ }) + local offset=0 + local i=0 + + echo "Test SOM for muti-client ($num) writes" + touch $DIR/$tfile || error "touch $tfile failed" + $TRUNCATE $DIR/$tfile 0 + for client in ${CLIENTS//,/ }; do + do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c & + local pids[$i]=$! + i=$((i + 1)) + offset=$((offset + $bs)) + done + for (( i=0; i < $num; i++ )); do + wait ${pids[$i]} + done + + sleep 5 + $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT + check_lsom_data $DIR/$tdir/trunc + check_lsom_data $DIR/$tdir/single_dd + check_lsom_data $DIR/$tfile + + rm -rf $DIR/$tdir + # Deregistration step + changelog_deregister || error "changelog_deregister failed" +} +run_test 807 "verify LSOM syncing tool" + # # tests that do cleanup/setup should be run at the end #