[PATCH v2 03/17] md/raid5-cache: Refactor r5l_start() to take a struct r5conf

From: Logan Gunthorpe
Date: Thu May 26 2022 - 12:36:40 EST


All calls to r5l_start() have to dereference conf to get the
log. The log pointer should be protected by RCU, but isn't. Push
the dereference of conf->log into r5l_start() to reduce
the number of sites that dereference conf->log so this can be improved.

No functional changes intended.

Signed-off-by: Logan Gunthorpe <logang@xxxxxxxxxxxx>
Reviewed-by: Christoph Hellwig <hch@xxxxxx>
---
drivers/md/raid5-cache.c | 9 +++------
drivers/md/raid5-log.h | 2 +-
drivers/md/raid5.c | 4 ++--
3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index 96f51ce9b6c1..7c5dc45b1ea8 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -3034,20 +3034,17 @@ static int r5l_load_log(struct r5l_log *log)
return ret;
}

-int r5l_start(struct r5l_log *log)
+int r5l_start(struct r5conf *conf)
{
+ struct r5l_log *log = conf->log;
int ret;

if (!log)
return 0;

ret = r5l_load_log(log);
- if (ret) {
- struct mddev *mddev = log->rdev->mddev;
- struct r5conf *conf = mddev->private;
-
+ if (ret)
r5l_exit_log(conf);
- }
return ret;
}

diff --git a/drivers/md/raid5-log.h b/drivers/md/raid5-log.h
index 720e164e4d4d..db4c1262b380 100644
--- a/drivers/md/raid5-log.h
+++ b/drivers/md/raid5-log.h
@@ -29,7 +29,7 @@ void r5c_check_cached_full_stripe(struct r5conf *conf);
extern struct md_sysfs_entry r5c_journal_mode;
void r5c_update_on_rdev_error(struct mddev *mddev, struct md_rdev *rdev);
bool r5c_big_stripe_cached(struct r5conf *conf, sector_t sect);
-int r5l_start(struct r5l_log *log);
+int r5l_start(struct r5conf *conf);

struct dma_async_tx_descriptor *
ops_run_partial_parity(struct stripe_head *sh, struct raid5_percpu *percpu,
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 458d88faf2e9..83911affcd88 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -8040,7 +8040,7 @@ static int raid5_add_disk(struct mddev *mddev, struct md_rdev *rdev)
if (ret)
return ret;

- ret = r5l_start(conf->log);
+ ret = r5l_start(conf);
if (ret)
return ret;

@@ -8743,7 +8743,7 @@ static int raid5_start(struct mddev *mddev)
{
struct r5conf *conf = mddev->private;

- return r5l_start(conf->log);
+ return r5l_start(conf);
}

static struct md_personality raid6_personality =
--
2.30.2