Skip to content

Commit 8e0ef41

Browse files
Christoph Hellwigaxboe
authored andcommitted
dm: use queue_limits_set
Use queue_limits_set which validates the limits and takes care of updating the readahead settings instead of directly assigning them to the queue. For that make sure all limits are actually updated before the assignment. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Mike Snitzer <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent c1373f1 commit 8e0ef41

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

block/blk-settings.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ int queue_limits_commit_update(struct request_queue *q,
267267
EXPORT_SYMBOL_GPL(queue_limits_commit_update);
268268

269269
/**
270-
* queue_limits_commit_set - apply queue limits to queue
270+
* queue_limits_set - apply queue limits to queue
271271
* @q: queue to update
272272
* @lim: limits to apply
273273
*

drivers/md/dm-table.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,26 +1963,27 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
19631963
bool wc = false, fua = false;
19641964
int r;
19651965

1966-
/*
1967-
* Copy table's limits to the DM device's request_queue
1968-
*/
1969-
q->limits = *limits;
1970-
19711966
if (dm_table_supports_nowait(t))
19721967
blk_queue_flag_set(QUEUE_FLAG_NOWAIT, q);
19731968
else
19741969
blk_queue_flag_clear(QUEUE_FLAG_NOWAIT, q);
19751970

19761971
if (!dm_table_supports_discards(t)) {
1977-
q->limits.max_discard_sectors = 0;
1978-
q->limits.max_hw_discard_sectors = 0;
1979-
q->limits.discard_granularity = 0;
1980-
q->limits.discard_alignment = 0;
1981-
q->limits.discard_misaligned = 0;
1972+
limits->max_hw_discard_sectors = 0;
1973+
limits->discard_granularity = 0;
1974+
limits->discard_alignment = 0;
1975+
limits->discard_misaligned = 0;
19821976
}
19831977

1978+
if (!dm_table_supports_write_zeroes(t))
1979+
limits->max_write_zeroes_sectors = 0;
1980+
19841981
if (!dm_table_supports_secure_erase(t))
1985-
q->limits.max_secure_erase_sectors = 0;
1982+
limits->max_secure_erase_sectors = 0;
1983+
1984+
r = queue_limits_set(q, limits);
1985+
if (r)
1986+
return r;
19861987

19871988
if (dm_table_supports_flush(t, (1UL << QUEUE_FLAG_WC))) {
19881989
wc = true;
@@ -2007,9 +2008,6 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
20072008
else
20082009
blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
20092010

2010-
if (!dm_table_supports_write_zeroes(t))
2011-
q->limits.max_write_zeroes_sectors = 0;
2012-
20132011
dm_table_verify_integrity(t);
20142012

20152013
/*
@@ -2047,7 +2045,6 @@ int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
20472045
}
20482046

20492047
dm_update_crypto_profile(q, t);
2050-
disk_update_readahead(t->md->disk);
20512048

20522049
/*
20532050
* Check for request-based device is left to

0 commit comments

Comments
 (0)