aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/multipath.c24
-rw-r--r--drivers/md/raid1.c28
-rw-r--r--drivers/md/raid10.c22
3 files changed, 74 insertions, 0 deletions
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index e4f168d063db..171ff41b52b0 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -228,6 +228,28 @@ static int multipath_issue_flush(request_queue_t *q, struct gendisk *disk,
228 rcu_read_unlock(); 228 rcu_read_unlock();
229 return ret; 229 return ret;
230} 230}
231static int multipath_congested(void *data, int bits)
232{
233 mddev_t *mddev = data;
234 multipath_conf_t *conf = mddev_to_conf(mddev);
235 int i, ret = 0;
236
237 rcu_read_lock();
238 for (i = 0; i < mddev->raid_disks ; i++) {
239 mdk_rdev_t *rdev = rcu_dereference(conf->multipaths[i].rdev);
240 if (rdev && !test_bit(Faulty, &rdev->flags)) {
241 request_queue_t *q = bdev_get_queue(rdev->bdev);
242
243 ret |= bdi_congested(&q->backing_dev_info, bits);
244 /* Just like multipath_map, we just check the
245 * first available device
246 */
247 break;
248 }
249 }
250 rcu_read_unlock();
251 return ret;
252}
231 253
232/* 254/*
233 * Careful, this can execute in IRQ contexts as well! 255 * Careful, this can execute in IRQ contexts as well!
@@ -509,6 +531,8 @@ static int multipath_run (mddev_t *mddev)
509 531
510 mddev->queue->unplug_fn = multipath_unplug; 532 mddev->queue->unplug_fn = multipath_unplug;
511 mddev->queue->issue_flush_fn = multipath_issue_flush; 533 mddev->queue->issue_flush_fn = multipath_issue_flush;
534 mddev->queue->backing_dev_info.congested_fn = multipath_congested;
535 mddev->queue->backing_dev_info.congested_data = mddev;
512 536
513 return 0; 537 return 0;
514 538
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 99c4e031c7f1..dc9d2def0270 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -601,6 +601,32 @@ static int raid1_issue_flush(request_queue_t *q, struct gendisk *disk,
601 return ret; 601 return ret;
602} 602}
603 603
604static int raid1_congested(void *data, int bits)
605{
606 mddev_t *mddev = data;
607 conf_t *conf = mddev_to_conf(mddev);
608 int i, ret = 0;
609
610 rcu_read_lock();
611 for (i = 0; i < mddev->raid_disks; i++) {
612 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
613 if (rdev && !test_bit(Faulty, &rdev->flags)) {
614 request_queue_t *q = bdev_get_queue(rdev->bdev);
615
616 /* Note the '|| 1' - when read_balance prefers
617 * non-congested targets, it can be removed
618 */
619 if ((bits & (1<<BDI_write_congested)) || 1)
620 ret |= bdi_congested(&q->backing_dev_info, bits);
621 else
622 ret &= bdi_congested(&q->backing_dev_info, bits);
623 }
624 }
625 rcu_read_unlock();
626 return ret;
627}
628
629
604/* Barriers.... 630/* Barriers....
605 * Sometimes we need to suspend IO while we do something else, 631 * Sometimes we need to suspend IO while we do something else,
606 * either some resync/recovery, or reconfigure the array. 632 * either some resync/recovery, or reconfigure the array.
@@ -1965,6 +1991,8 @@ static int run(mddev_t *mddev)
1965 1991
1966 mddev->queue->unplug_fn = raid1_unplug; 1992 mddev->queue->unplug_fn = raid1_unplug;
1967 mddev->queue->issue_flush_fn = raid1_issue_flush; 1993 mddev->queue->issue_flush_fn = raid1_issue_flush;
1994 mddev->queue->backing_dev_info.congested_fn = raid1_congested;
1995 mddev->queue->backing_dev_info.congested_data = mddev;
1968 1996
1969 return 0; 1997 return 0;
1970 1998
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 64f8016ab740..1250f0eab4af 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -648,6 +648,26 @@ static int raid10_issue_flush(request_queue_t *q, struct gendisk *disk,
648 return ret; 648 return ret;
649} 649}
650 650
651static int raid10_congested(void *data, int bits)
652{
653 mddev_t *mddev = data;
654 conf_t *conf = mddev_to_conf(mddev);
655 int i, ret = 0;
656
657 rcu_read_lock();
658 for (i = 0; i < mddev->raid_disks && ret == 0; i++) {
659 mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
660 if (rdev && !test_bit(Faulty, &rdev->flags)) {
661 request_queue_t *q = bdev_get_queue(rdev->bdev);
662
663 ret |= bdi_congested(&q->backing_dev_info, bits);
664 }
665 }
666 rcu_read_unlock();
667 return ret;
668}
669
670
651/* Barriers.... 671/* Barriers....
652 * Sometimes we need to suspend IO while we do something else, 672 * Sometimes we need to suspend IO while we do something else,
653 * either some resync/recovery, or reconfigure the array. 673 * either some resync/recovery, or reconfigure the array.
@@ -2094,6 +2114,8 @@ static int run(mddev_t *mddev)
2094 2114
2095 mddev->queue->unplug_fn = raid10_unplug; 2115 mddev->queue->unplug_fn = raid10_unplug;
2096 mddev->queue->issue_flush_fn = raid10_issue_flush; 2116 mddev->queue->issue_flush_fn = raid10_issue_flush;
2117 mddev->queue->backing_dev_info.congested_fn = raid10_congested;
2118 mddev->queue->backing_dev_info.congested_data = mddev;
2097 2119
2098 /* Calculate max read-ahead size. 2120 /* Calculate max read-ahead size.
2099 * We need to readahead at least twice a whole stripe.... 2121 * We need to readahead at least twice a whole stripe....