Skip to contentSkip to conversation

common/dmlogwrites: add _require_logwrites_size helper

PATCH Superseded Disha Goel 3 participants 7 messages Apr 14 – Apr 27 Btrfs file system

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Disha Goel

author
#0 lore raw

PATCH 1/2 common/dmlogwrites: add _require_logwrites_size helper

Add a new helper function _require_logwrites_size() to check if the LOGWRITES_DEV meets a minimum size requirement.

This is useful for tests that use dm-log-writes with additional space requirements, such as creating LVM snapshots during log replay or tests that generate large amounts of logged I/O operations.

The function takes a size parameter in KB and skips the test if LOGWRITES_DEV is smaller than the required size.

---
 common/dmlogwrites | 9 +++++++++
 1 file changed, 9 insertions(+)
common/dmlogwrites +9 -0
index a27e1966..1ce2b2fb 100644
@@ -14,6 +14,15 @@ _require_log_writes()
 	_require_test_program "log-writes/replay-log"
 }
 
+_require_logwrites_size()
+{
+        [ $# -eq 1 ] || _fail "_require_logwrites_size: expected size param"
+
+        local devsize=$(_get_device_size $LOGWRITES_DEV)
+        [ $devsize -lt $1 ] && \
+                _notrun "LOGWRITES_DEV too small, ${devsize}KB < $1KB"
+}
+
 # Starting from v4.15-rc1, DAX support was added to dm-log-writes, but note
 # that it doesn't track the data that we write via the mmap(), so we can't do
 # any data integrity checking. We can only verify that the metadata writes for
Signature · 1 line
2.45.1
author
#1 lore raw

PATCH 2/2 btrfs/291: fix state transition logic and add size requirement

This patch fixes two issues in btrfs/291:

1. Add minimum 9GB LOGWRITES_DEV size requirement
The test creates LVM snapshots at each FUA point during replay, requiring significant space. Add _require_logwrites_size check to ensure sufficient space is available before running the test.

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.

---
 tests/btrfs/291 | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
tests/btrfs/291 +12 -4
index 122aeaa5..d29dc5dd 100755
@@ -37,6 +37,7 @@ _require_scratch
 _require_test
 _require_loop
 _require_log_writes
+_require_logwrites_size $((9 * 1024 * 1024))
 _require_dm_target snapshot
 _require_command $LVM_PROG lvm
 _require_scratch_verity
@@ -129,9 +130,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 +149,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 ] || \
Signature · 1 line
2.45.1
author
#2 lore raw
In reply to Disha Goel

Hi,

Looking for review comments on this patch series.

Quoted 35 lines · Disha Goel

Add a new helper function _require_logwrites_size() to check if the LOGWRITES_DEV meets a minimum size requirement.

This is useful for tests that use dm-log-writes with additional space requirements, such as creating LVM snapshots during log replay or tests that generate large amounts of logged I/O operations.

The function takes a size parameter in KB and skips the test if LOGWRITES_DEV is smaller than the required size.

---
  common/dmlogwrites | 9 +++++++++
  1 file changed, 9 insertions(+)
common/dmlogwrites +9 -0
index a27e1966..1ce2b2fb 100644
@@ -14,6 +14,15 @@ _require_log_writes()
  	_require_test_program "log-writes/replay-log"
  }
 
+_require_logwrites_size()
+{
+        [ $# -eq 1 ] || _fail "_require_logwrites_size: expected size param"
+
+        local devsize=$(_get_device_size $LOGWRITES_DEV)
+        [ $devsize -lt $1 ] && \
+                _notrun "LOGWRITES_DEV too small, ${devsize}KB < $1KB"
+}
+
  # Starting from v4.15-rc1, DAX support was added to dm-log-writes, but note
  # that it doesn't track the data that we write via the mmap(), so we can't do
  # any data integrity checking. We can only verify that the metadata writes for
Signature · 2 lines
Regards,
Disha
#3 lore raw
Quoted 20 lines · Disha Goel

Hi,

Looking for review comments on this patch series.

Quoted 15 lines · Disha Goel

Add a new helper function _require_logwrites_size() to check if the LOGWRITES_DEV meets a minimum size requirement.

This is useful for tests that use dm-log-writes with additional space requirements, such as creating LVM snapshots during log replay or tests that generate large amounts of logged I/O operations.

The function takes a size parameter in KB and skips the test if LOGWRITES_DEV is smaller than the required size.

---
  common/dmlogwrites | 9 +++++++++
  1 file changed, 9 insertions(+)
Quoted 10 lines

common/dmlogwrites _require_log_writes() · line 18

Quoted 10 lines
common/dmlogwrites +3 -0
index a27e1966..1ce2b2fb 100644
@@ -14,6 +14,15 @@ _require_log_writes()
  	_require_test_program "log-writes/replay-log"
  }
