print MANIFEST $in[$i];
}
}
- close MANIFEST;'
+ close MANIFEST;
+ exit(0);'
}
# create a large contiguous file using dd
# check checksums for remaining files
# create 3 minimum sized (16Mb) allocation groups
# xfs_repair is going to need three to verify the superblock
+
rm -f $seq.full
+bmap_cmd="xfs_bmap -v"
+mnt_cmd="mount -t xfs $SCRATCH_DEV $SCRATCH_MNT"
+_do_die_on_error=message_only
+
echo -n "Make a 48 megabyte filesystem on SCRATCH_DEV and mount... "
_do "mkfs -t xfs -d size=48m,agcount=3 -l internal -f $SCRATCH_DEV"
-_do "mount -t xfs $SCRATCH_DEV $SCRATCH_MNT"
+_do "$mnt_cmd"
echo "done"
+
echo -n "Reserve 16 1Mb unfragmented regions... "
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
do
_do "dd if=/dev/zero of=$SCRATCH_MNT/hole$i bs=4096 count=256"
_do "dd if=/dev/zero of=$SCRATCH_MNT/space$i bs=4096 count=1"
- _do "xfs_bmap $SCRATCH_MNT/hole$i"
+ _do "$bmap_cmd $SCRATCH_MNT/hole$i"
done
echo "done"
+
+# set up filesystem
echo -n "Fill filesystem with 4k files, generate manifest... "
-_do "src/fill2fs --verbose --dir=$SCRATCH_MNT/fill --seed=0 --filesize=4096 --stddev=0 --list=$tmp.manifest"
+fill_options="--verbose --seed=0 --filesize=4096 --stddev=0 --sync=1000000"
+_do "src/fill2fs $fill_options --dir=$SCRATCH_MNT/fill --list=- > $tmp.manifest"
echo "done"
+# flush the filesystem - make sure there is no space "lost" to pre-allocation
+_do "umount $SCRATCH_MNT"
+_do "$mnt_cmd"
echo -n "Use up any further available space using dd... "
_do "dd if=/dev/zero of=$SCRATCH_MNT/pad bs=4096"
echo "done"
-echo -n "Delete every second file... "
-if ! _do "_cull_files"; then
- echo "fail"
- echo "Could not cull files. Test failed see $seq.full"
- status=1; exit
-fi
-echo "done"
+
+# create fragmented file
+_do "Delete every second file" "_cull_files"
echo -n "Create one very large file... "
_do "src/fill2 -d nbytes=16000000,file=$SCRATCH_MNT/fragmented"
echo "done"
-_do "xfs_bmap $SCRATCH_MNT/fragmented"
+_do "$bmap_cmd $SCRATCH_MNT/fragmented"
_do "sum $SCRATCH_MNT/fragmented >$tmp.sum1"
-echo -n "Remove other files... "
-_do "rm -rf $SCRATCH_MNT/{pad,hole*}"
-echo "done"
+_do "Remove other files" "rm -rf $SCRATCH_MNT/{pad,hole*}"
-# flush everything
-_do "umount $SCRATCH_MNT"
-_do "mount -t xfs $SCRATCH_DEV $SCRATCH_MNT"
-
-echo -n "Run xfs_fsr on filesystem... "
-_do "xfs_fsr -v $SCRATCH_DEV"
-echo "done"
-_do "xfs_bmap $SCRATCH_MNT/fragmented"
+# defragment
+_do "Run xfs_fsr on filesystem" "xfs_fsr -v $SCRATCH_DEV"
+_do "$bmap_cmd $SCRATCH_MNT/fragmented"
+_do "Check 4k files" "src/fill2fs_check $tmp.manifest"
-echo -n "Check 4k files... "
-if ! _do "src/fill2fs_check $tmp.manifest"; then
- echo "fail"
- echo "4k file is corrupt/missing after fsr. Test failed see $seq.full"
- status=1; exit
-fi
-echo "done"
+# check
echo -n "Check large file... "
_do "sum $SCRATCH_MNT/fragmented >$tmp.sum2"
-if ! diff $tmp.sum1 $tmp.sum2; then
+if ! _do "diff $tmp.sum1 $tmp.sum2"; then
echo "fail"
echo "File is corrupt/missing after fsr. Test failed see $seq.full"
status=1; exit
fi
echo "done"
+_do "Checking filesystem" "_check_fs $SCRATCH_DEV"
-echo -n "Checking filesystem... "
-_check_fs $SCRATCH_DEV
-echo "done"
# success, all done
echo "xfs_fsr tests passed."
status=0 ; exit
[ -b $1 ] && src/lstat64 $1 | $AWK_PROG '/Device type:/ { print $9 }'
}
-# do a command, log it to $seq.full, optionally test return status
-# and die if command fails
-#
+# Do a command, log it to $seq.full, optionally test return status
+# and die if command fails. If called with one argument _do executes the
+# command, logs it, and returns its exit status. With two arguments _do
+# first prints the message passed in the first argument, and then "done"
+# or "fail" depending on the return status of the command passed in the
+# second argument. If the command fails and the variable _do_die_on_error
+# is set to "always" or the two argument form is used and _do_die_on_error
+# is set to "message_only" _do will print an error message to
+# $seq.out and exit.
+
_do()
{
if [ $# -eq 1 ]; then
(eval "$_cmd") >$tmp._out 2>&1; ret=$?
cat $tmp._out | _fix_malloc >>$seq.full
if [ $# -eq 2 ]; then
- if [ $ret -eq 0 ]; then echo "done"; else echo "fail"; fi
+ if [ $ret -eq 0 ]; then
+ echo "done"
+ else
+ echo "fail"
+ fi
fi
- if [ "$_do_die_on_error" -a $ret -ne 0 ]; then
- eval "echo $_cmd failed \(returned $ret\): see $seq.full"
- status=1; exit
+ if [ $ret -ne 0 ] \
+ && [ "$_do_die_on_error" = "always" \
+ -o \( $# -eq 2 -a "$_do_die_on_error" = "message_only" \) ]
+ then
+ [ $# -ne 2 ] && echo
+ eval "echo \"$_cmd\" failed \(returned $ret\): see $seq.full"
+ status=1; exit
fi
return $ret
fi
[ $ok -eq 0 ] && exit 1
-
+ return 0
}
################################################################################
"percent=f" => \$percentage,
"seed=i" => \$seed,
"stddev=i" => \$stddev,
+ "sync=i" => \$sync_bytes,
"verbose!" => \$verbose);
--percent=num percentage of filesystem to fill
--seed=num seed for random number generator
--stddev set file size standard deviation
+ --sync=num sync every num bytes written
--verbose verbose output
EOF
exit(1) unless defined $help;
$files = 0;
$dirs = 0;
$d = 0;
+$sync_cnt = 1;
#
# fill filesystem
}
$total += $size;
$files++;
+
+ if (defined $sync_bytes && int($total / $sync_bytes) > $sync_cnt) {
+ $sync_cnt++;
+ system("sync");
+ }
}
# note that if d==0 create directories more frequently than files
elsif (($d == 0 && $r >= 0.5) || ($d > 0 && $r >= 2.4 && $r < 2.7)) {