Commit 70dd5bf3b99964d52862ad2810c24cc32a553535
Committed by
Jens Axboe
1 parent
7c958e3264
Exists in
master
and in
39 other branches
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>
Showing 1 changed file with 11 additions and 0 deletions Side-by-side Diff
block/blk-settings.c
... | ... | @@ -7,6 +7,7 @@ |
7 | 7 | #include <linux/bio.h> |
8 | 8 | #include <linux/blkdev.h> |
9 | 9 | #include <linux/bootmem.h> /* for max_pfn/max_low_pfn */ |
10 | +#include <linux/gcd.h> | |
10 | 11 | |
11 | 12 | #include "blk.h" |
12 | 13 | |
... | ... | @@ -519,6 +520,16 @@ |
519 | 520 | t->misaligned = 1; |
520 | 521 | return -1; |
521 | 522 | } |
523 | + | |
524 | + /* Find lcm() of optimal I/O size */ | |
525 | + if (t->io_opt && b->io_opt) | |
526 | + t->io_opt = (t->io_opt * b->io_opt) / gcd(t->io_opt, b->io_opt); | |
527 | + else if (b->io_opt) | |
528 | + t->io_opt = b->io_opt; | |
529 | + | |
530 | + /* Verify that optimal I/O size is a multiple of io_min */ | |
531 | + if (t->io_min && t->io_opt % t->io_min) | |
532 | + return -1; | |
522 | 533 | |
523 | 534 | return 0; |
524 | 535 | } |