Skip to content

Commit 7d9f107

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md: use new helpers in md_do_sync()
Make code cleaner. and also use the action_name directly in kernel log: - "check" instead of "data-check" - "repair" instead of "requested-resync" Signed-off-by: Yu Kuai <[email protected]> Signed-off-by: Song Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5ce10a3 commit 7d9f107

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

drivers/md/md.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8929,7 +8929,8 @@ void md_do_sync(struct md_thread *thread)
89298929
sector_t last_check;
89308930
int skipped = 0;
89318931
struct md_rdev *rdev;
8932-
char *desc, *action = NULL;
8932+
enum sync_action action;
8933+
const char *desc;
89338934
struct blk_plug plug;
89348935
int ret;
89358936

@@ -8960,21 +8961,9 @@ void md_do_sync(struct md_thread *thread)
89608961
goto skip;
89618962
}
89628963

8963-
if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) {
8964-
if (test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) {
8965-
desc = "data-check";
8966-
action = "check";
8967-
} else if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) {
8968-
desc = "requested-resync";
8969-
action = "repair";
8970-
} else
8971-
desc = "resync";
8972-
} else if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery))
8973-
desc = "reshape";
8974-
else
8975-
desc = "recovery";
8976-
8977-
mddev->last_sync_action = action ?: desc;
8964+
action = md_sync_action(mddev);
8965+
desc = md_sync_action_name(action);
8966+
mddev->last_sync_action = desc;
89788967

89798968
/*
89808969
* Before starting a resync we must have set curr_resync to

drivers/md/md.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ struct mddev {
432432
* when the sync thread is "frozen" (interrupted) or "idle" (stopped
433433
* or finished). It is overwritten when a new sync operation is begun.
434434
*/
435-
char *last_sync_action;
435+
const char *last_sync_action;
436436
sector_t curr_resync; /* last block scheduled */
437437
/* As resync requests can complete out of order, we cannot easily track
438438
* how much resync has been completed. So we occasionally pause until

0 commit comments

Comments
 (0)