[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240826074452.1490072-15-yukuai1@huaweicloud.com>
Date: Mon, 26 Aug 2024 15:44:24 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: mariusz.tkaczyk@...ux.intel.com,
xni@...hat.com,
song@...nel.org
Cc: linux-kernel@...r.kernel.org,
linux-raid@...r.kernel.org,
yukuai3@...wei.com,
yukuai1@...weicloud.com,
yi.zhang@...wei.com,
yangerkun@...wei.com
Subject: [PATCH md-6.12 v2 14/42] md/md-bitmap: merge md_bitmap_load() into bitmap_operations
From: Yu Kuai <yukuai3@...wei.com>
So that the implementation won't be exposed, and it'll be possible
to invent a new bitmap by replacing bitmap_operations.
Signed-off-by: Yu Kuai <yukuai3@...wei.com>
---
drivers/md/dm-raid.c | 4 +++-
drivers/md/md-bitmap.c | 6 +++---
drivers/md/md-bitmap.h | 2 +-
drivers/md/md.c | 7 ++++---
4 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
index 0c3323e0adb2..c3e201fde4c5 100644
--- a/drivers/md/dm-raid.c
+++ b/drivers/md/dm-raid.c
@@ -3949,7 +3949,9 @@ static int __load_dirty_region_bitmap(struct raid_set *rs)
/* Try loading the bitmap unless "raid0", which does not have one */
if (!rs_is_raid0(rs) &&
!test_and_set_bit(RT_FLAG_RS_BITMAP_LOADED, &rs->runtime_flags)) {
- r = md_bitmap_load(&rs->md);
+ struct mddev *mddev = &rs->md;
+
+ r = mddev->bitmap_ops->load(mddev);
if (r)
DMERR("Failed to load bitmap");
}
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index c534382f0b57..c236754df66e 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1977,7 +1977,7 @@ static int bitmap_create(struct mddev *mddev, int slot)
return 0;
}
-int md_bitmap_load(struct mddev *mddev)
+static int bitmap_load(struct mddev *mddev)
{
int err = 0;
sector_t start = 0;
@@ -2033,7 +2033,6 @@ int md_bitmap_load(struct mddev *mddev)
out:
return err;
}
-EXPORT_SYMBOL_GPL(md_bitmap_load);
/* caller need to free returned bitmap with md_bitmap_free() */
struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot)
@@ -2425,7 +2424,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
if (rv)
goto out;
- rv = md_bitmap_load(mddev);
+ rv = bitmap_load(mddev);
if (rv) {
mddev->bitmap_info.offset = 0;
md_bitmap_destroy(mddev);
@@ -2724,6 +2723,7 @@ const struct attribute_group md_bitmap_group = {
static struct bitmap_operations bitmap_ops = {
.create = bitmap_create,
+ .load = bitmap_load,
};
void mddev_set_bitmap_ops(struct mddev *mddev)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index f4c4925102b6..f5b04b61d9e9 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -248,13 +248,13 @@ struct md_bitmap_stats {
struct bitmap_operations {
int (*create)(struct mddev *mddev, int slot);
+ int (*load)(struct mddev *mddev);
};
/* the bitmap API */
void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are used only by md/bitmap */
-int md_bitmap_load(struct mddev *mddev);
void md_bitmap_flush(struct mddev *mddev);
void md_bitmap_destroy(struct mddev *mddev);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index f766f5b8d2d3..ff59826aa192 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6316,7 +6316,8 @@ int do_md_run(struct mddev *mddev)
err = md_run(mddev);
if (err)
goto out;
- err = md_bitmap_load(mddev);
+
+ err = mddev->bitmap_ops->load(mddev);
if (err) {
md_bitmap_destroy(mddev);
goto out;
@@ -7284,7 +7285,7 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
if (fd >= 0) {
err = mddev->bitmap_ops->create(mddev, -1);
if (!err)
- err = md_bitmap_load(mddev);
+ err = mddev->bitmap_ops->load(mddev);
if (err) {
md_bitmap_destroy(mddev);
@@ -7578,7 +7579,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
mddev->bitmap_info.default_space;
rv = mddev->bitmap_ops->create(mddev, -1);
if (!rv)
- rv = md_bitmap_load(mddev);
+ rv = mddev->bitmap_ops->load(mddev);
if (rv)
md_bitmap_destroy(mddev);
--
2.39.2
Powered by blists - more mailing lists