Commit 242ea5ad authored by Heinz Mauelshagen's avatar Heinz Mauelshagen Committed by Mike Snitzer

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: default avatarHeinz Mauelshagen <heinzm@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 67143510
...@@ -209,6 +209,7 @@ struct raid_dev { ...@@ -209,6 +209,7 @@ struct raid_dev {
#define RT_FLAG_UPDATE_SBS 3 #define RT_FLAG_UPDATE_SBS 3
#define RT_FLAG_RESHAPE_RS 4 #define RT_FLAG_RESHAPE_RS 4
#define RT_FLAG_RS_SUSPENDED 5 #define RT_FLAG_RS_SUSPENDED 5
#define RT_FLAG_RS_IN_SYNC 6
/* Array elements of 64 bit needed for rebuild/failed disk bits */ /* Array elements of 64 bit needed for rebuild/failed disk bits */
#define DISKS_ARRAY_ELEMS ((MAX_RAID_DEVICES + (sizeof(uint64_t) * 8 - 1)) / sizeof(uint64_t) / 8) #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,7 +3336,7 @@ static const char *decipher_sync_action(struct mddev *mddev, unsigned long recov
* 'A' = Alive and in-sync raid set component _or_ alive raid4/5/6 'write_through' journal device * 'A' = Alive and in-sync raid set component _or_ alive raid4/5/6 'write_through' journal device
* '-' = Non-existing device (i.e. uspace passed '- -' into the ctr) * '-' = Non-existing device (i.e. uspace passed '- -' into the ctr)
*/ */
static const char *__raid_dev_status(struct raid_set *rs, struct md_rdev *rdev, bool array_in_sync) static const char *__raid_dev_status(struct raid_set *rs, struct md_rdev *rdev)
{ {
if (!rdev->bdev) if (!rdev->bdev)
return "-"; return "-";
...@@ -3343,25 +3344,27 @@ static const char *__raid_dev_status(struct raid_set *rs, struct md_rdev *rdev, ...@@ -3343,25 +3344,27 @@ static const char *__raid_dev_status(struct raid_set *rs, struct md_rdev *rdev,
return "D"; return "D";
else if (test_bit(Journal, &rdev->flags)) else if (test_bit(Journal, &rdev->flags))
return (rs->journal_dev.mode == R5C_JOURNAL_MODE_WRITE_THROUGH) ? "A" : "a"; return (rs->journal_dev.mode == R5C_JOURNAL_MODE_WRITE_THROUGH) ? "A" : "a";
else if (!array_in_sync || !test_bit(In_sync, &rdev->flags)) else if (!test_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags) &&
!test_bit(In_sync, &rdev->flags))
return "a"; return "a";
else else
return "A"; return "A";
} }
/* Helper to return resync/reshape progress for @rs and @array_in_sync */ /* Helper to return resync/reshape progress for @rs and runtime flags for raid set in sync / resynching */
static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery, static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery,
sector_t resync_max_sectors, bool *array_in_sync) sector_t resync_max_sectors)
{ {
sector_t r, curr_resync_completed; sector_t r, curr_resync_completed;
struct mddev *mddev = &rs->md; struct mddev *mddev = &rs->md;
clear_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags);
curr_resync_completed = mddev->curr_resync_completed ?: mddev->recovery_cp; curr_resync_completed = mddev->curr_resync_completed ?: mddev->recovery_cp;
*array_in_sync = false;
if (rs_is_raid0(rs)) { if (rs_is_raid0(rs)) {
r = resync_max_sectors; r = resync_max_sectors;
*array_in_sync = true; set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags);
} else { } else {
r = mddev->reshape_position; r = mddev->reshape_position;
...@@ -3370,7 +3373,7 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery, ...@@ -3370,7 +3373,7 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery,
if (test_bit(MD_RECOVERY_RESHAPE, &recovery) || if (test_bit(MD_RECOVERY_RESHAPE, &recovery) ||
r != MaxSector) { r != MaxSector) {
if (r == MaxSector) { if (r == MaxSector) {
*array_in_sync = true; set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags);
r = resync_max_sectors; r = resync_max_sectors;
} else { } else {
/* Got to reverse on backward reshape */ /* Got to reverse on backward reshape */
...@@ -3393,7 +3396,7 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery, ...@@ -3393,7 +3396,7 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery,
/* /*
* Sync complete. * Sync complete.
*/ */
*array_in_sync = true; set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags);
r = resync_max_sectors; r = resync_max_sectors;
} else if (test_bit(MD_RECOVERY_REQUESTED, &recovery)) { } else if (test_bit(MD_RECOVERY_REQUESTED, &recovery)) {
/* /*
...@@ -3401,7 +3404,7 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery, ...@@ -3401,7 +3404,7 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery,
* undergone an initial sync and the health characters * undergone an initial sync and the health characters
* should not be 'a' anymore. * should not be 'a' anymore.
*/ */
*array_in_sync = true; set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags);
} else { } else {
struct md_rdev *rdev; struct md_rdev *rdev;
...@@ -3414,7 +3417,7 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery, ...@@ -3414,7 +3417,7 @@ static sector_t rs_get_progress(struct raid_set *rs, unsigned long recovery,
rdev_for_each(rdev, mddev) rdev_for_each(rdev, mddev)
if (!test_bit(Journal, &rdev->flags) && if (!test_bit(Journal, &rdev->flags) &&
!test_bit(In_sync, &rdev->flags)) !test_bit(In_sync, &rdev->flags))
*array_in_sync = true; set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags);
#if 0 #if 0
r = 0; /* HM FIXME: TESTME: https://bugzilla.redhat.com/show_bug.cgi?id=1210637 ? */ r = 0; /* HM FIXME: TESTME: https://bugzilla.redhat.com/show_bug.cgi?id=1210637 ? */
#endif #endif
...@@ -3437,7 +3440,6 @@ static void raid_status(struct dm_target *ti, status_type_t type, ...@@ -3437,7 +3440,6 @@ static void raid_status(struct dm_target *ti, status_type_t type,
struct mddev *mddev = &rs->md; struct mddev *mddev = &rs->md;
struct r5conf *conf = mddev->private; struct r5conf *conf = mddev->private;
int i, max_nr_stripes = conf ? conf->max_nr_stripes : 0; int i, max_nr_stripes = conf ? conf->max_nr_stripes : 0;
bool array_in_sync;
unsigned long recovery; unsigned long recovery;
unsigned int raid_param_cnt = 1; /* at least 1 for chunksize */ unsigned int raid_param_cnt = 1; /* at least 1 for chunksize */
unsigned int sz = 0; unsigned int sz = 0;
...@@ -3462,14 +3464,14 @@ static void raid_status(struct dm_target *ti, status_type_t type, ...@@ -3462,14 +3464,14 @@ static void raid_status(struct dm_target *ti, status_type_t type,
/* Get sensible max sectors even if raid set not yet started */ /* Get sensible max sectors even if raid set not yet started */
resync_max_sectors = test_bit(RT_FLAG_RS_PRERESUMED, &rs->runtime_flags) ? resync_max_sectors = test_bit(RT_FLAG_RS_PRERESUMED, &rs->runtime_flags) ?
mddev->resync_max_sectors : mddev->dev_sectors; mddev->resync_max_sectors : mddev->dev_sectors;
progress = rs_get_progress(rs, recovery, resync_max_sectors, &array_in_sync); progress = rs_get_progress(rs, recovery, resync_max_sectors);
resync_mismatches = (mddev->last_sync_action && !strcasecmp(mddev->last_sync_action, "check")) ? resync_mismatches = (mddev->last_sync_action && !strcasecmp(mddev->last_sync_action, "check")) ?
atomic64_read(&mddev->resync_mismatches) : 0; atomic64_read(&mddev->resync_mismatches) : 0;
sync_action = decipher_sync_action(&rs->md, recovery); sync_action = decipher_sync_action(&rs->md, recovery);
/* HM FIXME: do we want another state char for raid0? It shows 'D'/'A'/'-' now */ /* HM FIXME: do we want another state char for raid0? It shows 'D'/'A'/'-' now */
for (i = 0; i < rs->raid_disks; i++) for (i = 0; i < rs->raid_disks; i++)
DMEMIT(__raid_dev_status(rs, &rs->dev[i].rdev, array_in_sync)); DMEMIT(__raid_dev_status(rs, &rs->dev[i].rdev));
/* /*
* In-sync/Reshape ratio: * In-sync/Reshape ratio:
...@@ -3520,7 +3522,7 @@ static void raid_status(struct dm_target *ti, status_type_t type, ...@@ -3520,7 +3522,7 @@ static void raid_status(struct dm_target *ti, status_type_t type,
* v1.10.0+: * v1.10.0+:
*/ */
DMEMIT(" %s", test_bit(__CTR_FLAG_JOURNAL_DEV, &rs->ctr_flags) ? DMEMIT(" %s", test_bit(__CTR_FLAG_JOURNAL_DEV, &rs->ctr_flags) ?
__raid_dev_status(rs, &rs->journal_dev.rdev, 0) : "-"); __raid_dev_status(rs, &rs->journal_dev.rdev) : "-");
break; break;
case STATUSTYPE_TABLE: case STATUSTYPE_TABLE:
......
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