Whamcloud - gitweb
LU-9166 mdt: Add trailing newlines to proc files
[fs/lustre-release.git] / lustre / tests / sanity.sh
index f66a8c8..146525c 100755 (executable)
@@ -1909,6 +1909,9 @@ check_seq_oid()
                local ff_pstripe
                if echo $ff_parent | grep -q 'stripe='; then
                        ff_pstripe=$(echo $ff_parent | sed -e 's/.*stripe=//')
+                       if echo $ff_pstripe | grep -q 'stripe_size='; then
+                               ff_pstripe=$(echo $ff_pstripe | cut -d' ' -f1)
+                       fi
                else
                        #
                        # $LL_DECODE_FILTER_FID does not print "stripe="; look
@@ -1919,6 +1922,15 @@ check_seq_oid()
                                sed -e 's/\]//')
                fi
 
+               if echo $ff_parent | grep -q 'stripe_count='; then
+                       local ff_scnt=$(echo $ff_parent |
+                                       sed -e 's/.*stripe_count=//' |
+                                       cut -d' ' -f1)
+
+                       [ $lmm_count -eq $ff_scnt ] ||
+                               error "FF stripe count $lmm_count != $ff_scnt"
+               fi
+
                 # compare lmm_seq and filter_fid->ff_parent.f_seq
                 [ $ff_pseq = $lmm_seq ] ||
                         error "FF parent SEQ $ff_pseq != $lmm_seq"
