Skip to content

Commit 0fcb04d

Browse files
committed
dm thin: fix regression in advertised discard limits
When establishing a thin device's discard limits we cannot rely on the underlying thin-pool device's discard capabilities (which are inherited from the thin-pool's underlying data device) given that DM thin devices must provide discard support even when the thin-pool's underlying data device doesn't support discards. Users were exposed to this thin device discard limits regression if their thin-pool's underlying data device does _not_ support discards. This regression caused all upper-layers that called the blkdev_issue_discard() interface to not be able to issue discards to thin devices (because discard_granularity was 0). This regression wasn't caught earlier because the device-mapper-test-suite's extensive 'thin-provisioning' discard tests are only ever performed against thin-pool's with data devices that support discards. Fix is to have thin_io_hints() test the pool's 'discard_enabled' feature rather than inferring whether or not a thin device's discard support should be enabled by looking at the thin-pool's discard_granularity. Fixes: 2160767 ("dm thin: disable discard support for thin devices if pool's is disabled") Reported-by: Mike Gerber <mike@sprachgewalt.de> Signed-off-by: Mike Snitzer <snitzer@redhat.com> Cc: stable@vger.kernel.org # 4.1+
1 parent bcbd94f commit 0fcb04d

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

drivers/md/dm-thin.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4250,10 +4250,9 @@ static void thin_io_hints(struct dm_target *ti, struct queue_limits *limits)
42504250
{
42514251
struct thin_c *tc = ti->private;
42524252
struct pool *pool = tc->pool;
4253-
struct queue_limits *pool_limits = dm_get_queue_limits(pool->pool_md);
42544253

4255-
if (!pool_limits->discard_granularity)
4256-
return; /* pool's discard support is disabled */
4254+
if (!pool->pf.discard_enabled)
4255+
return;
42574256

42584257
limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT;
42594258
limits->max_discard_sectors = 2048 * 1024 * 16; /* 16G */

0 commit comments

Comments
 (0)