Skip to contentSkip to conversation

fstests: btrfs/057: Fix false alerts due to orphan files

PATCH Superseded Qu Wenruo 2 participants 2 messages Oct 30, 2018 Btrfs file system

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH v2 1/1 fstests: btrfs/057: Fix false alerts due to orphan files

For any recent kernel, there is a chance that btrfs/057 reports false errors.

The false error would look like:
btrfs/057 4s ... - output mismatch (see /home/adam/xfstests-dev/results//btrfs/057.out.bad)

      --- tests/btrfs/057.out	2017-08-21 09:25:33.166666666 +0800
      +++ /home/adam/xfstests-dev/results//btrfs/057.out.bad	2018-10-29 14:07:28.443651293 +0800
      @@ -1,3 +1,3 @@
       QA output created by 057
       4096 4096
      -4096 4096
      +28672 28672

This is related to the fact that "btrfs subvolume sync" (or vanilla sync) will not ensure orphan (unlinked but still exist) files to be removed.

In fact, for that false error case, if inspecting the fs after umount, its qgroup number is correct and btrfs check won't report qgroup error.

To fix the false alerts, just skip any manual qgroup number comparison, and let fsck done after the test case to detect problem.

This also elimiate the necessary of using specified mount and mkfs option, allowing us to improve coverage.

---
Changelog:
v2:
Update commit message to show this is a long existing bug.

---
 tests/btrfs/057     | 17 ++++-------------
 tests/btrfs/057.out |  3 +--
 2 files changed, 5 insertions(+), 15 deletions(-)
tests/btrfs/057 +4 -13
index b019f4e1e054..0b5a36d34852 100755
@@ -33,12 +33,9 @@ _require_scratch
 rm -f $seqres.full
 
 # use small leaf size to get higher btree height.
-run_check _scratch_mkfs "-b 1g --nodesize 4096"
+run_check _scratch_mkfs "-b 1g"
 
-# inode cache is saved in the FS tree itself for every
-# individual FS tree,that affects the sizes reported by qgroup show
-# so we need to explicitly turn it off to get consistent values.
-_scratch_mount "-o noinode_cache"
+_scratch_mount
 
 # -w ensures that the only ops are ones which cause write I/O
 run_check $FSSTRESS_PROG -d $SCRATCH_MNT -w -p 5 -n 1000 \
@@ -53,14 +50,8 @@ run_check $FSSTRESS_PROG -d $SCRATCH_MNT/snap1 -w -p 5 -n 1000 \
 _run_btrfs_util_prog quota enable $SCRATCH_MNT
 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
 
-# remove all file/dir other than subvolume
-rm -rf $SCRATCH_MNT/snap1/* >& /dev/null
-rm -rf $SCRATCH_MNT/p* >& /dev/null
-
-_run_btrfs_util_prog filesystem sync $SCRATCH_MNT
-units=`_btrfs_qgroup_units`
-$BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | $SED_PROG -n '/[0-9]/p' \
-	| $AWK_PROG '{print $2" "$3}'
+echo "Silence is golden"
+# btrfs check will detect any qgroup number mismatch.
 
 status=0
 exit
tests/btrfs/057.out +1 -2
index 60cb92d0926c..185023c79961 100644
@@ -1,3 +1,2 @@
 QA output created by 057
-4096 4096
-4096 4096
+Silence is golden
Signature · 1 line
2.19.1
#1 lore raw
Quoted 42 lines · Qu Wenruo

For any recent kernel, there is a chance that btrfs/057 reports false errors.

The false error would look like:
btrfs/057 4s ... - output mismatch (see /home/adam/xfstests-dev/results//btrfs/057.out.bad)

      --- tests/btrfs/057.out	2017-08-21 09:25:33.166666666 +0800
      +++ /home/adam/xfstests-dev/results//btrfs/057.out.bad	2018-10-29 14:07:28.443651293 +0800
      @@ -1,3 +1,3 @@
       QA output created by 057
       4096 4096
      -4096 4096
      +28672 28672

This is related to the fact that "btrfs subvolume sync" (or vanilla sync) will not ensure orphan (unlinked but still exist) files to be removed.

In fact, for that false error case, if inspecting the fs after umount, its qgroup number is correct and btrfs check won't report qgroup error.

To fix the false alerts, just skip any manual qgroup number comparison, and let fsck done after the test case to detect problem.

This also elimiate the necessary of using specified mount and mkfs option, allowing us to improve coverage.

---
Changelog:
v2:
Update commit message to show this is a long existing bug.

---
 tests/btrfs/057     | 17 ++++-------------
 tests/btrfs/057.out |  3 +--
 2 files changed, 5 insertions(+), 15 deletions(-)
tests/btrfs/057 +0 -0
index b019f4e1e054..0b5a36d34852 100755

tests/btrfs/057 _require_scratch · line 36

Quoted 5 lines
tests/btrfs/057 +1 -1
@@ -33,12 +33,9 @@ _require_scratch
 rm -f $seqres.full
 
 # use small leaf size to get higher btree height.
-run_check _scratch_mkfs "-b 1g --nodesize 4096"
+run_check _scratch_mkfs "-b 1g"

There was feedback from Filipe on V1 that you also need to delete the above comment since it's no longer valid.

Quoted 36 lines
tests/btrfs/057 +3 -12
-# inode cache is saved in the FS tree itself for every
-# individual FS tree,that affects the sizes reported by qgroup show
-# so we need to explicitly turn it off to get consistent values.
-_scratch_mount "-o noinode_cache"
+_scratch_mount
 
 # -w ensures that the only ops are ones which cause write I/O
 run_check $FSSTRESS_PROG -d $SCRATCH_MNT -w -p 5 -n 1000 \
@@ -53,14 +50,8 @@ run_check $FSSTRESS_PROG -d $SCRATCH_MNT/snap1 -w -p 5 -n 1000 \
 _run_btrfs_util_prog quota enable $SCRATCH_MNT
 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
 
-# remove all file/dir other than subvolume
-rm -rf $SCRATCH_MNT/snap1/* >& /dev/null
-rm -rf $SCRATCH_MNT/p* >& /dev/null
-
-_run_btrfs_util_prog filesystem sync $SCRATCH_MNT
-units=`_btrfs_qgroup_units`
-$BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | $SED_PROG -n '/[0-9]/p' \
-	| $AWK_PROG '{print $2" "$3}'
+echo "Silence is golden"
+# btrfs check will detect any qgroup number mismatch.
 
 status=0
 exit
tests/btrfs/057.out +1 -2
index 60cb92d0926c..185023c79961 100644
@@ -1,3 +1,2 @@
 QA output created by 057
-4096 4096
-4096 4096
+Silence is golden