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

md/md-bitmap: merge md_bitmap_load() 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-15-yukuai1@huaweicloud.comSigned-off-by: default avatarSong Liu <song@kernel.org>
parent 04c80e64
...@@ -3949,7 +3949,9 @@ static int __load_dirty_region_bitmap(struct raid_set *rs) ...@@ -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 */ /* Try loading the bitmap unless "raid0", which does not have one */
if (!rs_is_raid0(rs) && if (!rs_is_raid0(rs) &&
!test_and_set_bit(RT_FLAG_RS_BITMAP_LOADED, &rs->runtime_flags)) { !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) if (r)
DMERR("Failed to load bitmap"); DMERR("Failed to load bitmap");
} }
......
...@@ -1977,7 +1977,7 @@ static int bitmap_create(struct mddev *mddev, int slot) ...@@ -1977,7 +1977,7 @@ static int bitmap_create(struct mddev *mddev, int slot)
return 0; return 0;
} }
int md_bitmap_load(struct mddev *mddev) static int bitmap_load(struct mddev *mddev)
{ {
int err = 0; int err = 0;
sector_t start = 0; sector_t start = 0;
...@@ -2033,7 +2033,6 @@ int md_bitmap_load(struct mddev *mddev) ...@@ -2033,7 +2033,6 @@ int md_bitmap_load(struct mddev *mddev)
out: out:
return err; return err;
} }
EXPORT_SYMBOL_GPL(md_bitmap_load);
/* caller need to free returned bitmap with md_bitmap_free() */ /* caller need to free returned bitmap with md_bitmap_free() */
struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot) 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) ...@@ -2425,7 +2424,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
if (rv) if (rv)
goto out; goto out;
rv = md_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); md_bitmap_destroy(mddev);
...@@ -2724,6 +2723,7 @@ const struct attribute_group md_bitmap_group = { ...@@ -2724,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, .create = bitmap_create,
.load = bitmap_load,
}; };
void mddev_set_bitmap_ops(struct mddev *mddev) void mddev_set_bitmap_ops(struct mddev *mddev)
......
...@@ -248,13 +248,13 @@ struct md_bitmap_stats { ...@@ -248,13 +248,13 @@ 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);
}; };
/* 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_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);
......
...@@ -6316,7 +6316,8 @@ int do_md_run(struct mddev *mddev) ...@@ -6316,7 +6316,8 @@ int do_md_run(struct mddev *mddev)
err = md_run(mddev); err = md_run(mddev);
if (err) if (err)
goto out; goto out;
err = md_bitmap_load(mddev);
err = mddev->bitmap_ops->load(mddev);
if (err) { if (err) {
md_bitmap_destroy(mddev); md_bitmap_destroy(mddev);
goto out; goto out;
...@@ -7284,7 +7285,7 @@ static int set_bitmap_file(struct mddev *mddev, int fd) ...@@ -7284,7 +7285,7 @@ static int set_bitmap_file(struct mddev *mddev, int fd)
if (fd >= 0) { if (fd >= 0) {
err = mddev->bitmap_ops->create(mddev, -1); err = mddev->bitmap_ops->create(mddev, -1);
if (!err) if (!err)
err = md_bitmap_load(mddev); err = mddev->bitmap_ops->load(mddev);
if (err) { if (err) {
md_bitmap_destroy(mddev); md_bitmap_destroy(mddev);
...@@ -7578,7 +7579,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info) ...@@ -7578,7 +7579,7 @@ static int update_array_info(struct mddev *mddev, mdu_array_info_t *info)
mddev->bitmap_info.default_space; mddev->bitmap_info.default_space;
rv = mddev->bitmap_ops->create(mddev, -1); rv = mddev->bitmap_ops->create(mddev, -1);
if (!rv) if (!rv)
rv = md_bitmap_load(mddev); rv = mddev->bitmap_ops->load(mddev);
if (rv) if (rv)
md_bitmap_destroy(mddev); md_bitmap_destroy(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