-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrun-daisy-nfsd.sh
executable file
·94 lines (84 loc) · 1.79 KB
/
run-daisy-nfsd.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
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
set -eu
#
# Usage: ./run-daisy-nfsd.sh go run ./cmd/fs-smallfile
#
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
# root of repo
cd "$DIR"/..
disk_file=/dev/shm/nfs.img
size_mb=400
cpu_list=""
nfs_mount_path="/mnt/nfs"
# go-journal patch
patch_file=""
extra_args=()
while [[ $# -gt 0 ]]; do
case "$1" in
-disk)
shift
disk_file="$1"
shift
;;
-size)
shift
size_mb="$1"
shift
;;
-mount-path)
shift
nfs_mount_path="$1"
extra_args+=("-mount-path" "$nfs_mount_path")
shift
;;
-patch)
shift
patch_file="$1"
shift
;;
--cpu-list)
shift
cpu_list="$1"
shift
;;
# some argument in -foo=value syntax
-*=*)
extra_args+=("$1")
shift
;;
-*)
extra_args+=("$1" "$2")
shift
shift
;;
*)
break
;;
esac
done
if [[ -n "$patch_file" && ! -f "$patch_file" ]]; then
echo "Invalid patch file $patch_file" 1>&2
exit 1
fi
if [ -n "$patch_file" ]; then
./bench/set-gojournal-patch.sh "$patch_file"
fi
if [ -z "$cpu_list" ]; then
./bench/start-daisy-nfsd.sh -disk "$disk_file" -size "$size_mb" "${extra_args[@]}" || exit 1
else
taskset --cpu-list "$cpu_list" ./bench/start-daisy-nfsd.sh -size "$size_mb" -disk "$disk_file" "${extra_args[@]}" || exit 1
fi
function cleanup {
./bench/stop-daisy-nfsd.sh "$nfs_mount_path"
if [ -n "$patch_file" ]; then
./bench/set-gojournal-patch.sh --undo
fi
# only delete regular files
if [ -f "$disk_file" ]; then
rm -f "$disk_file"
fi
}
trap cleanup EXIT
echo "# daisy-nfsd -disk $disk_file ${extra_args[*]}" 1>&2
echo "run $*" 1>&2
"$@"