diff options
author | Heinz Mauelshagen <heinzm@redhat.com> | 2017-12-01 19:03:54 -0500 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2017-12-08 10:59:58 -0500 |
commit | 242ea5ad11a03f2fbdfc2fe422d8e1b0601a8073 (patch) | |
tree | 7b92016cfccb3dc9cba6f92c42626eff3193003a /drivers/md/dm-raid.c | |
parent | 67143510a7e3634a23f06a48445d1148b2fdbc4d (diff) |
dm raid: avoid passing array_in_sync variable to raid_status() callees
The raid_status() function passes the bool array_in_sync variable around
providing synchronization state of the MD array. Replace it with a
runtime flag. This will avoid a pattern of having to pass discrete
variables to various functions.
Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-raid.c')
-rw-r--r-- | drivers/md/dm-raid.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c index 3df7c5bd5a9b..5730b32034aa 100644 --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c | |||
@@ -209,6 +209,7 @@ struct raid_dev { | |||
209 | #define RT_FLAG_UPDATE_SBS 3 | 209 | #define RT_FLAG_UPDATE_SBS 3 |
210 | #define RT_FLAG_RESHAPE_RS 4 | 210 | #define RT_FLAG_RESHAPE_RS 4 |
211 | #define RT_FLAG_RS_SUSPENDED 5 | 211 | #define RT_FLAG_RS_SUSPENDED 5 |
212 | #define RT_FLAG_RS_IN_SYNC 6 | ||
212 | 213 | ||
213 | /* Array elements of 64 bit needed for rebuild/failed disk bits */ | 214 | /* Array elements of 64 bit needed for rebuild/failed disk bits */ |
214 | #define DISKS_ARRAY_ELEMS ((MAX_RAID_DEVICES + (sizeof(uint64_t) * 8 - 1)) / sizeof(uint64_t) / 8) | 215 | #define DISKS_ARRAY_ELEMS ((MAX_RAID_DEVICES + (sizeof(uint64_t) * 8 - 1)) / sizeof(uint64_t) / 8) |
@@ -3335,7 +3336,7 @@ static const char *decipher_sync_action(struct mddev *mddev, unsigned long recov | |||
3335 | * 'A' = Alive and in-sync raid set component _or_ alive raid4/5/6 'write_through' journal device | 3336 | * 'A' = Alive and in-sync raid set component _or_ alive raid4/5/6 'write_through' journal device |
3336 | * '-' = Non-existing device (i.e. uspace passed '- -' into the ctr) | 3337 | * '-' = Non-existing device (i.e. uspace passed '- -' into the ctr) |
3337 | */ | 3338 | */ |
3338 | static const char *__raid_dev_status(struct raid_set *rs, struct md_rdev *rdev, bool array_in_sync) | 3339 | static const char *__raid_dev_status(struct raid_set *rs, struct md_rdev *rdev) |
3339 | { | 3340 | { |
3340 | if (!rdev->bdev) | 3341 | if (!rdev->bdev) |
3341 | return "-"; | 3342 | return "-"; |
@@ -3343,25 +3344,27 @@ static const char *__raid_dev_status(struct raid_set *rs, struct md_rdev *rdev, | |||
3343 | return "D"; | 3344 | return "D"; |
3344 | else if (test_bit(Journal, &rdev->flags)) | 3345 | else if (test_bit(Journal, &rdev->flags)) |
3345 | return (rs->journal_dev.mode == R5C_JOURNAL_MODE_WRITE_THROUGH) ? "A" : "a"; | 3346 | return (rs->journal_dev.mode == R5C_JOURNAL_MODE_WRITE_THROUGH) ? "A" : "a"; |
3346 | else if (!array_in_sync || !test_bit(In_sync, &rdev->flags)) | 3347 | else if (!test_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags) && |
3348 | !test_bit(In_sync, &rdev->flags)) | ||
3347 | return "a"; | 3349 | return "a"; |
3348 | else | 3350 | else |
3349 | return "A"; | 3351 | return "A"; |
3350 | } | 3352 | } |
3351 | 3353 | ||
3352 | /* Helper to return resync/reshape progress for @rs and @array_in_sync */ | 3354 | /* Helper to return resync/reshape progress for @rs and runtime flags for raid set in sync / resynching */ |
3353 | static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery, | 3355 | static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery, |
3354 | sector_t resync_max_sectors, bool *array_in_sync) | 3356 | sector_t resync_max_sectors) |
3355 | { | 3357 | { |
3356 | sector_t r, curr_resync_completed; | 3358 | sector_t r, curr_resync_completed; |
3357 | struct mddev *mddev = &rs->md; | 3359 | struct mddev *mddev = &rs->md; |
3358 | 3360 | ||
3361 | clear_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); | ||
3362 | |||
3359 | curr_resync_completed = mddev->curr_resync_completed ?: mddev->recovery_cp; | 3363 | curr_resync_completed = mddev->curr_resync_completed ?: mddev->recovery_cp; |
3360 | *array_in_sync = false; | ||
3361 | 3364 | ||
3362 | if (rs_is_raid0(rs)) { | 3365 | if (rs_is_raid0(rs)) { |
3363 | r = resync_max_sectors; | 3366 | r = resync_max_sectors; |
3364 | *array_in_sync = true; | 3367 | set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); |
3365 | 3368 | ||
3366 | } else { | 3369 | } else { |
3367 | r = mddev->reshape_position; | 3370 | r = mddev->reshape_position; |
@@ -3370,7 +3373,7 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery, | |||
3370 | if (test_bit(MD_RECOVERY_RESHAPE, &recovery) || | 3373 | if (test_bit(MD_RECOVERY_RESHAPE, &recovery) || |
3371 | r != MaxSector) { | 3374 | r != MaxSector) { |
3372 | if (r == MaxSector) { | 3375 | if (r == MaxSector) { |
3373 | *array_in_sync = true; | 3376 | set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); |
3374 | r = resync_max_sectors; | 3377 | r = resync_max_sectors; |
3375 | } else { | 3378 | } else { |
3376 | /* Got to reverse on backward reshape */ | 3379 | /* Got to reverse on backward reshape */ |
@@ -3393,7 +3396,7 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery, | |||
3393 | /* | 3396 | /* |
3394 | * Sync complete. | 3397 | * Sync complete. |
3395 | */ | 3398 | */ |
3396 | *array_in_sync = true; | 3399 | set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); |
3397 | r = resync_max_sectors; | 3400 | r = resync_max_sectors; |
3398 | } else if (test_bit(MD_RECOVERY_REQUESTED, &recovery)) { | 3401 | } else if (test_bit(MD_RECOVERY_REQUESTED, &recovery)) { |
3399 | /* | 3402 | /* |
@@ -3401,7 +3404,7 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery, | |||
3401 | * undergone an initial sync and the health characters | 3404 | * undergone an initial sync and the health characters |
3402 | * should not be 'a' anymore. | 3405 | * should not be 'a' anymore. |
3403 | */ | 3406 | */ |
3404 | *array_in_sync = true; | 3407 | set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); |
3405 | } else { | 3408 | } else { |
3406 | struct md_rdev *rdev; | 3409 | struct md_rdev *rdev; |
3407 | 3410 | ||
@@ -3414,7 +3417,7 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery, | |||
3414 | rdev_for_each(rdev, mddev) | 3417 | rdev_for_each(rdev, mddev) |
3415 | if (!test_bit(Journal, &rdev->flags) && | 3418 | if (!test_bit(Journal, &rdev->flags) && |
3416 | !test_bit(In_sync, &rdev->flags)) | 3419 | !test_bit(In_sync, &rdev->flags)) |
3417 | *array_in_sync = true; | 3420 | set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); |
3418 | #if 0 | 3421 | #if 0 |
3419 | r = 0; /* HM FIXME: TESTME: https://bugzilla.redhat.com/show_bug.cgi?id=1210637 ? */ | 3422 | r = 0; /* HM FIXME: TESTME: https://bugzilla.redhat.com/show_bug.cgi?id=1210637 ? */ |
3420 | #endif | 3423 | #endif |
@@ -3437,7 +3440,6 @@ static void raid_status(struct dm_target *ti, status_type_t type, | |||
3437 | struct mddev *mddev = &rs->md; | 3440 | struct mddev *mddev = &rs->md; |
3438 | struct r5conf *conf = mddev->private; | 3441 | struct r5conf *conf = mddev->private; |
3439 | int i, max_nr_stripes = conf ? conf->max_nr_stripes : 0; | 3442 | int i, max_nr_stripes = conf ? conf->max_nr_stripes : 0; |
3440 | bool array_in_sync; | ||
3441 | unsigned long recovery; | 3443 | unsigned long recovery; |
3442 | unsigned int raid_param_cnt = 1; /* at least 1 for chunksize */ | 3444 | unsigned int raid_param_cnt = 1; /* at least 1 for chunksize */ |
3443 | unsigned int sz = 0; | 3445 | unsigned int sz = 0; |
@@ -3462,14 +3464,14 @@ static void raid_status(struct dm_target *ti, status_type_t type, | |||
3462 | /* Get sensible max sectors even if raid set not yet started */ | 3464 | /* Get sensible max sectors even if raid set not yet started */ |
3463 | resync_max_sectors = test_bit(RT_FLAG_RS_PRERESUMED, &rs->runtime_flags) ? | 3465 | resync_max_sectors = test_bit(RT_FLAG_RS_PRERESUMED, &rs->runtime_flags) ? |
3464 | mddev->resync_max_sectors : mddev->dev_sectors; | 3466 | mddev->resync_max_sectors : mddev->dev_sectors; |
3465 | progress = rs_get_progress(rs, recovery, resync_max_sectors, &array_in_sync); | 3467 | progress = rs_get_progress(rs, recovery, resync_max_sectors); |
3466 | resync_mismatches = (mddev->last_sync_action && !strcasecmp(mddev->last_sync_action, "check")) ? | 3468 | resync_mismatches = (mddev->last_sync_action && !strcasecmp(mddev->last_sync_action, "check")) ? |
3467 | atomic64_read(&mddev->resync_mismatches) : 0; | 3469 | atomic64_read(&mddev->resync_mismatches) : 0; |
3468 | sync_action = decipher_sync_action(&rs->md, recovery); | 3470 | sync_action = decipher_sync_action(&rs->md, recovery); |
3469 | 3471 | ||
3470 | /* HM FIXME: do we want another state char for raid0? It shows 'D'/'A'/'-' now */ | 3472 | /* HM FIXME: do we want another state char for raid0? It shows 'D'/'A'/'-' now */ |
3471 | for (i = 0; i < rs->raid_disks; i++) | 3473 | for (i = 0; i < rs->raid_disks; i++) |
3472 | DMEMIT(__raid_dev_status(rs, &rs->dev[i].rdev, array_in_sync)); | 3474 | DMEMIT(__raid_dev_status(rs, &rs->dev[i].rdev)); |
3473 | 3475 | ||
3474 | /* | 3476 | /* |
3475 | * In-sync/Reshape ratio: | 3477 | * In-sync/Reshape ratio: |
@@ -3520,7 +3522,7 @@ static void raid_status(struct dm_target *ti, status_type_t type, | |||
3520 | * v1.10.0+: | 3522 | * v1.10.0+: |
3521 | */ | 3523 | */ |
3522 | DMEMIT(" %s", test_bit(__CTR_FLAG_JOURNAL_DEV, &rs->ctr_flags) ? | 3524 | DMEMIT(" %s", test_bit(__CTR_FLAG_JOURNAL_DEV, &rs->ctr_flags) ? |
3523 | __raid_dev_status(rs, &rs->journal_dev.rdev, 0) : "-"); | 3525 | __raid_dev_status(rs, &rs->journal_dev.rdev) : "-"); |
3524 | break; | 3526 | break; |
3525 | 3527 | ||
3526 | case STATUSTYPE_TABLE: | 3528 | case STATUSTYPE_TABLE: |