2023-09-27 06:31:04

by Yu Kuai

[permalink] [raw]
Subject: [PATCH v3 0/2] md: simplify md_seq_ops

From: Yu Kuai <[email protected]>

Changes in v3:
- rework patch 1, because the condition is confusing

Changes in v2:
- don't hold lock while show mddev in md_seq_show
- add patch 1
- add commit message

Yu Kuai (2):
md: factor out a helper from mddev_put()
md: simplify md_seq_ops

drivers/md/md.c | 129 +++++++++++++++---------------------------------
1 file changed, 39 insertions(+), 90 deletions(-)

--
2.39.2


2023-09-27 06:31:09

by Yu Kuai

[permalink] [raw]
Subject: [PATCH v3 1/2] md: factor out a helper from mddev_put()

From: Yu Kuai <[email protected]>

There are no functional changes, prepare to simplify md_seq_ops in next
patch.

Signed-off-by: Yu Kuai <[email protected]>
---
drivers/md/md.c | 29 +++++++++++++++++------------
1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 10cb4dfbf4ae..73782cafad4e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -616,23 +616,28 @@ static inline struct mddev *mddev_get(struct mddev *mddev)

static void mddev_delayed_delete(struct work_struct *ws);

+static void __mddev_put(struct mddev *mddev)
+{
+ if (mddev->raid_disks || !list_empty(&mddev->disks) ||
+ mddev->ctime || mddev->hold_active)
+ return;
+
+ /* Array is not configured at all, and not held active, so destroy it */
+ set_bit(MD_DELETED, &mddev->flags);
+
+ /*
+ * Call queue_work inside the spinlock so that flush_workqueue() after
+ * mddev_find will succeed in waiting for the work to be done.
+ */
+ queue_work(md_misc_wq, &mddev->del_work);
+}
+
void mddev_put(struct mddev *mddev)
{
if (!atomic_dec_and_lock(&mddev->active, &all_mddevs_lock))
return;
- if (!mddev->raid_disks && list_empty(&mddev->disks) &&
- mddev->ctime == 0 && !mddev->hold_active) {
- /* Array is not configured at all, and not held active,
- * so destroy it */
- set_bit(MD_DELETED, &mddev->flags);

- /*
- * Call queue_work inside the spinlock so that
- * flush_workqueue() after mddev_find will succeed in waiting
- * for the work to be done.
- */
- queue_work(md_misc_wq, &mddev->del_work);
- }
+ __mddev_put(mddev);
spin_unlock(&all_mddevs_lock);
}

--
2.39.2

2023-09-28 06:56:46

by Song Liu

[permalink] [raw]
Subject: Re: [PATCH v3 0/2] md: simplify md_seq_ops

On Tue, Sep 26, 2023 at 11:19 PM Yu Kuai <[email protected]> wrote:
>
> From: Yu Kuai <[email protected]>
>
> Changes in v3:
> - rework patch 1, because the condition is confusing
>
> Changes in v2:
> - don't hold lock while show mddev in md_seq_show
> - add patch 1
> - add commit message

Applied to md-next. Thanks!

Song

>
> Yu Kuai (2):
> md: factor out a helper from mddev_put()
> md: simplify md_seq_ops
>
> drivers/md/md.c | 129 +++++++++++++++---------------------------------
> 1 file changed, 39 insertions(+), 90 deletions(-)
>
> --
> 2.39.2
>