[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240814071113.346781-15-yukuai1@huaweicloud.com>
Date: Wed, 14 Aug 2024 15:10:46 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: mariusz.tkaczyk@...ux.intel.com,
hch@...radead.org,
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 RFC -next v2 14/41] md/md-bitmap: merge md_bitmap_destroy() 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/md-bitmap.c | 7 ++++---
drivers/md/md-bitmap.h | 2 +-
drivers/md/md.c | 15 ++++++++-------
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index 0113a972e42d..94cf3c6e96e3 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -1853,7 +1853,7 @@ void md_bitmap_wait_behind_writes(struct mddev *mddev)
}
EXPORT_SYMBOL_GPL(md_bitmap_wait_behind_writes);
-void md_bitmap_destroy(struct mddev *mddev)
+static void bitmap_destroy(struct mddev *mddev)
{
struct bitmap *bitmap = mddev->bitmap;
@@ -2381,7 +2381,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
goto out;
}
- md_bitmap_destroy(mddev);
+ bitmap_destroy(mddev);
mddev->bitmap_info.offset = 0;
if (mddev->bitmap_info.file) {
struct file *f = mddev->bitmap_info.file;
@@ -2424,7 +2424,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
rv = bitmap_load(mddev);
if (rv) {
mddev->bitmap_info.offset = 0;
- md_bitmap_destroy(mddev);
+ bitmap_destroy(mddev);
goto out;
}
}
@@ -2721,6 +2721,7 @@ const struct attribute_group md_bitmap_group = {
static struct bitmap_operations bitmap_ops = {
.create = bitmap_create,
.load = bitmap_load,
+ .destroy = bitmap_destroy,
};
void mddev_set_bitmap_ops(struct mddev *mddev)
diff --git a/drivers/md/md-bitmap.h b/drivers/md/md-bitmap.h
index ba912f5f3450..9376bbeb4698 100644
--- a/drivers/md/md-bitmap.h
+++ b/drivers/md/md-bitmap.h
@@ -248,6 +248,7 @@ struct md_bitmap_stats {
struct bitmap_operations {
int (*create)(struct mddev *mddev, int slot);
int (*load)(struct mddev *mddev);
+ void (*destroy)(struct mddev *mddev);
};
/* the bitmap API */
@@ -255,7 +256,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are used only by md/bitmap */
void md_bitmap_flush(struct mddev *mddev);
-void md_bitmap_destroy(struct mddev *mddev);
void md_bitmap_print_sb(struct bitmap *bitmap);
void md_bitmap_update_sb(struct bitmap *bitmap);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 2fe25a6257e6..7aecd99d50e2 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6284,7 +6284,7 @@ int md_run(struct mddev *mddev)
pers->free(mddev, mddev->private);
mddev->private = NULL;
module_put(pers->owner);
- md_bitmap_destroy(mddev);
+ mddev->bitmap_ops->destroy(mddev);
abort:
bioset_exit(&mddev->io_clone_set);
exit_sync_set:
@@ -6306,7 +6306,7 @@ int do_md_run(struct mddev *mddev)
err = mddev->bitmap_ops->load(mddev);
if (err) {
- md_bitmap_destroy(mddev);
+ mddev->bitmap_ops->destroy(mddev);
goto out;
}
@@ -6492,7 +6492,8 @@ static void mddev_detach(struct mddev *mddev)
static void __md_stop(struct mddev *mddev)
{
struct md_personality *pers = mddev->pers;
- md_bitmap_destroy(mddev);
+
+ mddev->bitmap_ops->destroy(mddev);
mddev_detach(mddev);
spin_lock(&mddev->lock);
mddev->pers = NULL;
@@ -7275,11 +7276,11 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
err = mddev->bitmap_ops->load(mddev);
if (err) {
- md_bitmap_destroy(mddev);
+ mddev->bitmap_ops->destroy(mddev);
fd = -1;
}
} else if (fd < 0) {
- md_bitmap_destroy(mddev);
+ mddev->bitmap_ops->destroy(mddev);
}
}
@@ -7569,7 +7570,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
rv = mddev->bitmap_ops->load(mddev);
if (rv)
- md_bitmap_destroy(mddev);
+ mddev->bitmap_ops->destroy(mddev);
} else {
struct md_bitmap_stats stats;
@@ -7596,7 +7597,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
module_put(md_cluster_mod);
mddev->safemode_delay = DEFAULT_SAFEMODE_DELAY;
}
- md_bitmap_destroy(mddev);
+ mddev->bitmap_ops->destroy(mddev);
mddev->bitmap_info.offset = 0;
}
}
--
2.39.2
Powered by blists - more mailing lists