Skip to content

Commit fa37564

Browse files
author
Mike Snitzer
committed
dm thin: disable discards for thin-pool if no_discard_passdown
Also rename disable_passdown_if_not_supported to disable_discard_passdown_if_not_supported. And fold passdown_enabled() into only caller. Signed-off-by: Mike Snitzer <[email protected]>
1 parent 862c666 commit fa37564

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

drivers/md/dm-thin.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,16 +2528,11 @@ static void noflush_work(struct thin_c *tc, void (*fn)(struct work_struct *))
25282528

25292529
/*----------------------------------------------------------------*/
25302530

2531-
static bool passdown_enabled(struct pool_c *pt)
2532-
{
2533-
return pt->adjusted_pf.discard_passdown;
2534-
}
2535-
25362531
static void set_discard_callbacks(struct pool *pool)
25372532
{
25382533
struct pool_c *pt = pool->ti->private;
25392534

2540-
if (passdown_enabled(pt)) {
2535+
if (pt->adjusted_pf.discard_passdown) {
25412536
pool->process_discard_cell = process_discard_cell_passdown;
25422537
pool->process_prepared_discard = process_prepared_discard_passdown_pt1;
25432538
pool->process_prepared_discard_pt2 = process_prepared_discard_passdown_pt2;
@@ -2846,7 +2841,7 @@ static bool is_factor(sector_t block_size, uint32_t n)
28462841
* If discard_passdown was enabled verify that the data device
28472842
* supports discards. Disable discard_passdown if not.
28482843
*/
2849-
static void disable_passdown_if_not_supported(struct pool_c *pt)
2844+
static void disable_discard_passdown_if_not_supported(struct pool_c *pt)
28502845
{
28512846
struct pool *pool = pt->pool;
28522847
struct block_device *data_bdev = pt->data_dev->bdev;
@@ -4100,7 +4095,9 @@ static void pool_io_hints(struct dm_target *ti, struct queue_limits *limits)
41004095
*/
41014096

41024097
if (pt->adjusted_pf.discard_enabled) {
4103-
disable_passdown_if_not_supported(pt);
4098+
disable_discard_passdown_if_not_supported(pt);
4099+
if (!pt->adjusted_pf.discard_passdown)
4100+
limits->max_discard_sectors = 0;
41044101
/*
41054102
* The pool uses the same discard limits as the underlying data
41064103
* device. DM core has already set this up.

0 commit comments

Comments
 (0)