-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfs_utils.sh
65 lines (58 loc) · 1.25 KB
/
fs_utils.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
#!/bin/bash
set -euo pipefail
set -x
IFS=$'\n\t'
source /tests/test_env.sh
umount_fs() {
echo 'Umounting fs'
busy=true
while $busy
do
if mountpoint -q $DESTINATION
then
exit_code=$?
if umount -rv $DESTINATION ; then
busy=false # umount successful
else
sync
echo '.' # output to show that the script is alive
sleep 5 # 5 seconds for testing, modify to 300 seconds later on
fi
else
busy=false # not mounted
fi
done
echo "Unmounted successfully"
}
mount_fs() {
fallocate --verbose -l $FILESYSTEM_FILE_SIZE $FILESYSTEM_FILE
mkfs -t nilfs2 $FILESYSTEM_FILE
mkdir -pv $DESTINATION
mount -i -v -t nilfs2 $FILESYSTEM_FILE $DESTINATION
}
remount_fs() {
umount_fs
mount -i -v -t nilfs2 $FILESYSTEM_FILE $DESTINATION
}
destroy_fs() {
umount_fs || true
rm -fv $FILESYSTEM_FILE
sync
sleep 2
umount_fs || true
rm -fv $FILESYSTEM_FILE
sync
}
run_gc_cleanup() {
echo "Running gc cleanup"
echo "Launching cleanerd daemon"
nilfs_cleanerd
sleep 2
echo "Cleaning"
nilfs-clean -p 0 -m 0 --verbose --speed 32
echo 'Waiting for garbage collection end'
timeout 240s bash -c "( tail -n0 -f /var/log/daemon.log &) | grep -q -e 'manual run completed' -e 'wait 10.000000000'"
echo 'Garbage collection ended'
nilfs-clean --stop
nilfs-clean --quit
}