diff options
author | Martin K. Petersen <martin.petersen@oracle.com> | 2009-07-31 11:49:12 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-08-01 10:24:35 +0200 |
commit | 70dd5bf3b99964d52862ad2810c24cc32a553535 (patch) | |
tree | 912cef9cf7545b9019ad4c54def7f651213f2725 /block/blk-settings.c | |
parent | 7c958e32649e0c35801762878fb0b6da8c55a515 (diff) |
block: Stack optimal I/O size
When stacking block devices ensure that optimal I/O size is scaled
accordingly.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/blk-settings.c')
-rw-r--r-- | block/blk-settings.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/block/blk-settings.c b/block/blk-settings.c index 1f7197434166..e1327ddfc13b 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -7,6 +7,7 @@ #include <linux/bio.h> #include <linux/blkdev.h> #include <linux/bootmem.h> /* for max_pfn/max_low_pfn */ +#include <linux/gcd.h> #include "blk.h" @@ -520,6 +521,16 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, return -1; } + /* Find lcm() of optimal I/O size */ + if (t->io_opt && b->io_opt) + t->io_opt = (t->io_opt * b->io_opt) / gcd(t->io_opt, b->io_opt); + else if (b->io_opt) + t->io_opt = b->io_opt; + + /* Verify that optimal I/O size is a multiple of io_min */ + if (t->io_min && t->io_opt % t->io_min) + return -1; + return 0; } EXPORT_SYMBOL(blk_stack_limits); |