2016-11-17 22:46:21 +01:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
#
|
|
|
|
|
# Mount a go-fuse loopback filesystem in /tmp and run fsstress against it
|
|
|
|
|
# in an infinite loop, only exiting on errors.
|
|
|
|
|
#
|
|
|
|
|
# When called as "fsstress-gocryptfs.bash", a gocryptfs filesystem is tested
|
|
|
|
|
# instead.
|
|
|
|
|
#
|
|
|
|
|
# This test used to fail on older go-fuse versions after a few iterations with
|
|
|
|
|
# errors like this:
|
|
|
|
|
# "rm: cannot remove ‘/tmp/b/fsstress.2/pd/d1XXX/f4a’: No such file or directory"
|
|
|
|
|
#
|
|
|
|
|
# Nowadays it should pass an indefinite number of iterations.
|
|
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
2020-10-03 14:21:21 +02:00
|
|
|
|
# Init variables to default values if unset or empty
|
|
|
|
|
export TMPDIR=${TMPDIR:-/var/tmp}
|
|
|
|
|
DEBUG=${DEBUG:-0}
|
|
|
|
|
|
2017-02-15 23:02:01 +01:00
|
|
|
|
cd "$(dirname "$0")"
|
2021-08-31 19:01:47 +02:00
|
|
|
|
MYNAME=$(basename "$0")
|
2017-02-15 23:02:01 +01:00
|
|
|
|
source ../fuse-unmount.bash
|
|
|
|
|
|
2016-11-17 22:46:21 +01:00
|
|
|
|
# fsstress binary
|
2021-08-26 07:46:28 +02:00
|
|
|
|
FSSTRESS=/opt/fuse-xfstests/ltp/fsstress
|
2020-10-03 14:21:21 +02:00
|
|
|
|
if [[ ! -x $FSSTRESS ]]
|
2016-11-17 22:46:21 +01:00
|
|
|
|
then
|
2017-07-21 23:31:13 +02:00
|
|
|
|
echo "$MYNAME: fsstress binary not found at $FSSTRESS"
|
|
|
|
|
echo "Please clone and compile https://github.com/rfjakob/fuse-xfstests"
|
2016-11-17 22:46:21 +01:00
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2017-07-21 23:31:13 +02:00
|
|
|
|
# Backing directory
|
2021-08-31 19:01:47 +02:00
|
|
|
|
DIR=$(mktemp -d "$TMPDIR/$MYNAME.XXX")
|
2017-07-21 23:31:13 +02:00
|
|
|
|
# Mountpoint
|
|
|
|
|
MNT="$DIR.mnt"
|
2021-08-31 19:01:47 +02:00
|
|
|
|
mkdir "$MNT"
|
2017-02-19 20:43:07 +01:00
|
|
|
|
|
2017-07-21 23:31:13 +02:00
|
|
|
|
# Set the GOPATH variable to the default if it is empty
|
|
|
|
|
GOPATH=$(go env GOPATH)
|
2017-02-19 20:43:07 +01:00
|
|
|
|
|
2019-11-10 22:06:40 +01:00
|
|
|
|
# Clean up old mounts
|
2021-08-31 19:01:47 +02:00
|
|
|
|
for i in $(mount | cut -d" " -f3 | grep "$TMPDIR/$MYNAME") ; do
|
|
|
|
|
fusermount -u "$i"
|
2019-11-10 22:06:40 +01:00
|
|
|
|
done
|
|
|
|
|
|
2016-11-17 22:46:21 +01:00
|
|
|
|
# FS-specific compile and mount
|
2020-10-03 14:21:21 +02:00
|
|
|
|
if [[ $MYNAME = fsstress-loopback.bash ]]; then
|
2020-09-18 13:27:55 +02:00
|
|
|
|
echo -n "Recompile go-fuse loopback: "
|
2021-08-31 19:01:47 +02:00
|
|
|
|
cd "$GOPATH/src/github.com/hanwen/go-fuse/example/loopback"
|
2020-09-18 13:27:55 +02:00
|
|
|
|
git describe
|
|
|
|
|
go build && go install
|
2020-10-03 14:21:21 +02:00
|
|
|
|
OPTS="-q"
|
|
|
|
|
if [[ $DEBUG -eq 1 ]]; then
|
|
|
|
|
OPTS="-debug"
|
|
|
|
|
fi
|
|
|
|
|
$GOPATH/bin/loopback $OPTS "$MNT" "$DIR" &
|
2016-11-17 22:46:21 +01:00
|
|
|
|
disown
|
2020-10-03 14:21:21 +02:00
|
|
|
|
elif [[ $MYNAME = fsstress-gocryptfs.bash ]]; then
|
2016-11-17 22:46:21 +01:00
|
|
|
|
echo "Recompile gocryptfs"
|
2021-08-31 19:01:47 +02:00
|
|
|
|
cd "$GOPATH/src/github.com/rfjakob/gocryptfs"
|
2020-09-18 13:27:55 +02:00
|
|
|
|
./build.bash # also prints the version
|
2021-08-31 19:01:47 +02:00
|
|
|
|
$GOPATH/bin/gocryptfs -q -init -extpass "echo test" -scryptn=10 "$DIR"
|
|
|
|
|
$GOPATH/bin/gocryptfs -q -extpass "echo test" -nosyslog -fusedebug="$DEBUG" "$DIR" "$MNT"
|
2020-10-03 14:21:21 +02:00
|
|
|
|
elif [[ $MYNAME = fsstress-encfs.bash ]]; then
|
2021-08-31 19:01:47 +02:00
|
|
|
|
encfs --extpass "echo test" --standard "$DIR" "$MNT"
|
2016-11-17 22:46:21 +01:00
|
|
|
|
else
|
2021-08-31 19:01:47 +02:00
|
|
|
|
echo "Unknown mode: $MYNAME"
|
2016-11-17 22:46:21 +01:00
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
sleep 0.5
|
2017-07-21 23:31:13 +02:00
|
|
|
|
echo -n "Waiting for mount: "
|
2021-08-31 19:01:47 +02:00
|
|
|
|
while ! grep "$(basename "$MNT") fuse" /proc/self/mounts > /dev/null
|
2016-11-17 22:46:21 +01:00
|
|
|
|
do
|
|
|
|
|
sleep 1
|
|
|
|
|
echo -n x
|
|
|
|
|
done
|
2020-09-18 13:27:55 +02:00
|
|
|
|
echo " ok: $MNT"
|
2016-11-17 22:46:21 +01:00
|
|
|
|
|
|
|
|
|
# Cleanup trap
|
2017-07-21 23:31:13 +02:00
|
|
|
|
trap "kill %1 ; cd / ; fuse-unmount -z $MNT ; rm -rf $DIR $MNT" EXIT
|
2016-11-17 22:46:21 +01:00
|
|
|
|
|
|
|
|
|
echo "Starting fsstress loop"
|
|
|
|
|
N=1
|
|
|
|
|
while true
|
|
|
|
|
do
|
2020-10-03 22:08:52 +02:00
|
|
|
|
echo "$N ................................. $(date)"
|
2021-08-31 19:01:47 +02:00
|
|
|
|
mkdir "$MNT/fsstress.1"
|
2016-11-17 22:46:21 +01:00
|
|
|
|
echo -n " fsstress.1 "
|
2021-08-31 19:01:47 +02:00
|
|
|
|
$FSSTRESS -r -m 8 -n 1000 -d "$MNT/fsstress.1" &
|
2016-11-17 22:46:21 +01:00
|
|
|
|
wait
|
|
|
|
|
|
2021-08-31 19:01:47 +02:00
|
|
|
|
mkdir "$MNT/fsstress.2"
|
2016-11-17 22:46:21 +01:00
|
|
|
|
echo -n " fsstress.2 "
|
2021-08-31 19:01:47 +02:00
|
|
|
|
$FSSTRESS -p 20 -r -m 8 -n 1000 -d "$MNT/fsstress.2" &
|
2016-11-17 22:46:21 +01:00
|
|
|
|
wait
|
|
|
|
|
|
2021-08-31 19:01:47 +02:00
|
|
|
|
mkdir "$MNT/fsstress.3"
|
2016-11-17 22:46:21 +01:00
|
|
|
|
echo -n " fsstress.3 "
|
|
|
|
|
$FSSTRESS -p 4 -z -f rmdir=10 -f link=10 -f creat=10 -f mkdir=10 \
|
|
|
|
|
-f rename=30 -f stat=30 -f unlink=30 -f truncate=20 -m 8 \
|
2021-08-31 19:01:47 +02:00
|
|
|
|
-n 1000 -d "$MNT/fsstress.3" &
|
2016-11-17 22:46:21 +01:00
|
|
|
|
wait
|
|
|
|
|
|
|
|
|
|
echo " rm"
|
2021-08-31 19:01:47 +02:00
|
|
|
|
rm -Rf "$MNT"/*
|
2016-11-17 22:46:21 +01:00
|
|
|
|
|
2021-08-31 19:01:47 +02:00
|
|
|
|
N=$((N+1))
|
2016-11-17 22:46:21 +01:00
|
|
|
|
done
|