Skip to content

Commit 16ef510

Browse files
Christoph Hellwigaxboe
authored andcommitted
md: update the optimal I/O size on reshape
The raid5 and raid10 drivers currently update the read-ahead size, but not the optimal I/O size on reshape. To prepare for deriving the read-ahead size from the optimal I/O size make sure it is updated as well. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Acked-by: Song Liu <song@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 55b2598 commit 16ef510

2 files changed

Lines changed: 22 additions & 10 deletions

File tree

‎drivers/md/raid10.c‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3703,10 +3703,20 @@ static struct r10conf *setup_conf(struct mddev *mddev)
37033703
return ERR_PTR(err);
37043704
}
37053705

3706+
static void raid10_set_io_opt(struct r10conf *conf)
3707+
{
3708+
int raid_disks = conf->geo.raid_disks;
3709+
3710+
if (!(conf->geo.raid_disks % conf->geo.near_copies))
3711+
raid_disks /= conf->geo.near_copies;
3712+
blk_queue_io_opt(conf->mddev->queue, (conf->mddev->chunk_sectors << 9) *
3713+
raid_disks);
3714+
}
3715+
37063716
static int raid10_run(struct mddev *mddev)
37073717
{
37083718
struct r10conf *conf;
3709-
int i, disk_idx, chunk_size;
3719+
int i, disk_idx;
37103720
struct raid10_info *disk;
37113721
struct md_rdev *rdev;
37123722
sector_t size;
@@ -3742,18 +3752,13 @@ static int raid10_run(struct mddev *mddev)
37423752
mddev->thread = conf->thread;
37433753
conf->thread = NULL;
37443754

3745-
chunk_size = mddev->chunk_sectors << 9;
37463755
if (mddev->queue) {
37473756
blk_queue_max_discard_sectors(mddev->queue,
37483757
mddev->chunk_sectors);
37493758
blk_queue_max_write_same_sectors(mddev->queue, 0);
37503759
blk_queue_max_write_zeroes_sectors(mddev->queue, 0);
3751-
blk_queue_io_min(mddev->queue, chunk_size);
3752-
if (conf->geo.raid_disks % conf->geo.near_copies)
3753-
blk_queue_io_opt(mddev->queue, chunk_size * conf->geo.raid_disks);
3754-
else
3755-
blk_queue_io_opt(mddev->queue, chunk_size *
3756-
(conf->geo.raid_disks / conf->geo.near_copies));
3760+
blk_queue_io_min(mddev->queue, mddev->chunk_sectors << 9);
3761+
raid10_set_io_opt(conf);
37573762
}
37583763

37593764
rdev_for_each(rdev, mddev) {
@@ -4727,6 +4732,7 @@ static void end_reshape(struct r10conf *conf)
47274732
stripe /= conf->geo.near_copies;
47284733
if (conf->mddev->queue->backing_dev_info->ra_pages < 2 * stripe)
47294734
conf->mddev->queue->backing_dev_info->ra_pages = 2 * stripe;
4735+
raid10_set_io_opt(conf);
47304736
}
47314737
conf->fullsync = 0;
47324738
}

‎drivers/md/raid5.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7232,6 +7232,12 @@ static int only_parity(int raid_disk, int algo, int raid_disks, int max_degraded
72327232
return 0;
72337233
}
72347234

7235+
static void raid5_set_io_opt(struct r5conf *conf)
7236+
{
7237+
blk_queue_io_opt(conf->mddev->queue, (conf->chunk_sectors << 9) *
7238+
(conf->raid_disks - conf->max_degraded));
7239+
}
7240+
72357241
static int raid5_run(struct mddev *mddev)
72367242
{
72377243
struct r5conf *conf;
@@ -7521,8 +7527,7 @@ static int raid5_run(struct mddev *mddev)
75217527

75227528
chunk_size = mddev->chunk_sectors << 9;
75237529
blk_queue_io_min(mddev->queue, chunk_size);
7524-
blk_queue_io_opt(mddev->queue, chunk_size *
7525-
(conf->raid_disks - conf->max_degraded));
7530+
raid5_set_io_opt(conf);
75267531
mddev->queue->limits.raid_partial_stripes_expensive = 1;
75277532
/*
75287533
* We can only discard a whole stripe. It doesn't make sense to
@@ -8115,6 +8120,7 @@ static void end_reshape(struct r5conf *conf)
81158120
/ PAGE_SIZE);
81168121
if (conf->mddev->queue->backing_dev_info->ra_pages < 2 * stripe)
81178122
conf->mddev->queue->backing_dev_info->ra_pages = 2 * stripe;
8123+
raid5_set_io_opt(conf);
81188124
}
81198125
}
81208126
}

0 commit comments

Comments
 (0)