+_require_logwrites_size()
+{
+        [ $# -eq 1 ] || _fail "_require_logwrites_size: expected size param"

What are the units of the size parameter? Bytes? 512b sectors?

The helper should have a comment clarifying that.

--D

Quoted 15 lines
Quoted 9 lines
common/dmlogwrites +6 -0
+
+        local devsize=$(_get_device_size $LOGWRITES_DEV)
+        [ $devsize -lt $1 ] && \
+                _notrun "LOGWRITES_DEV too small, ${devsize}KB < $1KB"
+}
+
  # Starting from v4.15-rc1, DAX support was added to dm-log-writes, but note
  # that it doesn't track the data that we write via the mmap(), so we can't do
  # any data integrity checking. We can only verify that the metadata writes for
Signature · 2 lines
Regards,
Disha
author
#4 lore raw
Quoted 34 lines · Darrick J. Wong
Quoted 20 lines · Disha Goel

Hi,

Looking for review comments on this patch series.

Quoted 15 lines · Disha Goel

Add a new helper function _require_logwrites_size() to check if the LOGWRITES_DEV meets a minimum size requirement.

This is useful for tests that use dm-log-writes with additional space requirements, such as creating LVM snapshots during log replay or tests that generate large amounts of logged I/O operations.

The function takes a size parameter in KB and skips the test if LOGWRITES_DEV is smaller than the required size.

---
   common/dmlogwrites | 9 +++++++++
   1 file changed, 9 insertions(+)
Quoted 10 lines

common/dmlogwrites _require_log_writes() · line 18

Quoted 10 lines
common/dmlogwrites +3 -0
index a27e1966..1ce2b2fb 100644
@@ -14,6 +14,15 @@ _require_log_writes()
   	_require_test_program "log-writes/replay-log"
   }
+_require_logwrites_size()
+{
+        [ $# -eq 1 ] || _fail "_require_logwrites_size: expected size param"

What are the units of the size parameter? Bytes? 512b sectors?

Quoted 4 lines

The helper should have a comment clarifying that.

--D

Thanks for the review. I've addressed this in v2 by adding a comment block documenting that the parameter is in KB.

v2 has been sent: https://lore.kernel.org/fstests/[email protected]/T/#t

Quoted 15 lines
Quoted 15 lines
Quoted 9 lines
common/dmlogwrites +6 -0
+
+        local devsize=$(_get_device_size $LOGWRITES_DEV)
+        [ $devsize -lt $1 ] && \
+                _notrun "LOGWRITES_DEV too small, ${devsize}KB < $1KB"
+}
+
   # Starting from v4.15-rc1, DAX support was added to dm-log-writes, but note
   # that it doesn't track the data that we write via the mmap(), so we can't do
   # any data integrity checking. We can only verify that the metadata writes for
Signature · 2 lines
Regards,
Disha
Signature · 2 lines
Regards,
Disha
#5 lore raw
In reply to Disha Goel
Quoted 25 lines · Disha Goel

Add a new helper function _require_logwrites_size() to check if the LOGWRITES_DEV meets a minimum size requirement.

This is useful for tests that use dm-log-writes with additional space requirements, such as creating LVM snapshots during log replay or tests that generate large amounts of logged I/O operations.

The function takes a size parameter in KB and skips the test if LOGWRITES_DEV is smaller than the required size.

---
 common/dmlogwrites | 9 +++++++++
 1 file changed, 9 insertions(+)
common/dmlogwrites +2 -0
index a27e1966..1ce2b2fb 100644
@@ -14,6 +14,15 @@ _require_log_writes()
 	_require_test_program "log-writes/replay-log"
 }
 
+_require_logwrites_size()
+{

common/dmlogwrites _require_log_writes() · line 28

Quoted 10 lines
common/dmlogwrites +7 -0
+        [ $# -eq 1 ] || _fail "_require_logwrites_size: expected size param"
+
+        local devsize=$(_get_device_size $LOGWRITES_DEV)
+        [ $devsize -lt $1 ] && \
+                _notrun "LOGWRITES_DEV too small, ${devsize}KB < $1KB"
+}
+
 # Starting from v4.15-rc1, DAX support was added to dm-log-writes, but note
 # that it doesn't track the data that we write via the mmap(), so we can't do
 # any data integrity checking. We can only verify that the metadata writes for

_require_logwrites_size() should be designed something like this

_require_log_writes_sized()

{
	local size=$1

	_require_log_writes
	check $size || _notrun
}

So, patch 2/2 can simply call _require_log_writes_sized <>

Thanks.

author
#6 lore raw
Quoted 48 lines · Anand Jain
Quoted 25 lines · Disha Goel

Add a new helper function _require_logwrites_size() to check if the LOGWRITES_DEV meets a minimum size requirement.

This is useful for tests that use dm-log-writes with additional space requirements, such as creating LVM snapshots during log replay or tests that generate large amounts of logged I/O operations.

The function takes a size parameter in KB and skips the test if LOGWRITES_DEV is smaller than the required size.

---
  common/dmlogwrites | 9 +++++++++
  1 file changed, 9 insertions(+)
common/dmlogwrites +2 -0
index a27e1966..1ce2b2fb 100644
@@ -14,6 +14,15 @@ _require_log_writes()
  	_require_test_program "log-writes/replay-log"
  }
 
+_require_logwrites_size()
+{

common/dmlogwrites _require_log_writes() · line 28

Quoted 10 lines
common/dmlogwrites +7 -0
+        [ $# -eq 1 ] || _fail "_require_logwrites_size: expected size param"
+
+        local devsize=$(_get_device_size $LOGWRITES_DEV)
+        [ $devsize -lt $1 ] && \
+                _notrun "LOGWRITES_DEV too small, ${devsize}KB < $1KB"
+}
+
  # Starting from v4.15-rc1, DAX support was added to dm-log-writes, but note
  # that it doesn't track the data that we write via the mmap(), so we can't do
  # any data integrity checking. We can only verify that the metadata writes for

_require_logwrites_size() should be designed something like this

_require_log_writes_sized()

{
	local size=$1

	_require_log_writes
	check $size || _notrun
}
Quoted 3 lines

So, patch 2/2 can simply call _require_log_writes_sized <>

Thanks.

Thanks for the suggestion. I've implemented this in v2.

v2 has been sent: https://lore.kernel.org/fstests/[email protected]/T/#t

Signature · 2 lines
Regards,
Disha