All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v10 0/9] xfstests: fixes and new tests for rmap/reflink
@ 2016-09-30  2:23 Darrick J. Wong
  2016-09-30  2:23 ` [PATCH 1/9] xfs/122: decrease the log update done item sizes Darrick J. Wong
                   ` (8 more replies)
  0 siblings, 9 replies; 17+ messages in thread
From: Darrick J. Wong @ 2016-09-30  2:23 UTC (permalink / raw)
  To: david, eguan, darrick.wong; +Cc: linux-xfs, fstests

Hi all,

This is the tenth revision of a patchset that adds to XFS kernel
support for mapping multiple file logical blocks to the same physical
block (reflink/deduplication).

The first few patches fix errors in existing tests.  After that are
a couple of patches to refactor some incorrect open-coded program
usage.  Finally, there are more tests for XFS reverse mapping and
some fragmentation tests for XFS reflink.

If you're going to start using this mess, you probably ought to just
pull from my github trees for kernel[1], xfsprogs[2], and xfstests[3].

This is an extraordinary way to eat your data.  Enjoy! 
Comments and questions are, as always, welcome.

--D

[1] https://github.com/djwong/linux/tree/for-dave-for-4.9-8
[2] https://github.com/djwong/xfsprogs/tree/djwong-wtf
[3] https://github.com/djwong/xfstests/tree/djwong-devel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/9] xfs/122: decrease the log update done item sizes
  2016-09-30  2:23 [PATCH v10 0/9] xfstests: fixes and new tests for rmap/reflink Darrick J. Wong
@ 2016-09-30  2:23 ` Darrick J. Wong
  2016-09-30  7:06   ` Christoph Hellwig
  2016-09-30  2:23 ` [PATCH 2/9] xfs/130: don't modify files after failed mount Darrick J. Wong
                   ` (7 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Darrick J. Wong @ 2016-09-30  2:23 UTC (permalink / raw)
  To: david, eguan, darrick.wong; +Cc: linux-xfs, fstests, Dave Chinner

Redundant fields were removed from the rmap/refcount/bmap update done
log items, so fix the size tests.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
---
 tests/xfs/122.out |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)


diff --git a/tests/xfs/122.out b/tests/xfs/122.out
index ae84283..67f7698 100644
--- a/tests/xfs/122.out
+++ b/tests/xfs/122.out
@@ -64,10 +64,10 @@ sizeof(struct xfs_btree_block) = 72
 sizeof(struct xfs_btree_block_lhdr) = 64
 sizeof(struct xfs_btree_block_shdr) = 48
 sizeof(struct xfs_bud_log_format) = 16
-sizeof(struct xfs_bui_log_format) = 48
+sizeof(struct xfs_bui_log_format) = 16
 sizeof(struct xfs_clone_args) = 32
 sizeof(struct xfs_cud_log_format) = 16
-sizeof(struct xfs_cui_log_format) = 32
+sizeof(struct xfs_cui_log_format) = 16
 sizeof(struct xfs_da3_blkinfo) = 56
 sizeof(struct xfs_da3_intnode) = 64
 sizeof(struct xfs_da3_node_hdr) = 64
@@ -94,7 +94,7 @@ sizeof(struct xfs_rtrmap_key) = 24
 sizeof(struct xfs_rtrmap_rec) = 32
 sizeof(struct xfs_rtrmap_root) = 4
 sizeof(struct xfs_rud_log_format) = 16
