* [PATCH v3] btrfs: zoned: reset leaked zones on read-write mount
@ 2026-11-02 15:35 Mark Korenberg via B4 Relay
2026-11-17 6:54 ` Mark Korenberg
2026-11-17 11:46 ` Johannes Thumshirn
0 siblings, 2 replies; 3+ messages in thread
From: Mark Korenberg via B4 Relay @ 2026-11-02 15:35 UTC (permalink / raw)
To: David Sterba, Chris Mason
Cc: Johannes Thumshirn, Naohiro Aota, linux-btrfs, linux-kernel,
Mark Korenberg
From: Mark Korenberg <socketpair@gmail.com>
If a transaction commit is aborted after the zones of a new block group
were written but before the superblock was, the chunk item and the dev
extent are never persisted and the zones leak. The chunk allocator skips
non-empty zones, so they are never reused, open ones keep counting
against the active zone limit, and btrfs check reports them as
unreferenced.
On a read-write mount, reset every non-empty sequential zone that is
neither a superblock log zone nor allocated to a chunk. Commit the
running transaction under reclaim_bgs_lock first, so that a chunk
removal is not mistaken for a leak, hold chunk_mutex so that no chunk is
allocated meanwhile, and skip it all while a device replace is ongoing,
as no chunk references the replace target yet.
Suggested-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Mark Korenberg <socketpair@gmail.com>
---
This follows up on my RFC about stale zones in unallocated device space.
Johannes replied to it with v1 of this patch and handed it over to me,
and I posted v2 as an attachment in the same thread. This is v3, now
tested and posted as a regular patch.
RFC: https://lore.kernel.org/all/CAEmTpZGu5x9PS7vFwgc_dFH80rL3cFD4-geuuL_w8i=vFDo8AA@mail.gmail.com/
Changes in v3:
- Don't ask the device for the zone condition under chunk_mutex. On
virtio-blk a zone report takes vdev_mutex, under which the
BLKREPORTZONE ioctl copies to user space, and btrfs_fallocate()
allocates chunks under i_mmap_lock, which a write fault takes. Lockdep
would report the same kind of cycle as the one fixed by "btrfs: zoned:
fix lockdep splat on mount". A zone reset takes no such lock.
As a result, offline and read-only zones are no longer skipped:
resetting a run that contains one fails, which is logged and
otherwise ignored.
- Link to v2: https://lore.kernel.org/all/CAEmTpZGifFxr+yaKddZcG8UxhntYvZROygi6s-8goAoxuUzqHQ@mail.gmail.com/
Changes in v2:
- Skip while a device replace is ongoing; v1 reset the data already
copied to the replace target.
- Hold chunk_mutex; v1 raced with chunk allocation in open_ctree().
- Hold reclaim_bgs_lock and commit first; v1 could reset the zones of a
chunk removed by a relocating repair before the removal was committed.
- Check coverage in device->alloc_state: covers whole stripes, no
bitmap allocation, no NULL physical_map case.
- Walk alloc_list (writeable devices) under chunk_mutex instead of the
device list under device_list_mutex, only up to total_bytes.
- Skip offline and read-only zones, they cannot be reset.
- Reset adjacent zones in one call and log each reset range.
- Link to v1: https://lore.kernel.org/all/52925d79-4dce-4621-b9e1-fd062b47e35d@wdc.com/
Testing: virtme-ng VM, zoned null_blk with 64 MiB zones,
CONFIG_PROVE_LOCKING, this patch plus debug logging of every decision:
- not zoned filesystem: nothing done
- fresh filesystem: the first mount resets zone 3, which mkfs.btrfs
(btrfs-progs 7.1) leaves written outside any chunk; nothing to do on
the next mount, btrfs check clean
- zones written behind the back of btrfs: reset, data intact
- a run of leaked zones containing an offline and a read-only zone:
the reset fails with -EIO and is logged, the mount goes on, both
zones keep their condition, data intact
- ro mount leaves leaked zones, remount,rw resets them
- replace interrupted with remount,ro and resumed with remount,rw: the
pass is skipped, nothing reset
- no lockdep report or warning from this patch
Not tested: lockdep on a zoned virtio-blk device, the cycle fixed in v3
was found by reading the code. A replace interrupted by umount and
resumed by mount: on master a device replace on this setup aborts the
transaction with -EAGAIN within seconds (commit from
scrub_enumerate_chunks()), and the scrub then waits for itself in
btrfs_scrub_cancel() called from cleanup_transaction(). That is
unrelated to this patch, I will report it separately.
Reviewed with the help of an AI assistant (Claude), which also drafted
the v2 and v3 changes and the tests.
---
fs/btrfs/disk-io.c | 2 +
fs/btrfs/zoned.c | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++++
fs/btrfs/zoned.h | 3 ++
3 files changed, 145 insertions(+)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index c45cda4290d5..f3e15c575e8a 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3059,6 +3059,8 @@ int btrfs_start_pre_rw_mount(struct btrfs_fs_info *fs_info)
int ret;
bool rebuild_free_space_tree = false;
+ btrfs_reset_unreferenced_zones(fs_info);
+
if (btrfs_test_opt(fs_info, CLEAR_CACHE) &&
btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE)) {
if (btrfs_fs_incompat(fs_info, EXTENT_TREE_V2))
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 1cda88332284..56940eaf1594 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -3226,6 +3226,146 @@ int btrfs_reset_unused_block_groups(struct btrfs_space_info *space_info, u64 num
return 0;
}
+/*
+ * A zone is leaked if it is a non-empty sequential zone that is neither a
+ * superblock log zone nor part of any stripe of any chunk. Chunk stripes are
+ * looked up in the device's alloc_state, which covers every chunk in the
+ * mapping tree over the whole stripe length.
+ */
+static bool is_leaked_zone(struct btrfs_device *device, u32 zno)
+{
+ struct btrfs_zoned_device_info *zinfo = device->zone_info;
+ u64 start = (u64)zno << zinfo->zone_size_shift;
+
+ if (!btrfs_dev_is_sequential(device, start))
+ return false;
+
+ if (btrfs_dev_is_empty_zone(device, start))
+ return false;
+
+ if (btrfs_test_range_bit_exists(&device->alloc_state, start,
+ start + zinfo->zone_size - 1,
+ CHUNK_ALLOCATED))
+ return false;
+
+ for (int mirror = 0; mirror < BTRFS_SUPER_MIRROR_MAX; mirror++) {
+ u32 sb_zno = sb_zone_number(zinfo->zone_size_shift, mirror);
+
+ if (sb_zno + BTRFS_NR_SB_LOG_ZONES > zinfo->nr_zones)
+ continue;
+ if (zno >= sb_zno && zno < sb_zno + BTRFS_NR_SB_LOG_ZONES)
+ return false;
+ }
+
+ return true;
+}
+
+void btrfs_reset_unreferenced_zones(struct btrfs_fs_info *fs_info)
+{
+ struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
+ struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
+ struct btrfs_device *device;
+ bool replace_ongoing;
+ int ret;
+
+ if (!btrfs_is_zoned(fs_info))
+ return;
+
+ /*
+ * No chunk stripe points to the target of an interrupted device replace
+ * until the replace finishes, so the data already copied to it would
+ * look leaked. The replace resumes from the last committed cursor and
+ * would never copy that data again.
+ *
+ * The target is not on alloc_list, which is walked below, so strictly
+ * speaking it would be enough to skip only the device that has
+ * BTRFS_DEV_STATE_REPLACE_TGT set. Still, do not reset anything at all
+ * while a replace is ongoing, the leaked zones can be reclaimed on the
+ * next mount after the replace has finished or was canceled.
+ *
+ * Do not hold the rwsem across the pass, the replace code takes it
+ * after chunk_mutex. A replace cannot be started while we are in the
+ * (re)mount path.
+ */
+ down_read(&dev_replace->rwsem);
+ replace_ongoing = btrfs_dev_replace_is_ongoing(dev_replace);
+ up_read(&dev_replace->rwsem);
+ if (replace_ongoing) {
+ btrfs_info(fs_info,
+ "zoned: device replace is ongoing, not resetting leaked zones");
+ return;
+ }
+
+ /*
+ * Chunks are only removed under reclaim_bgs_lock, and their zones must
+ * not be reset before the removal is committed. A relocating repair,
+ * started by a read error during mount, may already have removed one in
+ * the running transaction, so commit it before looking for leaked zones.
+ */
+ mutex_lock(&fs_info->reclaim_bgs_lock);
+ ret = btrfs_commit_current_transaction(fs_info->tree_root);
+ if (ret) {
+ btrfs_warn(fs_info,
+ "zoned: failed to commit transaction, not resetting leaked zones: %pe",
+ ERR_PTR(ret));
+ goto out;
+ }
+
+ /*
+ * Hold chunk_mutex, which also protects alloc_list, so that no chunk can
+ * be allocated between checking a zone and resetting it.
+ */
+ mutex_lock(&fs_info->chunk_mutex);
+ list_for_each_entry(device, &fs_devices->alloc_list, dev_alloc_list) {
+ struct btrfs_zoned_device_info *zinfo = device->zone_info;
+ u32 nr_zones;
+
+ if (!device->bdev || !zinfo || !bdev_is_zoned(device->bdev))
+ continue;
+
+ /* Nothing is ever allocated beyond total_bytes, leave it alone. */
+ nr_zones = min_t(u64, zinfo->nr_zones,
+ device->total_bytes >> zinfo->zone_size_shift);
+
+ for (u32 zno = 0; zno < nr_zones; zno++) {
+ u32 first = zno;
+ u64 reset_bytes;
+
+ cond_resched();
+
+ while (zno < nr_zones && is_leaked_zone(device, zno))
+ zno++;
+ if (zno == first)
+ continue;
+
+ ret = btrfs_reset_device_zone(device,
+ (u64)first << zinfo->zone_size_shift,
+ (u64)(zno - first) << zinfo->zone_size_shift,
+ &reset_bytes);
+ /*
+ * Offline and read-only zones look leaked too, as they are
+ * never marked empty, but cannot be reset. Don't ask the
+ * device for the zone condition here: on virtio-blk a zone
+ * report takes a lock that nests outside of chunk_mutex.
+ * Just log a failed reset and move on, the run is retried
+ * on the next mount.
+ */
+ if (ret)
+ btrfs_warn(fs_info,
+ "zoned: failed to reset leaked zones %u-%u on device %s (devid %llu): %pe",
+ first, zno - 1, btrfs_dev_name(device),
+ device->devid, ERR_PTR(ret));
+ else
+ btrfs_info(fs_info,
+ "zoned: reset leaked zones %u-%u on device %s (devid %llu)",
+ first, zno - 1, btrfs_dev_name(device), device->devid);
+ }
+ }
+ mutex_unlock(&fs_info->chunk_mutex);
+out:
+ mutex_unlock(&fs_info->reclaim_bgs_lock);
+}
+
void btrfs_show_zoned_stats(struct btrfs_fs_info *fs_info, struct seq_file *seq)
{
struct btrfs_block_group *bg;
diff --git a/fs/btrfs/zoned.h b/fs/btrfs/zoned.h
index 8e21a836f858..76b40e81ca32 100644
--- a/fs/btrfs/zoned.h
+++ b/fs/btrfs/zoned.h
@@ -97,6 +97,7 @@ int btrfs_zone_finish_one_bg(struct btrfs_fs_info *fs_info);
int btrfs_zoned_activate_one_bg(struct btrfs_space_info *space_info, bool do_finish);
void btrfs_check_active_zone_reservation(struct btrfs_fs_info *fs_info);
int btrfs_reset_unused_block_groups(struct btrfs_space_info *space_info, u64 num_bytes);
+void btrfs_reset_unreferenced_zones(struct btrfs_fs_info *fs_info);
void btrfs_show_zoned_stats(struct btrfs_fs_info *fs_info, struct seq_file *seq);
#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
@@ -287,6 +288,8 @@ static inline int btrfs_reset_unused_block_groups(struct btrfs_space_info *space
return 0;
}
+static inline void btrfs_reset_unreferenced_zones(struct btrfs_fs_info *fs_info) { }
+
static inline int btrfs_show_zoned_stats(struct btrfs_fs_info *fs_info, struct seq_file *seq)
{
return 0;
---
base-commit: d135ab453a7400a34930bdda1ef4bdc8acfac80e
change-id: 20261030-b4-btrfs-zoned-reset-leaked-zones-96f6846d8704
Best regards,
--
Mark Korenberg <socketpair@gmail.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v3] btrfs: zoned: reset leaked zones on read-write mount
2026-11-02 15:35 [PATCH v3] btrfs: zoned: reset leaked zones on read-write mount Mark Korenberg via B4 Relay
@ 2026-11-17 6:54 ` Mark Korenberg
2026-11-17 11:46 ` Johannes Thumshirn
1 sibling, 0 replies; 3+ messages in thread
From: Mark Korenberg @ 2026-11-17 6:54 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: David Sterba, Chris Mason, Naohiro Aota, linux-btrfs,
linux-kernel
On Mon, 02 Nov 2026 20:35:04 +0500, Mark Korenberg wrote:
> If a transaction commit is aborted after the zones of a new block group
> were written but before the superblock was, the chunk item and the dev
> extent are never persisted and the zones leak.
Hi Johannes,
a gentle ping on this one. It is the patch you handed over to me in the
RFC thread, could you have a look when you have time?
It still applies cleanly on top of today's for-next (146946479b45) and
builds there, no changes since v3. I can resend it rebased if that is
more convenient.
Thanks,
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] btrfs: zoned: reset leaked zones on read-write mount
2026-11-02 15:35 [PATCH v3] btrfs: zoned: reset leaked zones on read-write mount Mark Korenberg via B4 Relay
2026-11-17 6:54 ` Mark Korenberg
@ 2026-11-17 11:46 ` Johannes Thumshirn
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2026-11-17 11:46 UTC (permalink / raw)
To: socketpair
Cc: David Sterba, Chris Mason, Naohiro Aota, linux-btrfs,
linux-kernel
On Mon, Nov 02, 2026 at 08:35:04PM +0500, Mark Korenberg wrote:
> If a transaction commit is aborted after the zones of a new block group
> were written but before the superblock was, the chunk item and the dev
> extent are never persisted and the zones leak. The chunk allocator skips
> non-empty zones, so they are never reused, open ones keep counting
> against the active zone limit, and btrfs check reports them as
> unreferenced.
Sorry for the delay and thanks for picking this up.
Please mention that this needs btrfs-progs v7.3 or later, older versions
don't check for leaked zones.
[...]
> Testing: virtme-ng VM, zoned null_blk with 64 MiB zones,
> CONFIG_PROVE_LOCKING, this patch plus debug logging of every decision:
> - not zoned filesystem: nothing done
> - fresh filesystem: the first mount resets zone 3, which mkfs.btrfs
> (btrfs-progs 7.1) leaves written outside any chunk; nothing to do on
> the next mount, btrfs check clean
That one is fixed in btrfs-progs v7.3 by commit dcc41ad6 ("btrfs-progs:
zoned: refresh stale cached zone state in btrfs_reset_dev_zone()").
mkfs didn't reset the zone of a removed temporary chunk because the
cached zone state was stale.
[...]
> + /*
> + * Chunks are only removed under reclaim_bgs_lock, and their zones must
> + * not be reset before the removal is committed. A relocating repair,
> + * started by a read error during mount, may already have removed one in
> + * the running transaction, so commit it before looking for leaked zones.
> + */
> + mutex_lock(&fs_info->reclaim_bgs_lock);
> + ret = btrfs_commit_current_transaction(fs_info->tree_root);
On a filesystem without free active zones, this commit can be the one
that aborts with -EAGAIN, before the reset could free anything. In my
tests there was never a running transaction at this point, so it didn't
matter. Can you skip the commit when nothing is running, or add a
sentence to the changelog why it is safe here?
With that
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Btw, I tested v3 on top of for-next (146946479b45) and told Claude to write an
fstests [1] case for it (zloop with dm-flakey on top, power failure after direct
I/O to new zones). It fails on for-next and passes with your patch, I'll send
it to fstests once you've send a v4.
Thanks,
Johannes
[1]
diff --git a/tests/generic/815 b/tests/generic/815
new file mode 100755
index 00000000..f5969e1a
--- /dev/null
+++ b/tests/generic/815
@@ -0,0 +1,78 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Western Digital Corporation. All Rights Reserved.
+#
+# FS QA Test 815
+#
+# Simulate a power failure on a zoned device after data has been written to
+# newly allocated zones, but before the allocation itself was committed. The
+# zones written that way are not referenced by the filesystem. Check that the
+# filesystem is consistent after the next read-write mount, i.e. that it
+# doesn't leave these zones written and active.
+#
+. ./common/preamble
+_begin_fstest auto quick zone log
+
+_cleanup()
+{
+ cd /
+ [ -n "$mnt" ] && _unmount $mnt 2>/dev/null
+ [ -n "$flakey" ] && _cleanup_flakey_dev $flakey
+ _destroy_zloop $zloop
+ rm -r -f $tmp.*
+}
+
+. ./common/zoned
+. ./common/dmflakey
+
+_fixed_by_fs_commit btrfs XXXXXXXXXXXX \
+ "btrfs: zoned: reset leaked zones on read-write mount"
+
+_require_scratch_size $((4 * 1024 * 1024)) # kB
+_require_block_device $SCRATCH_DEV
+_require_zloop
+_require_dm_target flakey
+_require_command "$BLKZONE_PROG" blkzone
+
+_scratch_mkfs > /dev/null 2>&1
+_scratch_mount
+
+mnt=$SCRATCH_MNT/mnt
+mkdir -p $mnt
+zloop=$(_create_zloop $SCRATCH_MNT/zloop 64 4)
+
+flakey=zflakey-test.$seq
+_init_flakey_dev $flakey $zloop
+dev=/dev/mapper/$flakey
+
+_try_mkfs_dev $dev >> $seqres.full 2>&1 || \
+ _notrun "cannot mkfs zoned filesystem"
+_mount $dev $mnt
+sync
+
+# Direct I/O puts the data on the device right away, but the allocation of
+# the zones it went to is only persisted with the next commit.
+for i in $(seq 4); do
+ $XFS_IO_PROG -f -d -c "pwrite -q -b 1m 0 96m" $mnt/file$i >> $seqres.full 2>&1
+done
+
+echo "zones before power failure:" >> $seqres.full
+$BLKZONE_PROG report $zloop | grep -cvE "\((em|nw)\)" >> $seqres.full
+
+_load_flakey_dev $flakey $zloop $FLAKEY_DROP_WRITES
+_unmount $mnt
+_load_flakey_dev $flakey $zloop $FLAKEY_ALLOW_WRITES
+
+# The read-write mount is expected to clean up after the power failure.
+_mount $dev $mnt
+_unmount $mnt
+
+echo "zones after recovery:" >> $seqres.full
+$BLKZONE_PROG report $zloop | grep -cvE "\((em|nw)\)" >> $seqres.full
+
+_check_dev_fs $dev
+
+echo "Silence is golden"
+
+# success, all done
+_exit 0
diff --git a/tests/generic/815.out b/tests/generic/815.out
new file mode 100644
index 00000000..6ea462f3
--- /dev/null
+++ b/tests/generic/815.out
@@ -0,0 +1,2 @@
+QA output created by 815
+Silence is golden
diff --git a/common/dmflakey b/common/dmflakey
index 6ac666f5..9bba8958 100644
--- a/common/dmflakey
+++ b/common/dmflakey
@@ -12,6 +12,47 @@ export FLAKEY_NAME="flakey-test.$seq"
export FLAKEY_RTNAME="flakey-rttest.$seq"
export FLAKEY_LOGNAME="flakey-logtest.$seq"
+_flakey_table()
+{
+ local size=`blockdev --getsz $1`
+
+ case "$2" in
+ "$FLAKEY_DROP_WRITES")
+ echo "0 $size flakey $1 0 0 180 1 drop_writes"
+ ;;
+ "$FLAKEY_ERROR_WRITES")
+ echo "0 $size flakey $1 0 0 180 1 error_writes"
+ ;;
+ *)
+ echo "0 $size flakey $1 0 180 0"
+ ;;
+ esac
+}
+
+_init_flakey_dev()
+{
+ _dmsetup_create $1 --table "`_flakey_table $2`" || \
+ _fatal "failed to create flakey device $1"
+}
+
+_load_flakey_dev()
+{
+ local suspend_opt="--nolockfs"
+
+ [ $# -gt 3 ] && [ $4 -eq 1 ] && suspend_opt=""
+
+ $DMSETUP_PROG suspend $suspend_opt $1 || _fatal "failed to suspend $1"
+ _flakey_table $2 $3 | $DMSETUP_PROG load $1 || \
+ _fatal "failed to load table into $1"
+ $DMSETUP_PROG resume $1 || _fatal "failed to resume $1"
+}
+
+_cleanup_flakey_dev()
+{
+ $DMSETUP_PROG resume $1 &> /dev/null
+ _dmsetup_remove $1
+}
+
_init_flakey()
{
# Scratch device
@@ -24,12 +65,10 @@ _init_flakey()
# Already set up; recreate tables
local backing_dev="$NON_FLAKEY_DEV"
fi
- local BLK_DEV_SIZE=`blockdev --getsz $backing_dev`
- FLAKEY_TABLE="0 $BLK_DEV_SIZE flakey $backing_dev 0 180 0"
- FLAKEY_TABLE_DROP="0 $BLK_DEV_SIZE flakey $backing_dev 0 0 180 1 drop_writes"
- FLAKEY_TABLE_ERROR="0 $BLK_DEV_SIZE flakey $backing_dev 0 0 180 1 error_writes"
- _dmsetup_create $FLAKEY_NAME --table "$FLAKEY_TABLE" || \
- _fatal "failed to create flakey device"
+ FLAKEY_TABLE=`_flakey_table $backing_dev`
+ FLAKEY_TABLE_DROP=`_flakey_table $backing_dev $FLAKEY_DROP_WRITES`
+ FLAKEY_TABLE_ERROR=`_flakey_table $backing_dev $FLAKEY_ERROR_WRITES`
+ _init_flakey_dev $FLAKEY_NAME $backing_dev
# Realtime device
if [ -n "$SCRATCH_RTDEV" ]; then
@@ -42,12 +81,10 @@ _init_flakey()
# Already set up; recreate tables
local backing_dev="$NON_FLAKEY_RTDEV"
fi
- local BLK_DEV_SIZE=`blockdev --getsz $backing_dev`
- FLAKEY_RTTABLE="0 $BLK_DEV_SIZE flakey $backing_dev 0 180 0"
- FLAKEY_RTTABLE_DROP="0 $BLK_DEV_SIZE flakey $backing_dev 0 0 180 1 drop_writes"
- FLAKEY_RTTABLE_ERROR="0 $BLK_DEV_SIZE flakey $backing_dev 0 0 180 1 error_writes"
- _dmsetup_create $FLAKEY_RTNAME --table "$FLAKEY_RTTABLE" || \
- _fatal "failed to create flakey rt device"
+ FLAKEY_RTTABLE=`_flakey_table $backing_dev`
+ FLAKEY_RTTABLE_DROP=`_flakey_table $backing_dev $FLAKEY_DROP_WRITES`
+ FLAKEY_RTTABLE_ERROR=`_flakey_table $backing_dev $FLAKEY_ERROR_WRITES`
+ _init_flakey_dev $FLAKEY_RTNAME $backing_dev
fi
# External log device
@@ -61,12 +98,10 @@ _init_flakey()
# Already set up; recreate tables
local backing_dev="$NON_FLAKEY_LOGDEV"
fi
- local BLK_DEV_SIZE=`blockdev --getsz $backing_dev`
- FLAKEY_LOGTABLE="0 $BLK_DEV_SIZE flakey $backing_dev 0 180 0"
- FLAKEY_LOGTABLE_DROP="0 $BLK_DEV_SIZE flakey $backing_dev 0 0 180 1 drop_writes"
- FLAKEY_LOGTABLE_ERROR="0 $BLK_DEV_SIZE flakey $backing_dev 0 0 180 1 error_writes"
- _dmsetup_create $FLAKEY_LOGNAME --table "$FLAKEY_LOGTABLE" || \
- _fatal "failed to create flakey log device"
+ FLAKEY_LOGTABLE=`_flakey_table $backing_dev`
+ FLAKEY_LOGTABLE_DROP=`_flakey_table $backing_dev $FLAKEY_DROP_WRITES`
+ FLAKEY_LOGTABLE_ERROR=`_flakey_table $backing_dev $FLAKEY_ERROR_WRITES`
+ _init_flakey_dev $FLAKEY_LOGNAME $backing_dev
fi
}
@@ -80,9 +115,9 @@ _cleanup_flakey()
_unmount $SCRATCH_MNT > /dev/null 2>&1
- test -n "$NON_FLAKEY_DEV" && _dmsetup_remove $FLAKEY_NAME
- test -n "$NON_FLAKEY_LOGDEV" && _dmsetup_remove $FLAKEY_LOGNAME
- test -n "$NON_FLAKEY_RTDEV" && _dmsetup_remove $FLAKEY_RTNAME
+ test -n "$NON_FLAKEY_DEV" && _cleanup_flakey_dev $FLAKEY_NAME
+ test -n "$NON_FLAKEY_LOGDEV" && _cleanup_flakey_dev $FLAKEY_LOGNAME
+ test -n "$NON_FLAKEY_RTDEV" && _cleanup_flakey_dev $FLAKEY_RTNAME
SCRATCH_DEV="$NON_FLAKEY_DEV"
unset NON_FLAKEY_DEV
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-17 11:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02 15:35 [PATCH v3] btrfs: zoned: reset leaked zones on read-write mount Mark Korenberg via B4 Relay
2026-11-17 6:54 ` Mark Korenberg
2026-11-17 11:46 ` Johannes Thumshirn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox