* [PATCH 1/2] btrfs: zoned: fix zone activation with missing devices
2025-03-17 11:24 [PATCH 0/2] btrfs: zoned: fix zone management on degraded filesystems Johannes Thumshirn
@ 2025-03-17 11:24 ` Johannes Thumshirn
2025-03-17 11:24 ` [PATCH 2/2] btrfs: zoned: fix zone finishing " Johannes Thumshirn
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Johannes Thumshirn @ 2025-03-17 11:24 UTC (permalink / raw)
To: linux-btrfs
Cc: Naohiro Aota, Damien Le Moal, Josef Bacik, David Sterba,
Johannes Thumshirn
From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
If btrfs_zone_activate() is called with a filesystem that has missing
devices (e.g. a RAID file system mounted in degraded mode) it is accessing
the btrfs_device::zone_info pointer, which will not be set if the device in
question is missing.
Check if the device is present (by checking if it has a valid block
device pointer associated) and if not, skip zone activation for it.
Fixes: f9a912a3c45f ("btrfs: zoned: make zone activation multi stripe capable")
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
fs/btrfs/zoned.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index c21a97b32f9a..8924f58919e8 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -2110,6 +2110,9 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group)
physical = map->stripes[i].physical;
zinfo = device->zone_info;
+ if (!device->bdev)
+ continue;
+
if (zinfo->max_active_zones == 0)
continue;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] btrfs: zoned: fix zone finishing with missing devices
2025-03-17 11:24 [PATCH 0/2] btrfs: zoned: fix zone management on degraded filesystems Johannes Thumshirn
2025-03-17 11:24 ` [PATCH 1/2] btrfs: zoned: fix zone activation with missing devices Johannes Thumshirn
@ 2025-03-17 11:24 ` Johannes Thumshirn
2025-03-18 1:27 ` [PATCH 0/2] btrfs: zoned: fix zone management on degraded filesystems Naohiro Aota
2025-03-18 10:10 ` Anand Jain
3 siblings, 0 replies; 5+ messages in thread
From: Johannes Thumshirn @ 2025-03-17 11:24 UTC (permalink / raw)
To: linux-btrfs
Cc: Naohiro Aota, Damien Le Moal, Josef Bacik, David Sterba,
Johannes Thumshirn
From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
If do_zone_finish() is called with a filesystem that has missing devices
(e.g. a RAID file system mounted in degraded mode) it is accessing the
btrfs_device::zone_info pointer, which will not be set if the device
in question is missing.
Check if the device is present (by checking if it has a valid block device
pointer associated) and if not, skip zone finishing for it.
Fixes: 4dcbb8ab31c1 ("btrfs: zoned: make zone finishing multi stripe capable")
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
fs/btrfs/zoned.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index 8924f58919e8..7c502192cd6b 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -2274,6 +2274,9 @@ static int do_zone_finish(struct btrfs_block_group *block_group, bool fully_writ
struct btrfs_zoned_device_info *zinfo = device->zone_info;
unsigned int nofs_flags;
+ if (!device->bdev)
+ continue;
+
if (zinfo->max_active_zones == 0)
continue;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 0/2] btrfs: zoned: fix zone management on degraded filesystems
2025-03-17 11:24 [PATCH 0/2] btrfs: zoned: fix zone management on degraded filesystems Johannes Thumshirn
2025-03-17 11:24 ` [PATCH 1/2] btrfs: zoned: fix zone activation with missing devices Johannes Thumshirn
2025-03-17 11:24 ` [PATCH 2/2] btrfs: zoned: fix zone finishing " Johannes Thumshirn
@ 2025-03-18 1:27 ` Naohiro Aota
2025-03-18 10:10 ` Anand Jain
3 siblings, 0 replies; 5+ messages in thread
From: Naohiro Aota @ 2025-03-18 1:27 UTC (permalink / raw)
To: Johannes Thumshirn, linux-btrfs@vger.kernel.org
Cc: Naohiro Aota, Damien Le Moal, Josef Bacik, David Sterba
On Mon Mar 17, 2025 at 8:24 PM JST, Johannes Thumshirn wrote:
> Two fixes around ZONE FINISH and ZONE ACTIVATE for multi device filesystems in
> degraded mode.
>
> Both times we're dereferencing the btrfs_device::zone_info pointer without
> prior checking if the device is present.
At first, I thought, we should not write into a block group containing a
missing device. But, yeah, in the degraded mode, we are allowed to make
un-synced writing.
So, for the series
Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
>
> Johannes Thumshirn (2):
> btrfs: zoned: fix zone activation with missing devices
> btrfs: zoned: fix zone finishing with missing devices
>
> fs/btrfs/zoned.c | 6 ++++++
> 1 file changed, 6 insertions(+)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] btrfs: zoned: fix zone management on degraded filesystems
2025-03-17 11:24 [PATCH 0/2] btrfs: zoned: fix zone management on degraded filesystems Johannes Thumshirn
` (2 preceding siblings ...)
2025-03-18 1:27 ` [PATCH 0/2] btrfs: zoned: fix zone management on degraded filesystems Naohiro Aota
@ 2025-03-18 10:10 ` Anand Jain
3 siblings, 0 replies; 5+ messages in thread
From: Anand Jain @ 2025-03-18 10:10 UTC (permalink / raw)
To: Johannes Thumshirn, linux-btrfs
Cc: Naohiro Aota, Damien Le Moal, Josef Bacik, David Sterba
On 17/3/25 19:24, Johannes Thumshirn wrote:
> Two fixes around ZONE FINISH and ZONE ACTIVATE for multi device filesystems in
> degraded mode.
>
> Both times we're dereferencing the btrfs_device::zone_info pointer without
> prior checking if the device is present.
>
> Johannes Thumshirn (2):
> btrfs: zoned: fix zone activation with missing devices
> btrfs: zoned: fix zone finishing with missing devices
>
> fs/btrfs/zoned.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
Looks good for now.
Reviewed-by: Anand Jain <anand.jain@oracle.com>
PS:
We have been using either of these methods to identify the
missing device.
test_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state)
or
device->bdev == NULL
IMO, it's a good idea to consolidate to the BTRFS_DEV_STATE_MISSING
flag. I have some incomplete patches for that. Also, I think we
should discuss how to handle reappearing devices;
Thanks, Anand
^ permalink raw reply [flat|nested] 5+ messages in thread