From: Mike Snitzer Date: Tue, 8 Sep 2015 12:56:13 +0000 (-0400) Subject: dm thin: disable discard support for thin devices if pool's is disabled X-Git-Tag: v4.2.4~151 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bc3b652089213873a43960cb686d2a1bd7cddf4;p=thirdparty%2Fkernel%2Fstable.git dm thin: disable discard support for thin devices if pool's is disabled commit 216076705d6ac291d42e0f8dd85e6a0da98c0fa3 upstream. If the pool is configured with 'ignore_discard' its discard support is disabled. The pool's thin devices should also have queue_limits that reflect discards are disabled. Fixes: 34fbcf62 ("dm thin: range discard support") Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index d2bbe8cc1e978..75aef240c2d1a 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c @@ -4333,6 +4333,10 @@ static void thin_io_hints(struct dm_target *ti, struct queue_limits *limits) { struct thin_c *tc = ti->private; struct pool *pool = tc->pool; + struct queue_limits *pool_limits = dm_get_queue_limits(pool->pool_md); + + if (!pool_limits->discard_granularity) + return; /* pool's discard support is disabled */ limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT; limits->max_discard_sectors = 2048 * 1024 * 16; /* 16G */