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