From 93452566b13360c76852b3d7ae3daa08912925f4 Mon Sep 17 00:00:00 2001 From: Fan Yong Date: Thu, 9 Oct 2014 17:36:11 +0800 Subject: [PATCH] LU-6033 tests: inject failure before counting the objects Some test cases need to inject some failure stub on OST that will be triggered when creating the OST objects. For that, we need to calculate how many objects to be created to guarantee that all the pre-created OST-objects on the MDT can be exhausted. Under some race cases, the MDT may be in pre-creating OST-objects and finished the pre-creation just after the precreated_ost_obj_count() returning zero to the caller but before the caller injecting the failure stub on the OST. Then the subsequent failure injection will be useless. To resolve such trouble, the caller of precreated_ost_obj_count() should inject related failure stub before calculating the pre-created OST-objects count. Signed-off-by: Fan Yong Change-Id: I01c98c0eb67aa0974c3223356557ae76f23ddb77 Reviewed-on: http://review.whamcloud.com/13098 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bobi Jam Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin --- lustre/tests/sanity-lfsck.sh | 4 ++-- lustre/tests/sanity-scrub.sh | 13 ++++++------- lustre/tests/test-framework.sh | 5 ++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lustre/tests/sanity-lfsck.sh b/lustre/tests/sanity-lfsck.sh index d725d64..2d971ce 100644 --- a/lustre/tests/sanity-lfsck.sh +++ b/lustre/tests/sanity-lfsck.sh @@ -1419,11 +1419,11 @@ test_14() { check_mount_and_prep $LFS setstripe -c 1 -i 0 $DIR/$tdir - local count=$(precreated_ost_obj_count 0 0) - echo "Inject failure stub to simulate dangling referenced MDT-object" #define OBD_FAIL_LFSCK_DANGLING 0x1610 do_facet ost1 $LCTL set_param fail_loc=0x1610 + local count=$(precreated_ost_obj_count 0 0) + createmany -o $DIR/$tdir/f $((count + 31)) touch $DIR/$tdir/guard do_facet ost1 $LCTL set_param fail_loc=0 diff --git a/lustre/tests/sanity-scrub.sh b/lustre/tests/sanity-scrub.sh index 14440d9..79e1437 100644 --- a/lustre/tests/sanity-scrub.sh +++ b/lustre/tests/sanity-scrub.sh @@ -987,12 +987,11 @@ test_12() { check_mount_and_prep $SETSTRIPE -c 1 -i 0 $DIR/$tdir - local count=$(precreated_ost_obj_count 0 0) - #define OBD_FAIL_OSD_COMPAT_INVALID_ENTRY 0x195 do_facet ost1 $LCTL set_param fail_loc=0x195 - createmany -o $DIR/$tdir/f $((count + 32)) + local count=$(precreated_ost_obj_count 0 0) + createmany -o $DIR/$tdir/f $((count + 32)) umount_client $MOUNT || error "(1) Fail to stop client!" stop ost1 || error "(2) Fail to stop ost1" @@ -1026,10 +1025,10 @@ test_13() { check_mount_and_prep $SETSTRIPE -c 1 -i 0 $DIR/$tdir - local count=$(precreated_ost_obj_count 0 0) - #define OBD_FAIL_OSD_COMPAT_NO_ENTRY 0x196 do_facet ost1 $LCTL set_param fail_loc=0x196 + local count=$(precreated_ost_obj_count 0 0) + createmany -o $DIR/$tdir/f $((count + 32)) do_facet ost1 $LCTL set_param fail_loc=0 @@ -1059,10 +1058,10 @@ test_14() { check_mount_and_prep $SETSTRIPE -c 1 -i 0 $DIR/$tdir - local count=$(precreated_ost_obj_count 0 0) - #define OBD_FAIL_OSD_COMPAT_NO_ENTRY 0x196 do_facet ost1 $LCTL set_param fail_loc=0x196 + local count=$(precreated_ost_obj_count 0 0) + createmany -o $DIR/$tdir/f $((count + 32)) do_facet ost1 $LCTL set_param fail_loc=0 diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 3388723..6d52df9 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -6997,11 +6997,10 @@ precreated_ost_obj_count() local mdt_name="MDT$(printf '%04x' $mdt_idx)" local ost_name="OST$(printf '%04x' $ost_idx)" local proc_path="${FSNAME}-${ost_name}-osc-${mdt_name}" - local last_id=$(do_facet mds${mdt_idx} lctl get_param -n \ + local last_id=$(do_facet mds$((mdt_idx + 1)) lctl get_param -n \ osp.$proc_path.prealloc_last_id) - local next_id=$(do_facet mds${mdt_idx} lctl get_param -n \ + local next_id=$(do_facet mds$((mdt_idx + 1)) lctl get_param -n \ osp.$proc_path.prealloc_next_id) - echo $((last_id - next_id + 1)) } -- 1.8.3.1