]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
btrfs/291: fix state transition logic and add size requirement
authorDisha Goel <disgoel@linux.ibm.com>
Fri, 8 May 2026 14:47:01 +0000 (20:17 +0530)
committerZorro Lang <zlang@kernel.org>
Mon, 11 May 2026 16:18:14 +0000 (00:18 +0800)
This patch fixes two issues in btrfs/291:

1. Add dynamic LOGWRITES_DEV size requirement based on SCRATCH_DEV
   The test creates LVM snapshots at each FUA point during replay,
   requiring significant space. Calculate the required size as 120%
   of SCRATCH_DEV size (adding 20% overhead for LVM snapshots and
   metadata) to ensure the test works regardless of SCRATCH_DEV size.

2. Fix state transition logic for verity enablement
   The original test assumed orphan items would always be created
   during verity enablement (state 0->1 transition). However, in
   some cases verity completes without creating orphan items,
   causing the test to fail with "expected to reach verity done state".

   Fix by transitioning to state 1 when either orphan items exist
   OR merkle items appear, handling both verity enablement paths.
   Also improve state 1 validation to only check for cleared merkle
   items when measurement actually fails.

The test now correctly handles verity enablement with or without
orphan items while maintaining crash consistency validation, and
works with any SCRATCH_DEV size.

Suggested-by: Anand Jain <anajain.sg@gmail.com>
Signed-off-by: Disha Goel <disgoel@linux.ibm.com>
Reviewed-by: Zorro Lang <zlang@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
tests/btrfs/291

index 122aeaa5d89c864c7a3e550ecebf722ebf17dd4a..e5ea4b5059b19eb3b15295ca0b1aa6ed5eba901e 100755 (executable)
@@ -36,7 +36,9 @@ _cleanup()
 _require_scratch
 _require_test
 _require_loop
-_require_log_writes
+scratch_size=$(_get_device_size $SCRATCH_DEV)
+required_log_size=$((scratch_size * 120 / 100))
+_require_log_writes_sized $required_log_size
 _require_dm_target snapshot
 _require_command $LVM_PROG lvm
 _require_scratch_verity
@@ -129,9 +131,14 @@ do
        _udev_wait /dev/mapper/$vgname-$snapname
 
        orphan=$(count_item $snap_dev ORPHAN)
-       [ $state -eq 0 ] && [ $orphan -gt 0 ] && state=1
-
        pre_mount=$(count_merkle_items $snap_dev)
+
+       if [ $state -eq 0 ]; then
+               if [ $orphan -gt 0 ] || [ $pre_mount -gt 0 ]; then
+                       state=1
+               fi
+       fi
+
        _mount $snap_dev $SCRATCH_MNT || _fail "mount failed at entry $cur"
        fsverity measure $SCRATCH_MNT/fsv >>$seqres.full 2>&1
        measured=$?
@@ -143,8 +150,10 @@ do
        echo "entry: $cur, state: $state, orphan: $orphan, pre_mount: $pre_mount, post_mount: $post_mount" >> $seqres.full
 
        if [ $state -eq 1 ]; then
-               [ $post_mount -eq 0 ] || \
-                       _fail "mount failed to clear under-construction merkle items pre: $pre_mount, post: $post_mount at entry $cur";
+               if [ $measured -ne 0 ]; then
+                       [ $post_mount -eq 0 ] || \
+                               _fail "mount failed to clear under-construction merkle items pre: $pre_mount, post: $post_mount at entry $cur";
+               fi
        fi
        if [ $state -eq 2 ]; then
                [ $pre_mount -gt 0 ] || \