Skip to content

Commit d249e54

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md: replace last_sync_action with new enum type
The only difference is that "none" is removed and initial last_sync_action will be idle. On the one hand, this value is introduced by commit c4a3955 ("MD: Remember the last sync operation that was performed"), and the usage described in commit message is not affected. On the other hand, last_sync_action is not used in mdadm or mdmon, and none of the tests that I can find. Signed-off-by: Yu Kuai <[email protected]> Signed-off-by: Song Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7d9f107 commit d249e54

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

drivers/md/dm-raid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3542,7 +3542,7 @@ static void raid_status(struct dm_target *ti, status_type_t type,
35423542
recovery = rs->md.recovery;
35433543
state = decipher_sync_action(mddev, recovery);
35443544
progress = rs_get_progress(rs, recovery, state, resync_max_sectors);
3545-
resync_mismatches = (mddev->last_sync_action && !strcasecmp(mddev->last_sync_action, "check")) ?
3545+
resync_mismatches = mddev->last_sync_action == ACTION_CHECK ?
35463546
atomic64_read(&mddev->resync_mismatches) : 0;
35473547

35483548
/* HM FIXME: do we want another state char for raid0? It shows 'D'/'A'/'-' now */

drivers/md/md.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ int mddev_init(struct mddev *mddev)
768768
init_waitqueue_head(&mddev->recovery_wait);
769769
mddev->reshape_position = MaxSector;
770770
mddev->reshape_backwards = 0;
771-
mddev->last_sync_action = "none";
771+
mddev->last_sync_action = ACTION_IDLE;
772772
mddev->resync_min = 0;
773773
mddev->resync_max = MaxSector;
774774
mddev->level = LEVEL_NONE;
@@ -5149,7 +5149,8 @@ __ATTR_PREALLOC(sync_action, S_IRUGO|S_IWUSR, action_show, action_store);
51495149
static ssize_t
51505150
last_sync_action_show(struct mddev *mddev, char *page)
51515151
{
5152-
return sprintf(page, "%s\n", mddev->last_sync_action);
5152+
return sprintf(page, "%s\n",
5153+
md_sync_action_name(mddev->last_sync_action));
51535154
}
51545155

51555156
static struct md_sysfs_entry md_last_scan_mode = __ATTR_RO(last_sync_action);
@@ -8963,7 +8964,7 @@ void md_do_sync(struct md_thread *thread)
89638964

89648965
action = md_sync_action(mddev);
89658966
desc = md_sync_action_name(action);
8966-
mddev->last_sync_action = desc;
8967+
mddev->last_sync_action = action;
89678968

89688969
/*
89698970
* Before starting a resync we must have set curr_resync to

drivers/md/md.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,12 @@ struct mddev {
426426
struct md_thread __rcu *thread; /* management thread */
427427
struct md_thread __rcu *sync_thread; /* doing resync or reconstruct */
428428

429-
/* 'last_sync_action' is initialized to "none". It is set when a
430-
* sync operation (i.e "data-check", "requested-resync", "resync",
431-
* "recovery", or "reshape") is started. It holds this value even
429+
/*
430+
* Set when a sync operation is started. It holds this value even
432431
* when the sync thread is "frozen" (interrupted) or "idle" (stopped
433-
* or finished). It is overwritten when a new sync operation is begun.
432+
* or finished). It is overwritten when a new sync operation is begun.
434433
*/
435-
const char *last_sync_action;
434+
enum sync_action last_sync_action;
436435
sector_t curr_resync; /* last block scheduled */
437436
/* As resync requests can complete out of order, we cannot easily track
438437
* how much resync has been completed. So we occasionally pause until

0 commit comments

Comments
 (0)