linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Logan Gunthorpe <logang@deltatee.com>
To: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org,
	Song Liu <song@kernel.org>
Cc: Christoph Hellwig <hch@infradead.org>,
	Donald Buczek <buczek@molgen.mpg.de>,
	Guoqing Jiang <guoqing.jiang@linux.dev>, Xiao Ni <xni@redhat.com>,
	Stephen Bates <sbates@raithlin.com>,
	Martin Oliveira <Martin.Oliveira@eideticom.com>,
	David Sloan <David.Sloan@eideticom.com>,
	Logan Gunthorpe <logang@deltatee.com>
Subject: [PATCH v3 05/11] md/raid5-cache: Drop RCU usage of conf->log
Date: Thu,  2 Jun 2022 12:18:11 -0600	[thread overview]
Message-ID: <20220602181818.50729-6-logang@deltatee.com> (raw)
In-Reply-To: <20220602181818.50729-1-logang@deltatee.com>

The only place that uses RCU to access conf->log is in
r5l_log_disk_error(). This function is mostly used in the IO path
and once with mddev_lock() held in raid5_change_consistency_policy().

It is known that the IO will be suspended before the log is freed and
r5l_log_exit() is called with the mddev_lock() held.

This should mean that conf->log can not be freed while the function is
being called, so the RCU protection is not necessary. Drop the
rcu_read_lock() as well as the synchronize_rcu() and
rcu_assign_pointer() usage.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
---
 drivers/md/raid5-cache.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index 69b95005abca..48020d36b334 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -1590,18 +1590,13 @@ void r5l_quiesce(struct r5l_log *log, int quiesce)
 
 bool r5l_log_disk_error(struct r5conf *conf)
 {
-	struct r5l_log *log;
-	bool ret;
-	/* don't allow write if journal disk is missing */
-	rcu_read_lock();
-	log = rcu_dereference(conf->log);
+	struct r5l_log *log = conf->log;
 
+	/* don't allow write if journal disk is missing */
 	if (!log)
-		ret = test_bit(MD_HAS_JOURNAL, &conf->mddev->flags);
+		return test_bit(MD_HAS_JOURNAL, &conf->mddev->flags);
 	else
-		ret = test_bit(Faulty, &log->rdev->flags);
-	rcu_read_unlock();
-	return ret;
+		return test_bit(Faulty, &log->rdev->flags);
 }
 
 #define R5L_RECOVERY_PAGE_POOL_SIZE 256
@@ -3148,7 +3143,7 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev)
 	spin_lock_init(&log->stripe_in_journal_lock);
 	atomic_set(&log->stripe_in_journal_count, 0);
 
-	rcu_assign_pointer(conf->log, log);
+	conf->log = log;
 
 	set_bit(MD_HAS_JOURNAL, &conf->mddev->flags);
 	return 0;
@@ -3173,7 +3168,6 @@ void r5l_exit_log(struct r5conf *conf)
 	lockdep_assert_held(&conf->mddev->reconfig_mutex);
 
 	conf->log = NULL;
-	synchronize_rcu();
 
 	/* Ensure disable_writeback_work wakes up and exits */
 	wake_up(&conf->mddev->sb_wait);
-- 
2.30.2


  parent reply	other threads:[~2022-06-02 18:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-02 18:18 [PATCH v3 00/11] Bug fixes for mdadm tests Logan Gunthorpe
2022-06-02 18:18 ` [PATCH v3 01/11] md/raid5-log: Drop extern decorators for function prototypes Logan Gunthorpe
2022-06-02 18:18 ` [PATCH v3 02/11] md/raid5-ppl: Drop unused argument from ppl_handle_flush_request() Logan Gunthorpe
2022-06-02 18:18 ` [PATCH v3 03/11] md/raid5: Ensure array is suspended for calls to log_exit() Logan Gunthorpe
2022-06-02 18:18 ` [PATCH v3 04/11] md/raid5-cache: Take mddev_lock in r5c_journal_mode_show() Logan Gunthorpe
2022-06-03  6:39   ` Christoph Hellwig
2022-06-03 21:47     ` Logan Gunthorpe
2022-06-02 18:18 ` Logan Gunthorpe [this message]
2022-06-03  6:43   ` [PATCH v3 05/11] md/raid5-cache: Drop RCU usage of conf->log Christoph Hellwig
2022-06-02 18:18 ` [PATCH v3 06/11] md/raid5-cache: Clear conf->log after finishing work Logan Gunthorpe
2022-06-03  6:43   ` Christoph Hellwig
2022-06-02 18:18 ` [PATCH v3 07/11] md/raid5-cache: Annotate pslot with __rcu notation Logan Gunthorpe
2022-06-02 18:18 ` [PATCH v3 08/11] md: Use enum for overloaded magic numbers used by mddev->curr_resync Logan Gunthorpe
2022-06-02 18:18 ` [PATCH v3 09/11] md: Ensure resync is reported after it starts Logan Gunthorpe
2022-06-02 18:18 ` [PATCH v3 10/11] md: Notify sysfs sync_completed in md_reap_sync_thread() Logan Gunthorpe
2022-06-02 18:18 ` [PATCH v3 11/11] md/raid5-ppl: Fix argument order in bio_alloc_bioset() Logan Gunthorpe
2022-06-03  6:45   ` 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=20220602181818.50729-6-logang@deltatee.com \
    --to=logang@deltatee.com \
    --cc=David.Sloan@eideticom.com \
    --cc=Martin.Oliveira@eideticom.com \
    --cc=buczek@molgen.mpg.de \
    --cc=guoqing.jiang@linux.dev \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=sbates@raithlin.com \
    --cc=song@kernel.org \
    --cc=xni@redhat.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).