[PATCH 5/9] xfs/327: fix inode reflink flag checking

Darrick J. Wong
2020-10-27T19:04:07Z

From: Darrick J. Wong <darrick.wong@oracle.com>

This is a regression test that tried to make sure that repair correctly
clears the XFS inode reflink flag when it detects files that do not
share any blocks. However, it does this checking by looking at the
(online) lsattr output. This worked fine during development when we
exposed the reflink state via the stat ioctls, but that has long since
been removed. Now the only way to check is via xfs_db, so switch it to
use that.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
tests/xfs/327 | 18 ++++++++++++++++--
tests/xfs/327.out | 13 +++++++------
2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/tests/xfs/327 b/tests/xfs/327
index 017e2a84..7a14798f 100755
--- a/tests/xfs/327
+++ b/tests/xfs/327
@@ -49,10 +49,21 @@ seq 1 $nr | while read i; do
done
sync

+ino_0=$(stat -c '%i' $SCRATCH_MNT/file.0)
+ino_64=$(stat -c '%i' $SCRATCH_MNT/file.64)
+ino_128=$(stat -c '%i' $SCRATCH_MNT/file.128)
+
+echo "Check filesystem"
+_scratch_unmount
+_scratch_xfs_db -c "inode $ino_0" -c print \
+ -c "inode $ino_64" -c print \
+ -c "inode $ino_128" -c print | grep reflink | sed -e 's/^v[0-9]*/vX/g'
+_scratch_mount
+
echo "Check files"
for i in 0 $((nr / 2)) $nr; do
md5sum $SCRATCH_MNT/file.$i | _filter_scratch
- $XFS_IO_PROG -c 'lsattr -v' $SCRATCH_MNT/file.$i | _filter_scratch
+ $XFS_IO_PROG -c 'lsattr -v' $SCRATCH_MNT/file.$i >> $seqres.full
done

echo "CoW all files"
@@ -63,12 +74,15 @@ done
echo "Repair filesystem"
_scratch_unmount
_repair_scratch_fs >> $seqres.full
+_scratch_xfs_db -c "inode $ino_0" -c print \
+ -c "inode $ino_64" -c print \
+ -c "inode $ino_128" -c print | grep reflink | sed -e 's/^v[0-9]*/vX/g'
_scratch_mount

echo "Check files again"
for i in 0 $((nr / 2)) $nr; do
md5sum $SCRATCH_MNT/file.$i | _filter_scratch
- $XFS_IO_PROG -c 'lsattr -v' $SCRATCH_MNT/file.$i | _filter_scratch
+ $XFS_IO_PROG -c 'lsattr -v' $SCRATCH_MNT/file.$i >> $seqres.full
done

echo "Done"
diff --git a/tests/xfs/327.out b/tests/xfs/327.out
index 5b3cba21..0e204205 100644
--- a/tests/xfs/327.out
+++ b/tests/xfs/327.out
@@ -1,20 +1,21 @@
QA output created by 327
Format filesystem
Create files
+Check filesystem
+vX.reflink = 1
+vX.reflink = 1
+vX.reflink = 1
Check files
8fa14cdd754f91cc6554c9e71929cce7 SCRATCH_MNT/file.0
-[] SCRATCH_MNT/file.0
8fa14cdd754f91cc6554c9e71929cce7 SCRATCH_MNT/file.64
-[] SCRATCH_MNT/file.64
8fa14cdd754f91cc6554c9e71929cce7 SCRATCH_MNT/file.128
-[] SCRATCH_MNT/file.128
CoW all files
Repair filesystem
+vX.reflink = 0
+vX.reflink = 0
+vX.reflink = 0
Check files again
8fa14cdd754f91cc6554c9e71929cce7 SCRATCH_MNT/file.0
-[] SCRATCH_MNT/file.0
0f17fd72b7bbf5bda0ff433e6d1fc118 SCRATCH_MNT/file.64
-[] SCRATCH_MNT/file.64
0f17fd72b7bbf5bda0ff433e6d1fc118 SCRATCH_MNT/file.128
-[] SCRATCH_MNT/file.128
Done