-sizeof(struct xfs_rui_log_format) = 48
+sizeof(struct xfs_rui_log_format) = 16
 sizeof(struct xfs_scrub_metadata) = 64
 sizeof(xfs_agf_t) = 224
 sizeof(xfs_agfl_t) = 36


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/9] xfs/130: don't modify files after failed mount
  2016-09-30  2:23 [PATCH v10 0/9] xfstests: fixes and new tests for rmap/reflink Darrick J. Wong
  2016-09-30  2:23 ` [PATCH 1/9] xfs/122: decrease the log update done item sizes Darrick J. Wong
@ 2016-09-30  2:23 ` Darrick J. Wong
  2016-09-30  7:07   ` Christoph Hellwig
  2016-09-30  2:23 ` [PATCH 3/9] xfs/{207,327}: fsxattr no longer has the reflink flag Darrick J. Wong
                   ` (6 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Darrick J. Wong @ 2016-09-30  2:23 UTC (permalink / raw)
  To: david, eguan, darrick.wong; +Cc: linux-xfs, fstests, Dave Chinner

In xfs/130, we try to mount a filesystem with the expectation that it
will fail.  Therefore, it is inappropriate to try to write to the
mountpoint, since it could otherwise be writable.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
---
 tests/xfs/130     |    9 +++------
 tests/xfs/130.out |    1 -
 2 files changed, 3 insertions(+), 7 deletions(-)


diff --git a/tests/xfs/130 b/tests/xfs/130
index 554d078..48f6a84 100755
--- a/tests/xfs/130
+++ b/tests/xfs/130
@@ -79,12 +79,9 @@ seq 0 $((agcount - 1)) | while read ag; do
 done
 
 echo "+ mount image"
-_scratch_mount
-
-echo "+ reflink more"
-_cp_reflink "${SCRATCH_MNT}/file1" "${SCRATCH_MNT}/file4" 2> /dev/null && \
-	_fail "should not be able to reflink with busted refcount btree"
-umount "${SCRATCH_MNT}"
+_scratch_mount >> $seqres.full 2>&1 && \
+	echo "Should not be able to mount with broken refcountbt."
+_scratch_unmount >> $seqres.full 2>&1
 
 echo "+ repair fs"
 _disable_dmesg_check
diff --git a/tests/xfs/130.out b/tests/xfs/130.out
index 58d153b..a0eab98 100644
--- a/tests/xfs/130.out
+++ b/tests/xfs/130.out
@@ -5,7 +5,6 @@ QA output created by 130
 + check fs
 + corrupt image
 + mount image
-+ reflink more
 + repair fs
 + mount image (2)
 + chattr -R -i


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/9] xfs/{207,327}: fsxattr no longer has the reflink flag
  2016-09-30  2:23 [PATCH v10 0/9] xfstests: fixes and new tests for rmap/reflink Darrick J. Wong
  2016-09-30  2:23 ` [PATCH 1/9] xfs/122: decrease the log update done item sizes Darrick J. Wong
  2016-09-30  2:23 ` [PATCH 2/9] xfs/130: don't modify files after failed mount Darrick J. Wong
@ 2016-09-30  2:23 ` Darrick J. Wong
  2016-09-30  7:07   ` Christoph Hellwig
  2016-09-30  2:23 ` [PATCH 4/9] misc: fix fallocate commands that need the unshare switch Darrick J. Wong
                   ` (5 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Darrick J. Wong @ 2016-09-30  2:23 UTC (permalink / raw)
  To: david, eguan, darrick.wong; +Cc: linux-xfs, fstests

The FS_XFLAG_REFLINK flag was removed from struct fsxattr prior to
the inclusion of reflink in XFS, so remove it from the test outputs.
Note that the inode flag still exists; it's simply not presented
to userspace any more.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/207.out |    4 ++--
 tests/xfs/327.out |    6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)


diff --git a/tests/xfs/207.out b/tests/xfs/207.out
index 434b8d9..f6dc17d 100644
--- a/tests/xfs/207.out
+++ b/tests/xfs/207.out
@@ -11,8 +11,8 @@ Check extsz and cowextsz settings on 1Mbyte file
 [0] SCRATCH_MNT/test-207/file2
 [1048576] SCRATCH_MNT/test-207/file2
 Set cowextsize and check flag
-fsxattr.xflags = 0x20000 [----------------C]
+fsxattr.xflags = 0x10000 [---------------C]
 [1048576] SCRATCH_MNT/test-207/file3
 Unset cowextsize and check flag
-fsxattr.xflags = 0x0 [-----------------]
+fsxattr.xflags = 0x0 [----------------]
 [0] SCRATCH_MNT/test-207/file3
diff --git a/tests/xfs/327.out b/tests/xfs/327.out
index c88d623..5b3cba2 100644
--- a/tests/xfs/327.out
+++ b/tests/xfs/327.out
@@ -3,11 +3,11 @@ Format filesystem
 Create files
 Check files
 8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.0
-[reflink] SCRATCH_MNT/file.0 
+[] SCRATCH_MNT/file.0 
 8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.64
-[reflink] SCRATCH_MNT/file.64 
+[] SCRATCH_MNT/file.64 
 8fa14cdd754f91cc6554c9e71929cce7  SCRATCH_MNT/file.128
-[reflink] SCRATCH_MNT/file.128 
+[] SCRATCH_MNT/file.128 
 CoW all files
 Repair filesystem
 Check files again

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/9] misc: fix fallocate commands that need the unshare switch
  2016-09-30  2:23 [PATCH v10 0/9] xfstests: fixes and new tests for rmap/reflink Darrick J. Wong
                   ` (2 preceding siblings ...)
  2016-09-30  2:23 ` [PATCH 3/9] xfs/{207,327}: fsxattr no longer has the reflink flag Darrick J. Wong
@ 2016-09-30  2:23 ` Darrick J. Wong
  2016-09-30 11:55   ` Christoph Hellwig
  2016-09-30  2:23 ` [PATCH 5/9] misc: use get_block_size helper Darrick J. Wong
                   ` (4 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Darrick J. Wong @ 2016-09-30  2:23 UTC (permalink / raw)
  To: david, eguan, darrick.wong; +Cc: linux-xfs, fstests

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/156 |   12 ++++++------
 tests/generic/264 |    4 ++--
 tests/xfs/132     |   12 ++++++------
 tests/xfs/184     |    2 +-
 tests/xfs/192     |    2 +-
 tests/xfs/200     |    2 +-
 tests/xfs/204     |    2 +-
 7 files changed, 18 insertions(+), 18 deletions(-)


diff --git a/tests/generic/156 b/tests/generic/156
index 52ac11f..7bfe7d8 100755
--- a/tests/generic/156
+++ b/tests/generic/156
@@ -62,7 +62,7 @@ fi
 _supported_os Linux
 _require_test_reflink
 _require_cp_reflink
-_require_xfs_io_command "falloc"
+_require_xfs_io_command "falloc" "-u"
 
 rm -f $seqres.full
 
@@ -89,18 +89,18 @@ _test_cycle_mount
 free_blocks1=$(stat -f $testdir -c '%f')
 
 echo "funshare part of a file"
-$XFS_IO_PROG -f -c "falloc 0 $((sz / 2))" $testdir/file2
+$XFS_IO_PROG -f -c "falloc -u 0 $((sz / 2))" $testdir/file2
 _test_cycle_mount
 
 echo "funshare some of the copies"
-$XFS_IO_PROG -f -c "falloc 0 $sz" $testdir/file2
-$XFS_IO_PROG -f -c "falloc 0 $sz" $testdir/file3
+$XFS_IO_PROG -f -c "falloc -u 0 $sz" $testdir/file2
+$XFS_IO_PROG -f -c "falloc -u 0 $sz" $testdir/file3
 _test_cycle_mount
 free_blocks2=$(stat -f $testdir -c '%f')
 
 echo "funshare the rest of the files"
-$XFS_IO_PROG -f -c "falloc 0 $sz" $testdir/file4
-$XFS_IO_PROG -f -c "falloc 0 $sz" $testdir/file1
+$XFS_IO_PROG -f -c "falloc -u 0 $sz" $testdir/file4
+$XFS_IO_PROG -f -c "falloc -u 0 $sz" $testdir/file1
 _test_cycle_mount
 free_blocks3=$(stat -f $testdir -c '%f')
 
diff --git a/tests/generic/264 b/tests/generic/264
index 631184c..bc2f7e6 100755
--- a/tests/generic/264
+++ b/tests/generic/264
@@ -47,7 +47,7 @@ _cleanup()
 _supported_os Linux
 _require_scratch_reflink
 _require_cp_reflink
-_require_xfs_io_command "falloc"
+_require_xfs_io_command "falloc" "-u"
 
 rm -f $seqres.full
 
@@ -75,7 +75,7 @@ md5sum $testdir/file2 | _filter_scratch
 md5sum $testdir/file2.chk | _filter_scratch
 
 echo "CoW and unmount"
-$XFS_IO_PROG -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "falloc $((blksz * 2)) $blksz" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" -c "falloc -u $((blksz * 2)) $blksz" $testdir/file2 >> $seqres.full
 _scratch_cycle_mount
 $XFS_IO_PROG -f -c "pwrite -S 0x62 -b $((blksz * 3)) $blksz $((blksz * 3))" $testdir/file2.chk >> $seqres.full
 _scratch_cycle_mount
diff --git a/tests/xfs/132 b/tests/xfs/132
index b09ccb6..5abcf30 100755
--- a/tests/xfs/132
+++ b/tests/xfs/132
@@ -63,7 +63,7 @@ _supported_os Linux
 _require_test_reflink
 _require_test_lsattr
 _require_cp_reflink
-_require_xfs_io_command "falloc"
+_require_xfs_io_command "falloc" "-u"
 
 rm -f $seqres.full
 
@@ -90,18 +90,18 @@ _test_cycle_mount
 free_blocks1=$(stat -f $testdir -c '%f')
 
 echo "funshare part of a file"
-$XFS_IO_PROG -f -c "falloc 0 $((sz / 2))" $testdir/file2
+$XFS_IO_PROG -f -c "falloc -u 0 $((sz / 2))" $testdir/file2
 _test_cycle_mount
 
 echo "funshare some of the copies"
-$XFS_IO_PROG -f -c "falloc 0 $sz" $testdir/file2
-$XFS_IO_PROG -f -c "falloc 0 $sz" $testdir/file3
+$XFS_IO_PROG -f -c "falloc -u 0 $sz" $testdir/file2
+$XFS_IO_PROG -f -c "falloc -u 0 $sz" $testdir/file3
 _test_cycle_mount
 free_blocks2=$(stat -f $testdir -c '%f')
 
 echo "funshare the rest of the files"
-$XFS_IO_PROG -f -c "falloc 0 $sz" $testdir/file4
-$XFS_IO_PROG -f -c "falloc 0 $sz" $testdir/file1
+$XFS_IO_PROG -f -c "falloc -u 0 $sz" $testdir/file4
+$XFS_IO_PROG -f -c "falloc -u 0 $sz" $testdir/file1
 _test_cycle_mount
 free_blocks3=$(stat -f $testdir -c '%f')
 
diff --git a/tests/xfs/184 b/tests/xfs/184
index 6d32e93..01c04c3 100755
--- a/tests/xfs/184
+++ b/tests/xfs/184
@@ -84,7 +84,7 @@ md5sum $testdir/file2 | _filter_scratch
 echo "CoW and unmount"
 $XFS_IO_PROG -f -c "cowextsize" $testdir/file2 >> $seqres.full
 $XFS_IO_PROG -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $((filesize + 1))" -c "fdatasync" $testdir/file2 >> $seqres.full
-$XFS_IO_PROG -f -c "falloc 0 $((filesize + 1))" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "falloc -u 0 $((filesize + 1))" $testdir/file2 >> $seqres.full
 _scratch_cycle_mount
 
 echo "Compare files"
diff --git a/tests/xfs/192 b/tests/xfs/192
index 8594787..244a2ec 100755
--- a/tests/xfs/192
+++ b/tests/xfs/192
@@ -85,7 +85,7 @@ md5sum $testdir/file2 | _filter_scratch
 echo "CoW and unmount"
 $XFS_IO_PROG -f -c "cowextsize" $testdir/file2 >> $seqres.full
 $XFS_IO_PROG -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $filesize" $testdir/file2 >> $seqres.full
-$XFS_IO_PROG -d -f -c "falloc 0 $filesize" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -d -f -c "falloc -u 0 $filesize" $testdir/file2 >> $seqres.full
 _scratch_cycle_mount
 
 echo "Compare files"
diff --git a/tests/xfs/200 b/tests/xfs/200
index a750ef6..92823b5 100755
--- a/tests/xfs/200
+++ b/tests/xfs/200
@@ -88,7 +88,7 @@ $XFS_IO_PROG -f -c "cowextsize" $testdir/file2 >> $seqres.full
 cat $testdir/file2 > /dev/null
 $XFS_IO_PROG -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $filesize" -c "fdatasync" $testdir/file2 >> $seqres.full
 $XFS_IO_PROG -f -c "fadvise -d 0 $filesize" -c "fsync" $testdir/file2 >> $seqres.full
-$XFS_IO_PROG -f -c "falloc 0 $filesize" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "falloc -u 0 $filesize" $testdir/file2 >> $seqres.full
 _scratch_cycle_mount
 
 echo "Compare files"
diff --git a/tests/xfs/204 b/tests/xfs/204
index ae21d6e..cc1683b 100755
--- a/tests/xfs/204
+++ b/tests/xfs/204
@@ -89,7 +89,7 @@ $XFS_IO_PROG -f -c "cowextsize" $testdir/file2 >> $seqres.full
 cat $testdir/file2 > /dev/null
 $XFS_IO_PROG -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $filesize" -c "fdatasync" $testdir/file2 >> $seqres.full
 $XFS_IO_PROG -f -c "fadvise -d 0 $filesize" -c "fsync" $testdir/file2 >> $seqres.full
-$XFS_IO_PROG -f -c "falloc 0 $filesize" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "falloc -u 0 $filesize" $testdir/file2 >> $seqres.full
 _scratch_cycle_mount
 
 echo "Compare files"


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 5/9] misc: use get_block_size helper
  2016-09-30  2:23 [PATCH v10 0/9] xfstests: fixes and new tests for rmap/reflink Darrick J. Wong
                   ` (3 preceding siblings ...)
  2016-09-30  2:23 ` [PATCH 4/9] misc: fix fallocate commands that need the unshare switch Darrick J. Wong
@ 2016-09-30  2:23 ` Darrick J. Wong
  2016-09-30 11:56   ` Christoph Hellwig
  2016-09-30  2:23 ` [PATCH 6/9] xfs: fix $XFS_DB_PROG usage Darrick J. Wong
                   ` (3 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Darrick J. Wong @ 2016-09-30  2:23 UTC (permalink / raw)
  To: david, eguan, darrick.wong; +Cc: linux-xfs, fstests

Don't open code grabbing the block size; just use the helper.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/150 |    2 +-
 tests/generic/151 |    2 +-
 tests/generic/152 |    2 +-
 tests/generic/153 |    2 +-
 tests/generic/154 |    2 +-
 tests/generic/155 |    2 +-
 tests/generic/156 |    2 +-
 tests/generic/157 |    2 +-
 tests/generic/158 |    2 +-
 tests/generic/159 |    2 +-
 tests/generic/160 |    2 +-
 tests/generic/171 |    2 +-
 tests/generic/173 |    2 +-
 tests/generic/174 |    2 +-
 tests/generic/175 |    2 +-
 tests/generic/176 |    2 +-
 tests/generic/205 |    2 +-
 tests/generic/206 |    2 +-
 tests/generic/216 |    2 +-
 tests/generic/217 |    2 +-
 tests/generic/218 |    2 +-
 tests/generic/220 |    2 +-
 tests/generic/222 |    2 +-
 tests/generic/227 |    2 +-
 tests/generic/229 |    2 +-
 tests/generic/238 |    2 +-
 tests/generic/242 |    2 +-
 tests/generic/243 |    2 +-
 tests/generic/296 |    2 +-
 tests/generic/297 |    2 +-
 tests/generic/298 |    2 +-
 tests/generic/301 |    2 +-
 tests/generic/302 |    2 +-
 tests/xfs/127     |    2 +-
 tests/xfs/128     |    2 +-
 tests/xfs/129     |    2 +-
 tests/xfs/132     |    2 +-
 tests/xfs/139     |    2 +-
 tests/xfs/140     |    2 +-
 tests/xfs/169     |    2 +-
 tests/xfs/180     |    2 +-
 tests/xfs/182     |    2 +-
 tests/xfs/184     |    2 +-
 tests/xfs/192     |    2 +-
 tests/xfs/193     |    2 +-
 tests/xfs/198     |    2 +-
 tests/xfs/200     |    2 +-
 tests/xfs/204     |    2 +-
 tests/xfs/208     |    2 +-
 tests/xfs/211     |    2 +-
 tests/xfs/215     |    2 +-
 tests/xfs/218     |    2 +-
 tests/xfs/219     |    2 +-
 tests/xfs/221     |    2 +-
 tests/xfs/223     |    2 +-
 tests/xfs/224     |    2 +-
 tests/xfs/225     |    2 +-
 tests/xfs/226     |    2 +-
 tests/xfs/228     |    2 +-
 tests/xfs/230     |    2 +-
 tests/xfs/231     |    2 +-
 tests/xfs/232     |    2 +-
 tests/xfs/233     |    2 +-
 tests/xfs/234     |    2 +-
 tests/xfs/236     |    2 +-
 tests/xfs/265     |    2 +-
 tests/xfs/309     |    2 +-
 tests/xfs/310     |    4 ++--
 tests/xfs/328     |    2 +-
 69 files changed, 70 insertions(+), 70 deletions(-)


diff --git a/tests/generic/150 b/tests/generic/150
index 2e21d37..fadbb42 100755
--- a/tests/generic/150
+++ b/tests/generic/150
@@ -55,7 +55,7 @@ rm -rf $testdir
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 blks=2000
 margin='15%'
 sz=$((blksz * blks))
diff --git a/tests/generic/151 b/tests/generic/151
index 55e0e02..b0f0521 100755
--- a/tests/generic/151
+++ b/tests/generic/151
@@ -59,7 +59,7 @@ rm -rf $testdir
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 blks=2000
 margin='15%'
 sz=$((blksz * blks))
diff --git a/tests/generic/152 b/tests/generic/152
index 9fe4d32..aa10bcf 100755
--- a/tests/generic/152
+++ b/tests/generic/152
@@ -60,7 +60,7 @@ rm -rf $testdir
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 blks=2000
 margin='15%'
 sz=$((blksz * blks))
diff --git a/tests/generic/153 b/tests/generic/153
index 5d22153..2ddb48d 100755
--- a/tests/generic/153
+++ b/tests/generic/153
@@ -60,7 +60,7 @@ rm -rf $testdir
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 blks=2000
 margin='15%'
 sz=$((blksz * blks))
diff --git a/tests/generic/154 b/tests/generic/154
index 23b626b..f270ccb 100755
--- a/tests/generic/154
+++ b/tests/generic/154
@@ -59,7 +59,7 @@ rm -rf $testdir
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 blks=2000
 margin='15%'
 free_blocks0=$(stat -f $testdir -c '%f')
diff --git a/tests/generic/155 b/tests/generic/155
index 50083e7..23057c0 100755
--- a/tests/generic/155
+++ b/tests/generic/155
@@ -64,7 +64,7 @@ rm -rf $testdir
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 blks=2000
 margin='15%'
 sz=$((blksz * blks))
diff --git a/tests/generic/156 b/tests/generic/156
index 7bfe7d8..4a0da3a 100755
--- a/tests/generic/156
+++ b/tests/generic/156
@@ -71,7 +71,7 @@ rm -rf $testdir
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 blks=2000
 margin='15%'
 sz=$((blksz * blks))
diff --git a/tests/generic/157 b/tests/generic/157
index fe294c8..9284c55 100755
--- a/tests/generic/157
+++ b/tests/generic/157
@@ -60,7 +60,7 @@ testdir2=$SCRATCH_MNT/test-$seq
 mkdir $testdir2
 
 echo "Create the original files"
-blksz="$(stat -f $testdir1 -c '%S')"
+blksz="$(get_block_size $testdir1)"
 blks=1000
 margin='7%'
 sz=$((blksz * blks))
diff --git a/tests/generic/158 b/tests/generic/158
index dd64562..086c522 100755
--- a/tests/generic/158
+++ b/tests/generic/158
@@ -60,7 +60,7 @@ testdir2=$SCRATCH_MNT/test-$seq
 mkdir $testdir2
 
 echo "Create the original files"
-blksz="$(stat -f $testdir1 -c '%S')"
+blksz="$(get_block_size $testdir1)"
 blks=1000
 margin='7%'
 sz=$((blksz * blks))
diff --git a/tests/generic/159 b/tests/generic/159
index 5e1a899..6f75b73 100755
--- a/tests/generic/159
+++ b/tests/generic/159
@@ -54,7 +54,7 @@ rm -rf $testdir1
 mkdir $testdir1
 
 echo "Create the original files"
-blksz="$(stat -f $testdir1 -c '%S')"
+blksz="$(get_block_size $testdir1)"
 blks=1000
 margin='7%'
 sz=$((blksz * blks))
diff --git a/tests/generic/160 b/tests/generic/160
index 1dc5b72..066bf5e 100755
--- a/tests/generic/160
+++ b/tests/generic/160
@@ -54,7 +54,7 @@ rm -rf $testdir1
 mkdir $testdir1
 
 echo "Create the original files"
-blksz="$(stat -f $testdir1 -c '%S')"
+blksz="$(get_block_size $testdir1)"
 blks=1000
 margin='7%'
 sz=$((blksz * blks))
diff --git a/tests/generic/171 b/tests/generic/171
index f391685..a69f798 100755
--- a/tests/generic/171
+++ b/tests/generic/171
@@ -57,7 +57,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Reformat with appropriate size"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 nr_blks=10240
 umount $SCRATCH_MNT
 sz_bytes=$((nr_blks * 8 * blksz))
diff --git a/tests/generic/173 b/tests/generic/173
index c5fac9e..e35597f 100755
--- a/tests/generic/173
+++ b/tests/generic/173
@@ -57,7 +57,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Reformat with appropriate size"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 nr_blks=10240
 umount $SCRATCH_MNT
 sz_bytes=$((nr_blks * 8 * blksz))
diff --git a/tests/generic/174 b/tests/generic/174
index 8077d76..e58d64b 100755
--- a/tests/generic/174
+++ b/tests/generic/174
@@ -58,7 +58,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Reformat with appropriate size"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 nr_blks=10240
 umount $SCRATCH_MNT
 sz_bytes=$((nr_blks * 8 * blksz))
diff --git a/tests/generic/175 b/tests/generic/175
index 964580c..f4f19f8 100755
--- a/tests/generic/175
+++ b/tests/generic/175
@@ -56,7 +56,7 @@ testdir="$SCRATCH_MNT/test-$seq"
 mkdir "$testdir"
 
 echo "Create a one block file"
-blksz="$(stat -f "$testdir" -c '%S')"
+blksz="$(get_block_size $testdir)"
 _pwrite_byte 0x61 0 $blksz "$testdir/file1" >> "$seqres.full"
 
 fnr=19
diff --git a/tests/generic/176 b/tests/generic/176
index f7d6495..b14255b 100755
--- a/tests/generic/176
+++ b/tests/generic/176
@@ -60,7 +60,7 @@ mkdir "$testdir"
 # 2^17 blocks... that should be plenty for anyone.
 fnr=20
 free_blocks=$(stat -f -c '%a' "$testdir")
-blksz=$(stat -f -c '%S' "$testdir")
+blksz=$(get_block_size "$testdir")
 space_avail=$((free_blocks * blksz))
 calc_space() {
 	blocks_needed=$(( 2 ** (fnr + 1) ))
diff --git a/tests/generic/205 b/tests/generic/205
index 65c3563..cfda8c3 100755
--- a/tests/generic/205
+++ b/tests/generic/205
@@ -60,7 +60,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/206 b/tests/generic/206
index 0d8006f..909956f 100755
--- a/tests/generic/206
+++ b/tests/generic/206
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/216 b/tests/generic/216
index 29fa6a0..d9b868a 100755
--- a/tests/generic/216
+++ b/tests/generic/216
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/217 b/tests/generic/217
index 3843a8b..65113d9 100755
--- a/tests/generic/217
+++ b/tests/generic/217
@@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/218 b/tests/generic/218
index 6e7f465..21029ef 100755
--- a/tests/generic/218
+++ b/tests/generic/218
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/220 b/tests/generic/220
index d3ee888..c54bf06 100755
--- a/tests/generic/220
+++ b/tests/generic/220
@@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/222 b/tests/generic/222
index 7de8ad6..d7ee57e 100755
--- a/tests/generic/222
+++ b/tests/generic/222
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/227 b/tests/generic/227
index daac550..fa6a33e 100755
--- a/tests/generic/227
+++ b/tests/generic/227
@@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 echo "Create the original files"
diff --git a/tests/generic/229 b/tests/generic/229
index a307408..3e2c6f4 100755
--- a/tests/generic/229
+++ b/tests/generic/229
@@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 runtest() {
diff --git a/tests/generic/238 b/tests/generic/238
index 38e3aac..a2f44e8 100755
--- a/tests/generic/238
+++ b/tests/generic/238
@@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 test $real_blksz != $blksz && _notrun "Failed to format with small blocksize."
 
 runtest() {
diff --git a/tests/generic/242 b/tests/generic/242
index 93fdc1d..2b07067 100755
--- a/tests/generic/242
+++ b/tests/generic/242
@@ -65,7 +65,7 @@ bufnr=1280
 bufsize=$((blksz * bufnr))
 
 free_blocks=$(stat -f -c '%a' $testdir)
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 space_needed=$(((filesize * 3) * 5 / 4))
 space_avail=$((free_blocks * real_blksz))
 test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
diff --git a/tests/generic/243 b/tests/generic/243
index ae9caa2..1ba3e8a 100755
--- a/tests/generic/243
+++ b/tests/generic/243
@@ -66,7 +66,7 @@ bufnr=1280
 bufsize=$((blksz * bufnr))
 
 free_blocks=$(stat -f -c '%a' $testdir)
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 space_needed=$(((filesize * 3) * 5 / 4))
 space_avail=$((free_blocks * real_blksz))
 test $space_needed -gt $space_avail && _notrun "Not enough space. $space_avail < $space_needed"
diff --git a/tests/generic/296 b/tests/generic/296
index 4297088..9199006 100755
--- a/tests/generic/296
+++ b/tests/generic/296
@@ -61,7 +61,7 @@ filesize=$((blksz * nr))
 bufnr=16
 bufsize=$((blksz * bufnr))
 
-real_blksz=$(stat -f -c '%S' "$testdir")
+real_blksz=$(get_block_size "$testdir")
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
 
 echo "Create the original files"
diff --git a/tests/generic/297 b/tests/generic/297
index 4ae2b9c..8dfc342 100755
--- a/tests/generic/297
+++ b/tests/generic/297
@@ -59,7 +59,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Create a one block file"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
 
 fnr=26		# 2^26 reflink extents should be enough to find a slow op?
diff --git a/tests/generic/298 b/tests/generic/298
index e85db12..3f6446c 100755
--- a/tests/generic/298
+++ b/tests/generic/298
@@ -59,7 +59,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Create a one block file"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 _pwrite_byte 0x61 0 $blksz $testdir/file1 >> $seqres.full
 
 fnr=26		# 2^26 reflink extents should be enough to find a slow op?
diff --git a/tests/generic/301 b/tests/generic/301
index a513333..a196cd4 100755
--- a/tests/generic/301
+++ b/tests/generic/301
@@ -65,7 +65,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/generic/302 b/tests/generic/302
index 1600b5a..b2298cb 100755
--- a/tests/generic/302
+++ b/tests/generic/302
@@ -66,7 +66,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/127 b/tests/xfs/127
index 6b768c9..8212ec3 100755
--- a/tests/xfs/127
+++ b/tests/xfs/127
@@ -55,7 +55,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Create the original file and reflink to copy1, copy2"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 _pwrite_byte 0x61 0 $((blksz * 14 + 71)) $testdir/original >> $seqres.full
 _cp_reflink $testdir/original $testdir/copy1
 _cp_reflink $testdir/copy1 $testdir/copy2
diff --git a/tests/xfs/128 b/tests/xfs/128
index 04633a1..6bb6282 100755
--- a/tests/xfs/128
+++ b/tests/xfs/128
@@ -60,7 +60,7 @@ echo "Create the original file and reflink to file2, file3"
 blks=2000
 margin=160
 blksz=65536
-real_blksz="$(stat -f $testdir -c '%S')"
+real_blksz="$(get_block_size $testdir)"
 blksz_factor=$((blksz / real_blksz))
 _pwrite_byte 0x61 0 $((blks * blksz)) $testdir/file1 >> $seqres.full
 _cp_reflink $testdir/file1 $testdir/file2
diff --git a/tests/xfs/129 b/tests/xfs/129
index 17ff238..10880e5 100755
--- a/tests/xfs/129
+++ b/tests/xfs/129
@@ -59,7 +59,7 @@ mkdir $testdir
 metadump_file=$TEST_DIR/${seq}_metadump
 
 echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 nr_blks=$((4 * blksz / 12))
 _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
 
diff --git a/tests/xfs/132 b/tests/xfs/132
index 5abcf30..6b8c05c 100755
--- a/tests/xfs/132
+++ b/tests/xfs/132
@@ -72,7 +72,7 @@ rm -rf $testdir
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 blks=2000
 margin=100
 sz=$((blksz * blks))
diff --git a/tests/xfs/139 b/tests/xfs/139
index 16193e5..b62ef1b 100755
--- a/tests/xfs/139
+++ b/tests/xfs/139
@@ -54,7 +54,7 @@ _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 
 echo "Create the original files"
 sz=$((48 * 1048576))
diff --git a/tests/xfs/140 b/tests/xfs/140
index 052c539..a87357b 100755
--- a/tests/xfs/140
+++ b/tests/xfs/140
@@ -54,7 +54,7 @@ _scratch_mount >> $seqres.full 2>&1
 
 testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
-blksz=$(stat -f -c '%S' $testdir)
+blksz=$(get_block_size $testdir)
 
 echo "Create the original files"
 sz=$((48 * 1048576))
diff --git a/tests/xfs/169 b/tests/xfs/169
index 996500e..acd4b89 100755
--- a/tests/xfs/169
+++ b/tests/xfs/169
@@ -57,7 +57,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 nr_blks=$((8 * blksz / 12))
 
 for i in 1 2 x; do
diff --git a/tests/xfs/180 b/tests/xfs/180
index 00e91a4..e2d3369 100755
--- a/tests/xfs/180
+++ b/tests/xfs/180
@@ -68,7 +68,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/182 b/tests/xfs/182
index b7aa5e7..2545f00 100755
--- a/tests/xfs/182
+++ b/tests/xfs/182
@@ -69,7 +69,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/184 b/tests/xfs/184
index 01c04c3..d2e1363 100755
--- a/tests/xfs/184
+++ b/tests/xfs/184
@@ -68,7 +68,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/192 b/tests/xfs/192
index 244a2ec..a003c45 100755
--- a/tests/xfs/192
+++ b/tests/xfs/192
@@ -69,7 +69,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/193 b/tests/xfs/193
index f59b3bd..2cd8880 100755
--- a/tests/xfs/193
+++ b/tests/xfs/193
@@ -67,7 +67,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/198 b/tests/xfs/198
index c12d915..f55ed23 100755
--- a/tests/xfs/198
+++ b/tests/xfs/198
@@ -68,7 +68,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/200 b/tests/xfs/200
index 92823b5..f7e2d04 100755
--- a/tests/xfs/200
+++ b/tests/xfs/200
@@ -70,7 +70,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/204 b/tests/xfs/204
index cc1683b..7775c6a 100755
--- a/tests/xfs/204
+++ b/tests/xfs/204
@@ -71,7 +71,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/208 b/tests/xfs/208
index 4f56884..e64106a 100755
--- a/tests/xfs/208
+++ b/tests/xfs/208
@@ -71,7 +71,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/211 b/tests/xfs/211
index 9f01d08..68abaf7 100755
--- a/tests/xfs/211
+++ b/tests/xfs/211
@@ -69,7 +69,7 @@ bufnr=16
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 2 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/215 b/tests/xfs/215
index b9c9ab4..c4bb322 100755
--- a/tests/xfs/215
+++ b/tests/xfs/215
@@ -66,7 +66,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_unwritten $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/218 b/tests/xfs/218
index 887a135..7fcca82 100755
--- a/tests/xfs/218
+++ b/tests/xfs/218
@@ -65,7 +65,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_unwritten $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/219 b/tests/xfs/219
index 5ae0714..f02cc2d 100755
--- a/tests/xfs/219
+++ b/tests/xfs/219
@@ -66,7 +66,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/221 b/tests/xfs/221
index 3afc75f..1dfcd96 100755
--- a/tests/xfs/221
+++ b/tests/xfs/221
@@ -65,7 +65,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/223 b/tests/xfs/223
index 3f34bcf..d93b311 100755
--- a/tests/xfs/223
+++ b/tests/xfs/223
@@ -67,7 +67,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/224 b/tests/xfs/224
index 91033fa..7a59dba 100755
--- a/tests/xfs/224
+++ b/tests/xfs/224
@@ -66,7 +66,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_holes $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/225 b/tests/xfs/225
index 2260441..596cdb8 100755
--- a/tests/xfs/225
+++ b/tests/xfs/225
@@ -66,7 +66,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_regular $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/226 b/tests/xfs/226
index ac70239..d3a0dc0 100755
--- a/tests/xfs/226
+++ b/tests/xfs/226
@@ -65,7 +65,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_regular $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/228 b/tests/xfs/228
index 65d7f51..994f501 100755
--- a/tests/xfs/228
+++ b/tests/xfs/228
@@ -72,7 +72,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/230 b/tests/xfs/230
index 73c6267..f4b9f15 100755
--- a/tests/xfs/230
+++ b/tests/xfs/230
@@ -72,7 +72,7 @@ echo "Create the original files"
 blksz=65536
 nr=64
 filesize=$((blksz * nr))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 $XFS_IO_PROG -c "cowextsize $((blksz * 16))" $testdir >> $seqres.full
 _weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
diff --git a/tests/xfs/231 b/tests/xfs/231
index d89139a..54fc46d 100755
--- a/tests/xfs/231
+++ b/tests/xfs/231
@@ -72,7 +72,7 @@ bufnr=2
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/232 b/tests/xfs/232
index 2438f1f..0ffa198 100755
--- a/tests/xfs/232
+++ b/tests/xfs/232
@@ -73,7 +73,7 @@ bufnr=2
 bufsize=$((blksz * bufnr))
 
 _require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
-real_blksz=$(stat -f -c '%S' $testdir)
+real_blksz=$(get_block_size $testdir)
 internal_blks=$((filesize / real_blksz))
 
 echo "Create the original files"
diff --git a/tests/xfs/233 b/tests/xfs/233
index 8fcf766..a0c1612 100755
--- a/tests/xfs/233
+++ b/tests/xfs/233
@@ -53,7 +53,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Create the original files"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 _pwrite_byte 0x61 0 $((blksz * 14 + 71)) $testdir/original >> $seqres.full
 cp -p $testdir/original $testdir/copy1
 cp -p $testdir/copy1 $testdir/copy2
diff --git a/tests/xfs/234 b/tests/xfs/234
index 8dadc34..9a60ec6 100755
--- a/tests/xfs/234
+++ b/tests/xfs/234
@@ -59,7 +59,7 @@ mkdir $testdir
 metadump_file=$TEST_DIR/${seq}_metadump
 
 echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 nr_blks=$((4 * blksz / 12))
 _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
 sync
diff --git a/tests/xfs/236 b/tests/xfs/236
index c7b3a19..e5840cb 100755
--- a/tests/xfs/236
+++ b/tests/xfs/236
@@ -57,7 +57,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 nr_blks=$((8 * blksz / 12))
 
 for i in 1 2 x; do
diff --git a/tests/xfs/265 b/tests/xfs/265
index 2039d9c..c8fb527 100755
--- a/tests/xfs/265
+++ b/tests/xfs/265
@@ -59,7 +59,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 nr_blks=$((2 * blksz / 12))
 
 for i in 1 2 x; do
diff --git a/tests/xfs/309 b/tests/xfs/309
index 3578690..38c0452 100755
--- a/tests/xfs/309
+++ b/tests/xfs/309
@@ -59,7 +59,7 @@ testdir=$SCRATCH_MNT/test-$seq
 mkdir $testdir
 
 echo "Create the original file blocks"
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 nr_blks=$((2 * blksz / 12))
 
 for i in 1 2 x; do
diff --git a/tests/xfs/310 b/tests/xfs/310
index 5125773..cce21be 100755
--- a/tests/xfs/310
+++ b/tests/xfs/310
@@ -58,7 +58,7 @@ _scratch_mkfs >/dev/null 2>&1
 _scratch_mount >> $seqres.full
 
 testdir=$SCRATCH_MNT/test-$seq
-blksz="$(stat -f $SCRATCH_MNT -c '%S')"
+blksz="$(get_block_size $SCRATCH_MNT)"
 
 umount $SCRATCH_MNT
 
@@ -72,7 +72,7 @@ xfs_info $SCRATCH_MNT >> $seqres.full
 
 echo "Create the original file blocks"
 mkdir $testdir
-blksz="$(stat -f $testdir -c '%S')"
+blksz="$(get_block_size $testdir)"
 $XFS_IO_PROG -f -c "falloc 0 $((nr_blks * blksz))" $testdir/file1 >> $seqres.full
 
 echo "Check extent count"
diff --git a/tests/xfs/328 b/tests/xfs/328
index 342fad5..33a0bef 100755
--- a/tests/xfs/328
+++ b/tests/xfs/328
@@ -62,7 +62,7 @@ mkdir "$testdir"
 # 2^10 blocks... that should be plenty for anyone.
 fnr=$((12 + LOAD_FACTOR))
 free_blocks=$(stat -f -c '%a' "$testdir")
-blksz=$(stat -f -c '%S' "$testdir")
+blksz=$(get_block_size $testdir)
 space_avail=$((free_blocks * blksz))
 calc_space()
 {


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 6/9] xfs: fix $XFS_DB_PROG usage
  2016-09-30  2:23 [PATCH v10 0/9] xfstests: fixes and new tests for rmap/reflink Darrick J. Wong
                   ` (4 preceding siblings ...)
  2016-09-30  2:23 ` [PATCH 5/9] misc: use get_block_size helper Darrick J. Wong
@ 2016-09-30  2:23 ` Darrick J. Wong
  2016-09-30 11:56   ` Christoph Hellwig
  2016-09-30  2:23 ` [PATCH 7/9] xfs: more rmapbt tests Darrick J. Wong
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 17+ messages in thread
From: Darrick J. Wong @ 2016-09-30  2:23 UTC (permalink / raw)
  To: david, eguan, darrick.wong; +Cc: linux-xfs, fstests

