Whamcloud - gitweb
LU-13366 tests: add SEL support to racer
[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 RACER_ENABLE_SEL=${RACER_ENABLE_SEL:-true}
7 DIR=$1
8 MAX=$2
9 MAX_MB=${RACER_MAX_MB:-8}
10
11 layout=(raid0 raid0)
12
13 # check if it supports PFL layout
14 $RACER_ENABLE_PFL && layout+=(pfl pfl pfl)
15
16 # check if it supports DoM
17 $RACER_ENABLE_DOM && layout+=(dom dom dom)
18
19 # check if it supports FLR
20 $RACER_ENABLE_FLR && layout+=(flr flr flr)
21
22 # check if it supports PFL layout
23 $RACER_ENABLE_SEL && layout+=(sel sel sel)
24
25 echo "layout: ${layout[*]}"
26
27 while /bin/true; do
28         file=$((RANDOM % MAX))
29         # $RANDOM is between 0 and 32767, and we want $blockcount in 64kB units
30         blockcount=$((RANDOM * MAX_MB / 32 / 64))
31         stripecount=$((RANDOM % (OSTCOUNT + 1)))
32
33         [ $stripecount -gt 0 ] && {
34                 stripesize=$(((1 << (RANDOM % 5)) * 64))K
35                 comp_end=$((${stripesize%K} * (RANDOM % 8 + 1)))K
36                 pattern=${layout[$RANDOM % ${#layout[*]}]}
37
38                 case $pattern in
39                 dom) opt="setstripe -E $stripesize -L mdt -E eof -c $stripecount -S 1M" ;;
40                 pfl) opt="setstripe -E $comp_end -S $stripesize -E eof -c $stripecount -S 2M" ;;
41                 flr) opt="mirror create -N2 -E $comp_end -S $stripesize -E eof -c $stripecount -S 2M" ;;
42                 sel) opt="setstripe -E 128M -S $stripesize -z 64M -E eof -c $stripecount -S 2M -z 128M" ;;
43                 raid0) opt="setstripe -S $stripesize -c $stripecount" ;;
44                 esac
45
46                 $LFS $opt $DIR/$file 2> /dev/null || true
47         }
48
49         # offset between 0 and 16MB (256 64k chunks), with 1/2 at offset 0
50         seek=$((RANDOM / 64)); [ $seek -gt 256 ] && seek=0
51         dd if=/dev/zero of=$DIR/$file bs=64k count=$blockcount \
52                 seek=$seek 2> /dev/null || true
53 done
54