All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Song Liu <song@kernel.org>
Cc: Logan Gunthorpe <logang@deltatee.com>,
	linux-raid@vger.kernel.org, linux-block@vger.kernel.org
Subject: [PATCH 5/9] md: stop using for_each_mddev in md_do_sync
Date: Wed, 13 Jul 2022 13:31:21 +0200	[thread overview]
Message-ID: <20220713113125.2232975-6-hch@lst.de> (raw)
In-Reply-To: <20220713113125.2232975-1-hch@lst.de>

Just do a plain list_for_each that only grabs a mddev reference in
the case where the thread sleeps and restarts the list iteration.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/md.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 5346135ab51c8..a2c2e45cb4c18 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -8726,7 +8726,6 @@ void md_do_sync(struct md_thread *thread)
 	unsigned long update_time;
 	sector_t mark_cnt[SYNC_MARKS];
 	int last_mark,m;
-	struct list_head *tmp;
 	sector_t last_check;
 	int skipped = 0;
 	struct md_rdev *rdev;
@@ -8790,7 +8789,8 @@ void md_do_sync(struct md_thread *thread)
 	try_again:
 		if (test_bit(MD_RECOVERY_INTR, &mddev->recovery))
 			goto skip;
-		for_each_mddev(mddev2, tmp) {
+		spin_lock(&all_mddevs_lock);
+		list_for_each_entry(mddev2, &all_mddevs, all_mddevs) {
 			if (mddev2 == mddev)
 				continue;
 			if (!mddev->parallel_resync
@@ -8822,7 +8822,8 @@ void md_do_sync(struct md_thread *thread)
 							desc, mdname(mddev),
 							mdname(mddev2));
 					}
-					mddev_put(mddev2);
+					spin_unlock(&all_mddevs_lock);
+
 					if (signal_pending(current))
 						flush_signals(current);
 					schedule();
@@ -8832,6 +8833,7 @@ void md_do_sync(struct md_thread *thread)
 				finish_wait(&resync_wait, &wq);
 			}
 		}
+		spin_unlock(&all_mddevs_lock);
 	} while (mddev->curr_resync < MD_RESYNC_DELAYED);
 
 	j = 0;
-- 
2.30.2


  parent reply	other threads:[~2022-07-13 11:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-13 11:31 fix md disk_name lifetime problems v2 Christoph Hellwig
2022-07-13 11:31 ` [PATCH 1/9] md: fix error handling in md_alloc Christoph Hellwig
2022-07-13 15:26   ` Logan Gunthorpe
2022-07-13 16:31     ` Logan Gunthorpe
2022-07-13 11:31 ` [PATCH 2/9] md: implement ->free_disk Christoph Hellwig
2022-07-13 11:31 ` [PATCH 3/9] md: rename md_free to md_kobj_release Christoph Hellwig
2022-07-15  9:00   ` Guoqing Jiang
2022-07-13 11:31 ` [PATCH 4/9] md: factor out the rdev overlaps check from rdev_size_store Christoph Hellwig
2022-07-15  9:01   ` Guoqing Jiang
2022-07-13 11:31 ` Christoph Hellwig [this message]
2022-07-13 11:31 ` [PATCH 6/9] md: stop using for_each_mddev in md_notify_reboot Christoph Hellwig
2022-07-15  9:02   ` Guoqing Jiang
2022-07-13 11:31 ` [PATCH 7/9] md: stop using for_each_mddev in md_exit Christoph Hellwig
2022-07-13 11:31 ` [PATCH 8/9] md: only delete entries from all_mddevs when the disk is freed Christoph Hellwig
2022-07-15  9:03   ` Guoqing Jiang
2022-07-13 11:31 ` [PATCH 9/9] md: simplify md_open Christoph Hellwig

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=20220713113125.2232975-6-hch@lst.de \
    --to=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=logang@deltatee.com \
    --cc=song@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.