From: Logan Gunthorpe <logang@deltatee.com>
To: linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org,
Song Liu <song@kernel.org>
Cc: Guoqing Jiang <guoqing.jiang@linux.dev>,
Logan Gunthorpe <logang@deltatee.com>
Subject: [PATCH v1 6/7] md/raid5-ppl: Annotate with rcu_dereference_protected()
Date: Thu, 7 Apr 2022 10:57:12 -0600 [thread overview]
Message-ID: <20220407165713.9243-7-logang@deltatee.com> (raw)
In-Reply-To: <20220407165713.9243-1-logang@deltatee.com>
To suppress the last remaining sparse warnings about accessing
rdev, add rcu_dereference_protected calls to a couple places
in raid5-ppl. All of these places are called under raid5_run and
therefore are occurring before the array has started and is thus
safe.
There's no sensible check to do for the second argument of
rcu_dereference_protected() so a comment is added instead.
Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
---
drivers/md/raid5-ppl.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/md/raid5-ppl.c b/drivers/md/raid5-ppl.c
index d3962d92df18..55d065a87b89 100644
--- a/drivers/md/raid5-ppl.c
+++ b/drivers/md/raid5-ppl.c
@@ -883,7 +883,9 @@ static int ppl_recover_entry(struct ppl_log *log, struct ppl_header_entry *e,
(unsigned long long)r_sector, dd_idx,
(unsigned long long)sector);
- rdev = conf->disks[dd_idx].rdev;
+ /* Array has not started so rcu dereference is safe */
+ rdev = rcu_dereference_protected(
+ conf->disks[dd_idx].rdev, 1);
if (!rdev || (!test_bit(In_sync, &rdev->flags) &&
sector >= rdev->recovery_offset)) {
pr_debug("%s:%*s data member disk %d missing\n",
@@ -934,7 +936,10 @@ static int ppl_recover_entry(struct ppl_log *log, struct ppl_header_entry *e,
parity_sector = raid5_compute_sector(conf, r_sector_first + i,
0, &disk, &sh);
BUG_ON(sh.pd_idx != le32_to_cpu(e->parity_disk));
- parity_rdev = conf->disks[sh.pd_idx].rdev;
+
+ /* Array has not started so rcu dereference is safe */
+ parity_rdev = rcu_dereference_protected(
+ conf->disks[sh.pd_idx].rdev, 1);
BUG_ON(parity_rdev->bdev->bd_dev != log->rdev->bdev->bd_dev);
pr_debug("%s:%*s write parity at sector %llu, disk %s\n",
@@ -1404,7 +1409,9 @@ int ppl_init_log(struct r5conf *conf)
for (i = 0; i < ppl_conf->count; i++) {
struct ppl_log *log = &ppl_conf->child_logs[i];
- struct md_rdev *rdev = conf->disks[i].rdev;
+ /* Array has not started so rcu dereference is safe */
+ struct md_rdev *rdev =
+ rcu_dereference_protected(conf->disks[i].rdev, 1);
mutex_init(&log->io_mutex);
spin_lock_init(&log->io_list_lock);
--
2.30.2
next prev parent reply other threads:[~2022-04-07 17:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-07 16:57 [PATCH v1 0/7] Minor Raid5 Fixes and Cleanup Logan Gunthorpe
2022-04-07 16:57 ` [PATCH v1 1/7] md/raid5: Cleanup setup_conf() error returns Logan Gunthorpe
2022-04-08 6:06 ` Christoph Hellwig
2022-04-07 16:57 ` [PATCH v1 2/7] md/raid5: Un-nest struct raid5_percpu definition Logan Gunthorpe
2022-04-08 6:06 ` Christoph Hellwig
2022-04-07 16:57 ` [PATCH v1 3/7] md/raid5: Add __rcu annotation to struct disk_info Logan Gunthorpe
2022-04-08 6:06 ` Christoph Hellwig
2022-04-07 16:57 ` [PATCH v1 4/7] md/raid5: Annotate rdev/replacement accesses when nr_pending is elevated Logan Gunthorpe
2022-04-08 6:07 ` Christoph Hellwig
2022-04-07 16:57 ` [PATCH v1 5/7] md/raid5: Annotate rdev/replacement access when mddev_lock is held Logan Gunthorpe
2022-04-08 6:07 ` Christoph Hellwig
2022-04-07 16:57 ` Logan Gunthorpe [this message]
2022-04-08 6:08 ` [PATCH v1 6/7] md/raid5-ppl: Annotate with rcu_dereference_protected() Christoph Hellwig
2022-04-07 16:57 ` [PATCH v1 7/7] md/raid5: Annotate functions that hold device_lock with __must_hold Logan Gunthorpe
2022-04-08 6:08 ` Christoph Hellwig
2022-04-08 17:18 ` [PATCH v1 0/7] Minor Raid5 Fixes and Cleanup Song Liu
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=20220407165713.9243-7-logang@deltatee.com \
--to=logang@deltatee.com \
--cc=guoqing.jiang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®