Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm: make dm_set_zones_restrictions work on the queue limits

Don't stuff the values directly into the queue without any
synchronization, but instead delay applying the queue limits in
the caller and let dm_set_zones_restrictions work on the limit
structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://lore.kernel.org/r/20240527123634.1116952-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
c8c1f701 5e7a4bbc

+14 -12
+6 -6
drivers/md/dm-table.c
··· 1981 1981 if (!dm_table_supports_secure_erase(t)) 1982 1982 limits->max_secure_erase_sectors = 0; 1983 1983 1984 - r = queue_limits_set(q, limits); 1985 - if (r) 1986 - return r; 1987 - 1988 1984 if (dm_table_supports_flush(t, (1UL << QUEUE_FLAG_WC))) { 1989 1985 wc = true; 1990 1986 if (dm_table_supports_flush(t, (1UL << QUEUE_FLAG_FUA))) ··· 2032 2036 * For a zoned target, setup the zones related queue attributes 2033 2037 * and resources necessary for zone append emulation if necessary. 2034 2038 */ 2035 - if (blk_queue_is_zoned(q)) { 2036 - r = dm_set_zones_restrictions(t, q); 2039 + if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) && limits->zoned) { 2040 + r = dm_set_zones_restrictions(t, q, limits); 2037 2041 if (r) 2038 2042 return r; 2039 2043 } 2044 + 2045 + r = queue_limits_set(q, limits); 2046 + if (r) 2047 + return r; 2040 2048 2041 2049 dm_update_crypto_profile(q, t); 2042 2050
+6 -5
drivers/md/dm-zone.c
··· 220 220 return true; 221 221 } 222 222 223 - int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q) 223 + int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q, 224 + struct queue_limits *lim) 224 225 { 225 226 struct mapped_device *md = t->md; 226 227 struct gendisk *disk = md->disk; ··· 237 236 clear_bit(DMF_EMULATE_ZONE_APPEND, &md->flags); 238 237 } else { 239 238 set_bit(DMF_EMULATE_ZONE_APPEND, &md->flags); 240 - blk_queue_max_zone_append_sectors(q, 0); 239 + lim->max_zone_append_sectors = 0; 241 240 } 242 241 243 242 if (!get_capacity(md->disk)) ··· 261 260 * a regular device. 262 261 */ 263 262 if (nr_conv_zones >= ret) { 264 - disk->queue->limits.max_open_zones = 0; 265 - disk->queue->limits.max_active_zones = 0; 266 - disk->queue->limits.zoned = false; 263 + lim->max_open_zones = 0; 264 + lim->max_active_zones = 0; 265 + lim->zoned = false; 267 266 clear_bit(DMF_EMULATE_ZONE_APPEND, &md->flags); 268 267 disk->nr_zones = 0; 269 268 return 0;
+2 -1
drivers/md/dm.h
··· 101 101 /* 102 102 * Zoned targets related functions. 103 103 */ 104 - int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q); 104 + int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q, 105 + struct queue_limits *lim); 105 106 void dm_zone_endio(struct dm_io *io, struct bio *clone); 106 107 #ifdef CONFIG_BLK_DEV_ZONED 107 108 int dm_blk_report_zones(struct gendisk *disk, sector_t sector,