File tree 1 file changed +66
-0
lines changed
1 file changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ COMPILEBENCH=/root/compilebench-0.6/
4
+ DEV=/dev/nvme1n1
5
+ MNT=/mnt/test
6
+ SNAP_INTERVAL=1
7
+ NUM_SNAPS=10
8
+
9
+ _fail () {
10
+ echo $1
11
+ exit 1
12
+ }
13
+
14
+ _snap_thread () {
15
+ local i=0
16
+ local del=0
17
+ local DEL_MOD=$(( NUM_SNAPS * 2 ))
18
+ local DEL_SNAPS=$NUM_SNAPS
19
+ while [ 1 ]
20
+ do
21
+ sleep $SNAP_INTERVAL
22
+ btrfs sub snap $MNT $MNT /snaps/snap$i > /dev/null || \
23
+ _fail " failed to create snap$i "
24
+ i=$(( i + 1 ))
25
+ if [ " $(( i % DEL_MOD)) " -eq " 0" ]
26
+ then
27
+ for c in $( seq 1 $DEL_SNAPS )
28
+ do
29
+ btrfs subvolume delete $MNT /snaps/snap$del || \
30
+ _fail " failed to delete snap$del "
31
+ del=$(( del + 1 ))
32
+ done
33
+ btrfs balance start --full-balance --bg $MNT
34
+ DEL_SNAPS=20
35
+ fi
36
+ done
37
+ }
38
+
39
+ _balance_thread () {
40
+ while [ 1 ]
41
+ do
42
+ sleep $SNAP_INTERVAL
43
+ btrfs balance start --full-balance $MNT || \
44
+ _fail " failed to balance"
45
+ done
46
+ }
47
+
48
+ mkfs.btrfs -f -n 4096 $DEV || _fail " couldn't mkfs"
49
+ mount $DEV $MNT || _fail " couldn't mount"
50
+
51
+ mkdir $MNT /snaps
52
+ _snap_thread &
53
+ SNAP_PID=$!
54
+
55
+ cd $COMPILEBENCH
56
+ for i in $( seq 0 100)
57
+ do
58
+ ./compilebench -i 300 -m -D $MNT || break
59
+ done
60
+
61
+ [ " $? " -ne " 0" ] && echo " compilebench failed"
62
+
63
+ btrfs balance cancel $MNT
64
+ kill -9 $SNAP_PID
65
+
66
+ wait
You can’t perform that action at this time.
0 commit comments