From: Martin K. Petersen Date: Fri, 31 Jul 2009 15:49:12 +0000 (-0400) Subject: block: Stack optimal I/O size X-Git-Tag: v2.6.31-rc6~67^2~2 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=70dd5bf3b99964d52862ad2810c24cc32a553535;p=linux.git 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 Reviewed-by: Mike Snitzer Signed-off-by: Jens Axboe --- 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 #include #include /* for max_pfn/max_low_pfn */ +#include #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);