diff options
author | Mike Snitzer <snitzer@redhat.com> | 2015-03-30 13:39:09 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-03-31 11:45:50 -0400 |
commit | e9637415a92cf25ad800b7fdeddcd30cce7b44ab (patch) | |
tree | 81fb7a27d9d7803fe93745e1a3a1c5f984b8af97 /block | |
parent | e42391cd048809d903291d07f86ed3934ce138e9 (diff) |
block: fix blk_stack_limits() regression due to lcm() change
Linux 3.19 commit 69c953c ("lib/lcm.c: lcm(n,0)=lcm(0,n) is 0, not n")
caused blk_stack_limits() to not properly stack queue_limits for stacked
devices (e.g. DM).
Fix this regression by establishing lcm_not_zero() and switching
blk_stack_limits() over to using it.
DM uses blk_set_stacking_limits() to establish the initial top-level
queue_limits that are then built up based on underlying devices' limits
using blk_stack_limits(). In the case of optimal_io_size (io_opt)
blk_set_stacking_limits() establishes a default value of 0. With commit
69c953c, lcm(0, n) is no longer n, which compromises proper stacking of
the underlying devices' io_opt.
Test:
$ modprobe scsi_debug dev_size_mb=10 num_tgts=1 opt_blks=1536
$ cat /sys/block/sde/queue/optimal_io_size
786432
$ dmsetup create node --table "0 100 linear /dev/sde 0"
Before this fix:
$ cat /sys/block/dm-5/queue/optimal_io_size
0
After this fix:
$ cat /sys/block/dm-5/queue/optimal_io_size
786432
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org # 3.19+
Acked-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-settings.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/block/blk-settings.c b/block/blk-settings.c index 6ed2cbe5e8c9..12600bfffca9 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c | |||
@@ -585,7 +585,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, | |||
585 | b->physical_block_size); | 585 | b->physical_block_size); |
586 | 586 | ||
587 | t->io_min = max(t->io_min, b->io_min); | 587 | t->io_min = max(t->io_min, b->io_min); |
588 | t->io_opt = lcm(t->io_opt, b->io_opt); | 588 | t->io_opt = lcm_not_zero(t->io_opt, b->io_opt); |
589 | 589 | ||
590 | t->cluster &= b->cluster; | 590 | t->cluster &= b->cluster; |
591 | t->discard_zeroes_data &= b->discard_zeroes_data; | 591 | t->discard_zeroes_data &= b->discard_zeroes_data; |
@@ -616,7 +616,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, | |||
616 | b->raid_partial_stripes_expensive); | 616 | b->raid_partial_stripes_expensive); |
617 | 617 | ||
618 | /* Find lowest common alignment_offset */ | 618 | /* Find lowest common alignment_offset */ |
619 | t->alignment_offset = lcm(t->alignment_offset, alignment) | 619 | t->alignment_offset = lcm_not_zero(t->alignment_offset, alignment) |
620 | % max(t->physical_block_size, t->io_min); | 620 | % max(t->physical_block_size, t->io_min); |
621 | 621 | ||
622 | /* Verify that new alignment_offset is on a logical block boundary */ | 622 | /* Verify that new alignment_offset is on a logical block boundary */ |
@@ -643,7 +643,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, | |||
643 | b->max_discard_sectors); | 643 | b->max_discard_sectors); |
644 | t->discard_granularity = max(t->discard_granularity, | 644 | t->discard_granularity = max(t->discard_granularity, |
645 | b->discard_granularity); | 645 | b->discard_granularity); |
646 | t->discard_alignment = lcm(t->discard_alignment, alignment) % | 646 | t->discard_alignment = lcm_not_zero(t->discard_alignment, alignment) % |
647 | t->discard_granularity; | 647 | t->discard_granularity; |
648 | } | 648 | } |
649 | 649 | ||