Whamcloud - gitweb
LU-3285 tests: add dom into racer test suite
[fs/lustre-release.git] / lustre / tests / racer / file_create.sh
1 #!/bin/bash
2 trap 'kill $(jobs -p)' EXIT
3
4 DIR=$1
5 MAX=$2
6 MAX_MB=${RACER_MAX_MB:-8}
7
8 . $LUSTRE/tests/test-framework.sh
9
10 OSTCOUNT=${OSTCOUNT:-$($LFS df $DIR 2> /dev/null | grep -c OST)}
11
12 layout=(raid0 raid0)
13
14 # check if it supports PFL layout
15 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.0) ]] &&
16         layout+=(pfl pfl pfl)
17
18 # check if it supports DoM
19 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.53) ]] &&
20         layout+=(dom dom)
21
22 echo "layout: ${layout[*]}"
23
24 while /bin/true; do
25         file=$((RANDOM % MAX))
26         # $RANDOM is between 0 and 32767, and we want $blockcount in 64kB units
27         blockcount=$((RANDOM * MAX_MB / 32 / 64))
28         stripecount=$((RANDOM % (OSTCOUNT + 1)))
29
30         [ $stripecount -gt 0 ] && {
31                 stripesize=$(((RANDOM % 16 + 1) * 64))K
32                 pattern=${layout[$RANDOM % ${#layout[*]}]}
33
34                 case $pattern in
35                 dom) opt="-E $stripesize -L mdt -E eof -c $stripecount -S 1M" ;;
36                 pfl) opt="-E 1M -S $stripesize -E eof -c $stripecount -S 2M" ;;
37                 raid0) opt="-S $stripesize -c $stripecount" ;;
38                 esac
39
40                 $LFS setstripe $opt $DIR/$file 2> /dev/null || true
41         }
42
43         # offset between 0 and 16MB (256 64k chunks), with 1/2 at offset 0
44         seek=$((RANDOM / 64)); [ $seek -gt 256 ] && seek=0
45         dd if=/dev/zero of=$DIR/$file bs=64k count=$blockcount \
46                 seek=$seek 2> /dev/null || true
47 done
48