Whamcloud - gitweb
LU-9771 flr: test script for mirrored file write 93/29093/14
authorJinshan Xiong <jinshan.xiong@intel.com>
Sun, 30 Jul 2017 01:10:58 +0000 (18:10 -0700)
committerJinshan Xiong <jinshan.xiong@intel.com>
Mon, 20 Nov 2017 21:50:22 +0000 (21:50 +0000)
Add a test case to verify that writing to mirrored files work.

Test-Parameters: testlist=sanity-flr

Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Change-Id: I98d97cc084554c769f2db5a3ef8a462d8db5dfce
Reviewed-on: https://review.whamcloud.com/29093
Reviewed-by: Jian Yu <jian.yu@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
lustre/tests/sanity-flr.sh

index 8e069e1..2318044 100644 (file)
@@ -469,6 +469,101 @@ test_34b() {
 }
 run_test 34b "read mirrored file with multiple components"
 
+test_35() {
+       local tf=$DIR/$tfile
+
+       $LFS setstripe -E eof $tf
+
+       # add an out-of-sync mirror to the file
+       $LFS setstripe --component-add --mirror -c 2 $tf
+
+       $MULTIOP $tf oO_WRONLY:c ||
+               error "write open a mirrored file failed"
+
+       # truncate file should return error
+       $TRUNCATE $tf 100 || error "error truncating a mirrored file"
+}
+run_test 35 "allow to write to mirrored files"
+
+verify_ost_layout_version() {
+       local tf=$1
+
+       # get file layout version
+       local flv=$($LFS getstripe $tf | awk '/lcm_layout_gen/{print $2}')
+
+       # layout version from OST objects
+       local olv=$($MULTIOP $tf oXc | awk '/ostlayoutversion/{print $2}')
+
+       [ $flv -eq $olv ] || error "layout version mismatch: $flv vs. $olv"
+}
+
+create_file_36() {
+       local tf
+
+       for tf in "$@"; do
+               $LFS setstripe -E 1M -E 2M -E 4M -E eof -c -1 $tf
+               $LFS setstripe -E 3M -E 6M -E eof -c -1 $tf-tmp
+
+               $LFS setstripe --component-add --mirror=$tf-tmp $tf
+               rm -f $tf-tmp
+       done
+}
+
+test_36() {
+       local tf=$DIR/$tfile
+
+       create_file_36 $tf $tf-2 $tf-3
+
+       [ $(get_mirror_ids $tf) -gt 1 ] || error "wrong mirror count"
+
+       # test case 1 - check file write and verify layout version
+       $MULTIOP $tf oO_WRONLY:c ||
+               error "write open a mirrored file failed"
+
+       # write open file should not return error
+       $MULTIOP $tf oO_WRONLY:w1024Yc || error "write mirrored file error"
+
+       # instantiate components should work
+       dd if=/dev/zero of=$tf bs=1M count=12 || error "write file error"
+
+       # verify OST layout version
+       verify_ost_layout_version $tf
+
+       # test case 2
+       local mds_idx=mds$(($($LFS getstripe -M $tf-2) + 1))
+
+       local delay_sec=10
+       do_facet $mds_idx $LCTL set_param fail_val=$delay_sec
+
+       #define OBD_FAIL_FLR_LV_DELAY 0x1A01
+       do_facet $mds_idx $LCTL set_param fail_loc=0x1A01
+
+       # write should take at least $fail_loc seconds and succeed
+       local st=$(date +%s)
+       $MULTIOP $tf-2 oO_WRONLY:w1024Yc || error "write mirrored file error"
+
+       [ $(date +%s) -ge $((st+delay_sec)) ] ||
+               error "write finished before layout version is transmitted"
+
+       # verify OST layout version
+       verify_ost_layout_version $tf
+
+       do_facet $mds_idx $LCTL set_param fail_loc=0
+
+       # test case 3
+       mds_idx=mds$(($($LFS getstripe -M $tf-3) + 1))
+
+       #define OBD_FAIL_FLR_LV_INC 0x1A02
+       do_facet $mds_idx $LCTL set_param fail_loc=0x1A02
+
+       # write open file should return error
+       $MULTIOP $tf-3 oO_WRONLY:O_SYNC:w1024c &&
+               error "write a mirrored file succeeded" || true
+
+       do_facet $mds_idx $LCTL set_param fail_loc=0
+}
+run_test 36 "write to mirrored files"
+
 complete $SECONDS
 check_and_cleanup_lustre
 exit_status