Skip to content

Commit cc4d1ef

Browse files
jbrassowneilbrown
authored andcommitted
MD RAID10: Export md_raid10_congested
md/raid10: Export is_congested test. In similar fashion to commits 11d8a6e 1ed7242 we export the RAID10 congestion checking function so that dm-raid.c can make use of it and make use of the personality. The 'queue' and 'gendisk' structures will not be available to the MD code when device-mapper sets up the device, so we conditionalize access to these fields also. Signed-off-by: Jonathan Brassow <jbrassow@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
1 parent 473e87c commit cc4d1ef

2 files changed

Lines changed: 37 additions & 22 deletions

File tree

‎drivers/md/raid10.c‎

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -853,18 +853,15 @@ static struct md_rdev *read_balance(struct r10conf *conf,
853853
return rdev;
854854
}
855855

856-
static int raid10_congested(void *data, int bits)
856+
int md_raid10_congested(struct mddev *mddev, int bits)
857857
{
858-
struct mddev *mddev = data;
859858
struct r10conf *conf = mddev->private;
860859
int i, ret = 0;
861860

862861
if ((bits & (1 << BDI_async_congested)) &&
863862
conf->pending_count >= max_queued_requests)
864863
return 1;
865864

866-
if (mddev_congested(mddev, bits))
867-
return 1;
868865
rcu_read_lock();
869866
for (i = 0;
870867
(i < conf->geo.raid_disks || i < conf->prev.raid_disks)
@@ -880,6 +877,15 @@ static int raid10_congested(void *data, int bits)
880877
rcu_read_unlock();
881878
return ret;
882879
}
880+
EXPORT_SYMBOL_GPL(md_raid10_congested);
881+
882+
static int raid10_congested(void *data, int bits)
883+
{
884+
struct mddev *mddev = data;
885+
886+
return mddev_congested(mddev, bits) ||
887+
md_raid10_congested(mddev, bits);
888+
}
883889

884890
static void flush_pending_writes(struct r10conf *conf)
885891
{
@@ -3486,12 +3492,14 @@ static int run(struct mddev *mddev)
34863492
conf->thread = NULL;
34873493

34883494
chunk_size = mddev->chunk_sectors << 9;
3489-
blk_queue_io_min(mddev->queue, chunk_size);
3490-
if (conf->geo.raid_disks % conf->geo.near_copies)
3491-
blk_queue_io_opt(mddev->queue, chunk_size * conf->geo.raid_disks);
3492-
else
3493-
blk_queue_io_opt(mddev->queue, chunk_size *
3494-
(conf->geo.raid_disks / conf->geo.near_copies));
3495+
if (mddev->queue) {
3496+
blk_queue_io_min(mddev->queue, chunk_size);
3497+
if (conf->geo.raid_disks % conf->geo.near_copies)
3498+
blk_queue_io_opt(mddev->queue, chunk_size * conf->geo.raid_disks);
3499+
else
3500+
blk_queue_io_opt(mddev->queue, chunk_size *
3501+
(conf->geo.raid_disks / conf->geo.near_copies));
3502+
}
34953503

34963504
rdev_for_each(rdev, mddev) {
34973505
long long diff;
@@ -3525,8 +3533,9 @@ static int run(struct mddev *mddev)
35253533
if (first || diff < min_offset_diff)
35263534
min_offset_diff = diff;
35273535

3528-
disk_stack_limits(mddev->gendisk, rdev->bdev,
3529-
rdev->data_offset << 9);
3536+
if (mddev->gendisk)
3537+
disk_stack_limits(mddev->gendisk, rdev->bdev,
3538+
rdev->data_offset << 9);
35303539

35313540
disk->head_position = 0;
35323541
}
@@ -3589,22 +3598,22 @@ static int run(struct mddev *mddev)
35893598
md_set_array_sectors(mddev, size);
35903599
mddev->resync_max_sectors = size;
35913600

3592-
mddev->queue->backing_dev_info.congested_fn = raid10_congested;
3593-
mddev->queue->backing_dev_info.congested_data = mddev;
3594-
3595-
/* Calculate max read-ahead size.
3596-
* We need to readahead at least twice a whole stripe....
3597-
* maybe...
3598-
*/
3599-
{
3601+
if (mddev->queue) {
36003602
int stripe = conf->geo.raid_disks *
36013603
((mddev->chunk_sectors << 9) / PAGE_SIZE);
3604+
mddev->queue->backing_dev_info.congested_fn = raid10_congested;
3605+
mddev->queue->backing_dev_info.congested_data = mddev;
3606+
3607+
/* Calculate max read-ahead size.
3608+
* We need to readahead at least twice a whole stripe....
3609+
* maybe...
3610+
*/
36023611
stripe /= conf->geo.near_copies;
36033612
if (mddev->queue->backing_dev_info.ra_pages < 2 * stripe)
36043613
mddev->queue->backing_dev_info.ra_pages = 2 * stripe;
3614+
blk_queue_merge_bvec(mddev->queue, raid10_mergeable_bvec);
36053615
}
36063616

3607-
blk_queue_merge_bvec(mddev->queue, raid10_mergeable_bvec);
36083617

36093618
if (md_integrity_register(mddev))
36103619
goto out_free_conf;
@@ -3655,7 +3664,10 @@ static int stop(struct mddev *mddev)
36553664
lower_barrier(conf);
36563665

36573666
md_unregister_thread(&mddev->thread);
3658-
blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
3667+
if (mddev->queue)
3668+
/* the unplug fn references 'conf'*/
3669+
blk_sync_queue(mddev->queue);
3670+
36593671
if (conf->r10bio_pool)
36603672
mempool_destroy(conf->r10bio_pool);
36613673
kfree(conf->mirrors);

‎drivers/md/raid10.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,7 @@ enum r10bio_state {
145145
*/
146146
R10BIO_Previous,
147147
};
148+
149+
extern int md_raid10_congested(struct mddev *mddev, int bits);
150+
148151
#endif

0 commit comments

Comments
 (0)