aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Brassow <jbrassow@redhat.com>2011-08-02 07:32:07 -0400
committerAlasdair G Kergon <agk@redhat.com>2011-08-02 07:32:07 -0400
commit46bed2b5c16bb7c82e1088d7ae75fb958c8a8c4e (patch)
treebab932a8eec324ca470407ff54097d86a3c0e27f
parentc1084561bb85da3630540ebe951749a8cd8fc714 (diff)
dm raid: add write_mostly parameter
Add the write_mostly parameter to RAID1 dm-raid tables. This allows the user to set the WriteMostly flag on a RAID1 device that should normally be avoided for read I/O. Signed-off-by: Jonathan Brassow <jbrassow@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
-rw-r--r--Documentation/device-mapper/dm-raid.txt4
-rw-r--r--drivers/md/dm-raid.c26
2 files changed, 28 insertions, 2 deletions
diff --git a/Documentation/device-mapper/dm-raid.txt b/Documentation/device-mapper/dm-raid.txt
index be4419a30781..a7d1c4abc927 100644
--- a/Documentation/device-mapper/dm-raid.txt
+++ b/Documentation/device-mapper/dm-raid.txt
@@ -50,6 +50,7 @@ The target is named "raid" and it accepts the following parameters:
50 50
51 [min_recovery_rate <kB/sec/disk>] Throttle RAID initialization 51 [min_recovery_rate <kB/sec/disk>] Throttle RAID initialization
52 [max_recovery_rate <kB/sec/disk>] Throttle RAID initialization 52 [max_recovery_rate <kB/sec/disk>] Throttle RAID initialization
53 [write_mostly <idx>] Drive index is write-mostly
53 [max_write_behind <sectors>] See '-write-behind=' (man mdadm) 54 [max_write_behind <sectors>] See '-write-behind=' (man mdadm)
54 [stripe_cache <sectors>] Stripe cache size (higher RAIDs only) 55 [stripe_cache <sectors>] Stripe cache size (higher RAIDs only)
55 [region_size <sectors>] 56 [region_size <sectors>]
@@ -87,9 +88,10 @@ Example tables
87 5 - 8:17 - 8:33 - 8:49 - 8:65 - 8:81 88 5 - 8:17 - 8:33 - 8:49 - 8:65 - 8:81
88 89
89'dmsetup table' displays the table used to construct the mapping. 90'dmsetup table' displays the table used to construct the mapping.
90The optional parameters will always be printed in the order listed 91The optional parameters are always printed in the order listed
91above with "sync" or "nosync" always output ahead of the other 92above with "sync" or "nosync" always output ahead of the other
92arguments, regardless of the order used when originally loading the table. 93arguments, regardless of the order used when originally loading the table.
94Arguments that can be repeated are ordered by value.
93 95
94'dmsetup status' yields information on the state and health of the 96'dmsetup status' yields information on the state and health of the
95array. 97array.
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index a8a1915a450d..88143a0303d2 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -308,6 +308,7 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size)
308 * [daemon_sleep <ms>] Time between bitmap daemon work to clear bits 308 * [daemon_sleep <ms>] Time between bitmap daemon work to clear bits
309 * [min_recovery_rate <kB/sec/disk>] Throttle RAID initialization 309 * [min_recovery_rate <kB/sec/disk>] Throttle RAID initialization
310 * [max_recovery_rate <kB/sec/disk>] Throttle RAID initialization 310 * [max_recovery_rate <kB/sec/disk>] Throttle RAID initialization
311 * [write_mostly <idx>] Indicate a write mostly drive via index
311 * [max_write_behind <sectors>] See '-write-behind=' (man mdadm) 312 * [max_write_behind <sectors>] See '-write-behind=' (man mdadm)
312 * [stripe_cache <sectors>] Stripe cache size for higher RAIDs 313 * [stripe_cache <sectors>] Stripe cache size for higher RAIDs
313 * [region_size <sectors>] Defines granularity of bitmap 314 * [region_size <sectors>] Defines granularity of bitmap
@@ -376,7 +377,21 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
376 clear_bit(In_sync, &rs->dev[value].rdev.flags); 377 clear_bit(In_sync, &rs->dev[value].rdev.flags);
377 rs->dev[value].rdev.recovery_offset = 0; 378 rs->dev[value].rdev.recovery_offset = 0;
378 rs->print_flags |= DMPF_REBUILD; 379 rs->print_flags |= DMPF_REBUILD;
380 } else if (!strcasecmp(key, "write_mostly")) {
381 if (rs->raid_type->level != 1) {
382 rs->ti->error = "write_mostly option is only valid for RAID1";
383 return -EINVAL;
384 }
385 if (value > rs->md.raid_disks) {
386 rs->ti->error = "Invalid write_mostly drive index given";
387 return -EINVAL;
388 }
389 set_bit(WriteMostly, &rs->dev[value].rdev.flags);
379 } else if (!strcasecmp(key, "max_write_behind")) { 390 } else if (!strcasecmp(key, "max_write_behind")) {
391 if (rs->raid_type->level != 1) {
392 rs->ti->error = "max_write_behind option is only valid for RAID1";
393 return -EINVAL;
394 }
380 rs->print_flags |= DMPF_MAX_WRITE_BEHIND; 395 rs->print_flags |= DMPF_MAX_WRITE_BEHIND;
381 396
382 /* 397 /*
@@ -621,11 +636,15 @@ static int raid_status(struct dm_target *ti, status_type_t type,
621 break; 636 break;
622 case STATUSTYPE_TABLE: 637 case STATUSTYPE_TABLE:
623 /* The string you would use to construct this array */ 638 /* The string you would use to construct this array */
624 for (i = 0; i < rs->md.raid_disks; i++) 639 for (i = 0; i < rs->md.raid_disks; i++) {
625 if ((rs->print_flags & DMPF_REBUILD) && 640 if ((rs->print_flags & DMPF_REBUILD) &&
626 rs->dev[i].data_dev && 641 rs->dev[i].data_dev &&
627 !test_bit(In_sync, &rs->dev[i].rdev.flags)) 642 !test_bit(In_sync, &rs->dev[i].rdev.flags))
628 raid_param_cnt += 2; /* for rebuilds */ 643 raid_param_cnt += 2; /* for rebuilds */
644 if (rs->dev[i].data_dev &&
645 test_bit(WriteMostly, &rs->dev[i].rdev.flags))
646 raid_param_cnt += 2;
647 }
629 648
630 raid_param_cnt += (hweight64(rs->print_flags & ~DMPF_REBUILD) * 2); 649 raid_param_cnt += (hweight64(rs->print_flags & ~DMPF_REBUILD) * 2);
631 if (rs->print_flags & (DMPF_SYNC | DMPF_NOSYNC)) 650 if (rs->print_flags & (DMPF_SYNC | DMPF_NOSYNC))
@@ -656,6 +675,11 @@ static int raid_status(struct dm_target *ti, status_type_t type,
656 if (rs->print_flags & DMPF_MAX_RECOVERY_RATE) 675 if (rs->print_flags & DMPF_MAX_RECOVERY_RATE)
657 DMEMIT(" max_recovery_rate %d", rs->md.sync_speed_max); 676 DMEMIT(" max_recovery_rate %d", rs->md.sync_speed_max);
658 677
678 for (i = 0; i < rs->md.raid_disks; i++)
679 if (rs->dev[i].data_dev &&
680 test_bit(WriteMostly, &rs->dev[i].rdev.flags))
681 DMEMIT(" write_mostly %u", i);
682
659 if (rs->print_flags & DMPF_MAX_WRITE_BEHIND) 683 if (rs->print_flags & DMPF_MAX_WRITE_BEHIND)
660 DMEMIT(" max_write_behind %lu", 684 DMEMIT(" max_write_behind %lu",
661 rs->md.bitmap_info.max_write_behind); 685 rs->md.bitmap_info.max_write_behind);