Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH v2 1/2] common/dmlogwrites: add _require_log_writes_sized helper
@ 2026-04-27 12:25 Disha Goel
  2026-04-27 12:25 ` [PATCH v2 2/2] btrfs/291: fix state transition logic and add size requirement Disha Goel
  2026-05-04 21:53 ` [PATCH v2 1/2] common/dmlogwrites: add _require_log_writes_sized helper Anand Jain
  0 siblings, 2 replies; 7+ messages in thread
From: Disha Goel @ 2026-04-27 12:25 UTC (permalink / raw)
  To: fstests
  Cc: linux-btrfs, ritesh.list, ojaswin, djwong, fdmanana,
	quwenruo.btrfs, zlang, anajain.sg, Disha Goel

Add a new helper function _require_log_writes_sized() 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, calls _require_log_writes()
internally, and skips the test if LOGWRITES_DEV is smaller than the
required size.

v2:
- Renamed function from _require_logwrites_size to _require_log_writes_sized
- Added documentation comment clarifying the parameter is in KB
- Made function call _require_log_writes() internally to avoid redundant
  calls in test code

Suggested-by: Darrick J. Wong <djwong@kernel.org>
Suggested-by: Anand Jain <anajain.sg@gmail.com>
Signed-off-by: Disha Goel <disgoel@linux.ibm.com>
---
 common/dmlogwrites | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/common/dmlogwrites b/common/dmlogwrites
index a27e1966..0925b333 100644
--- a/common/dmlogwrites
+++ b/common/dmlogwrites
@@ -14,6 +14,21 @@ _require_log_writes()
 	_require_test_program "log-writes/replay-log"
 }
 
+# Require a log writes device of a minimum size
+# $1: minimum size in KB
+_require_log_writes_sized()
+{
+        local size=$1
+
+        [ $# -eq 1 ] || _fail "_require_log_writes_sized: expected size param"
+
+        _require_log_writes
+
+        local devsize=$(_get_device_size $LOGWRITES_DEV)
+        [ $devsize -lt $1 ] && \
+                _notrun "LOGWRITES_DEV too small, ${devsize}KB < ${size}KB"
+}
+
 # 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
-- 
2.45.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-05-08 14:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 12:25 [PATCH v2 1/2] common/dmlogwrites: add _require_log_writes_sized helper Disha Goel
2026-04-27 12:25 ` [PATCH v2 2/2] btrfs/291: fix state transition logic and add size requirement Disha Goel
2026-05-05  2:46   ` Anand Jain
2026-05-08 14:52     ` Disha Goel
2026-05-04 21:53 ` [PATCH v2 1/2] common/dmlogwrites: add _require_log_writes_sized helper Anand Jain
2026-05-04 23:16   ` Anand Jain
2026-05-04 23:43     ` Anand Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox