016: Do not discard blocks at mkfs time
authorBoris Ranto <branto@redhat.com>
Wed, 30 May 2012 22:39:29 +0000 (17:39 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 30 May 2012 22:39:29 +0000 (17:39 -0500)
The test 016 fills scratch device with some data and then creates xfs fs
on the scratch device. Later, the test assumes that the previously
written data are still written there and checks for them at specific
locations. On ssd drive this will lead to a failure since the blocks are
discarded by default when the mkfs command is run.
This is a more verbose version of the previous patch.
This simple patch that adds -K to stop the discarding (if the mkfs
command supports it) fixed the issue for me:

Signed-off-by: Boris Ranto <branto@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
016

diff --git a/016 b/016
index 9275ade5d7c437d65956bd5a9c61cdb6d3fdfc4b..08a73f49ace8e727e12ac8bc3f8aeaf5907c17bb 100755 (executable)
--- a/016
+++ b/016
@@ -65,6 +65,15 @@ _init()
     $here/src/devzero -b 2048 -n 50 -v 198 $SCRATCH_DEV
     echo "*** mkfs"
     force_opts="-dsize=50m -lsize=$log_size"
+    #
+    # Do not discard blocks as we check for patterns in free space.
+    # 
+    # First, make sure that mkfs supports '-K' option by using its
+    # dry run (-N option) and then add it to the force_opts.
+    #
+    if _scratch_mkfs_xfs -N -K $force_opts >/dev/null 2>&1; then
+        force_opts="-K $force_opts"
+    fi
     echo mkfs_xfs $force_opts $SCRATCH_DEV >>$seq.full
     _scratch_mkfs_xfs $force_opts >$tmp.mkfs0 2>&1
     [ $? -ne 0 ] && \