2016-05-05 12:58:44 +02:00
|
|
|
#!/bin/bash
|
2016-05-24 21:08:13 +02:00
|
|
|
#
|
|
|
|
# Mount a gocryptfs filesystem somewhere on /tmp, then run two parallel
|
|
|
|
# infinite loops inside that do the following:
|
|
|
|
# 1) Extract linux-3.0.tar.gz
|
|
|
|
# 2) Verify the md5sums
|
|
|
|
# 3) Delete, go to (1)
|
|
|
|
#
|
|
|
|
# This test is good at discovering inode-related memory leaks because it creates
|
|
|
|
# huge numbers of files.
|
2018-01-21 20:04:37 +01:00
|
|
|
#
|
|
|
|
# See Documentation/extractloop.md for example output.
|
2016-05-05 12:58:44 +02:00
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
2016-05-24 21:08:13 +02:00
|
|
|
cd "$(dirname "$0")"
|
2016-06-07 23:36:35 +02:00
|
|
|
MD5="$PWD/linux-3.0.md5sums"
|
2016-09-24 20:38:05 +02:00
|
|
|
MYNAME=$(basename "$0")
|
2017-02-15 23:02:01 +01:00
|
|
|
source ../fuse-unmount.bash
|
2016-05-24 21:08:13 +02:00
|
|
|
|
2016-07-11 22:10:41 +02:00
|
|
|
# Setup dirs
|
2016-05-05 12:58:44 +02:00
|
|
|
cd /tmp
|
|
|
|
wget -nv --show-progress -c https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.0.tar.gz
|
2016-09-24 20:38:05 +02:00
|
|
|
CRYPT=$(mktemp -d /tmp/$MYNAME.XXX)
|
2016-07-16 21:18:59 +02:00
|
|
|
CSV=$CRYPT.csv
|
|
|
|
MNT=$CRYPT.mnt
|
|
|
|
mkdir $MNT
|
2016-07-11 22:10:41 +02:00
|
|
|
|
|
|
|
# Mount
|
2016-07-16 21:18:59 +02:00
|
|
|
FSPID=0
|
2016-07-11 22:10:41 +02:00
|
|
|
if [ $# -eq 1 ] && [ "$1" == "-encfs" ]; then
|
|
|
|
echo "Testing EncFS"
|
2016-07-16 21:18:59 +02:00
|
|
|
encfs --extpass="echo test" --standard $CRYPT $MNT > /dev/null
|
2016-07-12 08:30:29 +02:00
|
|
|
elif [ $# -eq 1 ] && [ "$1" == "-loopback" ]; then
|
|
|
|
echo "Testing go-fuse loopback"
|
2016-07-16 21:18:59 +02:00
|
|
|
rm -f /tmp/loopback*.memprof
|
|
|
|
loopback -l -memprofile=/tmp/loopback $MNT $CRYPT &
|
|
|
|
FSPID=$(jobs -p)
|
2016-07-11 22:10:41 +02:00
|
|
|
else
|
2016-07-16 21:18:59 +02:00
|
|
|
echo "Testing gocryptfs"
|
|
|
|
gocryptfs -q -init -extpass="echo test" -scryptn=10 $CRYPT
|
|
|
|
gocryptfs -q -extpass="echo test" -nosyslog -f $CRYPT $MNT &
|
|
|
|
FSPID=$(jobs -p)
|
|
|
|
#gocryptfs -q -extpass="echo test" -nosyslog -memprofile /tmp/extractloop-mem $CRYPT $MNT
|
2016-07-11 22:10:41 +02:00
|
|
|
fi
|
2016-07-16 21:18:59 +02:00
|
|
|
echo "Test dir: $CRYPT"
|
|
|
|
# Sleep to make sure the FS is already mounted on MNT
|
|
|
|
sleep 1
|
|
|
|
cd $MNT
|
|
|
|
|
|
|
|
ln -sTf $CSV /tmp/extractloop.csv
|
2016-05-05 12:58:44 +02:00
|
|
|
|
|
|
|
# Cleanup trap
|
|
|
|
# Note: gocryptfs may have already umounted itself because bash relays SIGINT
|
2017-02-15 23:02:01 +01:00
|
|
|
# Just ignore unmount errors.
|
|
|
|
trap "cd /; fuse-unmount -z $MNT; rm -rf $CRYPT $MNT" EXIT
|
2016-05-05 12:58:44 +02:00
|
|
|
|
2016-05-05 14:17:05 +02:00
|
|
|
function loop {
|
2016-07-16 21:18:59 +02:00
|
|
|
# Note: In a subshell, $$ returns the PID of the parent shell.
|
|
|
|
# We need our own PID, which is why we use $BASHPID.
|
2016-05-05 14:17:05 +02:00
|
|
|
mkdir $BASHPID
|
|
|
|
cd $BASHPID
|
|
|
|
|
2016-05-24 21:08:13 +02:00
|
|
|
echo "[pid $BASHPID] Starting loop"
|
|
|
|
|
2016-05-05 14:17:05 +02:00
|
|
|
N=1
|
2016-07-16 21:18:59 +02:00
|
|
|
RSS=0
|
2016-05-05 14:17:05 +02:00
|
|
|
while true
|
|
|
|
do
|
2016-05-24 21:22:02 +02:00
|
|
|
t1=$SECONDS
|
2016-05-05 14:17:05 +02:00
|
|
|
tar xf /tmp/linux-3.0.tar.gz
|
2016-05-24 21:08:13 +02:00
|
|
|
md5sum --status -c $MD5
|
2016-05-05 14:17:05 +02:00
|
|
|
rm -Rf linux-3.0
|
2016-05-24 21:22:02 +02:00
|
|
|
t2=$SECONDS
|
2016-05-24 21:08:13 +02:00
|
|
|
delta=$((t2-t1))
|
2016-07-16 21:18:59 +02:00
|
|
|
if [ $FSPID -gt 0 ]; then
|
|
|
|
RSS=$(grep VmRSS /proc/$FSPID/status | tr -s ' ' | cut -f2 -d ' ')
|
|
|
|
echo "$N,$SECONDS,$RSS" >> $CSV
|
|
|
|
fi
|
|
|
|
echo "[pid $BASHPID] Iteration $N done, $delta seconds, RSS $RSS kiB"
|
2016-05-05 14:17:05 +02:00
|
|
|
let N=$N+1
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2016-07-16 21:18:59 +02:00
|
|
|
function memprof {
|
|
|
|
while true; do
|
|
|
|
kill -USR1 $FSPID
|
|
|
|
sleep 60
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2016-05-05 14:17:05 +02:00
|
|
|
loop &
|
|
|
|
loop &
|
2016-07-16 21:18:59 +02:00
|
|
|
#memprof &
|
2016-05-05 14:17:05 +02:00
|
|
|
wait
|