Commit 04c80e64 authored by Yu Kuai's avatar Yu Kuai Committed by Song Liu

md/md-bitmap: merge md_bitmap_create() 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-14-yukuai1@huaweicloud.comSigned-off-by: default avatarSong Liu <song@kernel.org>
parent 7545d385
...@@ -1966,7 +1966,7 @@ static struct bitmap *__bitmap_create(struct mddev *mddev, int slot) ...@@ -1966,7 +1966,7 @@ static struct bitmap *__bitmap_create(struct mddev *mddev, int slot)
return ERR_PTR(err); return ERR_PTR(err);
} }
int md_bitmap_create(struct mddev *mddev, int slot) static int bitmap_create(struct mddev *mddev, int slot)
{ {
struct bitmap *bitmap = __bitmap_create(mddev, slot); struct bitmap *bitmap = __bitmap_create(mddev, slot);
...@@ -2421,7 +2421,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len) ...@@ -2421,7 +2421,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
} }
mddev->bitmap_info.offset = offset; mddev->bitmap_info.offset = offset;
rv = md_bitmap_create(mddev, -1); rv = bitmap_create(mddev, -1);
if (rv) if (rv)
goto out; goto out;
...@@ -2723,6 +2723,7 @@ const struct attribute_group md_bitmap_group = { ...@@ -2723,6 +2723,7 @@ const struct attribute_group md_bitmap_group = {
}; };
static struct bitmap_operations bitmap_ops = { static struct bitmap_operations bitmap_ops = {
.create = bitmap_create,
}; };
void mddev_set_bitmap_ops(struct mddev *mddev) void mddev_set_bitmap_ops(struct mddev *mddev)
......
...@@ -247,13 +247,13 @@ struct md_bitmap_stats { ...@@ -247,13 +247,13 @@ struct md_bitmap_stats {
}; };
struct bitmap_operations { struct bitmap_operations {
int (*create)(struct mddev *mddev, int slot);
}; };
/* the bitmap API */ /* the bitmap API */
void mddev_set_bitmap_ops(struct mddev *mddev); void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are used only by md/bitmap */ /* these are used only by md/bitmap */
int md_bitmap_create(struct mddev *mddev, int slot);
int md_bitmap_load(struct mddev *mddev); int md_bitmap_load(struct mddev *mddev);
void md_bitmap_flush(struct mddev *mddev); void md_bitmap_flush(struct mddev *mddev);
void md_bitmap_destroy(struct mddev *mddev); void md_bitmap_destroy(struct mddev *mddev);
......
...@@ -6224,7 +6224,7 @@ int md_run(struct mddev *mddev) ...@@ -6224,7 +6224,7 @@ int md_run(struct mddev *mddev)
} }
if (err == 0 && pers->sync_request && if (err == 0 && pers->sync_request &&
(mddev->bitmap_info.file || mddev->bitmap_info.offset)) { (mddev->bitmap_info.file || mddev->bitmap_info.offset)) {
err = md_bitmap_create(mddev, -1); err = mddev->bitmap_ops->create(mddev, -1);
if (err) if (err)
pr_warn("%s: failed to create bitmap (%d)\n", pr_warn("%s: failed to create bitmap (%d)\n",
mdname(mddev), err); mdname(mddev), err);
...@@ -7282,7 +7282,7 @@ static int set_bitmap_file(struct mddev *mddev, int fd) ...@@ -7282,7 +7282,7 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
err = 0; err = 0;
if (mddev->pers) { if (mddev->pers) {
if (fd >= 0) { if (fd >= 0) {
err = md_bitmap_create(mddev, -1); err = mddev->bitmap_ops->create(mddev, -1);
if (!err) if (!err)
err = md_bitmap_load(mddev); err = md_bitmap_load(mddev);
...@@ -7576,7 +7576,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info) ...@@ -7576,7 +7576,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
mddev->bitmap_info.default_offset; mddev->bitmap_info.default_offset;
mddev->bitmap_info.space = mddev->bitmap_info.space =
mddev->bitmap_info.default_space; mddev->bitmap_info.default_space;
rv = md_bitmap_create(mddev, -1); rv = mddev->bitmap_ops->create(mddev, -1);
if (!rv) if (!rv)
rv = md_bitmap_load(mddev); rv = md_bitmap_load(mddev);
......
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