5 # create a large fragmented file and check that xfs_fsr doesn't corrupt
6 # it or the other contents of the filesystem
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
10 #-----------------------------------------------------------------------
17 echo "QA output created by $seq"
21 status=1 # failure is the default!
28 trap "_cleanup ; exit \$status" 0 1 2 3 15
30 # get standard environment, filters and checks
34 # real QA test starts here
36 _supported_os IRIX Linux
42 perl -e "\$manifest=\"$tmp.manifest\";" -e '
43 open MANIFEST, $manifest;
46 open MANIFEST, ">$manifest";
47 for ($i = 0; $i < @in; $i++) {
48 if (($i+1) % 2 == 0) {
49 # remove every second file
51 if (unlink($s) != 1) {
52 print "_cull_files: could not delete \"$s\"\n";
57 print MANIFEST $in[$i];
64 # create a large contiguous file using dd
65 # use fill2fs to fill the filesystem up with 4k sized files
66 # fill any remaining space using dd
67 # delete every second 4k file - remaining free space should be fragmented
68 # use fill2 to generate a very large file - run it until it fails producing a truncated file
69 # delete the dd-generated file
70 # run xfs_fsr on the filesystem
71 # check checksums for remaining files
72 # create 3 minimum sized (16Mb) allocation groups
73 # xfs_repair is going to need three to verify the superblock
76 _do_die_on_error=message_only
78 echo -n "Make a 48 megabyte filesystem on SCRATCH_DEV and mount... "
79 _scratch_mkfs_xfs -dsize=48m,agcount=3 2>&1 >/dev/null || _fail "mkfs failed"
80 _scratch_mount || _fail "mount failed"
84 echo -n "Reserve 16 1Mb unfragmented regions... "
85 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
87 _do "dd if=/dev/zero of=$SCRATCH_MNT/hole$i bs=4096 count=256"
88 _do "dd if=/dev/zero of=$SCRATCH_MNT/space$i bs=4096 count=1"
89 _do "xfs_bmap -v $SCRATCH_MNT/hole$i"
94 echo -n "Fill filesystem with 4k files, generate manifest... "
95 fill_options="--verbose --seed=0 --filesize=4096 --stddev=0 --sync=1000000"
96 _do "src/fill2fs $fill_options --dir=$SCRATCH_MNT/fill --list=- > $tmp.manifest"
98 # flush the filesystem - make sure there is no space "lost" to pre-allocation
99 _do "umount $SCRATCH_MNT"
101 echo -n "Use up any further available space using dd... "
102 _do "dd if=/dev/zero of=$SCRATCH_MNT/pad bs=4096"
105 # create fragmented file
106 _do "Delete every second file" "_cull_files"
107 echo -n "Create one very large file... "
108 _do "src/fill2 -d nbytes=16000000,file=$SCRATCH_MNT/fragmented"
110 _do "xfs_bmap -v $SCRATCH_MNT/fragmented"
111 _do "sum $SCRATCH_MNT/fragmented >$tmp.sum1"
112 _do "Remove other files" "rm -rf $SCRATCH_MNT/{pad,hole*}"
115 _do "Run xfs_fsr on filesystem" "$XFS_FSR_PROG -v $SCRATCH_DEV"
116 _do "xfs_bmap -v $SCRATCH_MNT/fragmented"
117 _do "Check 4k files" "src/fill2fs_check $tmp.manifest"
120 echo -n "Check large file... "
121 _do "sum $SCRATCH_MNT/fragmented >$tmp.sum2"
122 if ! _do "diff $tmp.sum1 $tmp.sum2"; then
124 echo "File is corrupt/missing after fsr. Test failed see $seq.full"
128 _do "Checking filesystem" "_check_scratch_fs"
131 echo "xfs_fsr tests passed."