#! /bin/sh # # try-xfs-prealloc # # This script will create a file on an XFS file system and let it grow # (in increments of 10 * 16 kB) continuously, without closing it. # # In parallel, "ls -l" and "du" will be used to check the file size # and disk allocation. # Settings TESTDISK=/XFS_try TESTFILE=${TESTDISK}/somedir/bigfile FILLBYTES=/Downloads/ISO/SLE-12-Server-DVD-x86_64-GM-DVD2.iso # Any big file will do # The terminal is ... TTY=`ps -fp $$ | sed -n 's=.* \(pts/[0-9]*\) .*=\1=p'` echo echo "Test '$0' is running on TTY '$TTY'." # Ensure initial status mkdir -p `dirname $TESTFILE` rm -f $TESTFILE # Log the test settings echo uname -a mount | fgrep $TESTDISK df $TESTDISK # Set up a pipe for the data, ensure it will not be closed too early. DATAPIPE=/tmp/xfs-tst-$$ mkfifo $DATAPIPE cat $DATAPIPE & # Will run until killed. PID_CAT=$! # Cleanup function cleanup () { kill -9 $PID_CAT rm -f $DATAPIPE } # Establish cleanup function trap cleanup 0 # The test file must not be closed, but should grow in clear increments. # Use "dd" for the increments. # Feed it in pieces via a named pipe to limit the speed. # The process to extend the test file. # Run forever. Will die when its input pipe is closed and removed. dd if=$DATAPIPE of=$TESTFILE obs=16k >/dev/null 2>&1 & # A loop to get the data to write, but in discrete portions. CNT=0 while [ $CNT -lt 17500 ] do CNT=`expr $CNT + 1` dd if=$FILLBYTES bs=16k count=10 skip=$CNT of=$DATAPIPE >/dev/null 2>&1 echo -n . if [ `expr $CNT % 100` -eq 0 ]; then echo ls -ld --block-size=K $TESTFILE du -k $TESTFILE fi if [ `expr $CNT % 5` -eq 0 ]; then sleep 1 fi done # The end ... echo echo ===== echo "No further writes, file still open, status:" ls -ld --block-size=K $TESTFILE ; du -k $TESTFILE cleanup >/dev/null 2>&1 trap '' 0 echo echo "Writer process finished, status:" ls -ld --block-size=K $TESTFILE ; du -k $TESTFILE