X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fsanity-pfl.sh;h=30f2492b30f5ab5dfc8c834f86ac779f4387c883;hb=99d7a8ed43be126b2769ad8bb0b5350cd328ed7f;hp=372f9ba506880100c4b61a4af62ad14a58af0fbb;hpb=c75aa6c74cd86c69de893395735a6725571f11f4;p=fs%2Flustre-release.git diff --git a/lustre/tests/sanity-pfl.sh b/lustre/tests/sanity-pfl.sh index 372f9ba..30f2492 100644 --- a/lustre/tests/sanity-pfl.sh +++ b/lustre/tests/sanity-pfl.sh @@ -12,9 +12,6 @@ ONLY=${ONLY:-"$*"} ALWAYS_EXCEPT="$SANITY_PFL_EXCEPT" # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! -[ "$ALWAYS_EXCEPT$EXCEPT" ] && - echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT" - TMP=${TMP:-/tmp} CHECKSTAT=${CHECKSTAT:-"checkstat -v"} @@ -27,17 +24,23 @@ init_logging check_and_setup_lustre if [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.51) ]]; then - skip_env "Need MDS version at least 2.9.51" && exit + skip_env "Need MDS version at least 2.9.51" fi +[ "$ALWAYS_EXCEPT$EXCEPT" ] && + echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT" + build_test_filter [ $UID -eq 0 -a $RUNAS_ID -eq 0 ] && error "\$RUNAS_ID set to 0, but \$UID is also 0!" check_runas_id $RUNAS_ID $RUNAS_GID $RUNAS +assert_DIR +rm -rf $DIR/[Rdfs][0-9]* + test_0() { - [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return + [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" local comp_file=$DIR/$tdir/$tfile local rw_len=$((3 * 1024 * 1024)) # 3M @@ -109,7 +112,7 @@ test_2() { dd if=$comp_file of=/dev/null bs=1M count=2 > /dev/null 2>&1 || error "Read beyond component should short read, not fail" - $LFS setstripe --component-add -E 2M -c 1 $comp_file || + $LFS setstripe --component-add -E 2M -S 1M -c 1 $comp_file || error "Add component to $comp_file failed" comp_cnt=$($LFS getstripe --component-count $comp_file) @@ -156,7 +159,7 @@ test_3() { test_mkdir $DIR/$tdir rm -f $comp_file - $LFS setstripe -E 1M -E 64M -c 2 -E -1 -c 3 $comp_file || + $LFS setstripe -E 1M -S 1M -E 64M -c 2 -E -1 -c 3 $comp_file || error "Create $comp_file failed" local comp_cnt=$($LFS getstripe --component-count $comp_file) @@ -173,7 +176,7 @@ test_3() { rm -f $comp_file || error "Delete $comp_file failed" - $LFS setstripe -E 1M -E 16M -E -1 $comp_file || + $LFS setstripe -E 1M -S 1M -E 16M -E -1 $comp_file || error "Create second $comp_file failed" del_comp_and_verify $comp_file "^init" 1 0 @@ -184,7 +187,7 @@ test_3() { run_test 3 "Delete component from existing file" test_4() { - skip "Not supported in PFL" && return + skip "Not supported in PFL" # In PFL project, only LCME_FL_INIT is supported, and it can't # be altered by application. } @@ -304,7 +307,7 @@ test_7() { chmod 0777 $DIR/$tdir || error "chmod $tdir failed" local comp_file=$DIR/$tdir/$tfile - $RUNAS $LFS setstripe -E 1M -c 1 $comp_file || + $RUNAS $LFS setstripe -E 1M -S 1M -c 1 $comp_file || error "Create composite file $comp_file failed" $RUNAS $LFS setstripe --component-add -E 64M -c 4 $comp_file || @@ -342,7 +345,7 @@ test_9() { test_mkdir $DIR/$tdir rm -f $comp_file - $LFS setstripe -E 1m -S 1m -E 2M -c 1 $comp_file || + $LFS setstripe -E 1M -S 1M -E -1 -c 1 $comp_file || error "Create $comp_file failed" local comp_cnt=$($LFS getstripe --component-count $comp_file) @@ -374,16 +377,31 @@ component_dump() { test_10() { local parent=$DIR/$tdir - local root_layout=$(get_layout_param $MOUNT) + local root=$MOUNT + + save_layout_restore_at_exit $MOUNT rm -rf $parent - $LFS setstripe -d $MOUNT || error "clear root layout" + + # mount root on $MOUNT2 if FILESET is set + if [ -n "$FILESET" ]; then + FILESET="" mount_client $MOUNT2 || + error "mount $MOUNT2 fail" + root=$MOUNT2 + fi + + $LFS setstripe -d $root || error "clear root layout" # set root composite layout $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c2 -S 2M \ - -E -1 -c 4 -S 4M $MOUNT || + -E -1 -c 4 -S 4M $root || error "Set root layout failed" + if [ "$root" == "$MOUNT2" ]; then + umount_client $MOUNT2 || + error "umount $MOUNT2 fail" + fi + test_mkdir $parent # set a different layout for parent $LFS setstripe -E -1 -c 1 -S 1M $parent || @@ -413,7 +431,6 @@ test_10() { [ x$f2_expect != x$f2_entry ] && error "$parent/file2 does not inherite root layout" - $LFS setstripe $root_layout $MOUNT return 0 } run_test 10 "Inherit composite template from root" @@ -424,7 +441,7 @@ test_11() { rm -f $comp_file # only 1st component instantiated - $LFS setstripe -E 1m -E 2m -E 3m -E -1 $comp_file || + $LFS setstripe -E 1M -S 1M -E 2M -E 3M -E -1 $comp_file || error "Create $comp_file failed" local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid") @@ -451,7 +468,7 @@ test_11() { $TRUNCATE $comp_file $((1024*1024*1+1)) f2=$($LFS getstripe -I2 $comp_file | grep "l_fid") - [[ -z $f2 ]] && error "2: 2nd component uninstantiated" + [[ -z $f2 ]] && error "3: 2nd component uninstantiated" f3=$($LFS getstripe -I3 $comp_file | grep "l_fid") [[ -z $f3 ]] && error "3: 3rd component uninstantiated" f4=$($LFS getstripe -I4 $comp_file | grep "l_fid") @@ -471,15 +488,15 @@ test_11() { run_test 11 "Verify component instantiation with write/truncate" test_12() { - [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs" && return + [ $OSTCOUNT -lt 3 ] && skip "needs >= 3 OSTs" local file=$DIR/$tdir/$tfile test_mkdir $DIR/$tdir rm -f $file # specify ost list for component - $LFS setstripe -E1m -c2 -o0,1 -E2m -c2 -o1,2 -E3m -c2 -o2,1 \ - -E4m -c1 -i2 -E-1 $file || + $LFS setstripe -E 1M -S 1M -c 2 -o 0,1 -E 2M -c 2 -o 1,2 \ + -E 3M -c 2 -o 2,1 -E 4M -c 1 -i 2 -E -1 $file || error "Create $file failed" # clear lod component cache @@ -512,7 +529,7 @@ test_12() { run_test 12 "Verify ost list specification" test_13() { # LU-9311 - [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs" && return + [ $OSTCOUNT -lt 8 ] && skip "needs >= 8 OSTs" local file=$DIR/$tfile local dd_count=4 @@ -520,7 +537,7 @@ test_13() { # LU-9311 local real_size rm -f $file - $LFS setstripe -E 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file || + $LFS setstripe -E 1M -S 1M -c 1 -E 2M -c 2 -E -1 -c -1 -i 1 $file || error "Create $file failed" dd if=/dev/zero of=$file bs=1M count=$dd_count real_size=$(stat -c %s $file) @@ -532,7 +549,7 @@ test_13() { # LU-9311 run_test 13 "shouldn't reprocess granted resent request" test_14() { - [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return + [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" local file=$DIR/$tdir/$tfile test_mkdir -p $DIR/$tdir rm -f $file @@ -580,10 +597,10 @@ test_15() { $LFS setstripe -d $parent || error "delete default layout" - $LFS setstripe -E 1M -E 10M -E eof $parent/f1 || error "create f1" + $LFS setstripe -E 1M -S 1M -E 10M -E eof $parent/f1 || error "create f1" $LFS setstripe -E 4M -E 20M -E eof $parent/f2 || error "create f2" test_mkdir $parent/subdir - $LFS setstripe -E 6M -E 30M -E eof $parent/subdir || + $LFS setstripe -E 6M -S 1M -E 30M -E eof $parent/subdir || error "setstripe to subdir" $LFS setstripe -E 8M -E eof $parent/subdir/f3 || error "create f3" $LFS setstripe -c 1 $parent/subdir/f4 || error "create f4" @@ -636,13 +653,62 @@ test_15() { } run_test 15 "Verify component options for lfs find" +test_16() { + [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" + + local file=$DIR/$tdir/$tfile + local dir=$DIR/$tdir/dir + local temp=$DIR/$tdir/template + rm -rf $DIR/$tdir + test_mkdir $DIR/$tdir + + ##################################################################### + # 1. PFL file + # set stripe for source file + $LFS setstripe -E1m -S 1M -c2 -o0,1 -E2m -c2 -E3m -o1,0 -E4m -c1 -E-1 \ + $file || error "Create $file failed" + + echo "1. PFL file" + verify_yaml_layout $file $file.copy $temp "1. PFL file" + + ##################################################################### + # 2. plain file + # set stripe for source file + rm -f $file + $LFS setstripe -c2 -o0,1 -i1 $file || error "Create $file failed" + + rm -f $file.copy + echo "2. plain file" + verify_yaml_layout $file $file.copy $temp "2. plain file" + + ##################################################################### + # 3. PFL dir + # set stripe for source dir + test_mkdir $dir + $LFS setstripe -E1m -S 1M -c2 -E2m -c1 -E-1 $dir || + error "setstripe $dir failed" + + test_mkdir $dir.copy + echo "3. PFL dir" + verify_yaml_layout $dir $dir.copy $temp.dir "3. PFL dir" + + ##################################################################### + # 4. plain dir + # set stripe for source dir + $LFS setstripe -c2 -i-1 $dir || error "setstripe $dir failed" + + echo "4. plain dir" + verify_yaml_layout $dir $dir.copy $temp.dir "4. plain dir" +} +run_test 16 "Verify setstripe/getstripe with YAML config file" + test_17() { - [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return + [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" local file=$DIR/$tdir/$tfile test_mkdir -p $DIR/$tdir rm -f $file - $LFS setstripe -E1m -E2m -c2 -E-1 -c-1 $file || + $LFS setstripe -E 1M -S 1M -E 2M -c 2 -E -1 -c -1 $file || error "Create $file failed" local s1=$($LFS getstripe -I1 -v $file | awk '/lcme_size:/{print $2}') @@ -672,6 +738,80 @@ test_17() { } run_test 17 "Verify LOVEA grows with more component inited" +check_distribution() { + local file=$1 + local objs + local ave + local obj_min_one=$((OSTCOUNT - 1)) + + objs=$($LFS getstripe $file | + awk '/l_ost_idx:/ { print $5 }' | wc -l) + let ave=$((objs / OSTCOUNT)) + + # collect objects per OST distribution + $LFS getstripe $file | awk '/l_ost_idx:/ { print $5 }' | tr -d "," | + (inuse=( $(for i in $(seq 0 $obj_min_one); do echo 0; done) ) + while read O; do + let inuse[$O]=$((1 + ${inuse[$O]})) + done; + + # verify object distribution varies no more than +-1 + for idx in $(seq 0 $obj_min_one); do + let dif=$((${inuse[$idx]} - ave)) + let dif=${dif#-} + if [ "$dif" -gt 1 ]; then + echo "OST${idx}: ${inuse[$idx]} objects" + error "bad distribution on OST${idx}" + fi + done) +} + +test_18() { + local file1=$DIR/${tfile}-1 + local file2=$DIR/${tfile}-2 + local file3=$DIR/${tfile}-3 + + rm -f $file1 $file2 $file3 + + $LFS setstripe -E 1m -S 1m $file1 || + error "Create $file1 failed" + $LFS setstripe -E 1m -S 1m $file2 || + error "Create $file2 failed" + $LFS setstripe -E 1m -S 1m $file3 || + error "Create $file3 failed" + + local objs=$((OSTCOUNT+1)) + for comp in $(seq 1 $OSTCOUNT); do + $LFS setstripe --component-add -E $((comp+1))M -c 1 $file1 || + error "Add component to $file1 failed 2" + $LFS setstripe --component-add -E $((comp+1))M -c 1 $file2 || + error "Add component to $file2 failed 2" + $LFS setstripe --component-add -E $((comp+1))M -c 1 $file3 || + error "Add component to $file3 failed 2" + done + + $LFS setstripe --component-add -E -1 -c -1 $file1 || + error "Add component to $file1 failed 3" + $LFS setstripe --component-add -E -1 -c -1 $file2 || + error "Add component to $file2 failed 3" + $LFS setstripe --component-add -E -1 -c -1 $file3 || + error "Add component to $file3 failed 3" + + # Instantiate all components + dd if=/dev/urandom of=$file1 bs=1M count=$((objs+1)) || + error "dd failed for $file1" + dd if=/dev/urandom of=$file2 bs=1M count=$((objs+1)) || + error "dd failed for $file2" + dd if=/dev/urandom of=$file3 bs=1M count=$((objs+1)) || + error "dd failed for $file3" + + check_distribution $file1 + check_distribution $file2 + check_distribution $file3 + +} +run_test 18 "check component distribution" + complete $SECONDS check_and_cleanup_lustre exit_status