xfs_db requires us to pass in the log device, if any; this can be
accomplished via _scratch_xfs_db_options (if we're operating on the
scratch device, anyway).  However, many of the tests/xfs/ scripts
pass only $SCRATCH_DEV directly, so they'll fail if we test with an
external log.  Fix that by adding a new _scratch_xfs_db helper.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/populate |  100 ++++++++++++++++++++++++++-----------------------------
 common/rc       |   11 ++++--
 tests/xfs/001   |   16 ++++-----
 tests/xfs/002   |    4 +-
 tests/xfs/070   |    4 +-
 tests/xfs/077   |    6 ++-
 tests/xfs/086   |    2 +
 tests/xfs/087   |    2 +
 tests/xfs/088   |    2 +
 tests/xfs/089   |    2 +
 tests/xfs/091   |    2 +
 tests/xfs/093   |    2 +
 tests/xfs/097   |    2 +
 tests/xfs/098   |    4 +-
 tests/xfs/099   |    2 +
 tests/xfs/100   |    4 +-
 tests/xfs/101   |    2 +
 tests/xfs/102   |    4 +-
 tests/xfs/105   |    4 +-
 tests/xfs/111   |    2 +
 tests/xfs/112   |    4 +-
 tests/xfs/113   |    4 +-
 tests/xfs/117   |    2 +
 tests/xfs/120   |    2 +
 tests/xfs/123   |    2 +
 tests/xfs/124   |   10 +++---
 tests/xfs/125   |    8 ++--
 tests/xfs/126   |   10 +++---
 tests/xfs/130   |    4 +-
 tests/xfs/135   |    2 +
 tests/xfs/137   |    6 ++-
 tests/xfs/179   |   10 +++---
 tests/xfs/186   |    8 ++--
 tests/xfs/187   |   14 ++++----
 tests/xfs/235   |    4 +-
 tests/xfs/287   |    5 +--
 tests/xfs/298   |    2 +
 37 files changed, 137 insertions(+), 137 deletions(-)


