Skip to content

Commit c8c1f70

Browse files
Christoph Hellwigaxboe
authored andcommitted
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 <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 5e7a4bb commit c8c1f70

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

drivers/md/dm-table.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,10 +1981,6 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
19811981
if (!dm_table_supports_secure_erase(t))
19821982
limits->max_secure_erase_sectors = 0;
19831983

1984-
r = queue_limits_set(q, limits);
1985-
if (r)
1986-
return r;
1987-
19881984
if (dm_table_supports_flush(t, (1UL << QUEUE_FLAG_WC))) {
19891985
wc = true;
19901986
if (dm_table_supports_flush(t, (1UL << QUEUE_FLAG_FUA)))
@@ -2036,12 +2032,16 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
20362032
* For a zoned target, setup the zones related queue attributes
20372033
* and resources necessary for zone append emulation if necessary.
20382034
*/
2039-
if (blk_queue_is_zoned(q)) {
2040-
r = dm_set_zones_restrictions(t, q);
2035+
if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) && limits->zoned) {
2036+
r = dm_set_zones_restrictions(t, q, limits);
20412037
if (r)
20422038
return r;
20432039
}
20442040

2041+
r = queue_limits_set(q, limits);
2042+
if (r)
2043+
return r;
2044+
20452045
dm_update_crypto_profile(q, t);
20462046

20472047
/*

drivers/md/dm-zone.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ static bool dm_table_supports_zone_append(struct dm_table *t)
220220
return true;
221221
}
222222

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)
224225
{
225226
struct mapped_device *md = t->md;
226227
struct gendisk *disk = md->disk;
@@ -236,7 +237,7 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q)
236237
clear_bit(DMF_EMULATE_ZONE_APPEND, &md->flags);
237238
} else {
238239
set_bit(DMF_EMULATE_ZONE_APPEND, &md->flags);
239-
blk_queue_max_zone_append_sectors(q, 0);
240+
lim->max_zone_append_sectors = 0;
240241
}
241242

242243
if (!get_capacity(md->disk))
@@ -260,9 +261,9 @@ int dm_set_zones_restrictions(struct dm_table *t, struct request_queue *q)
260261
* a regular device.
261262
*/
262263
if (nr_conv_zones >= ret) {
263-
disk->queue->limits.max_open_zones = 0;
264-
disk->queue->limits.max_active_zones = 0;
265-
disk->queue->limits.zoned = false;
264+
lim->max_open_zones = 0;
265+
lim->max_active_zones = 0;
266+
lim->zoned = false;
266267
clear_bit(DMF_EMULATE_ZONE_APPEND, &md->flags);
267268
disk->nr_zones = 0;
268269
return 0;

drivers/md/dm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ int dm_setup_md_queue(struct mapped_device *md, struct dm_table *t);
101101
/*
102102
* Zoned targets related functions.
103103
*/
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);
105106
void dm_zone_endio(struct dm_io *io, struct bio *clone);
106107
#ifdef CONFIG_BLK_DEV_ZONED
107108
int dm_blk_report_zones(struct gendisk *disk, sector_t sector,

0 commit comments

Comments
 (0)