Skip to content

Commit ef6953f

Browse files
author
Mike Snitzer
committed
dm thin: update .io_hints methods to not require handling discards last
Removes assumptions about what might follow the discard setup code (previously the code would return early if discards not enabled). Makes it possible to add more capabilites to the end of each .io_hints method (which is the natural thing to do when adding new features). Signed-off-by: Mike Snitzer <[email protected]>
1 parent c0a7a0a commit ef6953f

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

drivers/md/dm-thin.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4098,21 +4098,20 @@ static void pool_io_hints(struct dm_target *ti, struct queue_limits *limits)
40984098
* They get transferred to the live pool in bind_control_target()
40994099
* called from pool_preresume().
41004100
*/
4101-
if (!pt->adjusted_pf.discard_enabled) {
4101+
4102+
if (pt->adjusted_pf.discard_enabled) {
4103+
disable_passdown_if_not_supported(pt);
4104+
/*
4105+
* The pool uses the same discard limits as the underlying data
4106+
* device. DM core has already set this up.
4107+
*/
4108+
} else {
41024109
/*
41034110
* Must explicitly disallow stacking discard limits otherwise the
41044111
* block layer will stack them if pool's data device has support.
41054112
*/
41064113
limits->discard_granularity = 0;
4107-
return;
41084114
}
4109-
4110-
disable_passdown_if_not_supported(pt);
4111-
4112-
/*
4113-
* The pool uses the same discard limits as the underlying data
4114-
* device. DM core has already set this up.
4115-
*/
41164115
}
41174116

41184117
static struct target_type pool_target = {
@@ -4496,11 +4495,10 @@ static void thin_io_hints(struct dm_target *ti, struct queue_limits *limits)
44964495
struct thin_c *tc = ti->private;
44974496
struct pool *pool = tc->pool;
44984497

4499-
if (!pool->pf.discard_enabled)
4500-
return;
4501-
4502-
limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT;
4503-
limits->max_discard_sectors = pool->sectors_per_block * BIO_PRISON_MAX_RANGE;
4498+
if (pool->pf.discard_enabled) {
4499+
limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT;
4500+
limits->max_discard_sectors = pool->sectors_per_block * BIO_PRISON_MAX_RANGE;
4501+
}
45044502
}
45054503

45064504
static struct target_type thin_target = {

0 commit comments

Comments
 (0)