Commit 1ed7242e authored by Jonathan Brassow's avatar Jonathan Brassow Committed by NeilBrown

MD: raid1 changes to allow use by device mapper

MD RAID1: Changes to allow RAID1 to be used by device-mapper (dm-raid.c)

Added the necessary congestion function and conditionalize calls requiring an
array 'queue' or 'gendisk'.
Signed-off-by: default avatarJonathan Brassow <jbrassow@redhat.com>
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent 0fd018af
...@@ -497,21 +497,19 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio) ...@@ -497,21 +497,19 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
return best_disk; return best_disk;
} }
static int raid1_congested(void *data, int bits) int md_raid1_congested(mddev_t *mddev, int bits)
{ {
mddev_t *mddev = data;
conf_t *conf = mddev->private; conf_t *conf = mddev->private;
int i, ret = 0; int i, ret = 0;
if (mddev_congested(mddev, bits))
return 1;
rcu_read_lock(); rcu_read_lock();
for (i = 0; i < mddev->raid_disks; i++) { for (i = 0; i < mddev->raid_disks; i++) {
mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev); mdk_rdev_t *rdev = rcu_dereference(conf->mirrors[i].rdev);
if (rdev && !test_bit(Faulty, &rdev->flags)) { if (rdev && !test_bit(Faulty, &rdev->flags)) {
struct request_queue *q = bdev_get_queue(rdev->bdev); struct request_queue *q = bdev_get_queue(rdev->bdev);
BUG_ON(!q);
/* Note the '|| 1' - when read_balance prefers /* Note the '|| 1' - when read_balance prefers
* non-congested targets, it can be removed * non-congested targets, it can be removed
*/ */
...@@ -524,7 +522,15 @@ static int raid1_congested(void *data, int bits) ...@@ -524,7 +522,15 @@ static int raid1_congested(void *data, int bits)
rcu_read_unlock(); rcu_read_unlock();
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(md_raid1_congested);
static int raid1_congested(void *data, int bits)
{
mddev_t *mddev = data;
return mddev_congested(mddev, bits) ||
md_raid1_congested(mddev, bits);
}
static void flush_pending_writes(conf_t *conf) static void flush_pending_writes(conf_t *conf)
{ {
...@@ -1972,6 +1978,8 @@ static int run(mddev_t *mddev) ...@@ -1972,6 +1978,8 @@ static int run(mddev_t *mddev)
return PTR_ERR(conf); return PTR_ERR(conf);
list_for_each_entry(rdev, &mddev->disks, same_set) { list_for_each_entry(rdev, &mddev->disks, same_set) {
if (!mddev->gendisk)
continue;
disk_stack_limits(mddev->gendisk, rdev->bdev, disk_stack_limits(mddev->gendisk, rdev->bdev,
rdev->data_offset << 9); rdev->data_offset << 9);
/* as we don't honour merge_bvec_fn, we must never risk /* as we don't honour merge_bvec_fn, we must never risk
...@@ -2013,8 +2021,10 @@ static int run(mddev_t *mddev) ...@@ -2013,8 +2021,10 @@ static int run(mddev_t *mddev)
md_set_array_sectors(mddev, raid1_size(mddev, 0, 0)); md_set_array_sectors(mddev, raid1_size(mddev, 0, 0));
mddev->queue->backing_dev_info.congested_fn = raid1_congested; if (mddev->queue) {
mddev->queue->backing_dev_info.congested_data = mddev; mddev->queue->backing_dev_info.congested_fn = raid1_congested;
mddev->queue->backing_dev_info.congested_data = mddev;
}
return md_integrity_register(mddev); return md_integrity_register(mddev);
} }
......
...@@ -126,4 +126,6 @@ struct r1bio_s { ...@@ -126,4 +126,6 @@ struct r1bio_s {
*/ */
#define R1BIO_Returned 6 #define R1BIO_Returned 6
extern int md_raid1_congested(mddev_t *mddev, int bits);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment