-
Notifications
You must be signed in to change notification settings - Fork 10
/
test-clone-rm-kernel.sh
executable file
·82 lines (73 loc) · 1.81 KB
/
test-clone-rm-kernel.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
set -ex
function do_clone_rm_kernel {
local c="$1"
local T="$(mktemp -d -p "." test.XXXXXX)"
pushd "$T"
if [ -n "$MAX_MDS" ]; then
setfattr -n ceph.dir.pin -v $(( RANDOM % MAX_MDS )) .
fi
# pick a random linux clone (not bootstrap)
stat /cephfs/sources
local source="$(find /cephfs/sources -maxdepth 1 -print0 | sort -z -R | sed -z '1q')"
date '+%s' > "/root/client-$c-start.time.txt"
git clone "file://$source" linux
date '+%s' > "/root/client-$c-mid.time.txt"
rm -rf linux
date '+%s' > "/root/client-$c-end.time.txt"
popd
rmdir "$T"
}
function main {
count=0
while true; do
if systemctl status ceph-fuse@-cephfs || [ "$(stat -f --format=%t /cephfs)" = c36400 ]; then
break # shell ! is stupid, can't move to while
fi
sleep 5
if ((++count > 60)); then
exit 1
fi
done
mkdir -p /cephfs/sources
pushd /cephfs/sources
if [ "$DISTRIBUTED" ]; then
setfattr -n ceph.dir.pin.distributed -v 1 .
fi
for ((i = 0; i < COUNT; ++i)); do
(do_clone_rm_kernel "$i") &> /root/client-output-$i.txt &
done
wait
popd
}
ARGUMENTS='--options d,h,p: --long distributed,help,pin:'
NEW_ARGUMENTS=$(getopt $ARGUMENTS -- "$@")
eval set -- "$NEW_ARGUMENTS"
function usage {
printf "%s: [--distributed|--pin=<max_mds>] <count>\n" "$0"
}
while [ "$#" -ge 0 ]; do
case "$1" in
-d|--distributed)
DISTRIBUTED=1
shift
;;
-h|--help)
usage
exit
;;
-p|--pin)
shift
PIN=1
MAX_MDS="$1"
shift
;;
--)
shift
break
;;
esac
done
COUNT="$1"
shift
main |& tee client-output.txt