DM-Devel Archive mirror
 help / color / mirror / Atom feed
From: Yu Kuai <yukuai1@huaweicloud.com>
To: agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com,
	song@kernel.org, xni@redhat.com
Cc: dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-raid@vger.kernel.org, yukuai3@huawei.com,
	yukuai1@huaweicloud.com, yi.zhang@huawei.com,
	yangerkun@huawei.com
Subject: [PATCH md-6.10 7/9] md: replace last_sync_action with new enum type
Date: Thu,  9 May 2024 09:18:58 +0800	[thread overview]
Message-ID: <20240509011900.2694291-8-yukuai1@huaweicloud.com> (raw)
In-Reply-To: <20240509011900.2694291-1-yukuai1@huaweicloud.com>

From: Yu Kuai <yukuai3@huawei.com>

The only difference is that "none" is removed and initial
last_sync_action will be idle.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 drivers/md/dm-raid.c | 2 +-
 drivers/md/md.c      | 7 ++++---
 drivers/md/md.h      | 9 ++++-----
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index abe88d1e6735..052c00c1eb15 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -3542,7 +3542,7 @@ static void raid_status(struct dm_target *ti, status_type_t type,
 		recovery = rs->md.recovery;
 		state = decipher_sync_action(mddev, recovery);
 		progress = rs_get_progress(rs, recovery, state, resync_max_sectors);
-		resync_mismatches = (mddev->last_sync_action && !strcasecmp(mddev->last_sync_action, "check")) ?
+		resync_mismatches = mddev->last_sync_action == ACTION_CHECK ?
 				    atomic64_read(&mddev->resync_mismatches) : 0;
 
 		/* HM FIXME: do we want another state char for raid0? It shows 'D'/'A'/'-' now */
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 0b609d79453a..2fc81175b46b 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -768,7 +768,7 @@ int mddev_init(struct mddev *mddev)
 	init_waitqueue_head(&mddev->recovery_wait);
 	mddev->reshape_position = MaxSector;
 	mddev->reshape_backwards = 0;
-	mddev->last_sync_action = "none";
+	mddev->last_sync_action = ACTION_IDLE;
 	mddev->resync_min = 0;
 	mddev->resync_max = MaxSector;
 	mddev->level = LEVEL_NONE;
@@ -5156,7 +5156,8 @@ __ATTR_PREALLOC(sync_action, S_IRUGO|S_IWUSR, action_show, action_store);
 static ssize_t
 last_sync_action_show(struct mddev *mddev, char *page)
 {
-	return sprintf(page, "%s\n", mddev->last_sync_action);
+	return sprintf(page, "%s\n",
+		       md_sync_action_name(mddev->last_sync_action));
 }
 
 static struct md_sysfs_entry md_last_scan_mode = __ATTR_RO(last_sync_action);
@@ -8977,7 +8978,7 @@ void md_do_sync(struct md_thread *thread)
 
 	action = md_sync_action(mddev);
 	desc = md_sync_action_name(action);
-	mddev->last_sync_action = desc;
+	mddev->last_sync_action = action;
 
 	/*
 	 * Before starting a resync we must have set curr_resync to
diff --git a/drivers/md/md.h b/drivers/md/md.h
index cf54870e89db..883b147a2c52 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -426,13 +426,12 @@ struct mddev {
 	struct md_thread __rcu		*thread;	/* management thread */
 	struct md_thread __rcu		*sync_thread;	/* doing resync or reconstruct */
 
-	/* 'last_sync_action' is initialized to "none".  It is set when a
-	 * sync operation (i.e "data-check", "requested-resync", "resync",
-	 * "recovery", or "reshape") is started.  It holds this value even
+	/*
+	 * Set when a sync operation is started. It holds this value even
 	 * when the sync thread is "frozen" (interrupted) or "idle" (stopped
-	 * or finished).  It is overwritten when a new sync operation is begun.
+	 * or finished). It is overwritten when a new sync operation is begun.
 	 */
-	char				*last_sync_action;
+	enum sync_action		last_sync_action;
 	sector_t			curr_resync;	/* last block scheduled */
 	/* As resync requests can complete out of order, we cannot easily track
 	 * how much resync has been completed.  So we occasionally pause until
-- 
2.39.2


  parent reply	other threads:[~2024-05-09  1:29 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-09  1:18 [PATCH RFC md-6.10 0/9] md: refactor and cleanup for sync action Yu Kuai
2024-05-09  1:18 ` [PATCH md-6.10 1/9] md: rearrange recovery_flage Yu Kuai
2024-05-13 15:12   ` Mariusz Tkaczyk
2024-05-14  1:36     ` Yu Kuai
2024-05-14  5:51   ` Xiao Ni
2024-05-14  6:10     ` Yu Kuai
2024-05-14  6:39       ` Xiao Ni
2024-05-09  1:18 ` [PATCH md-6.10 2/9] md: add a new enum type sync_action Yu Kuai
2024-05-14  6:13   ` Xiao Ni
2024-05-09  1:18 ` [PATCH md-6.10 3/9] md: add new helpers for sync_action Yu Kuai
2024-05-14  6:52   ` Xiao Ni
2024-05-14  7:39     ` Yu Kuai
2024-05-14  8:40       ` Xiao Ni
2024-05-14  8:52         ` Yu Kuai
2024-05-20 11:51   ` Su Yue
2024-05-21  2:30     ` Yu Kuai
2024-05-21  3:25     ` Xiao Ni
2024-05-21  3:50       ` Su Yue
2024-05-09  1:18 ` [PATCH md-6.10 4/9] md: factor out helper to start reshape from action_store() Yu Kuai
2024-05-09  1:18 ` [PATCH md-6.10 5/9] md: replace sysfs api sync_action with new helpers Yu Kuai
2024-05-20 15:01   ` kernel test robot
2024-05-21  2:20     ` Yu Kuai
2024-05-21  3:01       ` Oliver Sang
2024-05-21  3:11         ` Yu Kuai
2024-05-21  3:21         ` Xiao Ni
2024-05-22  2:46           ` Yu Kuai
2024-05-09  1:18 ` [PATCH md-6.10 6/9] md: use new helers in md_do_sync() Yu Kuai
2024-05-09  1:18 ` Yu Kuai [this message]
2024-05-09  1:18 ` [PATCH md-6.10 8/9] md: factor out helpers for different sync_action " Yu Kuai
2024-05-14  7:27   ` Xiao Ni
2024-05-09  1:19 ` [PATCH md-6.10 9/9] md: pass in max_sectors for pers->sync_request() Yu Kuai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240509011900.2694291-8-yukuai1@huaweicloud.com \
    --to=yukuai1@huaweicloud.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@kernel.org \
    --cc=song@kernel.org \
    --cc=xni@redhat.com \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).