From bf7bf5f81af2d60aeb744a62bd8187d70e90fdff Mon Sep 17 00:00:00 2001 From: Johann Lombardi Date: Fri, 25 Jun 2010 18:36:54 +0200 Subject: [PATCH] b=17485 add regression test to verify that MDS does not allocate some objid twice o=hongchao i=johann i=grev --- lustre/tests/replay-single.sh | 75 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh index dfbae3f..54b157b 100644 --- a/lustre/tests/replay-single.sh +++ b/lustre/tests/replay-single.sh @@ -2192,6 +2192,81 @@ test_86() { } run_test 86 "umount server after clear nid_stats should not hit LBUG" +test_87() { #bug 17485 + mkdir -p $DIR/$tdir + mkdir -p $TMP/$tdir + + lfs setstripe $DIR/$tdir -o 0 -c 1 || error "setstripe" + + replay_barrier ost1 + replay_barrier mds + + # exhaust precreations on ost1 + local OST=$(lfs osts | grep ^0": " | awk '{print $2}' | sed -e 's/_UUID$//') + local mdtosc=$(get_mdtosc_proc_path $OST) + local last_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_last_id) + local next_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_next_id) + echo "before test: last_id = $last_id, next_id = $next_id" + + echo "Creating to objid $last_id on ost $OST..." + createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) + + #create some files to use some uncommitted objids + last_id=$(($last_id + 1)) + createmany -o $DIR/$tdir/f-%d $last_id 8 + + last_id2=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_last_id) + next_id2=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_next_id) + echo "before recovery: last_id = $last_id2, next_id = $next_id2" + + shutdown_facet mds + shutdown_facet ost1 + + reboot_facet mds + change_active mds + wait_for mds + mount_facet mds || error "Restart of mds failed" + + reboot_facet ost1 + change_active ost1 + wait_for ost1 + mount_facet ost1 || error "Restart of ost1 failed" + + clients_up + + last_id2=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_last_id) + next_id2=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_next_id) + echo "after recovery: last_id = $last_id2, next_id = $next_id2" + + # create new files, which should use new objids, and ensure the orphan + # cleanup phase for ost1 is completed at the same time + for i in `seq 8`; do + file_id=$(($last_id + 10 + $i)) + dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128 + done + + # if the objids were not recreated, then "ls" will failed for -ENOENT + ls -l $DIR/$tdir/* || error "can't get the status of precreated files" + + local file_id + # write into previously created files + for i in `seq 8`; do + file_id=$(($last_id + $i)) + dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128 + cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/ + done + + # compare the content + for i in `seq 8`; do + file_id=$(($last_id + $i)) + cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id || error "the content" \ + "of file is modified!" + done + + rm -fr $TMP/$tdir +} +run_test 87 "MDS should not assign same objid to different files " + equals_msg `basename $0`: test complete, cleaning up check_and_cleanup_lustre [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true -- 1.8.3.1