Whamcloud - gitweb
LU-11663 osd-zfs: write partial pages with correct offset
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 18ad4eb..500d660 100755 (executable)
@@ -15468,6 +15468,56 @@ test_230j() {
 }
 run_test 230j "DoM file data not changed after dir migration"
 
+test_230k() {
+       [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs"
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
+               skip "Need MDS version at least 2.11.56"
+
+       local total=20
+       local files_on_starting_mdt=0
+
+       $LFS mkdir -i -1 -c 2 $DIR/$tdir || error "mkdir failed"
+       $LFS getdirstripe $DIR/$tdir
+       for i in $(seq $total); do
+               echo $((i*i - i)) > $DIR/$tdir/$tfile.$i || error "write failed"
+               [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
+                       files_on_starting_mdt=$((files_on_starting_mdt + 1))
+       done
+
+       echo "$files_on_starting_mdt files on MDT0"
+
+       $LFS migrate -m 1,3 $DIR/$tdir || error "migrate -m 1,3 failed"
+       $LFS getdirstripe $DIR/$tdir
+
+       files_on_starting_mdt=0
+       for i in $(seq $total); do
+               $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
+                       error "file $tfile.$i mismatch after migration"
+               [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 1 ]] &&
+                       files_on_starting_mdt=$((files_on_starting_mdt + 1))
+       done
+
+       echo "$files_on_starting_mdt files on MDT1 after migration"
+       [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT1"
+
+       $LFS migrate -m 0 -c 2 $DIR/$tdir || error "migrate -m 0 -c 2 failed"
+       $LFS getdirstripe $DIR/$tdir
+
+       files_on_starting_mdt=0
+       for i in $(seq $total); do
+               $(echo $((i*i - i)) | cmp $DIR/$tdir/$tfile.$i -) ||
+                       error "file $tfile.$i mismatch after 2nd migration"
+               [[ $($LFS getstripe -m $DIR/$tdir/$tfile.$i) -eq 0 ]] &&
+                       files_on_starting_mdt=$((files_on_starting_mdt + 1))
+       done
+
+       echo "$files_on_starting_mdt files on MDT0 after 2nd migration"
+       [[ $files_on_starting_mdt -eq $total ]] && error "all files on MDT0"
+
+       true
+}
+run_test 230k "file data not changed after dir migration"
+
 test_231a()
 {
        # For simplicity this test assumes that max_pages_per_rpc
@@ -19944,6 +19994,51 @@ test_808() {
 }
 run_test 808 "Check trusted.som xattr not logged in Changelogs"
 
+check_som_nodata()
+{
+       $LFS getsom $1
+       [[ $? -eq 61 ]] || error "DoM-only file $1 has SOM xattr"
+}
+
+test_809() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
+               skip "Need MDS version at least 2.11.56" && return
+
+       $LFS setstripe -E 1M -L mdt $DIR/$tfile ||
+               error "failed to create DoM-only file $DIR/$tfile"
+       touch $DIR/$tfile || error "touch $tfile failed"
+       check_som_nodata $DIR/$tfile
+
+       dd if=/dev/zero of=$DIR/$tfile bs=2048 count=1 ||
+               error "write $tfile failed"
+       check_som_nodata $DIR/$tfile
+
+       $TRUNCATE $DIR/$tfile 1234
+       check_som_nodata $DIR/$tfile
+
+       $TRUNCATE $DIR/$tfile 4097
+       check_som_nodata $DIR/$file
+}
+run_test 809 "Verify no SOM xattr store for DoM-only files"
+
+test_810() {
+       local ORIG
+       local CSUM
+
+       # t10 seem to dislike partial pages
+       lctl set_param osc.*.checksum_type=adler
+       lctl set_param fail_loc=0x411
+       dd if=/dev/urandom of=$DIR/$tfile bs=10240 count=2
+       ORIG=$(md5sum $DIR/$tfile)
+       lctl set_param ldlm.namespaces.*osc*.lru_size=clear
+       CSUM=$(md5sum $DIR/$tfile)
+       set_checksum_type adler
+       if [ "$ORIG" != "$CSUM" ]; then
+               error "$ORIG != $CSUM"
+       fi
+}
+run_test 810 "partial page writes on ZFS (LU-11663)"
+
 #
 # tests that do cleanup/setup should be run at the end
 #