diff --git a/common/populate b/common/populate
index aa6ed79..d0003c5 100644
--- a/common/populate
+++ b/common/populate
@@ -275,38 +275,35 @@ __populate_find_inode() {
 
 # Check data fork format of XFS file
 __populate_check_xfs_dformat() {
-	dev="$1"
-	inode="$2"
-	format="$3"
+	inode="$1"
+	format="$2"
 
-	fmt="$($XFS_DB_PROG -c "inode ${inode}" -c 'p core.format' "${dev}" | sed -e 's/^.*(\([a-z]*\)).*$/\1/g')"
+	fmt="$(_scratch_xfs_db -c "inode ${inode}" -c 'p core.format' | sed -e 's/^.*(\([a-z]*\)).*$/\1/g')"
 	test "${format}" = "${fmt}" || _fail "failed to create ino ${inode} dformat expected ${format} saw ${fmt}"
 }
 
 # Check attr fork format of XFS file
 __populate_check_xfs_aformat() {
-	dev="$1"
-	inode="$2"
-	format="$3"
+	inode="$1"
+	format="$2"
 
-	fmt="$($XFS_DB_PROG -c "inode ${inode}" -c 'p core.aformat' "${dev}" | sed -e 's/^.*(\([a-z]*\)).*$/\1/g')"
+	fmt="$(_scratch_xfs_db -c "inode ${inode}" -c 'p core.aformat' | sed -e 's/^.*(\([a-z]*\)).*$/\1/g')"
 	test "${format}" = "${fmt}" || _fail "failed to create ino ${inode} aformat expected ${format} saw ${fmt}"
 }
 
 # Check structure of XFS directory
 __populate_check_xfs_dir() {
-	dev="$1"
-	inode="$2"
-	dtype="$3"
+	inode="$1"
+	dtype="$2"
 
 	(test -n "${leaf_lblk}" && test -n "${node_lblk}") || _fail "must define leaf_lblk and node_lblk before calling __populate_check_xfs_dir"
 	datab=0
 	leafb=0
 	freeb=0
-	#echo "== check dir ${inode} type ${dtype}" ; $XFS_DB_PROG -x -c "inode ${inode}" -c "bmap" "${SCRATCH_DEV}"
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock 0" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' || datab=1
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${leaf_lblk}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' || leafb=1
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${node_lblk}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' || freeb=1
+	#echo "== check dir ${inode} type ${dtype}" ; _scratch_xfs_db -x -c "inode ${inode}" -c "bmap"
+	_scratch_xfs_db -x -c "inode ${inode}" -c "dblock 0" -c "stack" | grep -q 'file data block is unmapped' || datab=1
+	_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${leaf_lblk}" -c "stack" | grep -q 'file data block is unmapped' || leafb=1
+	_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${node_lblk}" -c "stack" | grep -q 'file data block is unmapped' || freeb=1
 
 	case "${dtype}" in
 	"shortform"|"inline"|"local")
@@ -328,15 +325,14 @@ __populate_check_xfs_dir() {
 
 # Check structure of XFS attr
 __populate_check_xfs_attr() {
-	dev="$1"
-	inode="$2"
-	atype="$3"
+	inode="$1"
+	atype="$2"
 
 	datab=0
 	leafb=0
-	#echo "== check attr ${inode} type ${dtype}" ; $XFS_DB_PROG -x -c "inode ${inode}" -c "bmap -a" "${SCRATCH_DEV}"
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock 0" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' || datab=1
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock 1" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' || leafb=1
+	#echo "== check attr ${inode} type ${dtype}" ; _scratch_xfs_db -x -c "inode ${inode}" -c "bmap -a"
+	_scratch_xfs_db -x -c "inode ${inode}" -c "ablock 0" -c "stack" | grep -q 'file attr block is unmapped' || datab=1
+	_scratch_xfs_db -x -c "inode ${inode}" -c "ablock 1" -c "stack" | grep -q 'file attr block is unmapped' || leafb=1
 
 	case "${atype}" in
 	"shortform"|"inline"|"local")
@@ -378,28 +374,28 @@ _scratch_xfs_populate_check() {
 	node_lblk="$((64 * 1073741824 / blksz))"
 	umount "${SCRATCH_MNT}"
 
-	__populate_check_xfs_dformat "${SCRATCH_DEV}" "${extents_file}" "extents"
-	__populate_check_xfs_dformat "${SCRATCH_DEV}" "${btree_file}" "btree"
-	__populate_check_xfs_dir "${SCRATCH_DEV}" "${inline_dir}" "inline"
-	__populate_check_xfs_dir "${SCRATCH_DEV}" "${block_dir}" "block"
-	__populate_check_xfs_dir "${SCRATCH_DEV}" "${leaf_dir}" "leaf"
-	__populate_check_xfs_dir "${SCRATCH_DEV}" "${node_dir}" "node"
-	__populate_check_xfs_dir "${SCRATCH_DEV}" "${btree_dir}" "btree"
-	__populate_check_xfs_dformat "${SCRATCH_DEV}" "${btree_dir}" "btree"
-	__populate_check_xfs_dformat "${SCRATCH_DEV}" "${bdev}" "dev"
-	__populate_check_xfs_dformat "${SCRATCH_DEV}" "${cdev}" "dev"
-	__populate_check_xfs_attr "${SCRATCH_DEV}" "${local_attr}" "local"
-	__populate_check_xfs_attr "${SCRATCH_DEV}" "${leaf_attr}" "leaf"
-	__populate_check_xfs_attr "${SCRATCH_DEV}" "${node_attr}" "node"
-	__populate_check_xfs_attr "${SCRATCH_DEV}" "${btree_attr}" "btree"
-	__populate_check_xfs_aformat "${SCRATCH_DEV}" "${btree_attr}" "btree"
+	__populate_check_xfs_dformat "${extents_file}" "extents"
+	__populate_check_xfs_dformat "${btree_file}" "btree"
+	__populate_check_xfs_dir "${inline_dir}" "inline"
+	__populate_check_xfs_dir "${block_dir}" "block"
+	__populate_check_xfs_dir "${leaf_dir}" "leaf"
+	__populate_check_xfs_dir "${node_dir}" "node"
+	__populate_check_xfs_dir "${btree_dir}" "btree"
+	__populate_check_xfs_dformat "${btree_dir}" "btree"
+	__populate_check_xfs_dformat "${bdev}" "dev"
+	__populate_check_xfs_dformat "${cdev}" "dev"
+	__populate_check_xfs_attr "${local_attr}" "local"
+	__populate_check_xfs_attr "${leaf_attr}" "leaf"
+	__populate_check_xfs_attr "${node_attr}" "node"
+	__populate_check_xfs_attr "${btree_attr}" "btree"
+	__populate_check_xfs_aformat "${btree_attr}" "btree"
 }
 
 # Check data fork format of ext4 file
 __populate_check_ext4_dformat() {
-	dev="$1"
-	inode="$2"
-	format="$3"
+	dev="${SCRATCH_DEV}"
+	inode="$1"
+	format="$2"
 
 	extents=0
 	etree=0
@@ -424,9 +420,9 @@ __populate_check_ext4_dformat() {
 
 # Check attr fork format of ext4 file
 __populate_check_ext4_aformat() {
-	dev="$1"
-	inode="$2"
-	format="$3"
+	dev="${SCRATCH_DEV}"
+	inode="$1"
+	format="$2"
 
 	ablock=1
 	debugfs -R "stat <${inode}>" "${dev}" 2> /dev/null | grep 'File ACL: 0' -q && ablock=0
@@ -445,9 +441,9 @@ __populate_check_ext4_aformat() {
 
 # Check structure of ext4 dir
 __populate_check_ext4_dir() {
-	dev="$1"
-	inode="$2"
-	dtype="$3"
+	dev="${SCRATCH_DEV}"
+	inode="$1"
+	dtype="$2"
 
 	htree=0
 	inline=0
@@ -483,13 +479,13 @@ _scratch_ext4_populate_check() {
 	block_attr="$(__populate_find_inode "${SCRATCH_MNT}/ATTR.FMT_BLOCK")"
 	umount "${SCRATCH_MNT}"
 
-	__populate_check_ext4_dformat "${SCRATCH_DEV}" "${extents_file}" "extents"
-	__populate_check_ext4_dformat "${SCRATCH_DEV}" "${etree_file}" "etree"
-	__populate_check_ext4_dir "${SCRATCH_DEV}" "${block_dir}" "block"
-	__populate_check_ext4_dir "${SCRATCH_DEV}" "${htree_dir}" "htree"
-	__populate_check_ext4_dformat "${SCRATCH_DEV}" "${extents_slink}" "extents"
-	__populate_check_ext4_aformat "${SCRATCH_DEV}" "${local_attr}" "local"
-	__populate_check_ext4_aformat "${SCRATCH_DEV}" "${block_attr}" "block"
+	__populate_check_ext4_dformat "${extents_file}" "extents"
+	__populate_check_ext4_dformat "${etree_file}" "etree"
+	__populate_check_ext4_dir "${block_dir}" "block"
+	__populate_check_ext4_dir "${htree_dir}" "htree"
+	__populate_check_ext4_dformat "${extents_slink}" "extents"
+	__populate_check_ext4_aformat "${local_attr}" "local"
+	__populate_check_ext4_aformat "${block_attr}" "block"
 }
 
 # Populate a scratch FS and check the contents to make sure we got that
diff --git a/common/rc b/common/rc
index cd0810a..53f5560 100644
--- a/common/rc
+++ b/common/rc
@@ -1106,6 +1106,11 @@ _scratch_xfs_db_options()
     echo $SCRATCH_OPTIONS $* $SCRATCH_DEV
 }
 
+_scratch_xfs_db()
+{
+	$XFS_DB_PROG "$@" $(_scratch_xfs_db_options)
+}
+
 _scratch_xfs_logprint()
 {
     SCRATCH_OPTIONS=""
@@ -2083,7 +2088,7 @@ _require_xfs_db_command()
 	fi
 	command=$1
 
-	$XFS_DB_PROG -x -c "help" $SCRATCH_DEV | grep $command > /dev/null || \
+	_scratch_xfs_db -x -c "help" | grep $command > /dev/null || \
 		_notrun "xfs_db $command support is missing"
 }
 
@@ -3368,11 +3373,11 @@ _require_meta_uuid()
 	# This will create a crc fs on $SCRATCH_DEV
 	_require_xfs_crc
 
-	$XFS_DB_PROG -x -c "uuid restore" $SCRATCH_DEV 2>&1 \
+	_scratch_xfs_db -x -c "uuid restore" 2>&1 \
 	   | grep -q "invalid UUID\|supported on V5 fs" \
 	   && _notrun "Userspace doesn't support meta_uuid feature"
 
-	$XFS_DB_PROG -x -c "uuid generate" $SCRATCH_DEV >/dev/null 2>&1
+	_scratch_xfs_db -x -c "uuid generate" >/dev/null 2>&1
 
 	_scratch_mount >/dev/null 2>&1 \
 	   || _notrun "Kernel doesn't support meta_uuid feature"
diff --git a/tests/xfs/001 b/tests/xfs/001
index c33adae..2c205f0 100755
--- a/tests/xfs/001
+++ b/tests/xfs/001
@@ -44,11 +44,11 @@ _do_bit_test()
 	bits="$2"
 
 	echo "testing $field with $bits bits"
-	$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write $field 0" $SCRATCH_DEV
+	_scratch_xfs_db -x -c "inode $FILE_INO" -c "write $field 0"
 	num=1
 	for n in `seq 0 1 $bits`; do
-		$XFS_DB_PROG -x -c "inode $FILE_INO" \
-			  -c "write $field $num" $SCRATCH_DEV
+		_scratch_xfs_db -x -c "inode $FILE_INO" \
+			  -c "write $field $num"
 		let num=$num*2
 	done
 	echo
@@ -89,10 +89,10 @@ _do_bit_test "u.bmx[0].startoff" $BMBT_STARTOFF_BITLEN
 _do_bit_test "u.bmx[0].startblock" $BMBT_STARTBLOCK_BITLEN
 _do_bit_test "u.bmx[0].blockcount" $BMBT_BLOCKCOUNT_BITLEN
 # test setting the 32 bit generation number
-$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0x5a" $SCRATCH_DEV
-$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0xa5" $SCRATCH_DEV
-$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0" $SCRATCH_DEV
-$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen #5a5a" $SCRATCH_DEV
-$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen #a5a5" $SCRATCH_DEV
+_scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen 0x5a"
+_scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen 0xa5"
+_scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen 0"
+_scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen #5a5a"
+_scratch_xfs_db -x -c "inode $FILE_INO" -c "write core.gen #a5a5"
 status=0
 exit
diff --git a/tests/xfs/002 b/tests/xfs/002
index 6dfdd6c..741117b 100755
--- a/tests/xfs/002
+++ b/tests/xfs/002
@@ -62,8 +62,8 @@ _scratch_mkfs_xfs -m crc=0 -d size=128m >> $seqres.full 2>&1 || _fail "mkfs fail
 # Scribble past a couple V4 secondary superblocks to populate sb_crc
 # (We can't write to the structure member because it doesn't exist
 # on a v4 superblock, so we use the data type & "write fill")
-$XFS_DB_PROG -x -c "sb 1" -c "type data" -c "write fill 0xff 224 4" $SCRATCH_DEV
-$XFS_DB_PROG -x -c "sb 2" -c "type data" -c "write fill 0xff 224 4" $SCRATCH_DEV
+_scratch_xfs_db -x -c "sb 1" -c "type data" -c "write fill 0xff 224 4"
+_scratch_xfs_db -x -c "sb 2" -c "type data" -c "write fill 0xff 224 4"
 
 _scratch_mount
 
diff --git a/tests/xfs/070 b/tests/xfs/070
index e3a48b3..0ae6eff 100755
--- a/tests/xfs/070
+++ b/tests/xfs/070
@@ -100,8 +100,8 @@ _scratch_mkfs | _filter_mkfs > /dev/null 2> $tmp.mkfs || _fail "mkfs failed"
 . $tmp.mkfs # import agcount
 
 # corrupt the last secondary sb in the fs
-$XFS_DB_PROG -x -c "sb $((agcount - 1))" -c "type data" \
-	-c "write fill 0xff 0 512" $SCRATCH_DEV
+_scratch_xfs_db -x -c "sb $((agcount - 1))" -c "type data" \
+	-c "write fill 0xff 0 512"
 
 # attempt to repair
 _xfs_repair_noscan
diff --git a/tests/xfs/077 b/tests/xfs/077
index 007d05d..eba4f08 100755
--- a/tests/xfs/077
+++ b/tests/xfs/077
@@ -64,9 +64,9 @@ _test_uuid()
 	ACTION=$1
 	EXPECTED_UUID=$2
 
-	$XFS_DB_PROG -x -c "uuid $ACTION" $SCRATCH_DEV \
+	_scratch_xfs_db -x -c "uuid $ACTION" \
 					| _filter_uuid $EXPECTED_UUID
-	NEW_UUID=`$XFS_DB_PROG -c "uuid"  $SCRATCH_DEV | awk '{print $NF}'`
+	NEW_UUID=`_scratch_xfs_db -c "uuid"  | awk '{print $NF}'`
 	_check_scratch_fs
 	_scratch_mount || _fail "Mount failed after UUID $ACTION"
 	_scratch_unmount
@@ -83,7 +83,7 @@ rm -f $seqres.full
 
 _scratch_mkfs_xfs -m crc=1 >> $seqres.full 2>&1 || _fail "mkfs failed"
 
-ORIG_UUID=`$XFS_DB_PROG -c "uuid" $SCRATCH_DEV | awk '{print $NF}'`
+ORIG_UUID=`_scratch_xfs_db -c "uuid" | awk '{print $NF}'`
 
 _scratch_mount
 # Put some stuff on the fs
diff --git a/tests/xfs/086 b/tests/xfs/086
index 143915b..cf0a71a 100755
--- a/tests/xfs/086
+++ b/tests/xfs/086
@@ -87,7 +87,7 @@ _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail
 
 echo "+ corrupt image"
 for ag in $(seq 1 $((agcount - 1))) 0; do
-	$XFS_DB_PROG -x -c "agf ${ag}" -c "agf ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+	_scratch_xfs_db -x -c "agf ${ag}" -c "agf ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
 done
 
 # Try to append to files; this should fail
diff --git a/tests/xfs/087 b/tests/xfs/087
index 97c6680..0bb3ec1 100755
--- a/tests/xfs/087
+++ b/tests/xfs/087
@@ -86,7 +86,7 @@ _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail
 
 echo "+ corrupt image"
 for ag in $(seq 1 $((agcount - 1))) 0; do
-	$XFS_DB_PROG -x -c "agi ${ag}" -c "agi ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+	_scratch_xfs_db -x -c "agi ${ag}" -c "agi ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
 done
 
 echo "+ mount image"
diff --git a/tests/xfs/088 b/tests/xfs/088
index 18bf6ad..d6972a4 100755
--- a/tests/xfs/088
+++ b/tests/xfs/088
@@ -86,7 +86,7 @@ _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail
 
 echo "+ corrupt image"
 for ag in $(seq 1 $((agcount - 1))) 0; do
-	$XFS_DB_PROG -x -c "agfl ${ag}" -c "agfl ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+	_scratch_xfs_db -x -c "agfl ${ag}" -c "agfl ${ag}" -c "stack" -c "blocktrash -x 32 -o +64 -y 4096 -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
 done
 
 # Try to append to files; this should fail
diff --git a/tests/xfs/089 b/tests/xfs/089
index b6e512f..06996a5 100755
--- a/tests/xfs/089
+++ b/tests/xfs/089
@@ -86,7 +86,7 @@ _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail
 
 echo "+ corrupt image"
 for ag in $(seq 1 $((agcount - 1))) 0; do
-	$XFS_DB_PROG -x -c "agf ${ag}" -c "agf ${ag}" -c "addr bnoroot" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+	_scratch_xfs_db -x -c "agf ${ag}" -c "agf ${ag}" -c "addr bnoroot" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
 done
 
 # Try to append to files; this should fail
diff --git a/tests/xfs/091 b/tests/xfs/091
index f995d9c..a263cb0 100755
--- a/tests/xfs/091
+++ b/tests/xfs/091
@@ -86,7 +86,7 @@ _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail
 
 echo "+ corrupt image"
 for ag in $(seq 1 $((agcount - 1))) 0; do
-	$XFS_DB_PROG -x -c "agf ${ag}" -c "agf ${ag}" -c "addr cntroot" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+	_scratch_xfs_db -x -c "agf ${ag}" -c "agf ${ag}" -c "addr cntroot" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
 done
 
 # Try to append to files; this should fail
diff --git a/tests/xfs/093 b/tests/xfs/093
index 7d4d9b8..753231e 100755
--- a/tests/xfs/093
+++ b/tests/xfs/093
@@ -86,7 +86,7 @@ _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail
 
 echo "+ corrupt image"
 for ag in $(seq 1 $((agcount - 1))) 0; do
-	$XFS_DB_PROG -x -c "agi ${ag}" -c "agi ${ag}" -c "addr root" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+	_scratch_xfs_db -x -c "agi ${ag}" -c "agi ${ag}" -c "addr root" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
 done
 
 echo "+ mount image"
diff --git a/tests/xfs/097 b/tests/xfs/097
index f5a8178..a75f06a 100755
--- a/tests/xfs/097
+++ b/tests/xfs/097
@@ -89,7 +89,7 @@ _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail
 
 echo "+ corrupt image"
 for ag in $(seq 1 $((agcount - 1))) 0; do
-	$XFS_DB_PROG -x -c "agi ${ag}" -c "agi ${ag}" -c "addr free_root" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+	_scratch_xfs_db -x -c "agi ${ag}" -c "agi ${ag}" -c "addr free_root" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
 done
 
 echo "+ mount image"
diff --git a/tests/xfs/098 b/tests/xfs/098
index 86ec62c..581377e 100755
--- a/tests/xfs/098
+++ b/tests/xfs/098
@@ -95,8 +95,8 @@ echo "+ check fs"
 _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
 
 echo "+ corrupt image"
-logstart="$($XFS_DB_PROG -c 'sb 0' -c 'p' "${SCRATCH_DEV}" | grep '^logstart =' | cut -d ' ' -f 3)"
-logstart="$($XFS_DB_PROG -c "convert fsblock ${logstart} byte" "${SCRATCH_DEV}" | sed -e 's/^.*(\([0-9]*\).*$/\1/g')"
+logstart="$(_scratch_xfs_db -c 'sb 0' -c 'p' | grep '^logstart =' | cut -d ' ' -f 3)"
+logstart="$(_scratch_xfs_db -c "convert fsblock ${logstart} byte" | sed -e 's/^.*(\([0-9]*\).*$/\1/g')"
 logblocks="$(xfs_db -c 'sb 0' -c 'p' "${SCRATCH_DEV}" | grep '^logblocks =' | cut -d ' ' -f 3)"
 $XFS_IO_PROG -f -c "pwrite -S 0x62 ${logstart} $((logblocks * blksz))" "${SCRATCH_DEV}" >> $seqres.full
 
diff --git a/tests/xfs/099 b/tests/xfs/099
index 36cf893..ebc02dd 100755
--- a/tests/xfs/099
+++ b/tests/xfs/099
@@ -78,7 +78,7 @@ echo "+ check dir"
 __populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" block
 
 echo "+ corrupt dir"
-$XFS_DB_PROG -x -c "inode ${inode}" -c 'dblock 0' -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
+_scratch_xfs_db -x -c "inode ${inode}" -c 'dblock 0' -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
 
 echo "+ mount image"
 _scratch_mount
diff --git a/tests/xfs/100 b/tests/xfs/100
index 397c613..2412c81 100755
--- a/tests/xfs/100
+++ b/tests/xfs/100
@@ -80,8 +80,8 @@ __populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" leaf
 echo "+ corrupt dir"
 loff=0
 while true; do
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' && break
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
+	_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" | grep -q 'file data block is unmapped' && break
+	_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
 	loff="$((loff + 1))"
 done
 
diff --git a/tests/xfs/101 b/tests/xfs/101
index 09af649..679940f 100755
--- a/tests/xfs/101
+++ b/tests/xfs/101
@@ -78,7 +78,7 @@ echo "+ check dir"
 __populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" leaf
 
 echo "+ corrupt dir"
-$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${leaf_lblk}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
+_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${leaf_lblk}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
 
 echo "+ mount image"
 _scratch_mount
diff --git a/tests/xfs/102 b/tests/xfs/102
index 5d1965e..8018a9e 100755
--- a/tests/xfs/102
+++ b/tests/xfs/102
@@ -80,8 +80,8 @@ __populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" node
 echo "+ corrupt dir"
 loff=0
 while true; do
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' && break
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
+	_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" | grep -q 'file data block is unmapped' && break
+	_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
 	loff="$((loff + 1))"
 done
 
diff --git a/tests/xfs/105 b/tests/xfs/105
index 516639a..27ee4b3 100755
--- a/tests/xfs/105
+++ b/tests/xfs/105
@@ -80,8 +80,8 @@ __populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" node
 echo "+ corrupt dir"
 loff="${leaf_lblk}"
 while true; do
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' && break
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
+	_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" | grep -q 'file data block is unmapped' && break
+	_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
 	loff="$((loff + 1))"
 done
 
diff --git a/tests/xfs/111 b/tests/xfs/111
index f6a41a8..d5a09bb 100755
--- a/tests/xfs/111
+++ b/tests/xfs/111
@@ -64,7 +64,7 @@ INO=`ls -i $SCRATCH_MNT/512 | awk '{print $1}'`
 _scratch_unmount
 
 # Figure out where that middle inode starts
-BYTE=`$XFS_DB_PROG -c "convert inode $INO byte" $SCRATCH_DEV \
+BYTE=`_scratch_xfs_db -c "convert inode $INO byte" \
 	| awk '{print $2}' | sed s/[\(\)]//g`
 
 echo Blat inode clusters
diff --git a/tests/xfs/112 b/tests/xfs/112
index aa7561e..c237f03 100755
--- a/tests/xfs/112
+++ b/tests/xfs/112
@@ -80,8 +80,8 @@ __populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" node
 echo "+ corrupt dir"
 loff="${node_lblk}"
 while true; do
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' && break
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
+	_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" | grep -q 'file data block is unmapped' && break
+	_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
 	loff="$((loff + 1))"
 done
 
diff --git a/tests/xfs/113 b/tests/xfs/113
index 8aa3395..6d6e6fd 100755
--- a/tests/xfs/113
+++ b/tests/xfs/113
@@ -80,8 +80,8 @@ __populate_check_xfs_dir "${SCRATCH_DEV}" "${inode}" btree
 echo "+ corrupt dir"
 loff=0
 while true; do
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file data block is unmapped' && break
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
+	_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" | grep -q 'file data block is unmapped' && break
+	_scratch_xfs_db -x -c "inode ${inode}" -c "dblock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
 	loff="$((loff + 1))"
 done
 
diff --git a/tests/xfs/117 b/tests/xfs/117
index 27dafd9..f251fb3 100755
--- a/tests/xfs/117
+++ b/tests/xfs/117
@@ -85,7 +85,7 @@ _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail
 
 echo "+ corrupt image"
 seq "${inode}" "$((inode + 64))" | while read ino; do
-	$XFS_DB_PROG -x -c "inode ${ino}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full 2>&1
+	_scratch_xfs_db -x -c "inode ${ino}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full 2>&1
 done
 
 echo "+ mount image"
diff --git a/tests/xfs/120 b/tests/xfs/120
index 08a4615..3deece6 100755
--- a/tests/xfs/120
+++ b/tests/xfs/120
@@ -75,7 +75,7 @@ echo "+ check fs"
 _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
 
 echo "+ corrupt image"
-$XFS_DB_PROG -x -c "inode ${inode}" -c "addr u.bmbt.ptrs[1]" -c "addr u3.bmbt.ptrs[1]" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
+_scratch_xfs_db -x -c "inode ${inode}" -c "addr u.bmbt.ptrs[1]" -c "addr u3.bmbt.ptrs[1]" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
 
 echo "+ mount image"
 _scratch_mount
diff --git a/tests/xfs/123 b/tests/xfs/123
index a746d5c..e6cd8e7 100755
--- a/tests/xfs/123
+++ b/tests/xfs/123
@@ -74,7 +74,7 @@ echo "+ check fs"
 _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
 
 echo "+ corrupt image"
-$XFS_DB_PROG -x -c "inode ${inode}" -c "dblock 0" -c "stack" -c "blocktrash -x 32 -o 256 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
+_scratch_xfs_db -x -c "inode ${inode}" -c "dblock 0" -c "stack" -c "blocktrash -x 32 -o 256 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
 
 echo "+ mount image"
 _scratch_mount
diff --git a/tests/xfs/124 b/tests/xfs/124
index 239c246..cfea2e6 100755
--- a/tests/xfs/124
+++ b/tests/xfs/124
@@ -77,13 +77,13 @@ echo "+ check fs"
 _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
 
 echo "+ check xattr"
-$XFS_DB_PROG -x -c "inode ${inode}" -c "bmap" "${SCRATCH_DEV}" >> $seqres.full
-$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock 0" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' && _fail "failed to create a block xattr (data)"
-$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock ${leaf_lblk}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' || _fail "failed to create a block xattr (leaf)"
-$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock ${node_lblk}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' || _fail "failed to create a block xattr (free)"
+_scratch_xfs_db -x -c "inode ${inode}" -c "bmap" >> $seqres.full
+_scratch_xfs_db -x -c "inode ${inode}" -c "ablock 0" -c "stack" | grep -q 'file attr block is unmapped' && _fail "failed to create a block xattr (data)"
+_scratch_xfs_db -x -c "inode ${inode}" -c "ablock ${leaf_lblk}" -c "stack" | grep -q 'file attr block is unmapped' || _fail "failed to create a block xattr (leaf)"
+_scratch_xfs_db -x -c "inode ${inode}" -c "ablock ${node_lblk}" -c "stack" | grep -q 'file attr block is unmapped' || _fail "failed to create a block xattr (free)"
 
 echo "+ corrupt xattr"
-$XFS_DB_PROG -x -c "inode ${inode}" -c 'ablock 0' -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
+_scratch_xfs_db -x -c "inode ${inode}" -c 'ablock 0' -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
 
 echo "+ mount image"
 _scratch_mount
diff --git a/tests/xfs/125 b/tests/xfs/125
index cf61e02..3f2f6f0 100755
--- a/tests/xfs/125
+++ b/tests/xfs/125
@@ -78,12 +78,12 @@ echo "+ check fs"
 _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
 
 echo "+ check xattr"
-$XFS_DB_PROG -x -c "inode ${inode}" -c "bmap" "${SCRATCH_DEV}" >> $seqres.full
-$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock 0" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' && _fail "failed to create a leaf xattr (index)"
-$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock 1" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' && _fail "failed to create a leaf xattr (data)"
+_scratch_xfs_db -x -c "inode ${inode}" -c "bmap" >> $seqres.full
+_scratch_xfs_db -x -c "inode ${inode}" -c "ablock 0" -c "stack" | grep -q 'file attr block is unmapped' && _fail "failed to create a leaf xattr (index)"
+_scratch_xfs_db -x -c "inode ${inode}" -c "ablock 1" -c "stack" | grep -q 'file attr block is unmapped' && _fail "failed to create a leaf xattr (data)"
 
 echo "+ corrupt xattr"
-$XFS_DB_PROG -x -c "inode ${inode}" -c 'ablock 0' -c "stack" -c "blocktrash -x 32 -o +32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
+_scratch_xfs_db -x -c "inode ${inode}" -c 'ablock 0' -c "stack" -c "blocktrash -x 32 -o +32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
 
 echo "+ mount image"
 _scratch_mount
diff --git a/tests/xfs/126 b/tests/xfs/126
index ebe84fc..77779e0 100755
--- a/tests/xfs/126
+++ b/tests/xfs/126
@@ -78,15 +78,15 @@ echo "+ check fs"
 _scratch_xfs_repair -n >> $seqres.full 2>&1 || _fail "xfs_repair should not fail"
 
 echo "+ check xattr"
-$XFS_DB_PROG -x -c "inode ${inode}" -c "bmap" "${SCRATCH_DEV}" >> $seqres.full
-$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock 0" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' && _fail "failed to create a leaf xattr (index)"
-$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock 1" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' && _fail "failed to create a leaf xattr (data)"
+_scratch_xfs_db -x -c "inode ${inode}" -c "bmap" >> $seqres.full
+_scratch_xfs_db -x -c "inode ${inode}" -c "ablock 0" -c "stack" | grep -q 'file attr block is unmapped' && _fail "failed to create a leaf xattr (index)"
+_scratch_xfs_db -x -c "inode ${inode}" -c "ablock 1" -c "stack" | grep -q 'file attr block is unmapped' && _fail "failed to create a leaf xattr (data)"
 
 echo "+ corrupt xattr"
 loff=1
 while true; do
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock ${loff}" -c "stack" "${SCRATCH_DEV}" | grep -q 'file attr block is unmapped' && break
-	$XFS_DB_PROG -x -c "inode ${inode}" -c "ablock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" "${SCRATCH_DEV}" >> $seqres.full
+	_scratch_xfs_db -x -c "inode ${inode}" -c "ablock ${loff}" -c "stack" | grep -q 'file attr block is unmapped' && break
+	_scratch_xfs_db -x -c "inode ${inode}" -c "ablock ${loff}" -c "stack" -c "blocktrash -x 32 -y $((blksz * 8)) -z ${FUZZ_ARGS}" >> $seqres.full
 	loff="$((loff + 1))"
 done
 
diff --git a/tests/xfs/130 b/tests/xfs/130
index 48f6a84..1c3d642 100755
--- a/tests/xfs/130
+++ b/tests/xfs/130
@@ -73,9 +73,9 @@ _scratch_xfs_repair -n >> "$seqres.full" 2>&1 || \
 
 echo "+ corrupt image"
 seq 0 $((agcount - 1)) | while read ag; do
-	$XFS_DB_PROG -x -c "agf ${ag}" -c "agf ${ag}" -c "addr refcntroot" \
+	_scratch_xfs_db -x -c "agf ${ag}" -c "agf ${ag}" -c "addr refcntroot" \
 		-c "stack" -c "blocktrash -x 4096 -y 4096 -z -n 8 -3" \
-		"${SCRATCH_DEV}" >> "$seqres.full" 2>&1
+		>> "$seqres.full" 2>&1
 done
 
 echo "+ mount image"
diff --git a/tests/xfs/135 b/tests/xfs/135
index 0487f0e..01fa4a6 100755
--- a/tests/xfs/135
+++ b/tests/xfs/135
@@ -60,7 +60,7 @@ _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
 # (the log is zeroed when cycle == 1).
 for i in 16 32 64 128 256; do
 	lsunit=$((i * 1024))
-	$XFS_DB_PROG -x -c "logformat -c 3 -s $lsunit" $SCRATCH_DEV | \
+	_scratch_xfs_db -x -c "logformat -c 3 -s $lsunit" | \
 		tee -a $seqres.full
 	# don't redirect error output so it causes test failure
 	$XFS_LOGPRINT_PROG $SCRATCH_DEV >> $seqres.full
diff --git a/tests/xfs/137 b/tests/xfs/137
index dec9fc9..093ef00 100755
--- a/tests/xfs/137
+++ b/tests/xfs/137
@@ -58,7 +58,7 @@ _require_xfs_db_command "logformat"
 _scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
 
 # push the log cycle ahead so we have room to move it backwards later
-$XFS_DB_PROG -x -c "logformat -c 3" $SCRATCH_DEV >> $seqres.full 2>&1
+_scratch_xfs_db -x -c "logformat -c 3" >> $seqres.full 2>&1
 
 # do some work on the fs to update metadata LSNs
 _scratch_mount
@@ -68,13 +68,13 @@ _scratch_unmount
 # Reformat to the current cycle and try to mount. This fails in most cases
 # because the sb LSN is ahead of the current LSN. If it doesn't fail, push the
 # cycle back further and try again.
-$XFS_DB_PROG -x -c "logformat" $SCRATCH_DEV >> $seqres.full 2>&1
+_scratch_xfs_db -x -c "logformat" >> $seqres.full 2>&1
 _scratch_mount >> $seqres.full 2>&1
 if [ $? != 0 ]; then
 	echo mount failure detected
 else
 	_scratch_unmount
-	$XFS_DB_PROG -x -c "logformat -c 2" $SCRATCH_DEV >> $seqres.full 2>&1
+	_scratch_xfs_db -x -c "logformat -c 2" >> $seqres.full 2>&1
 	_scratch_mount >> $seqres.full 2>&1 || echo mount failure detected
 fi
 
diff --git a/tests/xfs/179 b/tests/xfs/179
index 18459cb..4aeabb2 100755
--- a/tests/xfs/179
+++ b/tests/xfs/179
@@ -67,9 +67,9 @@ _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
 echo "Change reference count"
 _scratch_unmount
 echo "set refcount to -4" >> $seqres.full
-$XFS_DB_PROG -x -c 'agf 0' -c 'addr refcntroot' -c 'write recs[1].refcount 4294967292' $SCRATCH_DEV >> $seqres.full
+_scratch_xfs_db -x -c 'agf 0' -c 'addr refcntroot' -c 'write recs[1].refcount 4294967292' >> $seqres.full
 echo "check refcount after setting to -4" >> $seqres.full
-$XFS_DB_PROG -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' $SCRATCH_DEV >> $seqres.full
+_scratch_xfs_db -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' >> $seqres.full
 _scratch_mount >> $seqres.full
 
 echo "Reflink the overlinked file"
@@ -82,7 +82,7 @@ _cp_reflink $testdir/file1 $testdir/file7 >> $seqres.full
 echo "Check scratch fs"
 _scratch_unmount
 echo "check refcount after reflinking 5 more times" >> $seqres.full
-$XFS_DB_PROG -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' $SCRATCH_DEV >> $seqres.full
+_scratch_xfs_db -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' >> $seqres.full
 _scratch_mount >> $seqres.full
 
 echo "CoW a couple files"
@@ -93,7 +93,7 @@ _pwrite_byte 0x62 0 $blksz $testdir/file7 >> $seqres.full
 echo "Check scratch fs"
 _scratch_unmount
 echo "check refcount after cowing 3 files" >> $seqres.full
-$XFS_DB_PROG -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' $SCRATCH_DEV >> $seqres.full
+_scratch_xfs_db -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' >> $seqres.full
 _scratch_mount >> $seqres.full
 
 echo "Remove reflinked files"
@@ -102,7 +102,7 @@ rm -rf $testdir/file*
 echo "Check scratch fs"
 _scratch_unmount
 echo "check refcount after removing all files" >> $seqres.full
-$XFS_DB_PROG -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' $SCRATCH_DEV >> $seqres.full
+_scratch_xfs_db -c 'agf 0' -c 'addr refcntroot' -c 'p recs[1]' >> $seqres.full
 _scratch_xfs_repair -o force_geometry -n >> $seqres.full 2>&1
 res=$?
 if [ $res -eq 0 ]; then
diff --git a/tests/xfs/186 b/tests/xfs/186
index 192a8c8..4b36ae6 100755
--- a/tests/xfs/186
+++ b/tests/xfs/186
@@ -98,8 +98,8 @@ _print_inode()
 {
 	echo ""
 	echo "================================="
-	$XFS_DB_PROG -c "version" $SCRATCH_DEV 2>&1 | _filter_version
-	$XFS_DB_PROG -c "inode $inum" -c p $SCRATCH_DEV 2>&1 | _filter_inode
+	_scratch_xfs_db -c "version" 2>&1 | _filter_version
+	_scratch_xfs_db -c "inode $inum" -c p 2>&1 | _filter_inode
 	echo "================================="
 }
 
@@ -136,7 +136,7 @@ _changeto_attr1()
 	echo ""
 	echo "Try setting attr1 by db"
 	echo ""
-	$XFS_DB_PROG -x -c "version attr1" $SCRATCH_DEV | _filter_version
+	_scratch_xfs_db -x -c "version attr1" | _filter_version
 }
 
 # get standard environment, filters and checks
@@ -173,7 +173,7 @@ fi
 
 # set inum to root dir ino
 # we'll add in dirents and EAs into the root directory
-eval `$XFS_DB_PROG -r -c 'sb 0' -c 'p rootino' $SCRATCH_DEV | $SED_PROG 's/ //g'`
+eval `_scratch_xfs_db -r -c 'sb 0' -c 'p rootino' | $SED_PROG 's/ //g'`
 inum=$rootino
 fork_dir=$SCRATCH_MNT
 _print_inode
diff --git a/tests/xfs/187 b/tests/xfs/187
index 836b924..07ef3ae 100755
--- a/tests/xfs/187
+++ b/tests/xfs/187
@@ -76,7 +76,7 @@ export MKFS_LAZY="-m crc=0 -l lazy-count=1 -i projid32bit=0"
 # Make sure that when we think we are testing with morebits off
 # that we really are.
 _scratch_mkfs -i attr=1 $MKFS_NO_LAZY  >/dev/null 2>&1
-$XFS_DB_PROG -c version $SCRATCH_DEV 2>&1 >$tmp.db
+_scratch_xfs_db -c version 2>&1 >$tmp.db
 if grep -i morebits $tmp.db
 then
 	echo ""
@@ -91,13 +91,13 @@ echo ""
 echo "attr2 fs"
 echo ""
 _scratch_mkfs -i attr=2 $MKFS_NO_LAZY >/dev/null 2>&1
-$XFS_DB_PROG -r -c version $SCRATCH_DEV 2>&1 | _filter_version
+_scratch_xfs_db -r -c version 2>&1 | _filter_version
 echo ""
 echo "noattr2 fs"
 echo ""
 _scratch_mount -o noattr2
 $UMOUNT_PROG $SCRATCH_MNT
-$XFS_DB_PROG -r -c version $SCRATCH_DEV 2>&1 | _filter_version
+_scratch_xfs_db -r -c version 2>&1 | _filter_version
 
 # adding an EA will ensure the ATTR1 flag is turned on
 echo ""
@@ -106,7 +106,7 @@ echo ""
 echo "attr2 fs"
 echo ""
 _scratch_mkfs -i attr=2 $MKFS_NO_LAZY >/dev/null 2>&1
-$XFS_DB_PROG -r -c version $SCRATCH_DEV 2>&1 | _filter_version
+_scratch_xfs_db -r -c version 2>&1 | _filter_version
 echo ""
 echo "noattr2 fs"
 echo ""
@@ -117,7 +117,7 @@ $SETFATTR_PROG -n user.test -v 0xbabe testfile
 $GETFATTR_PROG testfile
 cd $here
 $UMOUNT_PROG $SCRATCH_MNT
-$XFS_DB_PROG -r -c version $SCRATCH_DEV 2>&1 | _filter_version
+_scratch_xfs_db -r -c version 2>&1 | _filter_version
 
 echo ""
 echo "*** 3. test noattr2 mount and lazy sb ***"
@@ -126,7 +126,7 @@ echo ""
 echo "attr2 fs"
 echo ""
 _scratch_mkfs -i attr=2 $MKFS_LAZY >/dev/null 2>&1
-$XFS_DB_PROG -r -c version $SCRATCH_DEV 2>&1 | _filter_version
+_scratch_xfs_db -r -c version 2>&1 | _filter_version
 echo ""
 echo "noattr2 fs"
 echo ""
@@ -135,7 +135,7 @@ cd $SCRATCH_MNT
 touch testfile
 cd $here
 $UMOUNT_PROG $SCRATCH_MNT
-$XFS_DB_PROG -r -c version $SCRATCH_DEV 2>&1 | _filter_version
+_scratch_xfs_db -r -c version 2>&1 | _filter_version
 
 # success, all done
 status=0
diff --git a/tests/xfs/235 b/tests/xfs/235
index ef51d22..88101f2 100755
--- a/tests/xfs/235
+++ b/tests/xfs/235
@@ -71,9 +71,9 @@ _scratch_xfs_repair -n >> $seqres.full 2>&1 || \
 
 echo "+ corrupt image"
 seq 0 $((agcount - 1)) | while read ag; do
-	$XFS_DB_PROG -x -c "agf ${ag}" -c "agf ${ag}" -c "addr rmaproot" \
+	_scratch_xfs_db -x -c "agf ${ag}" -c "agf ${ag}" -c "addr rmaproot" \
 		-c "stack" -c "blocktrash -x 4096 -y 4096 -z -n 8 -3" \
-		${SCRATCH_DEV} >> $seqres.full 2>&1
+		>> $seqres.full 2>&1
 done
 
 echo "+ mount image"
diff --git a/tests/xfs/287 b/tests/xfs/287
index aca410a..e718df8 100755
--- a/tests/xfs/287
+++ b/tests/xfs/287
@@ -46,10 +46,9 @@ _cleanup()
 
 _print_projid()
 {
-	$XFS_DB_PROG -r -c "inode $1" \
+	_scratch_xfs_db -r -c "inode $1" \
 		-c "print core.projid_lo" \
-		-c "print core.projid_hi" \
-		$SCRATCH_DEV
+		-c "print core.projid_hi"
 }
 
 # real QA test starts here
diff --git a/tests/xfs/298 b/tests/xfs/298
index bb836a0..7702526 100755
--- a/tests/xfs/298
+++ b/tests/xfs/298
@@ -82,7 +82,7 @@ while [ $SIZE -lt 1024 ];do
 # umount and check the number of extents on the inode. Should be 0.
 	cd
 	_scratch_unmount >/dev/null 2>&1
-	$XFS_DB_PROG  -c "inode $inode" -c "p core.nextents" $SCRATCH_DEV
+	_scratch_xfs_db  -c "inode $inode" -c "p core.nextents"
 
 	let SIZE=$SIZE+32
 done


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 7/9] xfs: more rmapbt tests
  2016-09-30  2:23 [PATCH v10 0/9] xfstests: fixes and new tests for rmap/reflink Darrick J. Wong
                   ` (5 preceding siblings ...)
  2016-09-30  2:23 ` [PATCH 6/9] xfs: fix $XFS_DB_PROG usage Darrick J. Wong
@ 2016-09-30  2:23 ` Darrick J. Wong
  2016-09-30  2:23 ` [PATCH 8/9] xfs: test realtime rmapbt code Darrick J. Wong
  2016-09-30  2:24 ` [PATCH 9/9] xfs: test copy-on-write fragmentation when no cow extent size hint is set Darrick J. Wong
  8 siblings, 0 replies; 17+ messages in thread
From: Darrick J. Wong @ 2016-09-30  2:23 UTC (permalink / raw)
  To: david, eguan, darrick.wong; +Cc: linux-xfs, fstests

More tests for the reverse mapping functionality.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/876     |   78 +++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/876.out |    4 ++
 tests/xfs/877     |   92 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/877.out |   10 ++++++
 tests/xfs/group   |    2 +
 5 files changed, 186 insertions(+)
 create mode 100755 tests/xfs/876
 create mode 100644 tests/xfs/876.out
 create mode 100755 tests/xfs/877
 create mode 100644 tests/xfs/877.out


diff --git a/tests/xfs/876 b/tests/xfs/876
new file mode 100755
index 0000000..dae3f3a
--- /dev/null
+++ b/tests/xfs/876
@@ -0,0 +1,78 @@
+#! /bin/bash
+# FS QA Test No. 876
+#
+# Create a big enough rmapbt that we tickle a fdblocks accounting bug.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf "$tmp".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch
+_require_xfs_scratch_rmapbt
+_require_scratch_reflink
+_require_test_program "punch-alternating"
+
+rm -f "$seqres.full"
+
+echo "+ create scratch fs"
+_scratch_mkfs > "$seqres.full" 2>&1
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(get_block_size $SCRATCH_MNT)"
+
+# btree header is 56 bytes; an rmapbt record is 24 bytes; and
+# a rmapbt key/pointer pair is 44 bytes.
+bt_ptrs=$(( (blksz - 56) / 44 ))
+bt_recs=$(( (blksz - 56) / 24 ))
+
+blocks=$((bt_ptrs * bt_recs + 1))
+# Need (2 * blocks * blksz) bytes for files, and 20% for metadata
+_require_fs_space $SCRATCH_MNT $(( (2 * blocks * blksz) * 5 / 4096 ))
+len=$((blocks * blksz))
+
+echo "+ make some files"
+$XFS_IO_PROG -f -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
+$XFS_IO_PROG -f -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f2 >> $seqres.full
+./src/punch-alternating $SCRATCH_MNT/f1 >> "$seqres.full"
+./src/punch-alternating $SCRATCH_MNT/f2 >> "$seqres.full"
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/876.out b/tests/xfs/876.out
new file mode 100644
index 0000000..96c1970
--- /dev/null
+++ b/tests/xfs/876.out
@@ -0,0 +1,4 @@
+QA output created by 876
++ create scratch fs
++ mount fs image
++ make some files
diff --git a/tests/xfs/877 b/tests/xfs/877
new file mode 100755
index 0000000..194b3be
--- /dev/null
+++ b/tests/xfs/877
@@ -0,0 +1,92 @@
+#! /bin/bash
+# FS QA Test No. 877
+#
+# Make sure query_range returns -EINVAL if lowkey > highkey.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf "$tmp".* $metadump_file
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/attr
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_xfs_scratch_rmapbt
+_require_command "$XFS_DB_PROG" "xfs_db"
+_require_xfs_io_command "falloc"
+_require_xfs_io_command "fpunch"
+_require_xfs_io_command "fzero"
+_require_xfs_io_command "fcollapse"
+_require_xfs_io_command "finsert"
+
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_scratch_mount
+blksz=65536
+blocks=16
+len=$((blocks * blksz))
+
+echo "Create some files"
+$XFS_IO_PROG -f -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
+
+echo "Manipulate file"
+$XFS_IO_PROG -c "fpunch $blksz $blksz" \
+	-c "fzero $((3 * blksz)) $blksz" \
+	-c "pwrite -S 0x69 $((5 * blksz)) $blksz" \
+	-c "fpunch $((7 * blksz)) $blksz" \
+	-c "fsync" \
+	-c "pwrite -S 0x70 $((7 * blksz)) $blksz" \
+	-c "fcollapse $((9 * blksz)) $blksz" \
+	-c "finsert $((10 * blksz)) $blksz" $SCRATCH_MNT/f1 >> $seqres.full
+
+echo "Check file"
+md5sum $SCRATCH_MNT/f1 | _filter_scratch
+od -tx1 -Ad -c $SCRATCH_MNT/f1 >> $seqres.full
+
+echo "Unmount"
+_scratch_unmount
+
+echo "Try a regular fsmap"
+_scratch_xfs_db -c 'fsmap' >> $seqres.full
+_scratch_xfs_db -c 'fsmap 0 5' >> $seqres.full
+
+echo "Try a bad fsmap"
+_scratch_xfs_db -c 'fsmap 5 4'
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/877.out b/tests/xfs/877.out
new file mode 100644
index 0000000..4a2242f
--- /dev/null
+++ b/tests/xfs/877.out
@@ -0,0 +1,10 @@
+QA output created by 877
+Format and mount
+Create some files
+Manipulate file
+Check file
+e45c5707fcf6817e914ffb6ce37a0ac7  SCRATCH_MNT/f1
+Unmount
+Try a regular fsmap
+Try a bad fsmap
+Error 22 while querying fsmap btree.
diff --git a/tests/xfs/group b/tests/xfs/group
index 798bf99..c09c8a1 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -315,3 +315,5 @@
 328 auto quick clone fsr
 329 auto quick clone fsr
 330 auto quick clone fsr quota
+876 auto quick rmap clone
+877 auto quick rmap clone


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 8/9] xfs: test realtime rmapbt code
  2016-09-30  2:23 [PATCH v10 0/9] xfstests: fixes and new tests for rmap/reflink Darrick J. Wong
                   ` (6 preceding siblings ...)
  2016-09-30  2:23 ` [PATCH 7/9] xfs: more rmapbt tests Darrick J. Wong
@ 2016-09-30  2:23 ` Darrick J. Wong
  2016-10-07 11:41   ` Eryu Guan
  2016-09-30  2:24 ` [PATCH 9/9] xfs: test copy-on-write fragmentation when no cow extent size hint is set Darrick J. Wong
  8 siblings, 1 reply; 17+ messages in thread
From: Darrick J. Wong @ 2016-09-30  2:23 UTC (permalink / raw)
  To: david, eguan, darrick.wong; +Cc: linux-xfs, fstests

Test the realtime rmap btree code by exercising various IO patterns
on realtime files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/877     |    2 +
 tests/xfs/878     |   83 ++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/878.out |    9 +++++
 tests/xfs/879     |   67 ++++++++++++++++++++++++++++++++++
 tests/xfs/879.out |    7 ++++
 tests/xfs/880     |   89 +++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/880.out |    7 ++++
 tests/xfs/881     |   97 +++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/881.out |    8 ++++
 tests/xfs/882     |  106 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/882.out |   11 ++++++
 tests/xfs/883     |   75 ++++++++++++++++++++++++++++++++++++++
 tests/xfs/883.out |    7 ++++
 tests/xfs/884     |   83 ++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/884.out |    9 +++++
 tests/xfs/885     |   80 ++++++++++++++++++++++++++++++++++++++++
 tests/xfs/885.out |    7 ++++
 tests/xfs/886     |   99 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/886.out |    7 ++++
 tests/xfs/887     |  100 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/887.out |    7 ++++
 tests/xfs/888     |   81 +++++++++++++++++++++++++++++++++++++++++
 tests/xfs/888.out |    6 +++
 tests/xfs/group   |   11 ++++++
 24 files changed, 1057 insertions(+), 1 deletion(-)
 create mode 100755 tests/xfs/878
 create mode 100644 tests/xfs/878.out
 create mode 100755 tests/xfs/879
 create mode 100644 tests/xfs/879.out
 create mode 100755 tests/xfs/880
 create mode 100644 tests/xfs/880.out
 create mode 100755 tests/xfs/881
 create mode 100644 tests/xfs/881.out
 create mode 100755 tests/xfs/882
 create mode 100644 tests/xfs/882.out
 create mode 100755 tests/xfs/883
 create mode 100644 tests/xfs/883.out
 create mode 100755 tests/xfs/884
 create mode 100644 tests/xfs/884.out
 create mode 100755 tests/xfs/885
 create mode 100644 tests/xfs/885.out
 create mode 100755 tests/xfs/886
 create mode 100644 tests/xfs/886.out
 create mode 100755 tests/xfs/887
 create mode 100644 tests/xfs/887.out
 create mode 100755 tests/xfs/888
 create mode 100644 tests/xfs/888.out


diff --git a/tests/xfs/877 b/tests/xfs/877
index 194b3be..04fdb4c 100755
--- a/tests/xfs/877
+++ b/tests/xfs/877
@@ -32,7 +32,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 _cleanup()
 {
 	cd /
-	rm -rf "$tmp".* $metadump_file
+	rm -rf "$tmp".*
 }
 
 # get standard environment, filters and checks
diff --git a/tests/xfs/878 b/tests/xfs/878
new file mode 100755
index 0000000..c9ec8c6
--- /dev/null
+++ b/tests/xfs/878
@@ -0,0 +1,83 @@
+#! /bin/bash
+# FS QA Test No. 878
+#
+# Set rrmapino to another inode on an non-rt rmap fs and see if repair fixes it.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf "$tmp".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_xfs_scratch_rmapbt
+_disable_dmesg_check
+
+rm -f "$seqres.full"
+
+unset SCRATCH_RTDEV
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_scratch_mount
+
+echo "Create some files"
+$XFS_IO_PROG -f -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f1 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f2 >> $seqres.full
+echo garbage > $SCRATCH_MNT/f3
+ino=$(stat -c '%i' $SCRATCH_MNT/f3)
+_scratch_unmount
+
+echo "Corrupt fs"
+_scratch_xfs_db -x -c 'sb 0' -c "write rrmapino $ino" >> $seqres.full
+_scratch_mount
+
+echo "Check files"
+md5sum $SCRATCH_MNT/f1 2>&1 | _filter_scratch
+
+echo "Try to create more files"
+$XFS_IO_PROG -f -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f3 >> $seqres.full 2>&1
+
+echo "Repair fs"
+_scratch_unmount 2>&1 | _filter_scratch
+_repair_scratch_fs >> $seqres.full 2>&1
+
+echo "Try to create more files (again)"
+_scratch_mount
+$XFS_IO_PROG -f -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f4 >> $seqres.full
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/878.out b/tests/xfs/878.out
new file mode 100644
index 0000000..e134506
--- /dev/null
+++ b/tests/xfs/878.out
@@ -0,0 +1,9 @@
+QA output created by 878
+Format and mount
+Create some files
+Corrupt fs
+Check files
+8f27047948255cb84872e2dd7c0bc56d  SCRATCH_MNT/f1
+Try to create more files
+Repair fs
+Try to create more files (again)
diff --git a/tests/xfs/879 b/tests/xfs/879
new file mode 100755
index 0000000..247b3af
--- /dev/null
+++ b/tests/xfs/879
@@ -0,0 +1,67 @@
+#! /bin/bash
+# FS QA Test No. 879
+#
+# Ensure that we can create a few realtime files on a rmapbt filesystem.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf "$tmp".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_realtime
+_require_xfs_scratch_rmapbt
+
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_scratch_mount
+
+echo "Create a few files"
+$XFS_IO_PROG -f -R -c 'pwrite -S 0x67 0 50000' -c fsync $SCRATCH_MNT/f1 >> $seqres.full
+$XFS_IO_PROG -f -R -c 'pwrite -S 0x67 0 50000' -c fsync $SCRATCH_MNT/f2 >> $seqres.full
+_scratch_cycle_mount
+
+echo "Grab contents"
+md5sum $SCRATCH_MNT/f1 $SCRATCH_MNT/f2 | _filter_scratch
+
+echo "Remove one file"
+rm -rf $SCRATCH_MNT/f2
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/879.out b/tests/xfs/879.out
new file mode 100644
index 0000000..9dfe48b
--- /dev/null
+++ b/tests/xfs/879.out
@@ -0,0 +1,7 @@
+QA output created by 879
+Format and mount
+Create a few files
+Grab contents
+10abe2628d19eb1c2ebe18aad7b14820  SCRATCH_MNT/f1
+10abe2628d19eb1c2ebe18aad7b14820  SCRATCH_MNT/f2
+Remove one file
diff --git a/tests/xfs/880 b/tests/xfs/880
new file mode 100755
index 0000000..7c3879e
--- /dev/null
+++ b/tests/xfs/880
@@ -0,0 +1,89 @@
+#! /bin/bash
+# FS QA Test No. 880
+#
+# Exercise expanding and shrinking the realtime rmap btree.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf "$tmp".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_realtime
+_require_xfs_scratch_rmapbt
+_require_test_program "punch-alternating"
+_require_xfs_io_command "falloc"
+
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
+. $tmp.mkfs
+cat $tmp.mkfs > "$seqres.full" 2>&1
+_scratch_mount
+blksz="$(get_block_size $SCRATCH_MNT)"
+
+echo "Create a three-level rtrmapbt"
+# inode core size is at least 176 bytes; btree header is 56 bytes;
+# rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
+i_ptrs=$(( (isize - 176) / 56 ))
+bt_ptrs=$(( (blksz - 56) / 56 ))
+bt_recs=$(( (blksz - 56) / 32 ))
+
+blocks=$((i_ptrs * bt_ptrs * bt_recs))
+# Need (2 * blocks * blksz) bytes for files, and 20% more for metadata
+_require_fs_space $SCRATCH_MNT $(( (2 * blocks * blksz) * 5 / 4096 ))
+len=$((blocks * rtextsz))
+
+echo "Create big file"
+$XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
+$XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f2 >> $seqres.full
+
+echo "Explode the rtrmapbt"
+./src/punch-alternating $SCRATCH_MNT/f1 >> "$seqres.full"
+./src/punch-alternating $SCRATCH_MNT/f2 >> "$seqres.full"
+_scratch_cycle_mount
+
+echo "Remove half the records"
+rm -rf $SCRATCH_MNT/f1
+_scratch_cycle_mount
+
+echo "Remove the rest of the records"
+rm -rf $SCRATCH_MNT/f2
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/880.out b/tests/xfs/880.out
new file mode 100644
index 0000000..b87665b
--- /dev/null
+++ b/tests/xfs/880.out
@@ -0,0 +1,7 @@
+QA output created by 880
+Format and mount
+Create a three-level rtrmapbt
+Create big file
+Explode the rtrmapbt
+Remove half the records
+Remove the rest of the records
diff --git a/tests/xfs/881 b/tests/xfs/881
new file mode 100755
index 0000000..437895c
--- /dev/null
+++ b/tests/xfs/881
@@ -0,0 +1,97 @@
+#! /bin/bash
+# FS QA Test No. 881
+#
+# Exercise metadump on realtime rmapbt preservation.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf "$tmp".* $metadump_file
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_realtime
+_require_xfs_scratch_rmapbt
+_require_test_program "punch-alternating"
+_require_xfs_io_command "falloc"
+
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
+. $tmp.mkfs
+cat $tmp.mkfs > "$seqres.full" 2>&1
+_scratch_mount
+blksz="$(get_block_size $SCRATCH_MNT)"
+
+metadump_file=$TEST_DIR/${seq}_metadump
+rm -rf $metadump_file
+
+echo "Create a three-level rtrmapbt"
+# inode core size is at least 176 bytes; btree header is 56 bytes;
+# rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
+i_ptrs=$(( (isize - 176) / 56 ))
+bt_ptrs=$(( (blksz - 56) / 56 ))
+bt_recs=$(( (blksz - 56) / 32 ))
+
+blocks=$((i_ptrs * bt_ptrs * bt_recs))
+_require_fs_space $SCRATCH_MNT $(( (2 * blocks * blksz) * 5 / 4096 ))
+len=$((blocks * rtextsz))
+
+echo "Create big file"
+$XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
+$XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f2 >> $seqres.full
+
+echo "Explode the rtrmapbt"
+./src/punch-alternating $SCRATCH_MNT/f1 >> "$seqres.full"
+./src/punch-alternating $SCRATCH_MNT/f2 >> "$seqres.full"
+_scratch_cycle_mount
+
+echo "Create metadump file"
+_scratch_unmount
+_scratch_metadump $metadump_file
+
+# Now restore the obfuscated one back and take a look around
+echo "Restore metadump"
+xfs_mdrestore $metadump_file $TEST_DIR/image
+SCRATCH_DEV=$TEST_DIR/image _scratch_mount
+SCRATCH_DEV=$TEST_DIR/image _scratch_unmount
+
+echo "Check restored fs"
+_check_scratch_fs $TEST_DIR/image
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/881.out b/tests/xfs/881.out
new file mode 100644
index 0000000..6ad156c
--- /dev/null
+++ b/tests/xfs/881.out
@@ -0,0 +1,8 @@
+QA output created by 881
+Format and mount
+Create a three-level rtrmapbt
+Create big file
+Explode the rtrmapbt
+Create metadump file
+Restore metadump
+Check restored fs
diff --git a/tests/xfs/882 b/tests/xfs/882
new file mode 100755
index 0000000..17bd4f0
--- /dev/null
+++ b/tests/xfs/882
@@ -0,0 +1,106 @@
+#! /bin/bash
+# FS QA Test No. 882
+#
+# Corrupt the realtime rmapbt and see how the kernel and xfs_repair deal.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf "$tmp".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_realtime
+_require_xfs_scratch_rmapbt
+_require_test_program "punch-alternating"
+_require_xfs_io_command "falloc"
+_disable_dmesg_check
+
+rm -f "$seqres.full"
+
+echo "+ create scratch fs"
+_scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
+. $tmp.mkfs
+cat $tmp.mkfs > "$seqres.full" 2>&1
+
+echo "+ mount fs image"
+_scratch_mount
+blksz="$(get_block_size $SCRATCH_MNT)"
+
+# inode core size is at least 176 bytes; btree header is 56 bytes;
+# rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
+i_ptrs=$(( (isize - 176) / 56 ))
+bt_ptrs=$(( (blksz - 56) / 56 ))
+bt_recs=$(( (blksz - 56) / 32 ))
+
+blocks=$((i_ptrs * bt_ptrs * bt_recs + 1))
+_require_fs_space $SCRATCH_MNT $(( (2 * blocks * blksz) * 5 / 4096 ))
+len=$((blocks * blksz))
+
+echo "+ make some files"
+$XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
+$XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f2 >> $seqres.full
+./src/punch-alternating $SCRATCH_MNT/f1 >> "$seqres.full"
+./src/punch-alternating $SCRATCH_MNT/f2 >> "$seqres.full"
+_scratch_unmount
+
+echo "+ check fs"
+_scratch_xfs_repair -n >> $seqres.full 2>&1 || echo "xfs_repair should not fail"
+
+echo "+ corrupt image"
+_scratch_xfs_db -x -c "sb" -c "addr rrmapino" -c "addr u3.rtrmapbt.ptrs[1]" \
+	-c "stack" -c "blocktrash -x 4096 -y 4096 -n 8 -3 -z" \
+	>> $seqres.full 2>&1
+
+echo "+ mount image"
+_scratch_mount
+
+echo "+ copy more"
+$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 1" $SCRATCH_MNT/e3 >> $seqres.full 2>&1
+test -s ${SCRATCH_MNT}/f3 && echo "should not be able to copy with busted rtrmap btree"
+_scratch_unmount
+
+echo "+ repair fs"
+_repair_scratch_fs >> $seqres.full 2>&1
+
+echo "+ mount image (2)"
+_scratch_mount
+
+echo "+ copy more (2)"
+$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 1" $SCRATCH_MNT/e4 >> $seqres.full
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/882.out b/tests/xfs/882.out
new file mode 100644
index 0000000..5ebe620
--- /dev/null
+++ b/tests/xfs/882.out
@@ -0,0 +1,11 @@
+QA output created by 882
++ create scratch fs
++ mount fs image
++ make some files
++ check fs
++ corrupt image
++ mount image
++ copy more
++ repair fs
++ mount image (2)
++ copy more (2)
diff --git a/tests/xfs/883 b/tests/xfs/883
new file mode 100755
index 0000000..8b20b2b
--- /dev/null
+++ b/tests/xfs/883
@@ -0,0 +1,75 @@
+#! /bin/bash
+# FS QA Test No. 883
+#
+# Set rrmapino to zero on an rtrmap fs and see if repair fixes it.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf "$tmp".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_realtime
+_require_xfs_scratch_rmapbt
+
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_scratch_mount
+
+echo "Create some files"
+$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f1 >> $seqres.full
+$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f2 >> $seqres.full
+_scratch_unmount
+
+echo "Corrupt fs"
+_scratch_xfs_db -x -c 'sb 0' -c 'addr rrmapino' \
+	-c 'write core.nlinkv2 0' -c 'write core.mode 0' -c 'sb 0' \
+	-c 'write rrmapino 0' >> $seqres.full
+_scratch_mount >> $seqres.full 2>&1 && echo "mount should have failed"
+
+echo "Repair fs"
+_scratch_unmount 2>&1 | _filter_scratch
+_repair_scratch_fs >> $seqres.full 2>&1
+
+echo "Try to create more files (again)"
+_scratch_mount
+$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f4 >> $seqres.full
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/883.out b/tests/xfs/883.out
new file mode 100644
index 0000000..ac5117f
--- /dev/null
+++ b/tests/xfs/883.out
@@ -0,0 +1,7 @@
+QA output created by 883
+Format and mount
+Create some files
+Corrupt fs
+Repair fs
+umount: SCRATCH_DEV: not mounted
+Try to create more files (again)
diff --git a/tests/xfs/884 b/tests/xfs/884
new file mode 100755
index 0000000..3097fa0
--- /dev/null
+++ b/tests/xfs/884
@@ -0,0 +1,83 @@
+#! /bin/bash
+# FS QA Test No. 884
+#
+# Link rrmapino into the rootdir on an rtrmap fs and see if repair fixes it.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf "$tmp".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_realtime
+_require_xfs_scratch_rmapbt
+
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_scratch_mount
+
+echo "Create some files"
+$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f1 >> $seqres.full
+$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f2 >> $seqres.full
+echo garbage > $SCRATCH_MNT/f3
+ln $SCRATCH_MNT/f3 $SCRATCH_MNT/f4
+_scratch_unmount
+
+echo "Corrupt fs"
+rrmapino=$(_scratch_xfs_db -c 'sb 0' -c 'p rrmapino' | awk '{print $3}')
+_scratch_xfs_db -x -c 'sb 0' -c 'addr rootino' \
+	-c "write u3.sfdir3.list[3].inumber.i4 $rrmapino" >> $seqres.full
+_scratch_mount
+
+echo "Check files"
+md5sum $SCRATCH_MNT/f1 2>&1 | _filter_scratch
+
+echo "Try to create more files"
+$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f5 >> $seqres.full 2>&1
+
+echo "Repair fs"
+_scratch_unmount 2>&1 | _filter_scratch
+_repair_scratch_fs >> $seqres.full 2>&1
+
+echo "Try to create more files (again)"
+_scratch_mount
+$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f4 >> $seqres.full
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/884.out b/tests/xfs/884.out
new file mode 100644
index 0000000..17a73ef
--- /dev/null
+++ b/tests/xfs/884.out
@@ -0,0 +1,9 @@
+QA output created by 884
+Format and mount
+Create some files
+Corrupt fs
+Check files
+8f27047948255cb84872e2dd7c0bc56d  SCRATCH_MNT/f1
+Try to create more files
+Repair fs
+Try to create more files (again)
diff --git a/tests/xfs/885 b/tests/xfs/885
new file mode 100755
index 0000000..3e8aba9
--- /dev/null
+++ b/tests/xfs/885
@@ -0,0 +1,80 @@
+#! /bin/bash
+# FS QA Test No. 885
+#
+# Set rrmapino to another inode on an rtrmap fs and see if repair fixes it.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf "$tmp".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_realtime
+_require_xfs_scratch_rmapbt
+
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_scratch_mount
+
+echo "Create some files"
+$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f1 >> $seqres.full
+$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f2 >> $seqres.full
+echo garbage > $SCRATCH_MNT/f3
+ino=$(stat -c '%i' $SCRATCH_MNT/f3)
+_scratch_unmount
+
+echo "Corrupt fs"
+rrmapino=$(_scratch_xfs_db -c 'sb 0' -c 'p rrmapino' | awk '{print $3}')
+_scratch_xfs_db -x -c "inode $rrmapino" \
+	-c 'write core.format 2' -c 'write core.size 0' \
+	-c 'write core.nblocks 0' -c 'sb 0' -c 'addr rootino' \
+	-c "write u3.sfdir3.list[2].inumber.i4 $rrmapino" \
+	-c 'sb 0' -c "write rrmapino $ino" >> $seqres.full
+_scratch_mount >> $seqres.full 2>&1 && echo "mount should have failed"
+
+echo "Repair fs"
+_scratch_unmount 2>&1 | _filter_scratch
+_repair_scratch_fs >> $seqres.full 2>&1
+
+echo "Try to create more files (again)"
+_scratch_mount
+$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f4 >> $seqres.full
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/885.out b/tests/xfs/885.out
new file mode 100644
index 0000000..8bfd9b3
--- /dev/null
+++ b/tests/xfs/885.out
@@ -0,0 +1,7 @@
+QA output created by 885
+Format and mount
+Create some files
+Corrupt fs
+Repair fs
+umount: SCRATCH_DEV: not mounted
+Try to create more files (again)
diff --git a/tests/xfs/886 b/tests/xfs/886
new file mode 100755
index 0000000..f0c3997
--- /dev/null
+++ b/tests/xfs/886
@@ -0,0 +1,99 @@
+#! /bin/bash
+# FS QA Test No. 886
+#
+# Cross-link file block into rtrmapbt and see if repair fixes it.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf "$tmp".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_realtime
+_require_xfs_scratch_rmapbt
+_require_test_program "punch-alternating"
+_disable_dmesg_check
+
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
+. $tmp.mkfs
+cat $tmp.mkfs > "$seqres.full" 2>&1
+_scratch_mkfs > "$seqres.full" 2>&1
+_scratch_mount
+blksz="$(get_block_size $SCRATCH_MNT)"
+
+# inode core size is at least 176 bytes; btree header is 56 bytes;
+# rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
+i_ptrs=$(( (isize - 176) / 56 ))
+bt_recs=$(( (blksz - 56) / 32 ))
+
+blocks=$((i_ptrs * bt_recs + 1))
+len=$((blocks * rtextsz))
+
+echo "Create some files"
+$XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
+$XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f2 >> $seqres.full
+./src/punch-alternating $SCRATCH_MNT/f1 >> "$seqres.full"
+./src/punch-alternating $SCRATCH_MNT/f2 >> "$seqres.full"
+echo garbage > $SCRATCH_MNT/f3
+ino=$(stat -c '%i' $SCRATCH_MNT/f3)
+_scratch_unmount
+
+echo "Corrupt fs"
+fsbno=$(_scratch_xfs_db -c "inode $ino" -c 'bmap' | \
+	sed -e 's/^.*startblock \([0-9]*\) .*$/\1/g')
+
+_scratch_xfs_db -x -c 'sb 0' -c 'addr rrmapino' \
+	-c "write u3.rtrmapbt.ptrs[1] $fsbno" -c 'p' >> $seqres.full
+_scratch_mount
+
+echo "Try to create more files"
+$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f5 >> $seqres.full 2>&1
+test -e $SCRATCH_MNT/f5 && echo "should not have been able to write f5"
+
+echo "Repair fs"
+_scratch_unmount 2>&1 | _filter_scratch
+_repair_scratch_fs >> $seqres.full 2>&1
+
+echo "Try to create more files (again)"
+_scratch_mount
+$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f4 >> $seqres.full
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/886.out b/tests/xfs/886.out
new file mode 100644
index 0000000..7f00c5d
--- /dev/null
+++ b/tests/xfs/886.out
@@ -0,0 +1,7 @@
+QA output created by 886
+Format and mount
+Create some files
+Corrupt fs
+Try to create more files
+Repair fs
+Try to create more files (again)
diff --git a/tests/xfs/887 b/tests/xfs/887
new file mode 100755
index 0000000..ae3b2d4
--- /dev/null
+++ b/tests/xfs/887
@@ -0,0 +1,100 @@
+#! /bin/bash
+# FS QA Test No. 887
+#
+# Cross-link rtrmapbt block into a file and see if repair fixes it.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf "$tmp".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_realtime
+_require_xfs_scratch_rmapbt
+_require_test_program "punch-alternating"
+
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
+. $tmp.mkfs
+cat $tmp.mkfs > "$seqres.full" 2>&1
+_scratch_mkfs > "$seqres.full" 2>&1
+_scratch_mount
+blksz="$(get_block_size $SCRATCH_MNT)"
+
+# inode core size is at least 176 bytes; btree header is 56 bytes;
+# rtrmap record is 32 bytes; and rtrmap key/pointer are 56 bytes.
+i_ptrs=$(( (isize - 176) / 56 ))
+bt_recs=$(( (blksz - 56) / 32 ))
+
+blocks=$((i_ptrs * bt_recs + 1))
+len=$((blocks * rtextsz))
+
+echo "Create some files"
+$XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
+$XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f2 >> $seqres.full
+./src/punch-alternating $SCRATCH_MNT/f1 >> "$seqres.full"
+./src/punch-alternating $SCRATCH_MNT/f2 >> "$seqres.full"
+echo garbage > $SCRATCH_MNT/f3
+ino=$(stat -c '%i' $SCRATCH_MNT/f3)
+_scratch_unmount
+
+echo "Corrupt fs"
+_scratch_xfs_db -c 'sb 0' -c 'addr rrmapino' -c 'p u3.rtrmapbt.ptrs[1]' >> $seqres.full
+
+fsbno=$(_scratch_xfs_db -c 'sb 0' -c 'addr rrmapino' \
+	-c 'p u3.rtrmapbt.ptrs[1]' | sed -e 's/^.*://g')
+_scratch_xfs_db -x -c "inode $ino" -c "write u3.bmx[0].startblock $fsbno" >> $seqres.full
+_scratch_mount
+
+od -tx1 -Ad -c $SCRATCH_MNT/f3 >> $seqres.full
+
+echo "Try to create more files"
+$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f5 >> $seqres.full 2>&1
+test ! -e $SCRATCH_MNT/f5 && echo "should have been able to write f5"
+
+echo "Repair fs"
+_scratch_unmount 2>&1 | _filter_scratch
+_repair_scratch_fs >> $seqres.full 2>&1
+
+echo "Try to create more files (again)"
+_scratch_mount
+$XFS_IO_PROG -f -R -c "pwrite -S 0x68 0 9999" $SCRATCH_MNT/f4 >> $seqres.full
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/887.out b/tests/xfs/887.out
new file mode 100644
index 0000000..30cf032
--- /dev/null
+++ b/tests/xfs/887.out
@@ -0,0 +1,7 @@
+QA output created by 887
+Format and mount
+Create some files
+Corrupt fs
+Try to create more files
+Repair fs
+Try to create more files (again)
diff --git a/tests/xfs/888 b/tests/xfs/888
new file mode 100755
index 0000000..2441bfd
--- /dev/null
+++ b/tests/xfs/888
@@ -0,0 +1,81 @@
+#! /bin/bash
+# FS QA Test No. 888
+#
+# Basic rmap manipulation tests for realtime files.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename "$0"`
+seqres="$RESULT_DIR/$seq"
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf "$tmp".*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_realtime
+_require_xfs_scratch_rmapbt
+_require_xfs_io_command "falloc"
+_require_xfs_io_command "fpunch"
+_require_xfs_io_command "fzero"
+_require_xfs_io_command "fcollapse"
+_require_xfs_io_command "finsert"
+
+rm -f "$seqres.full"
+
+echo "Format and mount"
+_scratch_mkfs > "$seqres.full" 2>&1
+_scratch_mount
+blksz=65536
+blocks=16
+len=$((blocks * blksz))
+
+echo "Create some files"
+$XFS_IO_PROG -f -R -c "falloc 0 $len" -c "pwrite -S 0x68 -b 1048576 0 $len" $SCRATCH_MNT/f1 >> $seqres.full
+
+echo "Manipulate file"
+$XFS_IO_PROG -c "fpunch $blksz $blksz" \
+	-c "fzero $((3 * blksz)) $blksz" \
+	-c "pwrite -S 0x69 $((5 * blksz)) $blksz" \
+	-c "fpunch $((7 * blksz)) $blksz" \
+	-c "fsync" \
+	-c "pwrite -S 0x70 $((7 * blksz)) $blksz" \
+	-c "fcollapse $((9 * blksz)) $blksz" \
+	-c "finsert $((10 * blksz)) $blksz" $SCRATCH_MNT/f1 >> $seqres.full
+
+echo "Check file"
+md5sum $SCRATCH_MNT/f1 | _filter_scratch
+od -tx1 -Ad -c $SCRATCH_MNT/f1 >> $seqres.full
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/888.out b/tests/xfs/888.out
new file mode 100644
index 0000000..2587697
--- /dev/null
+++ b/tests/xfs/888.out
@@ -0,0 +1,6 @@
+QA output created by 888
+Format and mount
+Create some files
+Manipulate file
+Check file
+e45c5707fcf6817e914ffb6ce37a0ac7  SCRATCH_MNT/f1
diff --git a/tests/xfs/group b/tests/xfs/group
index c09c8a1..3dbf3d2 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -317,3 +317,14 @@
 330 auto quick clone fsr quota
 876 auto quick rmap clone
 877 auto quick rmap clone
+878 auto quick rmap
+879 auto quick rmap
+880 auto rmap
+881 auto rmap
+882 fuzzers rmap
+883 auto quick rmap
+884 auto quick rmap
+885 auto quick rmap
+886 auto quick rmap
+887 auto quick rmap
+888 auto quick rmap


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 9/9] xfs: test copy-on-write fragmentation when no cow extent size hint is set
  2016-09-30  2:23 [PATCH v10 0/9] xfstests: fixes and new tests for rmap/reflink Darrick J. Wong
                   ` (7 preceding siblings ...)
  2016-09-30  2:23 ` [PATCH 8/9] xfs: test realtime rmapbt code Darrick J. Wong
@ 2016-09-30  2:24 ` Darrick J. Wong
  8 siblings, 0 replies; 17+ messages in thread
From: Darrick J. Wong @ 2016-09-30  2:24 UTC (permalink / raw)
  To: david, eguan, darrick.wong; +Cc: linux-xfs, fstests

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/xfs/897     |  104 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/897.out |   10 +++++
 tests/xfs/898     |  102 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/898.out |   10 +++++
 tests/xfs/899     |  107 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/899.out |   10 +++++
 tests/xfs/900     |  106 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/900.out |   10 +++++
 tests/xfs/group   |    4 ++
 9 files changed, 463 insertions(+)
 create mode 100755 tests/xfs/897
 create mode 100644 tests/xfs/897.out
 create mode 100755 tests/xfs/898
 create mode 100644 tests/xfs/898.out
 create mode 100755 tests/xfs/899
 create mode 100644 tests/xfs/899.out
 create mode 100755 tests/xfs/900
 create mode 100644 tests/xfs/900.out


diff --git a/tests/xfs/897 b/tests/xfs/897
new file mode 100755
index 0000000..e7da5c0
--- /dev/null
+++ b/tests/xfs/897
@@ -0,0 +1,104 @@
+#! /bin/bash
+# FS QA Test No. 897
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set zero extsz hint on second file.
+# - Directio write to random offsets to scatter CoW reservations.
+# - falloc the whole file to unshare blocks.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+_require_odirect
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+blksz=65536
+nr=128
+filesize=$((blksz * nr))
+bufnr=16
+bufsize=$((blksz * bufnr))
+
+_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
+real_blksz=$(get_block_size $testdir)
+internal_blks=$((filesize / real_blksz))
+
+echo "Create the original files"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $((filesize + 1))" $testdir/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "cowextsize $real_blksz" $testdir/file2
+_cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+md5sum $testdir/file1 | _filter_scratch
+md5sum $testdir/file2 | _filter_scratch
+
+echo "CoW and unmount"
+$XFS_IO_PROG -f -c "cowextsize" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $filesize" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -d -f -c "falloc -u 0 $filesize" $testdir/file2 >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+md5sum $testdir/file1 | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents $testdir/file1)
+new_extents=$(_count_extents $testdir/file2)
+
+echo "old extents: $old_extents" >> $seqres.full
+echo "new extents: $new_extents" >> $seqres.full
+echo "maximum extents: $internal_blks" >> $seqres.full
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/897.out b/tests/xfs/897.out
new file mode 100644
index 0000000..b418552
--- /dev/null
+++ b/tests/xfs/897.out
@@ -0,0 +1,10 @@
+QA output created by 897
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-897/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-897/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-897/file1
+Check extent counts
diff --git a/tests/xfs/898 b/tests/xfs/898
new file mode 100755
index 0000000..aa62ee2
--- /dev/null
+++ b/tests/xfs/898
@@ -0,0 +1,102 @@
+#! /bin/bash
+# FS QA Test No. 898
+#
+# Test fragmentation after a lot of random CoW:
+# - Create two reflinked files.  Set zero extsz hint on second file.
+# - Buffered write to random offsets to scatter CoW reservations.
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+blksz=65536
+nr=128
+filesize=$((blksz * nr))
+bufnr=16
+bufsize=$((blksz * bufnr))
+
+_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
+real_blksz=$(get_block_size $testdir)
+internal_blks=$((filesize / real_blksz))
+
+echo "Create the original files"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $((filesize + 1))" $testdir/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "cowextsize $real_blksz" $testdir/file2
+_cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+md5sum $testdir/file1 | _filter_scratch
+md5sum $testdir/file2 | _filter_scratch
+
+echo "CoW and unmount"
+$XFS_IO_PROG -f -c "cowextsize" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $filesize" -c "fdatasync" $testdir/file2 >> $seqres.full
+$XFS_IO_PROG -f -c "falloc -u 0 $filesize" $testdir/file2 >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+md5sum $testdir/file1 | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents $testdir/file1)
+new_extents=$(_count_extents $testdir/file2)
+
+echo "old extents: $old_extents" >> $seqres.full
+echo "new extents: $new_extents" >> $seqres.full
+echo "maximum extents: $internal_blks" >> $seqres.full
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/898.out b/tests/xfs/898.out
new file mode 100644
index 0000000..e50bb3b
--- /dev/null
+++ b/tests/xfs/898.out
@@ -0,0 +1,10 @@
+QA output created by 898
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-898/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-898/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-898/file1
+Check extent counts
diff --git a/tests/xfs/899 b/tests/xfs/899
new file mode 100755
index 0000000..0eea915
--- /dev/null
+++ b/tests/xfs/899
@@ -0,0 +1,107 @@
+#! /bin/bash
+# FS QA Test No. 899
+#
+# Test fragmentation after writing and dropping CoW extent hint reservation:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Directio write to random offsets to scatter CoW reservations.
+# - Unmount, remount, repeat (twice more).
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+_require_odirect
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+blksz=65536
+nr=128
+filesize=$((blksz * nr))
+bufnr=8
+bufsize=$((blksz * bufnr))
+
+_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
+real_blksz=$(get_block_size $testdir)
+internal_blks=$((filesize / real_blksz))
+
+echo "Create the original files"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $((filesize + 1))" $testdir/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "cowextsize $bufsize" $testdir/file2
+_cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+md5sum $testdir/file1 | _filter_scratch
+md5sum $testdir/file2 | _filter_scratch
+
+echo "CoW and unmount"
+$XFS_IO_PROG -f -c "cowextsize" $testdir/file2 >> $seqres.full
+seq 1 10 | while read i; do
+	$XFS_IO_PROG -d -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $filesize" $testdir/file2 >> $seqres.full
+	_scratch_cycle_mount
+done
+$XFS_IO_PROG -f -c "falloc -u 0 $filesize" $testdir/file2 >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+md5sum $testdir/file1 | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents $testdir/file1)
+new_extents=$(_count_extents $testdir/file2)
+
+echo "old extents: $old_extents" >> $seqres.full
+echo "new extents: $new_extents" >> $seqres.full
+echo "maximum extents: $internal_blks" >> $seqres.full
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/899.out b/tests/xfs/899.out
new file mode 100644
index 0000000..fd3d7fe
--- /dev/null
+++ b/tests/xfs/899.out
@@ -0,0 +1,10 @@
+QA output created by 899
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-899/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-899/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-899/file1
+Check extent counts
diff --git a/tests/xfs/900 b/tests/xfs/900
new file mode 100755
index 0000000..659ca23
--- /dev/null
+++ b/tests/xfs/900
@@ -0,0 +1,106 @@
+#! /bin/bash
+# FS QA Test No. 900
+#
+# Test fragmentation after writing and dropping CoW extent hint reservation:
+# - Create two reflinked files.  Set extsz hint on second file.
+# - Buffered write to random offsets to scatter CoW reservations.
+# - Unmount, remount, repeat (twice more).
+# - Check the number of extents.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs xfs
+_require_scratch_reflink
+_require_cp_reflink
+_require_fiemap
+_require_xfs_io_command "cowextsize"
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+blksz=65536
+nr=128
+filesize=$((blksz * nr))
+bufnr=8
+bufsize=$((blksz * bufnr))
+
+_require_fs_space $SCRATCH_MNT $((filesize / 1024 * 3 * 5 / 4))
+real_blksz=$(get_block_size $testdir)
+internal_blks=$((filesize / real_blksz))
+
+echo "Create the original files"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 -b $bufsize 0 $((filesize + 1))" $testdir/file1 >> $seqres.full
+$XFS_IO_PROG -f -c "cowextsize $bufsize" $testdir/file2
+_cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+md5sum $testdir/file1 | _filter_scratch
+md5sum $testdir/file2 | _filter_scratch
+
+echo "CoW and unmount"
+$XFS_IO_PROG -f -c "cowextsize" $testdir/file2 >> $seqres.full
+seq 1 10 | while read i; do
+	$XFS_IO_PROG -f -c "pwrite -R -S 0x63 -b $real_blksz 0 $filesize" $testdir/file2 >> $seqres.full
+	_scratch_cycle_mount
+done
+$XFS_IO_PROG -f -c "falloc -u 0 $filesize" $testdir/file2 >> $seqres.full
+_scratch_cycle_mount
+
+echo "Compare files"
+md5sum $testdir/file1 | _filter_scratch
+
+echo "Check extent counts"
+old_extents=$(_count_extents $testdir/file1)
+new_extents=$(_count_extents $testdir/file2)
+
+echo "old extents: $old_extents" >> $seqres.full
+echo "new extents: $new_extents" >> $seqres.full
+echo "maximum extents: $internal_blks" >> $seqres.full
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/900.out b/tests/xfs/900.out
new file mode 100644
index 0000000..5ebf3e9
--- /dev/null
+++ b/tests/xfs/900.out
@@ -0,0 +1,10 @@
+QA output created by 900
+Format and mount
+Create the original files
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-900/file1
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-900/file2
+CoW and unmount
+Compare files
+2909feb63a37b0e95fe5cfb7f274f7b1  SCRATCH_MNT/test-900/file1
+Check extent counts
diff --git a/tests/xfs/group b/tests/xfs/group
index 3dbf3d2..b6bf5bf 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -328,3 +328,7 @@
 886 auto quick rmap
 887 auto quick rmap
 888 auto quick rmap
+897 auto quick clone
+898 auto quick clone
+899 auto quick clone
+900 auto quick clone


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/9] xfs/122: decrease the log update done item sizes
  2016-09-30  2:23 ` [PATCH 1/9] xfs/122: decrease the log update done item sizes Darrick J. Wong
@ 2016-09-30  7:06   ` Christoph Hellwig
  0 siblings, 0 replies; 17+ messages in thread
From: Christoph Hellwig @ 2016-09-30  7:06 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, eguan, linux-xfs, fstests, Dave Chinner

On Thu, Sep 29, 2016 at 07:23:09PM -0700, Darrick J. Wong wrote:
> Redundant fields were removed from the rmap/refcount/bmap update done
> log items, so fix the size tests.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> Reviewed-by: Dave Chinner <dchinner@redhat.com>

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/9] xfs/130: don't modify files after failed mount
  2016-09-30  2:23 ` [PATCH 2/9] xfs/130: don't modify files after failed mount Darrick J. Wong
@ 2016-09-30  7:07   ` Christoph Hellwig
  0 siblings, 0 replies; 17+ messages in thread
From: Christoph Hellwig @ 2016-09-30  7:07 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, eguan, linux-xfs, fstests, Dave Chinner

On Thu, Sep 29, 2016 at 07:23:15PM -0700, Darrick J. Wong wrote:
> In xfs/130, we try to mount a filesystem with the expectation that it
> will fail.  Therefore, it is inappropriate to try to write to the
> mountpoint, since it could otherwise be writable.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> Reviewed-by: Dave Chinner <dchinner@redhat.com>

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/9] xfs/{207,327}: fsxattr no longer has the reflink flag
  2016-09-30  2:23 ` [PATCH 3/9] xfs/{207,327}: fsxattr no longer has the reflink flag Darrick J. Wong
@ 2016-09-30  7:07   ` Christoph Hellwig
  0 siblings, 0 replies; 17+ messages in thread
From: Christoph Hellwig @ 2016-09-30  7:07 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, eguan, linux-xfs, fstests

On Thu, Sep 29, 2016 at 07:23:22PM -0700, Darrick J. Wong wrote:
> The FS_XFLAG_REFLINK flag was removed from struct fsxattr prior to
> the inclusion of reflink in XFS, so remove it from the test outputs.
> Note that the inode flag still exists; it's simply not presented
> to userspace any more.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/9] misc: fix fallocate commands that need the unshare switch
  2016-09-30  2:23 ` [PATCH 4/9] misc: fix fallocate commands that need the unshare switch Darrick J. Wong
@ 2016-09-30 11:55   ` Christoph Hellwig
  0 siblings, 0 replies; 17+ messages in thread
From: Christoph Hellwig @ 2016-09-30 11:55 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, eguan, linux-xfs, fstests

Doesn't this have the same issues my patch that checked for -k had?
Namely that we'll only check if the command support the option, not
that the fs beeing tested actually supports them as well?


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 5/9] misc: use get_block_size helper
  2016-09-30  2:23 ` [PATCH 5/9] misc: use get_block_size helper Darrick J. Wong
@ 2016-09-30 11:56   ` Christoph Hellwig
  0 siblings, 0 replies; 17+ messages in thread
From: Christoph Hellwig @ 2016-09-30 11:56 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, eguan, linux-xfs, fstests

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 6/9] xfs: fix $XFS_DB_PROG usage
  2016-09-30  2:23 ` [PATCH 6/9] xfs: fix $XFS_DB_PROG usage Darrick J. Wong
@ 2016-09-30 11:56   ` Christoph Hellwig
  0 siblings, 0 replies; 17+ messages in thread
From: Christoph Hellwig @ 2016-09-30 11:56 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, eguan, linux-xfs, fstests

Looks fine,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 8/9] xfs: test realtime rmapbt code
  2016-09-30  2:23 ` [PATCH 8/9] xfs: test realtime rmapbt code Darrick J. Wong
@ 2016-10-07 11:41   ` Eryu Guan
  0 siblings, 0 replies; 17+ messages in thread
From: Eryu Guan @ 2016-10-07 11:41 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: david, linux-xfs, fstests

On Thu, Sep 29, 2016 at 07:23:55PM -0700, Darrick J. Wong wrote:
> Test the realtime rmap btree code by exercising various IO patterns
> on realtime files.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---

[snip]

> 
> 
> diff --git a/tests/xfs/877 b/tests/xfs/877
> index 194b3be..04fdb4c 100755
> --- a/tests/xfs/877
> +++ b/tests/xfs/877
> @@ -32,7 +32,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
>  _cleanup()
>  {
>  	cd /
> -	rm -rf "$tmp".* $metadump_file
> +	rm -rf "$tmp".*
>  }

I fold this hunk into patch 7/9.

[snip]

> diff --git a/tests/xfs/886 b/tests/xfs/886
> new file mode 100755
> index 0000000..f0c3997
> --- /dev/null
> +++ b/tests/xfs/886
> @@ -0,0 +1,99 @@
> +#! /bin/bash
> +# FS QA Test No. 886
> +#
> +# Cross-link file block into rtrmapbt and see if repair fixes it.
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public License as
> +# published by the Free Software Foundation.
> +#
> +# This program is distributed in the hope that it would be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write the Free Software Foundation,
> +# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
> +#-----------------------------------------------------------------------
> +
> +seq=`basename "$0"`
> +seqres="$RESULT_DIR/$seq"
> +echo "QA output created by $seq"
> +
> +here=`pwd`
> +tmp=/tmp/$$
> +status=1    # failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +	cd /
> +	rm -rf "$tmp".*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_os Linux
> +_supported_fs xfs
> +_require_realtime
> +_require_xfs_scratch_rmapbt
> +_require_test_program "punch-alternating"
> +_disable_dmesg_check
> +
> +rm -f "$seqres.full"
> +
> +echo "Format and mount"
> +_scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >/dev/null
> +. $tmp.mkfs
> +cat $tmp.mkfs > "$seqres.full" 2>&1
> +_scratch_mkfs > "$seqres.full" 2>&1

This second _scratch_mkfs doesn't seem necessary, and it overwrites
$seqres.full. xfs/887 has the same issue. I can fix them at commit time
if you think they're safe to remove too.

Thanks,
Eryu

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2016-10-07 11:41 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-30  2:23 [PATCH v10 0/9] xfstests: fixes and new tests for rmap/reflink Darrick J. Wong
2016-09-30  2:23 ` [PATCH 1/9] xfs/122: decrease the log update done item sizes Darrick J. Wong
2016-09-30  7:06   ` Christoph Hellwig
2016-09-30  2:23 ` [PATCH 2/9] xfs/130: don't modify files after failed mount Darrick J. Wong
2016-09-30  7:07   ` Christoph Hellwig
2016-09-30  2:23 ` [PATCH 3/9] xfs/{207,327}: fsxattr no longer has the reflink flag Darrick J. Wong
2016-09-30  7:07   ` Christoph Hellwig
2016-09-30  2:23 ` [PATCH 4/9] misc: fix fallocate commands that need the unshare switch Darrick J. Wong
2016-09-30 11:55   ` Christoph Hellwig
2016-09-30  2:23 ` [PATCH 5/9] misc: use get_block_size helper Darrick J. Wong
2016-09-30 11:56   ` Christoph Hellwig
2016-09-30  2:23 ` [PATCH 6/9] xfs: fix $XFS_DB_PROG usage Darrick J. Wong
2016-09-30 11:56   ` Christoph Hellwig
2016-09-30  2:23 ` [PATCH 7/9] xfs: more rmapbt tests Darrick J. Wong
2016-09-30  2:23 ` [PATCH 8/9] xfs: test realtime rmapbt code Darrick J. Wong
2016-10-07 11:41   ` Eryu Guan
2016-09-30  2:24 ` [PATCH 9/9] xfs: test copy-on-write fragmentation when no cow extent size hint is set Darrick J. Wong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.