On Fri, Apr 05 2024 at 12:41P -0400, Damien Le Moal <dlemoal@xxxxxxxxxx> wrote: > For targets requiring zone append operation emulation with regular > writes (e.g. dm-crypt), we can use the block layer emulation provided by > zone write plugging. Remove DM implemented zone append emulation and > enable the block layer one. > > This is done by setting the max_zone_append_sectors limit of the > mapped device queue to 0 for mapped devices that have a target table > that cannot support native zone append operations (e.g. dm-crypt). > Such mapped devices are flagged with the DMF_EMULATE_ZONE_APPEND flag. > dm_split_and_process_bio() is modified to execute > blk_zone_write_plug_bio() for such device to let the block layer > transform zone append operations into regular writes. This is done > after ensuring that the submitted BIO is split if it straddles zone > boundaries. Both changes are implemented unsing the inline helpers > dm_zone_write_plug_bio() and dm_zone_bio_needs_split() respectively. > > dm_revalidate_zones() is also modified to use the block layer provided > function blk_revalidate_disk_zones() so that all zone resources needed > for zone append emulation are initialized by the block layer without DM > core needing to do anything. Since the device table is not yet live when > dm_revalidate_zones() is executed, enabling the use of > blk_revalidate_disk_zones() requires adding a pointer to the device > table in struct mapped_device. This avoids errors in > dm_blk_report_zones() trying to get the table with dm_get_live_table(). > The mapped device table pointer is set to the table passed as argument > to dm_revalidate_zones() before calling blk_revalidate_disk_zones() and > reset to NULL after this function returns to restore the live table > handling for user call of report zones. > > All the code related to zone append emulation is removed from > dm-zone.c. This leads to simplifications of the functions __map_bio() > and dm_zone_endio(). This later function now only needs to deal with > completions of real zone append operations for targets that support it. > > Signed-off-by: Damien Le Moal <dlemoal@xxxxxxxxxx> > Reviewed-by: Mike Snitzer <snitzer@xxxxxxxxxx> > Reviewed-by: Hannes Reinecke <hare@xxxxxxx> > Tested-by: Hans Holmberg <hans.holmberg@xxxxxxx> > --- > drivers/md/dm-core.h | 2 +- > drivers/md/dm-zone.c | 476 ++++--------------------------------------- > drivers/md/dm.c | 72 ++++--- > drivers/md/dm.h | 4 +- > 4 files changed, 94 insertions(+), 460 deletions(-) > > diff --git a/drivers/md/dm-zone.c b/drivers/md/dm-zone.c > index eb9832b22b14..174fda0a301c 100644 > --- a/drivers/md/dm-zone.c > +++ b/drivers/md/dm-zone.c > @@ -226,41 +154,32 @@ static int dm_zone_revalidate_cb(struct blk_zone *zone, unsigned int idx, > static int dm_revalidate_zones(struct mapped_device *md, struct dm_table *t) > { > struct gendisk *disk = md->disk; > - unsigned int noio_flag; > int ret; > > - /* > - * Check if something changed. If yes, cleanup the current resources > - * and reallocate everything. > - */ > + /* Revalidate ionly if something changed. */ Just noticed this ionly typo ^ Please fix. Thanks, Mike