On Fri, 11 Apr 2025, Damien Le Moal wrote:
> On 4/11/25 04:49, Benjamin Marzinski wrote:
> > There were multiple places in dm's __bind() function where it could fail
> > and not completely roll back, leaving the device using the the old
> > table, but with device limits and resources from the new table.
> > Additionally, unused mempools for request-based devices were not always
> > freed immediately.
> >
> > Also, there were a number of issues with switching zoned tables that
> > emulate zone append (in other words, dm-crypt on top of zoned devices).
> > dm_blk_report_zones() could be called while the device was initially
> > setting up a zoned table and creating zoned resources or could possibly
> > fail to end a srcu read section. More importantly,
> > blk_revalidate_disk_zones() would never get called when updating a zoned
> > table. This could cause the dm device to see the wrong zone write
> > offsets, not have a large enough zwplugs reserved in its mempool, or
> > read invalid memory when checking the conventional zones bitmap.
> >
> > Finally, any DM device created on top of a device emulating zone appeads
> > will automatically have zone write plug resources created for it, since
> > max_hw_zone_append_sectors will always be 0 for a device stacked on top
> > of a device max_hw_zone_append_sectors = 0
> >
> > This patchset fixes these issues. It deals with the problems around
> > blk_revalidate_disk_zones() by only calling it for devices that have no
> > zone write plug resources. This will always correctly update the zoned
> > settings. If a device has zone write plug resources, calling
> > blk_revalidate_disk_zones() will not correctly update them in many
> > cases, so DM simply doesn't call it for devices with zone write plug
> > resources. Instead of allowing people to load tables that can break the
> > device, like currently happens, DM disallosw any table reloads that
> > change the zoned setting for devices that already have zone write plug
> > resources. Finally, it deals with the max_hw_zone_append_sectors issue
> > by making sure that it is non-zero for zoned DM devices that do not need
> > zone write append emulation.
> >
> > Changes in V4:
> > - Fixed typos in 2 commit messages (patches 4 and 5)
> > - rephrased comment in dm_revalidate_zones() (patch 5)
>
> I gave this a quick spin and did not detect any issues.
> So feel free to add:
>
> Tested-by: Damien Le Moal <dlem...@kernel.org>
>
> --
> Damien Le Moal
> Western Digital Research
Thanks.
I staged the patches for the next merge window.
Mikulas