Re: [PATCH 1/3] dm zoned: do not update metadata state from an invalid superblock
From: Damien Le Moal
Date: Wed Dec 02 2026 - 01:41:56 EST
On 12/1/26 19:56, Yingjie Wang wrote:
> dmz_check_sb() stores the version, UUIDs and label of a superblock
> before it has finished validating it. If the superblock is then
> rejected, zmd and the device are left with the values it contained.
>
> If the secondary superblock is invalid, it is recovered from the primary
> one using these values, and the next metadata flush writes them to the
> primary superblock, too. For example:
>
> - If the secondary superblock has a bad checksum and a version of 1,
> both superblocks become version 1, and the tertiary superblocks are
> not checked anymore.
>
> - If it has no device UUID, the device UUID is cleared in both
> superblocks. Both are invalid then, and the table cannot be loaded
> anymore.
>
> Conversely, if the primary superblock is rejected after its UUID and
> label were stored, a valid secondary superblock is rejected, too, if
> these are different, and the volume is not recovered.
>
> Use local variables during validation and only update zmd and the
> device once the superblock is known to be valid.
>
> Fixes: bd5c40313a14 ("dm zoned: metadata version 2")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Yingjie Wang <x-professor@xxxxxxxxxxx>
Looks good.
Reviewed-by: Damien Le Moal <dlemoal@xxxxxxxxxx>
--
Damien Le Moal
Western Digital Research