Commit a2bd7031 authored by Yu Kuai's avatar Yu Kuai Committed by Song Liu

md/md-bitmap: merge md_bitmap_destroy() into bitmap_operations

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: default avatarYu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20240826074452.1490072-16-yukuai1@huaweicloud.comSigned-off-by: default avatarSong Liu <song@kernel.org>
parent e1e49080
...@@ -1853,7 +1853,7 @@ void md_bitmap_wait_behind_writes(struct mddev *mddev) ...@@ -1853,7 +1853,7 @@ void md_bitmap_wait_behind_writes(struct mddev *mddev)
} }
EXPORT_SYMBOL_GPL(md_bitmap_wait_behind_writes); 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; struct bitmap *bitmap = mddev->bitmap;
...@@ -2384,7 +2384,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len) ...@@ -2384,7 +2384,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
goto out; goto out;
} }
md_bitmap_destroy(mddev); bitmap_destroy(mddev);
mddev->bitmap_info.offset = 0; mddev->bitmap_info.offset = 0;
if (mddev->bitmap_info.file) { if (mddev->bitmap_info.file) {
struct file *f = mddev->bitmap_info.file; struct file *f = mddev->bitmap_info.file;
...@@ -2427,7 +2427,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len) ...@@ -2427,7 +2427,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
rv = bitmap_load(mddev); rv = bitmap_load(mddev);
if (rv) { if (rv) {
mddev->bitmap_info.offset = 0; mddev->bitmap_info.offset = 0;
md_bitmap_destroy(mddev); bitmap_destroy(mddev);
goto out; goto out;
} }
} }
...@@ -2724,6 +2724,7 @@ const struct attribute_group md_bitmap_group = { ...@@ -2724,6 +2724,7 @@ const struct attribute_group md_bitmap_group = {
static struct bitmap_operations bitmap_ops = { static struct bitmap_operations bitmap_ops = {
.create = bitmap_create, .create = bitmap_create,
.load = bitmap_load, .load = bitmap_load,
.destroy = bitmap_destroy,
}; };
void mddev_set_bitmap_ops(struct mddev *mddev) void mddev_set_bitmap_ops(struct mddev *mddev)
......
...@@ -249,6 +249,7 @@ struct md_bitmap_stats { ...@@ -249,6 +249,7 @@ struct md_bitmap_stats {
struct bitmap_operations { struct bitmap_operations {
int (*create)(struct mddev *mddev, int slot); int (*create)(struct mddev *mddev, int slot);
int (*load)(struct mddev *mddev); int (*load)(struct mddev *mddev);
void (*destroy)(struct mddev *mddev);
}; };
/* the bitmap API */ /* the bitmap API */
...@@ -256,7 +257,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev); ...@@ -256,7 +257,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are used only by md/bitmap */ /* these are used only by md/bitmap */
void md_bitmap_flush(struct mddev *mddev); 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_print_sb(struct bitmap *bitmap);
void md_bitmap_update_sb(struct bitmap *bitmap); void md_bitmap_update_sb(struct bitmap *bitmap);
......
...@@ -6297,7 +6297,7 @@ int md_run(struct mddev *mddev) ...@@ -6297,7 +6297,7 @@ int md_run(struct mddev *mddev)
pers->free(mddev, mddev->private); pers->free(mddev, mddev->private);
mddev->private = NULL; mddev->private = NULL;
module_put(pers->owner); module_put(pers->owner);
md_bitmap_destroy(mddev); mddev->bitmap_ops->destroy(mddev);
abort: abort:
bioset_exit(&mddev->io_clone_set); bioset_exit(&mddev->io_clone_set);
exit_sync_set: exit_sync_set:
...@@ -6319,7 +6319,7 @@ int do_md_run(struct mddev *mddev) ...@@ -6319,7 +6319,7 @@ int do_md_run(struct mddev *mddev)
err = mddev->bitmap_ops->load(mddev); err = mddev->bitmap_ops->load(mddev);
if (err) { if (err) {
md_bitmap_destroy(mddev); mddev->bitmap_ops->destroy(mddev);
goto out; goto out;
} }
...@@ -6505,7 +6505,8 @@ static void mddev_detach(struct mddev *mddev) ...@@ -6505,7 +6505,8 @@ static void mddev_detach(struct mddev *mddev)
static void __md_stop(struct mddev *mddev) static void __md_stop(struct mddev *mddev)
{ {
struct md_personality *pers = mddev->pers; struct md_personality *pers = mddev->pers;
md_bitmap_destroy(mddev);
mddev->bitmap_ops->destroy(mddev);
mddev_detach(mddev); mddev_detach(mddev);
spin_lock(&mddev->lock); spin_lock(&mddev->lock);
mddev->pers = NULL; mddev->pers = NULL;
...@@ -7288,11 +7289,11 @@ static int set_bitmap_file(struct mddev *mddev, int fd) ...@@ -7288,11 +7289,11 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
err = mddev->bitmap_ops->load(mddev); err = mddev->bitmap_ops->load(mddev);
if (err) { if (err) {
md_bitmap_destroy(mddev); mddev->bitmap_ops->destroy(mddev);
fd = -1; fd = -1;
} }
} else if (fd < 0) { } else if (fd < 0) {
md_bitmap_destroy(mddev); mddev->bitmap_ops->destroy(mddev);
} }
} }
...@@ -7582,7 +7583,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info) ...@@ -7582,7 +7583,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
rv = mddev->bitmap_ops->load(mddev); rv = mddev->bitmap_ops->load(mddev);
if (rv) if (rv)
md_bitmap_destroy(mddev); mddev->bitmap_ops->destroy(mddev);
} else { } else {
struct md_bitmap_stats stats; struct md_bitmap_stats stats;
...@@ -7609,7 +7610,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info) ...@@ -7609,7 +7610,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
module_put(md_cluster_mod); module_put(md_cluster_mod);
mddev->safemode_delay = DEFAULT_SAFEMODE_DELAY; mddev->safemode_delay = DEFAULT_SAFEMODE_DELAY;
} }
md_bitmap_destroy(mddev); mddev->bitmap_ops->destroy(mddev);
mddev->bitmap_info.offset = 0; mddev->bitmap_info.offset = 0;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment