aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@redhat.com>2014-10-09 18:43:25 -0400
committerMike Snitzer <snitzer@redhat.com>2014-11-10 15:25:27 -0500
commit604ea90641b45f41f8dee34ce45694f1e0c53a5a (patch)
treea438aa17637a26cf32284b635c792f83e42ad6b2 /drivers/md
parent7d327fe051edcccf54da7b6733c58992473f228b (diff)
dm thin: adjust max_sectors_kb based on thinp blocksize
Allows for filesystems to submit bios that are a factor of the thinp blocksize, improving dm-thinp efficiency (particularly when the data volume is RAID). Also set io_min to max_sectors_kb if it is a factor of the thinp blocksize. Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-thin.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 91b430b883fd..de55ae9d4926 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -11,6 +11,7 @@
11#include <linux/device-mapper.h> 11#include <linux/device-mapper.h>
12#include <linux/dm-io.h> 12#include <linux/dm-io.h>
13#include <linux/dm-kcopyd.h> 13#include <linux/dm-kcopyd.h>
14#include <linux/log2.h>
14#include <linux/list.h> 15#include <linux/list.h>
15#include <linux/rculist.h> 16#include <linux/rculist.h>
16#include <linux/init.h> 17#include <linux/init.h>
@@ -3242,15 +3243,42 @@ static void pool_io_hints(struct dm_target *ti, struct queue_limits *limits)
3242{ 3243{
3243 struct pool_c *pt = ti->private; 3244 struct pool_c *pt = ti->private;
3244 struct pool *pool = pt->pool; 3245 struct pool *pool = pt->pool;
3245 uint64_t io_opt_sectors = limits->io_opt >> SECTOR_SHIFT; 3246 sector_t io_opt_sectors = limits->io_opt >> SECTOR_SHIFT;
3247
3248 /*
3249 * Adjust max_sectors_kb to highest possible power-of-2
3250 * factor of pool->sectors_per_block.
3251 */
3252 if (limits->max_hw_sectors & (limits->max_hw_sectors - 1))
3253 limits->max_sectors = rounddown_pow_of_two(limits->max_hw_sectors);
3254 else
3255 limits->max_sectors = limits->max_hw_sectors;
3256
3257 if (limits->max_sectors < pool->sectors_per_block) {
3258 while (!is_factor(pool->sectors_per_block, limits->max_sectors)) {
3259 if ((limits->max_sectors & (limits->max_sectors - 1)) == 0)
3260 limits->max_sectors--;
3261 limits->max_sectors = rounddown_pow_of_two(limits->max_sectors);
3262 }
3263 } else if (block_size_is_power_of_two(pool)) {
3264 /* max_sectors_kb is >= power-of-2 thinp blocksize */
3265 while (!is_factor(limits->max_sectors, pool->sectors_per_block)) {
3266 if ((limits->max_sectors & (limits->max_sectors - 1)) == 0)
3267 limits->max_sectors--;
3268 limits->max_sectors = rounddown_pow_of_two(limits->max_sectors);
3269 }
3270 }
3246 3271
3247 /* 3272 /*
3248 * If the system-determined stacked limits are compatible with the 3273 * If the system-determined stacked limits are compatible with the
3249 * pool's blocksize (io_opt is a factor) do not override them. 3274 * pool's blocksize (io_opt is a factor) do not override them.
3250 */ 3275 */
3251 if (io_opt_sectors < pool->sectors_per_block || 3276 if (io_opt_sectors < pool->sectors_per_block ||
3252 do_div(io_opt_sectors, pool->sectors_per_block)) { 3277 !is_factor(io_opt_sectors, pool->sectors_per_block)) {
3253 blk_limits_io_min(limits, pool->sectors_per_block << SECTOR_SHIFT); 3278 if (is_factor(pool->sectors_per_block, limits->max_sectors))
3279 blk_limits_io_min(limits, limits->max_sectors << SECTOR_SHIFT);
3280 else
3281 blk_limits_io_min(limits, pool->sectors_per_block << SECTOR_SHIFT);
3254 blk_limits_io_opt(limits, pool->sectors_per_block << SECTOR_SHIFT); 3282 blk_limits_io_opt(limits, pool->sectors_per_block << SECTOR_SHIFT);
3255 } 3283 }
3256 3284