Re: [PATCH 2/3] dm zoned: check the metadata zones before recovering a metadata set

From: Yingjie Wang

Date: Thu Dec 03 2026 - 04:03:38 EST


Hi Hannes,

On 12/3/26 09:01, Hannes Reinecke wrote:
> But now the second iteration looks odd. Surely dmz_get() can fail here,
> no? But can't we move the 'set_bit' call in the first iteration?

I don't think dmz_get() can fail there: it walks the same zones as the
new loop in dmz_check_sb(). zmd->nr_meta_zones is only set at the end
of a successful dmz_check_sb() of the primary or secondary superblock,
and zmd->sb[0].zone doesn't change after the zones are initialized.
dmz_load_sb() fails unless one of these two superblocks passed, and the
tertiary superblocks return from dmz_check_sb() before the loop without
setting nr_meta_zones.

I didn't move set_bit() into dmz_check_sb() because a superblock can
still be rejected after that loop, and the two superblocks can describe
different numbers of metadata zones. For example, if the primary
superblock fails the nr_reserved_seq check and describes more metadata
zones than the secondary one, set 0 is recovered from set 1, and the
zones that only the primary counted would stay marked as metadata. So
the zones are only marked once dmz_load_sb() has succeeded.

I can add a comment to the second loop in a follow-up if you like.

Thanks,
Yingjie