@@ -521,3 +521,30 @@ _sweave_reflink_rainbow_delalloc() {
_pwrite_byte 0x62 $((blksz * i)) $blksz $dfile.chk
done
}
+
+# Require that the COW extent size hint can actually be used to combat
+# fragmentation on the scratch filesystem. This is (so far) true for any
+# filesystem except for the ones where the realtime extent size is larger
+# than one fs block, for it is assumed that setting a rt extent size is the
+# preferred fragmentation avoidance strategy.
+_require_scratch_cowextsize_useful() {
+ local testfile=$SCRATCH_MNT/hascowextsize
+ local param="${1:-1m}"
+
+ rm -f $testfile
+ touch $testfile
+ local before="$($XFS_IO_PROG -c 'cowextsize' $testfile)"
+
+ $XFS_IO_PROG -c "cowextsize $param" $testfile
+ local after="$($XFS_IO_PROG -c 'cowextsize' $testfile)"
+ rm -f $testfile
+
+ test "$before" != "$after" || \
+ _notrun "setting cowextsize to $param had no effect"
+
+ local fileblocksize=$(_get_file_block_size $SCRATCH_MNT)
+ local fsblocksize=$(_get_block_size $SCRATCH_MNT)
+
+ test $fsblocksize -eq $fileblocksize || \
+ _notrun "XFS does not support cowextsize when rt extsize ($fileblocksize) > 1FSB ($fsblocksize)"
+}
@@ -38,6 +38,7 @@ nr=128
filesize=$((blksz * nr))
bufnr=16
bufsize=$((blksz * bufnr))
+_require_scratch_cowextsize_useful $bufsize
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
real_blksz=$(_get_block_size $testdir)
@@ -39,6 +39,7 @@ nr=128
filesize=$((blksz * nr))
bufnr=16
bufsize=$((blksz * bufnr))
+_require_scratch_cowextsize_useful $bufsize
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
real_blksz=$(_get_block_size $testdir)
@@ -40,6 +40,7 @@ nr=128
filesize=$((blksz * nr))
bufnr=16
bufsize=$((blksz * bufnr))
+_require_scratch_cowextsize_useful $bufsize
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
real_blksz=$(_get_block_size $testdir)
@@ -42,6 +42,7 @@ nr=128
filesize=$((blksz * nr))
bufnr=16
bufsize=$((blksz * bufnr))
+_require_scratch_cowextsize_useful $bufsize
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
real_blksz=$(_get_block_size $testdir)
@@ -42,6 +42,7 @@ nr=128
filesize=$((blksz * nr))
bufnr=16
bufsize=$((blksz * bufnr))
+_require_scratch_cowextsize_useful $bufsize
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
real_blksz=$(_get_block_size $testdir)
@@ -44,6 +44,7 @@ nr=128
filesize=$((blksz * nr))
bufnr=16
bufsize=$((blksz * bufnr))
+_require_scratch_cowextsize_useful $bufsize
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
real_blksz=$(_get_block_size $testdir)
@@ -41,6 +41,7 @@ nr=128
filesize=$((blksz * nr))
bufnr=16
bufsize=$((blksz * bufnr))
+_require_scratch_cowextsize_useful $bufsize
_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
real_blksz=$(_get_file_block_size $testdir)
@@ -38,6 +38,7 @@ echo "Format filesystem"
_scratch_mkfs >/dev/null 2>&1
_scratch_mount >> $seqres.full
_require_congruent_file_oplen $SCRATCH_MNT $blksz
+_require_scratch_cowextsize_useful $sz
$XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT
@@ -55,6 +55,12 @@ $XFS_IO_PROG -c "cowextsize $sz" $SCRATCH_MNT
# staging extent for an unshared extent and trips over the injected error.
_require_no_xfs_always_cow
+# This test uses a very large cowextszhint to manipulate the COW fork to
+# contain a large unwritten extent before injecting the error. XFS ignores
+# cowextsize when the realtime extent size is greater than 1FSB, so this test
+# cannot set up the preconditions for the test.
+_require_scratch_cowextsize_useful $sz
+
echo "Create files"
_pwrite_byte 0x66 0 $sz $SCRATCH_MNT/file1 >> $seqres.full
_cp_reflink $SCRATCH_MNT/file1 $SCRATCH_MNT/file2