-
-
Save terrelln/7dd2919937dfbdb8e839e4ad11c81db4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# !/bin/sh | |
set -e | |
# Data from http://sun.aei.polsl.pl/~sdeor/index.php?page=silesia | |
# But, I don't think the actual data matters for the errors. Maybe | |
# the size does? | |
BENCHMARK_DIR=/tmp/silesia | |
N=1 | |
# Create the F2FS filesystem | |
rm -f /tmp/disk | |
losetup -D | |
umount /mnt/test ||: | |
dd if=/dev/zero of=/tmp/disk bs=4096 seek=1048575 count=1 | |
mkfs.f2fs -O compression,extra_attr /tmp/disk | |
losetup -f /tmp/disk | |
sleep 1 # yay udev races | |
# Mount the filesystem | |
mount -t f2fs -ocompress_algorithm=$1 /dev/loop0 /mnt/test | |
echo "Benchmarking $1" | |
# Run the benchmark | |
echo "Compression" | |
time sh -c "set -e; for i in \$(seq $N); do cp -r $BENCHMARK_DIR /mnt/test/\$i; find /mnt/test/\$i -type f | xargs -I__ sh -c 'chattr +c __; touch __'; done; sync;" | |
# Unmount and remount to avoid any caching | |
umount /mnt/test | |
losetup -D | |
losetup -f /tmp/disk | |
mount -t f2fs -ocompress_algorithm=$1 /dev/loop0 /mnt/test | |
echo "Approximate compression ratio" | |
printf "%d / %d\n" \ | |
$(df /mnt/test --output=used -B 1 | tail -n 1) \ | |
$(du /mnt/test -b -d 0 | tr '\t' '\n' | head -n 1); | |
# Unmount and remount to avoid any caching | |
umount /mnt/test | |
losetup -D | |
losetup -f /tmp/disk | |
mount -t f2fs -ocompress_algorithm=$1 /dev/loop0 /mnt/test | |
echo "Decompression" | |
time find /mnt/test -type f | xargs cat > /dev/null | |
# This is where the error happens | |
# I get checksum errors | |
for i in $(seq $N); do | |
for file in $(ls -1 $BENCHMARK_DIR); do | |
asha=$(sha1sum $BENCHMARK_DIR/$file) | |
bsha=$(sha1sum /mnt/test/$i/$file) | |
if [ "$asha" != "$bsha" ]; then | |
echo "FAILURE $file" | |
sha1sum $BENCHMARK_DIR/$file /mnt/test/$i/$file | |
exit 1 | |
fi | |
done | |
done | |
# Cleanup | |
losetup -D | |
umount /mnt/test | |
rm -f /tmp/disk | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment