Whamcloud - gitweb
LU-6095 tests: define TRUNCATE program for racer
[fs/lustre-release.git] / lustre / tests / racer / file_create.sh
1 #!/bin/bash
2
3 DIR=$1
4 MAX=$2
5 MAX_MB=${RACER_MAX_MB:-8}
6
7 OSTCOUNT=${OSTCOUNT:-$($LFS df $DIR 2> /dev/null | grep -c OST)}
8
9 while /bin/true; do
10         file=$((RANDOM % MAX))
11         # $RANDOM is between 0 and 32767, and we want $blockcount in 64kB units
12         blockcount=$((RANDOM * MAX_MB / 32 / 64))
13         stripecount=$((RANDOM % (OSTCOUNT + 1)))
14         [ $OSTCOUNT -gt 0 ] &&
15                 $LFS setstripe -c $stripecount $DIR/$file 2> /dev/null
16         dd if=/dev/zero of=$DIR/$file bs=64k count=$blockcount 2> /dev/null
17 done
18