From: Yu Kuai <yukuai1@huaweicloud.com>
To: song@kernel.org, xni@redhat.com, mariusz.tkaczyk@linux.intel.com
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com,
yangerkun@huawei.com
Subject: [PATCH -next v3 1/7] md: use separate work_struct for md_start_sync()
Date: Sun, 20 Aug 2023 17:09:43 +0800 [thread overview]
Message-ID: <20230820090949.2874537-2-yukuai1@huaweicloud.com> (raw)
In-Reply-To: <20230820090949.2874537-1-yukuai1@huaweicloud.com>
From: Yu Kuai <yukuai3@huawei.com>
It's a little weird to borrow 'del_work' for md_start_sync(), declare
a new work_struct 'sync_work' for md_start_sync().
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md.c | 10 ++++++----
drivers/md/md.h | 5 ++++-
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 5c3c19b8d509..90815be1e80f 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -631,13 +631,13 @@ void mddev_put(struct mddev *mddev)
* flush_workqueue() after mddev_find will succeed in waiting
* for the work to be done.
*/
- INIT_WORK(&mddev->del_work, mddev_delayed_delete);
queue_work(md_misc_wq, &mddev->del_work);
}
spin_unlock(&all_mddevs_lock);
}
static void md_safemode_timeout(struct timer_list *t);
+static void md_start_sync(struct work_struct *ws);
void mddev_init(struct mddev *mddev)
{
@@ -662,6 +662,9 @@ void mddev_init(struct mddev *mddev)
mddev->resync_min = 0;
mddev->resync_max = MaxSector;
mddev->level = LEVEL_NONE;
+
+ INIT_WORK(&mddev->sync_work, md_start_sync);
+ INIT_WORK(&mddev->del_work, mddev_delayed_delete);
}
EXPORT_SYMBOL_GPL(mddev_init);
@@ -9245,7 +9248,7 @@ static int remove_and_add_spares(struct mddev *mddev,
static void md_start_sync(struct work_struct *ws)
{
- struct mddev *mddev = container_of(ws, struct mddev, del_work);
+ struct mddev *mddev = container_of(ws, struct mddev, sync_work);
rcu_assign_pointer(mddev->sync_thread,
md_register_thread(md_do_sync, mddev, "resync"));
@@ -9458,8 +9461,7 @@ void md_check_recovery(struct mddev *mddev)
*/
md_bitmap_write_all(mddev->bitmap);
}
- INIT_WORK(&mddev->del_work, md_start_sync);
- queue_work(md_misc_wq, &mddev->del_work);
+ queue_work(md_misc_wq, &mddev->sync_work);
goto unlock;
}
not_running:
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 9bcb77bca963..64d05cb65287 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -450,7 +450,10 @@ struct mddev {
struct kernfs_node *sysfs_degraded; /*handle for 'degraded' */
struct kernfs_node *sysfs_level; /*handle for 'level' */
- struct work_struct del_work; /* used for delayed sysfs removal */
+ /* used for delayed sysfs removal */
+ struct work_struct del_work;
+ /* used for register new sync thread */
+ struct work_struct sync_work;
/* "lock" protects:
* flush_bio transition from NULL to !NULL
--
2.39.2
next prev parent reply other threads:[~2023-08-20 9:17 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-20 9:09 [PATCH -next v3 0/7] md: make rdev addition and removal independent from daemon thread Yu Kuai
2023-08-20 9:09 ` Yu Kuai [this message]
2023-08-22 10:04 ` [PATCH -next v3 1/7] md: use separate work_struct for md_start_sync() Xiao Ni
2023-08-20 9:09 ` [PATCH -next v3 2/7] md: factor out a helper to choose sync action from md_check_recovery() Yu Kuai
2023-08-22 10:04 ` Xiao Ni
2023-08-20 9:09 ` [PATCH -next v3 3/7] md: delay choosing sync action to md_start_sync() Yu Kuai
2023-08-22 10:06 ` Xiao Ni
2023-08-20 9:09 ` [PATCH -next v3 4/7] md: factor out a helper rdev_removeable() from remove_and_add_spares() Yu Kuai
2023-08-22 10:19 ` Xiao Ni
2023-08-23 2:45 ` Yu Kuai
2023-08-23 3:42 ` Xiao Ni
2023-08-20 9:09 ` [PATCH -next v3 5/7] md: factor out a helper rdev_is_spare() " Yu Kuai
2023-08-23 2:20 ` Xiao Ni
2023-08-23 2:28 ` Xiao Ni
2023-08-23 2:47 ` Yu Kuai
2023-08-20 9:09 ` [PATCH -next v3 6/7] md: factor out a helper rdev_addable() " Yu Kuai
2023-08-21 23:22 ` Song Liu
2023-08-22 2:17 ` Yu Kuai
2023-08-23 3:04 ` Yu Kuai
2023-08-23 5:26 ` Song Liu
2023-08-23 8:37 ` Yu Kuai
2023-08-23 11:25 ` Song Liu
2023-08-24 1:16 ` Yu Kuai
2023-08-20 9:09 ` [PATCH -next v3 7/7] md: delay remove_and_add_spares() for read only array to md_start_sync() Yu Kuai
2023-08-23 3:24 ` Xiao Ni
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=20230820090949.2874537-2-yukuai1@huaweicloud.com \
--to=yukuai1@huaweicloud.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=mariusz.tkaczyk@linux.intel.com \
--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 NNTP newsgroup(s).