aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-raid.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md/dm-raid.c')
-rw-r--r--drivers/md/dm-raid.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index e5d8904fc8f6..efa960ff5ba4 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -43,13 +43,14 @@ struct raid_dev {
43/* 43/*
44 * Flags for rs->print_flags field. 44 * Flags for rs->print_flags field.
45 */ 45 */
46#define DMPF_DAEMON_SLEEP 0x1 46#define DMPF_SYNC 0x1
47#define DMPF_MAX_WRITE_BEHIND 0x2 47#define DMPF_NOSYNC 0x2
48#define DMPF_SYNC 0x4 48#define DMPF_REBUILD 0x4
49#define DMPF_NOSYNC 0x8 49#define DMPF_DAEMON_SLEEP 0x8
50#define DMPF_STRIPE_CACHE 0x10 50#define DMPF_MIN_RECOVERY_RATE 0x10
51#define DMPF_MIN_RECOVERY_RATE 0x20 51#define DMPF_MAX_RECOVERY_RATE 0x20
52#define DMPF_MAX_RECOVERY_RATE 0x40 52#define DMPF_MAX_WRITE_BEHIND 0x40
53#define DMPF_STRIPE_CACHE 0x80
53 54
54struct raid_set { 55struct raid_set {
55 struct dm_target *ti; 56 struct dm_target *ti;
@@ -275,13 +276,13 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
275 set_bit(In_sync, &rs->dev[i].rdev.flags); 276 set_bit(In_sync, &rs->dev[i].rdev.flags);
276 277
277 for (i = 0; i < num_raid_params; i++) { 278 for (i = 0; i < num_raid_params; i++) {
278 if (!strcmp(argv[i], "nosync")) { 279 if (!strcasecmp(argv[i], "nosync")) {
279 rs->md.recovery_cp = MaxSector; 280 rs->md.recovery_cp = MaxSector;
280 rs->print_flags |= DMPF_NOSYNC; 281 rs->print_flags |= DMPF_NOSYNC;
281 rs->md.flags |= MD_SYNC_STATE_FORCED; 282 rs->md.flags |= MD_SYNC_STATE_FORCED;
282 continue; 283 continue;
283 } 284 }
284 if (!strcmp(argv[i], "sync")) { 285 if (!strcasecmp(argv[i], "sync")) {
285 rs->md.recovery_cp = 0; 286 rs->md.recovery_cp = 0;
286 rs->print_flags |= DMPF_SYNC; 287 rs->print_flags |= DMPF_SYNC;
287 rs->md.flags |= MD_SYNC_STATE_FORCED; 288 rs->md.flags |= MD_SYNC_STATE_FORCED;
@@ -300,7 +301,7 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
300 return -EINVAL; 301 return -EINVAL;
301 } 302 }
302 303
303 if (!strcmp(key, "rebuild")) { 304 if (!strcasecmp(key, "rebuild")) {
304 if (++rebuild_cnt > rs->raid_type->parity_devs) { 305 if (++rebuild_cnt > rs->raid_type->parity_devs) {
305 rs->ti->error = "Too many rebuild drives given"; 306 rs->ti->error = "Too many rebuild drives given";
306 return -EINVAL; 307 return -EINVAL;
@@ -311,7 +312,8 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
311 } 312 }
312 clear_bit(In_sync, &rs->dev[value].rdev.flags); 313 clear_bit(In_sync, &rs->dev[value].rdev.flags);
313 rs->dev[value].rdev.recovery_offset = 0; 314 rs->dev[value].rdev.recovery_offset = 0;
314 } else if (!strcmp(key, "max_write_behind")) { 315 rs->print_flags |= DMPF_REBUILD;
316 } else if (!strcasecmp(key, "max_write_behind")) {
315 rs->print_flags |= DMPF_MAX_WRITE_BEHIND; 317 rs->print_flags |= DMPF_MAX_WRITE_BEHIND;
316 318
317 /* 319 /*
@@ -324,14 +326,14 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
324 return -EINVAL; 326 return -EINVAL;
325 } 327 }
326 rs->md.bitmap_info.max_write_behind = value; 328 rs->md.bitmap_info.max_write_behind = value;
327 } else if (!strcmp(key, "daemon_sleep")) { 329 } else if (!strcasecmp(key, "daemon_sleep")) {
328 rs->print_flags |= DMPF_DAEMON_SLEEP; 330 rs->print_flags |= DMPF_DAEMON_SLEEP;
329 if (!value || (value > MAX_SCHEDULE_TIMEOUT)) { 331 if (!value || (value > MAX_SCHEDULE_TIMEOUT)) {
330 rs->ti->error = "daemon sleep period out of range"; 332 rs->ti->error = "daemon sleep period out of range";
331 return -EINVAL; 333 return -EINVAL;
332 } 334 }
333 rs->md.bitmap_info.daemon_sleep = value; 335 rs->md.bitmap_info.daemon_sleep = value;
334 } else if (!strcmp(key, "stripe_cache")) { 336 } else if (!strcasecmp(key, "stripe_cache")) {
335 rs->print_flags |= DMPF_STRIPE_CACHE; 337 rs->print_flags |= DMPF_STRIPE_CACHE;
336 338
337 /* 339 /*
@@ -348,14 +350,14 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
348 rs->ti->error = "Bad stripe_cache size"; 350 rs->ti->error = "Bad stripe_cache size";
349 return -EINVAL; 351 return -EINVAL;
350 } 352 }
351 } else if (!strcmp(key, "min_recovery_rate")) { 353 } else if (!strcasecmp(key, "min_recovery_rate")) {
352 rs->print_flags |= DMPF_MIN_RECOVERY_RATE; 354 rs->print_flags |= DMPF_MIN_RECOVERY_RATE;
353 if (value > INT_MAX) { 355 if (value > INT_MAX) {
354 rs->ti->error = "min_recovery_rate out of range"; 356 rs->ti->error = "min_recovery_rate out of range";
355 return -EINVAL; 357 return -EINVAL;
356 } 358 }
357 rs->md.sync_speed_min = (int)value; 359 rs->md.sync_speed_min = (int)value;
358 } else if (!strcmp(key, "max_recovery_rate")) { 360 } else if (!strcasecmp(key, "max_recovery_rate")) {
359 rs->print_flags |= DMPF_MAX_RECOVERY_RATE; 361 rs->print_flags |= DMPF_MAX_RECOVERY_RATE;
360 if (value > INT_MAX) { 362 if (value > INT_MAX) {
361 rs->ti->error = "max_recovery_rate out of range"; 363 rs->ti->error = "max_recovery_rate out of range";
@@ -547,11 +549,12 @@ static int raid_status(struct dm_target *ti, status_type_t type,
547 case STATUSTYPE_TABLE: 549 case STATUSTYPE_TABLE:
548 /* The string you would use to construct this array */ 550 /* The string you would use to construct this array */
549 for (i = 0; i < rs->md.raid_disks; i++) 551 for (i = 0; i < rs->md.raid_disks; i++)
550 if (rs->dev[i].data_dev && 552 if ((rs->print_flags & DMPF_REBUILD) &&
553 rs->dev[i].data_dev &&
551 !test_bit(In_sync, &rs->dev[i].rdev.flags)) 554 !test_bit(In_sync, &rs->dev[i].rdev.flags))
552 raid_param_cnt++; /* for rebuilds */ 555 raid_param_cnt += 2; /* for rebuilds */
553 556
554 raid_param_cnt += (hweight64(rs->print_flags) * 2); 557 raid_param_cnt += (hweight64(rs->print_flags & ~DMPF_REBUILD) * 2);
555 if (rs->print_flags & (DMPF_SYNC | DMPF_NOSYNC)) 558 if (rs->print_flags & (DMPF_SYNC | DMPF_NOSYNC))
556 raid_param_cnt--; 559 raid_param_cnt--;
557 560
@@ -565,7 +568,8 @@ static int raid_status(struct dm_target *ti, status_type_t type,
565 DMEMIT(" nosync"); 568 DMEMIT(" nosync");
566 569
567 for (i = 0; i < rs->md.raid_disks; i++) 570 for (i = 0; i < rs->md.raid_disks; i++)
568 if (rs->dev[i].data_dev && 571 if ((rs->print_flags & DMPF_REBUILD) &&
572 rs->dev[i].data_dev &&
569 !test_bit(In_sync, &rs->dev[i].rdev.flags)) 573 !test_bit(In_sync, &rs->dev[i].rdev.flags))
570 DMEMIT(" rebuild %u", i); 574 DMEMIT(" rebuild %u", i);
571 575