Commit b60ab990ccdf34b0159bf5ff52f4acee7c940d78
1 parent
f84cb8a46a
Exists in
master
and in
20 other branches
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>
Showing 1 changed file with 11 additions and 3 deletions Side-by-side Diff
drivers/md/dm-thin.c
... | ... | @@ -2095,6 +2095,7 @@ |
2095 | 2095 | * them down to the data device. The thin device's discard |
2096 | 2096 | * processing will cause mappings to be removed from the btree. |
2097 | 2097 | */ |
2098 | + ti->discard_zeroes_data_unsupported = true; | |
2098 | 2099 | if (pf.discard_enabled && pf.discard_passdown) { |
2099 | 2100 | ti->num_discard_bios = 1; |
2100 | 2101 | |
... | ... | @@ -2104,7 +2105,6 @@ |
2104 | 2105 | * thin devices' discard limits consistent). |
2105 | 2106 | */ |
2106 | 2107 | ti->discards_supported = true; |
2107 | - ti->discard_zeroes_data_unsupported = true; | |
2108 | 2108 | } |
2109 | 2109 | ti->private = pt; |
2110 | 2110 | |
2111 | 2111 | |
... | ... | @@ -2689,8 +2689,16 @@ |
2689 | 2689 | * They get transferred to the live pool in bind_control_target() |
2690 | 2690 | * called from pool_preresume(). |
2691 | 2691 | */ |
2692 | - if (!pt->adjusted_pf.discard_enabled) | |
2692 | + if (!pt->adjusted_pf.discard_enabled) { | |
2693 | + /* | |
2694 | + * Must explicitly disallow stacking discard limits otherwise the | |
2695 | + * block layer will stack them if pool's data device has support. | |
2696 | + * QUEUE_FLAG_DISCARD wouldn't be set but there is no way for the | |
2697 | + * user to see that, so make sure to set all discard limits to 0. | |
2698 | + */ | |
2699 | + limits->discard_granularity = 0; | |
2693 | 2700 | return; |
2701 | + } | |
2694 | 2702 | |
2695 | 2703 | disable_passdown_if_not_supported(pt); |
2696 | 2704 | |
2697 | 2705 | |
... | ... | @@ -2826,10 +2834,10 @@ |
2826 | 2834 | ti->per_bio_data_size = sizeof(struct dm_thin_endio_hook); |
2827 | 2835 | |
2828 | 2836 | /* In case the pool supports discards, pass them on. */ |
2837 | + ti->discard_zeroes_data_unsupported = true; | |
2829 | 2838 | if (tc->pool->pf.discard_enabled) { |
2830 | 2839 | ti->discards_supported = true; |
2831 | 2840 | ti->num_discard_bios = 1; |
2832 | - ti->discard_zeroes_data_unsupported = true; | |
2833 | 2841 | /* Discard bios must be split on a block boundary */ |
2834 | 2842 | ti->split_discard_bios = true; |
2835 | 2843 | } |