@@ -2053,7 +2065,7 @@ test_27D() {
 
        local skip27D
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
-               skip27D = "-s 29"
+               skip27D = "-s 29,30,31"
        llapi_layout_test -d$DIR/$tdir -p$POOL -o$OSTCOUNT $skip27D ||
                error "llapi_layout_test failed"
 
@@ -4549,6 +4561,30 @@ test_56b() {
 }
 run_test 56b "check $LFS getdirstripe"
 
+test_56c() {
+       local ost_idx=0
+       local ost_name=$(ostname_from_index $ost_idx)
+
+       local old_status=$(ost_dev_status $ost_idx)
+       [[ -z "$old_status" ]] ||
+               { skip_env "OST $ost_name is in $old_status status"; return 0; }
+
+       do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
+       sleep_maxage
+
+       local new_status=$(ost_dev_status $ost_idx)
+       [[ "$new_status" = "D" ]] ||
+               error "OST $ost_name is in status of '$new_status', not 'D'"
+
+       do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=0
+       sleep_maxage
+
+       new_status=$(ost_dev_status $ost_idx)
+       [[ -z "$new_status" ]] ||
+               error "OST $ost_name is in status of '$new_status', not ''"
+}
+run_test 56c "check 'lfs df' showing device status"
+
 NUMFILES=3
 NUMDIRS=3
 setup_56() {
@@ -5378,7 +5414,23 @@ test_60a() {
        start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "start mgs failed"
        $pass || error "test failed, see FAILED test_60a messages for specifics"
 }
-run_test 60a "llog_test run from kernel module and test llog_reader =========="
+run_test 60a "llog_test run from kernel module and test llog_reader"
+
+test_60aa() {
+       # test old logid format
+       if [ $(lustre_version_code mgs) -le $(version_code 3.1.53) ]; then
+               do_facet mgs $LCTL dl | grep MGS
+               do_facet mgs "$LCTL --device %MGS llog_print \\\\\\\$$FSNAME-client" ||
+                       error "old llog_print failed"
+       fi
+
+       # test new logid format
+       if [ $(lustre_version_code mgs) -ge $(version_code 2.9.53) ]; then
+               do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
+                       error "new llog_print failed"
+       fi
+}
+run_test 60aa "llog_print works with FIDs and simple names"
 
 test_60b() { # bug 6411
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
@@ -8949,6 +9001,9 @@ check_mds_dmesg() {
 }
 
 test_129() {
+       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
+               { skip "Need MDS version with at least 2.5.56"; return 0; }
+
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
                skip "Only applicable to ldiskfs-based MDTs"
@@ -9749,6 +9804,34 @@ test_133g() {
 }
 run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
 
+test_133h() {
+       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
+               skip "Need MDS version at least 2.9.54" && return
+
+       local facet
+       for facet in client mds1 ost1; do
+               local facet_proc_dirs=$(do_facet $facet \
+                                       \\\ls -d $proc_regexp 2> /dev/null)
+               [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
+               echo "${facet}_proc_dirs='$facet_proc_dirs'"
+               # Get the list of files that are missing the terminating newline
+               local missing=($(do_facet $facet \
+                       find ${facet_proc_dirs} -type f \|              \
+                               while read F\; do                       \
+                                       awk -v FS='\v' -v RS='\v\v'     \
+                                       "'END { if(NR>0 &&              \
+                                       \\\$NF !~ /.*\\\n\$/)           \
+                                               print FILENAME}'"       \
+                                       '\$F'\;                         \
+                               done 2>/dev/null))
+               [ ${#missing[*]} -eq 0 ] ||
+                       error "files do not end with newline: ${missing[*]}"
+       done
+}
+run_test 133h "Proc files should end with newlines"
+
 test_134a() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
@@ -11187,6 +11270,55 @@ test_161c() {
 }
 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
 
+test_161d() {
+       local user
+       local pid
+       local fid
+
+       # cleanup previous run
+       rm -rf $DIR/$tdir/$tfile
+
+       user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
+               changelog_register -n)
+       [[ $? -eq 0 ]] || error "changelog_register failed"
+
+       # work in a standalone dir to avoid locking on $DIR/$MOUNT to
+       # interfer with $MOUNT/.lustre/fid/ access
+       mkdir $DIR/$tdir
+       [[ $? -eq 0 ]] || error "mkdir failed"
+
+       #define OBD_FAIL_LLITE_CREATE_NODE_PAUSE 0x140c | OBD_FAIL_ONCE
+       $LCTL set_param fail_loc=0x8000140c
+       # 5s pause
+       $LCTL set_param fail_val=5
+
+       # create file
+       echo foofoo > $DIR/$tdir/$tfile &
+       pid=$!
+
+       # wait for create to be delayed
+       sleep 2
+
+       ps -p $pid
+       [[ $? -eq 0 ]] || error "create should be blocked"
+
+       local tempfile=$(mktemp)
+       fid=$(changelog_extract_field $MDT0 "CREAT" "$tfile" "t=")
+       cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
+       # some delay may occur during ChangeLog publishing and file read just
+       # above, that could allow file write to happen finally
+       [[ -s $tempfile ]] && echo "file should be empty"
+
+       $LCTL set_param fail_loc=0
+
+       wait $pid
+       [[ $? -eq 0 ]] || error "create failed"
+
+       $LFS changelog_clear $MDT0 $user 0
+       do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $user
+}
+run_test 161d "create with concurrent .lustre/fid access"
+
 check_path() {
     local expected=$1
     shift
@@ -14625,7 +14757,11 @@ test_striped_dir() {
                error "getdirstripe failed"
        stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
        if [ "$stripe_count" != "2" ]; then
-               error "stripe_count is $stripe_count, expect 2"
+               error "1:stripe_count is $stripe_count, expect 2"
+       fi
+       stripe_count=$($LFS getdirstripe -T $DIR/$tdir/striped_dir)
+       if [ "$stripe_count" != "2" ]; then
+               error "2:stripe_count is $stripe_count, expect 2"
        fi
 
        stripe_index=$($LFS getdirstripe -i $DIR/$tdir/striped_dir)
@@ -14791,13 +14927,13 @@ test_300e() {
        mkdir $DIR/$tdir/striped_dir/dir_c
 
        $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
-               error "set striped dir under striped dir error"
+               error "set striped adir under striped dir error"
 
-       $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_b ||
-               error "set striped dir under striped dir error"
+       $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
+               error "set striped bdir under striped dir error"
 
        $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
-               error "set striped dir under striped dir error"
+               error "set striped cdir under striped dir error"
 
        mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
                error "rename dir under striped dir fails"
@@ -15001,11 +15137,23 @@ test_300i() {
        createmany -o $DIR/$tdir/striped_dir/f- 10 ||
                error "create files under striped dir failed"
 
+       $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir ||
+               error "set striped hashdir error"
+
+       $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/hashdir/d0 ||
+               error "create dir0 under hash dir failed"
+       $LFS setdirstripe -i0 -c$MDSCOUNT -H fnv_1a_64 $DIR/$tdir/hashdir/d1 ||
+               error "create dir1 under hash dir failed"
+
        # unfortunately, we need to umount to clear dir layout cache for now
        # once we fully implement dir layout, we can drop this
        umount_client $MOUNT || error "umount failed"
        mount_client $MOUNT || error "mount failed"
 
+       $LFS find -H fnv_1a_64 $DIR/$tdir/hashdir
+       local dircnt=$($LFS find -H fnv_1a_64 $DIR/$tdir/hashdir | wc -l)
+       [ $dircnt -eq 1 ] || error "lfs find striped dir got:$dircnt,except:1"
+
        #set the stripe to be unknown hash type
        #define OBD_FAIL_UNKNOWN_LMV_STRIPE     0x1901
        $LCTL set_param fail_loc=0x1901