Whamcloud - gitweb
LU-4018 tests: improve racer file_create workload
[fs/lustre-release.git] / lustre / tests / racer / file_create.sh
index d94502c..e615365 100755 (executable)
@@ -2,16 +2,17 @@
 
 DIR=$1
 MAX=$2
-MAX_MB=256
+MAX_MB=${RACER_MAX_MB:-8}
 
-create() {
-    SIZE=$(($RANDOM*MAX_MB/32))
-    echo "file_create: SIZE=$SIZE"
-    dd if=/dev/zero of=$DIR/$file bs=1k count=$SIZE
-}
+OSTCOUNT=${OSTCOUNT:-$(lfs df $DIR 2> /dev/null | grep -c OST)}
 
 while /bin/true ; do 
-    file=$(($RANDOM%$MAX))
-    create 2> /dev/null
+       file=$((RANDOM % MAX))
+       # $RANDOM is between 0 and 32767, and we want $blockcount in 64kB units
+       blockcount=$((RANDOM * MAX_MB / 32 / 64))
+       stripecount=$((RANDOM % (OSTCOUNT + 1)))
+       [ $OSTCOUNT -gt 0 ] &&
+               lfs setstripe -c $stripecount $DIR/$file 2> /dev/null
+       dd if=/dev/zero of=$DIR/$file bs=64k count=$blockcount 2> /dev/null
 done