fstests: Introduce check for explicit SHARED extent flag reporting
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Thu, 17 Nov 2016 02:06:48 +0000 (10:06 +0800)
committerEryu Guan <eguan@redhat.com>
Fri, 18 Nov 2016 08:41:06 +0000 (16:41 +0800)
For fs support reflink, some of them (OK, btrfs again) doesn't split
SHARED flag for extent fiemap reporting.

For example:
  0         4K         8K
   / File1: Extent 0  \
  /                    \
  |<- On disk Extent-->|
  |        /
  | File2 /
    Extent: 0

Fs supports explicit SHARED extent reporting should report fiemap like:
File1: 2 extents
Extent 0-4K: SHARED
Extent 4-8K:
File2: 1 extents
Extent 0-4K: SHARED

Fs doesn't support explicit reporting will report fiemap like:
File1: 1 extent
Extent 0-8K: SHARED
File2: 1 extent
Extent 0-4K: SHARED

Test case like generic/372 require explicit reporting will cause
false alert on btrfs.

Add such runtime check for that requirememt.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/reflink
tests/generic/372

index 8b3404620a7457cf09f3ced255c56d0e90fc93c6..9d51729b1e644d32004a5fec2c7e05ffc9450932 100644 (file)
@@ -78,6 +78,50 @@ _require_scratch_reflink()
        _scratch_unmount
 }
 
+# this test requires scratch fs to report explicit SHARED flag
+# e.g.
+#   0         4K         8K
+#    / File1: Extent 0  \
+#   /                    \
+#   |<- On disk Extent-->|
+#   |        /
+#   | File2 /
+#     Extent: 0
+# Fs supports explicit SHARED extent reporting should report fiemap like:
+# File1: 2 extents
+# Extent 0-4K: SHARED
+# Extent 4-8K:
+# File2: 1 extents
+# Extent 0-4K: SHARED
+#
+# Fs doesn't support explicit reporting will report fiemap like:
+# File1: 1 extent
+# Extent 0-8K: SHARED
+# File2: 1 extent
+# Extent 0-4K: SHARED
+_require_scratch_explicit_shared_extents()
+{
+       _require_scratch
+       _require_fiemap
+       _require_scratch_reflink
+       _require_xfs_io_command "reflink"
+       local nr_extents
+
+       _scratch_mkfs > /dev/null
+       _scratch_mount
+
+       _pwrite_byte 0x61 0 128k $SCRATCH_MNT/file1 >/dev/null
+       _reflink_range $SCRATCH_MNT/file1 0 $SCRATCH_MNT/file2 0 64k >/dev/null
+
+       _scratch_cycle_mount
+
+       nr_extents=$(_count_extents $SCRATCH_MNT/file1)
+       if [ $nr_extents -eq 1 ]; then
+               _notrun "Explicit SHARED flag reporting not support by filesystem type: $FSTYP"
+       fi
+       _scratch_unmount
+}
+
 # this test requires the test fs support dedupe...
 _require_test_dedupe()
 {
index 31dff201123690853606be1e622c95ffa15d1bdf..51a3eca7fab66559732923ecfc6ed397cea71a32 100755 (executable)
@@ -47,6 +47,7 @@ _supported_os Linux
 _supported_fs generic
 _require_scratch_reflink
 _require_fiemap
+_require_scratch_explicit_shared_extents
 
 echo "Format and mount"
 _scratch_mkfs > $seqres.full 2>&1