On 3/11/25 02:43, Benjamin Marzinski wrote: > On Mon, Mar 10, 2025 at 08:59:26AM +0900, Damien Le Moal wrote: >> On 3/10/25 07:29, Benjamin Marzinski wrote: >>> dm_revalidate_zones() only allowed devices that had no zone resources >>> set up to call blk_revalidate_disk_zones(). If the device already had >>> zone resources, disk->nr_zones would always equal md->nr_zones so >>> dm_revalidate_zones() returned without doing any work. Instead, always >>> call blk_revalidate_disk_zones() if you are loading a new zoned table. >>> >>> However, if the device emulates zone append operations and already has >>> zone append emulation resources, the table size cannot change when >>> loading a new table. Otherwise, all those resources will be garbage. >>> >>> If emulated zone append operations are needed and the zone write pointer >>> offsets of the new table do not match those of the old table, writes to >>> the device will still fail. This patch allows users to safely grow and >>> shrink zone devices. But swapping arbitrary zoned tables will still not >>> work. >> >> I do not think that this patch correctly address the shrinking of dm zoned >> device: blk_revalidate_disk_zones() will look at a smaller set of zones, which >> will leave already hashed zone write plugs outside of that new zone range in the >> disk zwplug hash table. disk_revalidate_zone_resources() does not cleanup and >> reallocate the hash table if the number of zones shrinks. > > This is necessary for DM. There could be plugged bios that are on on > these no longer in-range zones. They will obviously fail when they get > reissued, but we need to keep the plugs around so that they *do* get > reissued. A cleaner alternative would be to add code to immediately > error out all the plugged bios on shrinks, but I was trying to avoid > adding a bunch of code to deal with these cases (of course simply > disallowing them adds even less code). I am confused now :) Under the assumption that we do not allow switching to a new table that changes the zone configuration (in particualr, there is no grow/shrink of the device), then I do not think we have to do anything special for DM. -- Damien Le Moal Western Digital Research