dm: fix stacking of geometry limits for thinp and cache
PATCH 1/1 dm: fix stacking of geometry limits for thinp and cache
Do not blindly override the queue limits (specifically io_min and io_opt). Allow traditional stacking of these limits if io_opt is a factor of each target's block size.
Without this patch mkfs.xfs does not recognize these target provided limits as a useful geometry (e.g. raid) so these hints are ignored. This was due to setting io_min to a useless value.
Signed-off-by Mike Snitzer <[email protected]>
--- drivers/md/dm-cache-target.c | 12 ++++++++++-- drivers/md/dm-thin.c | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-)
drivers/md/dm-cache-target.c +10 -2
@@ -2609,9 +2609,17 @@ static void set_discard_limits(struct castatic void cache_io_hints (struct dm_target *ti,struct queue_limits *limits) {struct cache *cache = ti->private; +unsigned io_opt_sectors = limits->io_opt >>SECTOR_SHIFT ; -blk_limits_io_min (limits,0 ); -blk_limits_io_opt (limits, cache->sectors_per_block <<SECTOR_SHIFT ); +/* +* If the system-determined stacked limits are compatible with the +* cache's blocksize (io_opt is a factor) do not override them. +*/ +if (io_opt_sectors < cache->sectors_per_block || +do_div (io_opt_sectors, cache->sectors_per_block)) { +blk_limits_io_min (limits,0 ); +blk_limits_io_opt (limits, cache->sectors_per_block <<SECTOR_SHIFT ); + }set_discard_limits (cache, limits); }
drivers/md/dm-thin.c +10 -2
@@ -2648,9 +2648,17 @@ static void pool_io_hints(struct dm_targ {struct pool_c *pt = ti->private;struct pool *pool = pt->pool; +unsigned io_opt_sectors = limits->io_opt >>SECTOR_SHIFT ; -blk_limits_io_min (limits,0 ); -blk_limits_io_opt (limits, pool->sectors_per_block <<SECTOR_SHIFT ); +/* +* If the system-determined stacked limits are compatible with the +* pool's blocksize (io_opt is a factor) do not override them. +*/ +if (io_opt_sectors < pool->sectors_per_block || +do_div (io_opt_sectors, pool->sectors_per_block)) { +blk_limits_io_min (limits,0 ); +blk_limits_io_opt (limits, pool->sectors_per_block <<SECTOR_SHIFT ); + }/* * pt->adjusted_pf is a staging area for the actual features to use.
Quoted 3 lines · Mike Snitzer
Do not blindly override the queue limits (specifically
io_minandio_opt). Allow traditional stacking of these limits ifio_optis a factor of each target's block size.
Ack