+test_88() { #bug 17485
+ mkdir -p $DIR/$tdir
+ mkdir -p $TMP/$tdir
+
+ $SETSTRIPE -i 0 -c 1 $DIR/$tdir || error "$SETSTRIPE"
+
+ replay_barrier ost1
+ replay_barrier $SINGLEMDS
+
+ # exhaust precreations on ost1
+ local OST=$(ostname_from_index 0)
+ local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
+ local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
+ local next_id=$(do_facet $SINGLEMDS 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 $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
+ next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
+ echo "before recovery: last_id = $last_id2, next_id = $next_id2"
+
+ # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
+ # it has to take care about the affected facets, bug20407
+ local affected_mds1=$(affected_facets mds1)
+ local affected_ost1=$(affected_facets ost1)
+
+ shutdown_facet $SINGLEMDS
+ shutdown_facet ost1
+
+ reboot_facet $SINGLEMDS
+ change_active $affected_mds1
+ wait_for_facet $affected_mds1
+ mount_facets $affected_mds1 || error "Restart of mds failed"
+
+ reboot_facet ost1
+ change_active $affected_ost1
+ wait_for_facet $affected_ost1
+ mount_facets $affected_ost1 || error "Restart of ost1 failed"
+
+ clients_up
+
+ last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
+ next_id2=$(do_facet $SINGLEMDS 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 88 "MDS should not assign same objid to different files "
+
+test_89() {
+ cancel_lru_locks osc
+ mkdir -p $DIR/$tdir
+ rm -f $DIR/$tdir/$tfile
+ wait_mds_ost_sync
+ wait_delete_completed
+ BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
+ $SETSTRIPE -i 0 -c 1 $DIR/$tdir/$tfile
+ dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
+ sync
+ stop ost1
+ facet_failover $SINGLEMDS
+ rm $DIR/$tdir/$tfile
+ umount $MOUNT
+ mount_facet ost1
+ zconf_mount $(hostname) $MOUNT
+ client_up || return 1
+ wait_mds_ost_sync
+ wait_delete_completed
+ BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
+ [ $((BLOCKS2 - BLOCKS1)) -le 4 ] || \
+ error $((BLOCKS2 - BLOCKS1)) blocks leaked
+}
+
+run_test 89 "no disk space leak on late ost connection"
+
+cleanup_90 () {
+ local facet=$1
+ trap 0
+ reboot_facet $facet
+ change_active $facet
+ wait_for_facet $facet
+ mount_facet $facet || error "Restart of $facet failed"
+ clients_up
+}
+
+test_90() { # bug 19494
+ local dir=$DIR/$tdir
+ local ostfail=$(get_random_entry $(get_facets OST))
+
+ if [[ $FAILURE_MODE = HARD ]]; then
+ local affected=$(affected_facets $ostfail);
+ if [[ "$affected" != $ostfail ]]; then
+ skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
+ return 0
+ fi
+ fi
+
+ mkdir -p $dir
+
+ echo "Create the files"
+
+ # file "f${index}" striped over 1 OST
+ # file "all" striped over all OSTs
+
+ $SETSTRIPE -c $OSTCOUNT $dir/all ||
+ error "setstripe failed to create $dir/all"
+
+ for (( i=0; i<$OSTCOUNT; i++ )); do
+ local f=$dir/f$i
+ $SETSTRIPE -i $i -c 1 $f || error "$SETSTRIPE failed to create $f"
+
+ # confirm setstripe actually created the stripe on the requested OST
+ local uuid=$(ostuuid_from_index $i)
+ for file in f$i all; do
+ if [[ $dir/$file != $($LFS find --obd $uuid --name $file $dir) ]]; then
+ $GETSTRIPE $dir/file
+ error wrong stripe: $file, uuid: $uuid
+ fi
+ done
+ done
+
+ # Before failing an OST, get its obd name and index
+ local varsvc=${ostfail}_svc
+ local obd=$(do_facet $ostfail lctl get_param -n obdfilter.${!varsvc}.uuid)
+ local index=${obd:(-6):1}
+
+ echo "Fail $ostfail $obd, display the list of affected files"
+ shutdown_facet $ostfail || return 2
+
+ trap "cleanup_90 $ostfail" EXIT INT
+ echo "General Query: lfs find $dir"
+ local list=$($LFS find $dir)
+ echo "$list"
+ for (( i=0; i<$OSTCOUNT; i++ )); do
+ list_member "$list" $dir/f$i || error_noexit "lfs find $dir: no file f$i"
+ done
+ list_member "$list" $dir/all || error_noexit "lfs find $dir: no file all"
+
+ # focus on the missing OST,
+ # we expect to see only two files affected: "f$(index)" and "all"
+
+ echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
+ list=$($LFS find --obd $obd $dir)
+ echo "$list"
+ for file in all f$index; do
+ list_member "$list" $dir/$file ||
+ error_noexit "lfs find does not report the affected $obd for $file"
+ done
+
+ [[ $(echo $list | wc -w) -eq 2 ]] ||
+ error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
+
+ echo "Check getstripe: $GETSTRIPE -r --obd $obd"
+ list=$($GETSTRIPE -r --obd $obd $dir)
+ echo "$list"
+ for file in all f$index; do
+ echo "$list" | grep $dir/$file ||
+ error_noexit "lfs getsripe does not report the affected $obd for $file"
+ done
+
+ cleanup_90 $ostfail
+}
+run_test 90 "lfs find identifies the missing striped file segments"
+
+complete $SECONDS