mirror of
https://github.com/fail0verflow/switch-linux.git
synced 2025-05-04 02:34:21 -04:00
dm thin: do not expose non-zero discard limits if discards disabled
Fix issue where the block layer would stack the discard limits of the pool's data device even if the "ignore_discard" pool feature was specified. The pool and thin device(s) still had discards disabled because the QUEUE_FLAG_DISCARD request_queue flag wasn't set. But to avoid user confusion when "ignore_discard" is used: both the pool device and the thin device(s) have zeroes for all discard limits. Also, always set discard_zeroes_data_unsupported in targets because they should never advertise the 'discard_zeroes_data' capability (even if the pool's data device supports it). Signed-off-by: Mike Snitzer <snitzer@redhat.com> Acked-by: Joe Thornber <ejt@redhat.com>
This commit is contained in:
parent
f84cb8a46a
commit
b60ab990cc
1 changed files with 11 additions and 3 deletions
|
@ -2095,6 +2095,7 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv)
|
||||||
* them down to the data device. The thin device's discard
|
* them down to the data device. The thin device's discard
|
||||||
* processing will cause mappings to be removed from the btree.
|
* processing will cause mappings to be removed from the btree.
|
||||||
*/
|
*/
|
||||||
|
ti->discard_zeroes_data_unsupported = true;
|
||||||
if (pf.discard_enabled && pf.discard_passdown) {
|
if (pf.discard_enabled && pf.discard_passdown) {
|
||||||
ti->num_discard_bios = 1;
|
ti->num_discard_bios = 1;
|
||||||
|
|
||||||
|
@ -2104,7 +2105,6 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv)
|
||||||
* thin devices' discard limits consistent).
|
* thin devices' discard limits consistent).
|
||||||
*/
|
*/
|
||||||
ti->discards_supported = true;
|
ti->discards_supported = true;
|
||||||
ti->discard_zeroes_data_unsupported = true;
|
|
||||||
}
|
}
|
||||||
ti->private = pt;
|
ti->private = pt;
|
||||||
|
|
||||||
|
@ -2689,8 +2689,16 @@ static void pool_io_hints(struct dm_target *ti, struct queue_limits *limits)
|
||||||
* They get transferred to the live pool in bind_control_target()
|
* They get transferred to the live pool in bind_control_target()
|
||||||
* called from pool_preresume().
|
* called from pool_preresume().
|
||||||
*/
|
*/
|
||||||
if (!pt->adjusted_pf.discard_enabled)
|
if (!pt->adjusted_pf.discard_enabled) {
|
||||||
|
/*
|
||||||
|
* Must explicitly disallow stacking discard limits otherwise the
|
||||||
|
* block layer will stack them if pool's data device has support.
|
||||||
|
* QUEUE_FLAG_DISCARD wouldn't be set but there is no way for the
|
||||||
|
* user to see that, so make sure to set all discard limits to 0.
|
||||||
|
*/
|
||||||
|
limits->discard_granularity = 0;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
disable_passdown_if_not_supported(pt);
|
disable_passdown_if_not_supported(pt);
|
||||||
|
|
||||||
|
@ -2826,10 +2834,10 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
|
||||||
ti->per_bio_data_size = sizeof(struct dm_thin_endio_hook);
|
ti->per_bio_data_size = sizeof(struct dm_thin_endio_hook);
|
||||||
|
|
||||||
/* In case the pool supports discards, pass them on. */
|
/* In case the pool supports discards, pass them on. */
|
||||||
|
ti->discard_zeroes_data_unsupported = true;
|
||||||
if (tc->pool->pf.discard_enabled) {
|
if (tc->pool->pf.discard_enabled) {
|
||||||
ti->discards_supported = true;
|
ti->discards_supported = true;
|
||||||
ti->num_discard_bios = 1;
|
ti->num_discard_bios = 1;
|
||||||
ti->discard_zeroes_data_unsupported = true;
|
|
||||||
/* Discard bios must be split on a block boundary */
|
/* Discard bios must be split on a block boundary */
|
||||||
ti->split_discard_bios = true;
|
ti->split_discard_bios = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue