local filesize
local origfile=/etc/hosts
- filesize=`stat -c %s $origfile`
+ filesize=$(stat -c %s $origfile)
# create an empty file
- $MCREATE $DIR1/$tfile
+ $MCREATE $DIR1/$tfile || error "can't create $DIR1/$tfile"
# cache layout lock on both mount point
- stat $DIR1/$tfile > /dev/null
- stat $DIR2/$tfile > /dev/null
+ stat $DIR1/$tfile > /dev/null || error "stat $DIR1/$tfile failed"
+ stat $DIR2/$tfile > /dev/null || error "stat $DIR2/$tfile failed"
# open and sleep 2 seconds then read
$MULTIOP $DIR2/$tfile o_2r${filesize}c &
sleep 1
# create the layout of testing file
- dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null
+ dd if=$origfile of=$DIR1/$tfile conv=notrunc > /dev/null ||
+ error "dd $DIR1/$tfile failed"
# MULTIOP proc should be able to read enough bytes and exit
sleep 2
- kill -0 $pid && error "multiop is still there"
- cmp $origfile $DIR2/$tfile || error "$MCREATE and $DIR2/$tfile differs"
+ kill -0 $pid 2> /dev/null && error "multiop is still there"
+ cmp $origfile $DIR2/$tfile || error "$origfile and $DIR2/$tfile differs"
rm -f $DIR1/$tfile
}
local tmpfile=`mktemp`
# create an empty file
- $MCREATE $DIR1/$tfile
+ $MCREATE $DIR1/$tfile || error "mcreate $DIR1/$tfile failed"
# delay glimpse so that layout has changed when glimpse finish
#define OBD_FAIL_GLIMPSE_DELAY 0x1404
sleep 1
# create layout of testing file
- dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc > /dev/null
+ dd if=/dev/zero of=$DIR1/$tfile bs=1k count=1 conv=notrunc >/dev/null ||
+ error "dd $DIR1/$tfile failed"
wait $pid
- local fsize=`cat $tmpfile`
+ local fsize=$(cat $tmpfile)
[ x$fsize = x1024 ] || error "file size is $fsize, should be 1024"
[ $OSTCOUNT -ge 2 ] || { skip "need at least 2 osts"; return; }
# set default layout to have 1 stripe
- mkdir -p $DIR1/$tdir
+ mkdir $DIR1/$tdir
$LFS setstripe -c 1 $DIR1/$tdir
# create a file with empty layout
- $MCREATE $DIR1/$tdir/$tfile
+ $MCREATE $DIR1/$tdir/$tfile ||
+ error "$MCREATE $DIR1/$tdir/$tfile failed"
#define OBD_FAIL_MDS_LL_BLOCK 0x172
do_facet $SINGLEMDS $LCTL set_param fail_loc=0x172
# write something to the file, it should be blocked on fetching layout
dd if=/dev/zero of=$DIR2/$tdir/$tfile bs=1k count=1 conv=notrunc
- local cnt=$($LFS getstripe -c $DIR2/$tdir/$tfile)
- [ $cnt -eq $OSTCOUNT ] || error "have $cnt stripes, expected $OSTCOUNT"
+ local stripecnt=$($LFS getstripe -c $DIR2/$tdir/$tfile)
+ wait $pid
+
+ # lod_qos.c::min_stripe_count() allows setstripe with a default stripe
+ # count to succeed with only 3/4 of the number of stripes (rounded up),
+ # so creating striped files does not fail if an OST is offline or full
+ [ $stripecnt -ge $((OSTCOUNT - $OSTCOUNT / 4)) ] ||
+ error "layout wrong: getstripe -c $stripecnt < $OSTCOUNT * 3/4"
rm -fr $DIR1/$tdir
}