Commit ef6953fb authored by Mike Snitzer's avatar Mike Snitzer

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: default avatarMike Snitzer <snitzer@kernel.org>
parent c0a7a0ac
...@@ -4098,21 +4098,20 @@ static void pool_io_hints(struct dm_target *ti, struct queue_limits *limits) ...@@ -4098,21 +4098,20 @@ static void pool_io_hints(struct dm_target *ti, struct queue_limits *limits)
* They get transferred to the live pool in bind_control_target() * They get transferred to the live pool in bind_control_target()
* called from pool_preresume(). * called from pool_preresume().
*/ */
if (!pt->adjusted_pf.discard_enabled) {
if (pt->adjusted_pf.discard_enabled) {
disable_passdown_if_not_supported(pt);
/*
* The pool uses the same discard limits as the underlying data
* device. DM core has already set this up.
*/
} else {
/* /*
* Must explicitly disallow stacking discard limits otherwise the * Must explicitly disallow stacking discard limits otherwise the
* block layer will stack them if pool's data device has support. * block layer will stack them if pool's data device has support.
*/ */
limits->discard_granularity = 0; limits->discard_granularity = 0;
return;
} }
disable_passdown_if_not_supported(pt);
/*
* The pool uses the same discard limits as the underlying data
* device. DM core has already set this up.
*/
} }
static struct target_type pool_target = { static struct target_type pool_target = {
...@@ -4496,11 +4495,10 @@ static void thin_io_hints(struct dm_target *ti, struct queue_limits *limits) ...@@ -4496,11 +4495,10 @@ static void thin_io_hints(struct dm_target *ti, struct queue_limits *limits)
struct thin_c *tc = ti->private; struct thin_c *tc = ti->private;
struct pool *pool = tc->pool; struct pool *pool = tc->pool;
if (!pool->pf.discard_enabled) if (pool->pf.discard_enabled) {
return; limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT;
limits->max_discard_sectors = pool->sectors_per_block * BIO_PRISON_MAX_RANGE;
limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT; }
limits->max_discard_sectors = pool->sectors_per_block * BIO_PRISON_MAX_RANGE;
} }
static struct target_type thin_target = { static struct target_type thin_target = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment