Commit 3dd9141a authored by Yu Kuai's avatar Yu Kuai Committed by Song Liu

md/md-bitmap: merge md_bitmap_copy_from_slot() into struct bitmap_operation.

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-38-yukuai1@huaweicloud.comSigned-off-by: default avatarSong Liu <song@kernel.org>
parent 57d60241
...@@ -2088,8 +2088,8 @@ static struct bitmap *bitmap_get_from_slot(struct mddev *mddev, int slot) ...@@ -2088,8 +2088,8 @@ static struct bitmap *bitmap_get_from_slot(struct mddev *mddev, int slot)
/* Loads the bitmap associated with slot and copies the resync information /* Loads the bitmap associated with slot and copies the resync information
* to our bitmap * to our bitmap
*/ */
int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, static int bitmap_copy_from_slot(struct mddev *mddev, int slot, sector_t *low,
sector_t *low, sector_t *high, bool clear_bits) sector_t *high, bool clear_bits)
{ {
int rv = 0, i, j; int rv = 0, i, j;
sector_t block, lo = 0, hi = 0; sector_t block, lo = 0, hi = 0;
...@@ -2131,7 +2131,6 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, ...@@ -2131,7 +2131,6 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
return rv; return rv;
} }
EXPORT_SYMBOL_GPL(md_bitmap_copy_from_slot);
void md_bitmap_set_pages(struct bitmap *bitmap, unsigned long pages) void md_bitmap_set_pages(struct bitmap *bitmap, unsigned long pages)
{ {
...@@ -2782,6 +2781,7 @@ static struct bitmap_operations bitmap_ops = { ...@@ -2782,6 +2781,7 @@ static struct bitmap_operations bitmap_ops = {
.sync_with_cluster = bitmap_sync_with_cluster, .sync_with_cluster = bitmap_sync_with_cluster,
.get_from_slot = bitmap_get_from_slot, .get_from_slot = bitmap_get_from_slot,
.copy_from_slot = bitmap_copy_from_slot,
}; };
void mddev_set_bitmap_ops(struct mddev *mddev) void mddev_set_bitmap_ops(struct mddev *mddev)
......
...@@ -277,6 +277,8 @@ struct bitmap_operations { ...@@ -277,6 +277,8 @@ struct bitmap_operations {
sector_t old_lo, sector_t old_hi, sector_t old_lo, sector_t old_hi,
sector_t new_lo, sector_t new_hi); sector_t new_lo, sector_t new_hi);
struct bitmap *(*get_from_slot)(struct mddev *mddev, int slot); struct bitmap *(*get_from_slot)(struct mddev *mddev, int slot);
int (*copy_from_slot)(struct mddev *mddev, int slot, sector_t *lo,
sector_t *hi, bool clear_bits);
}; };
/* the bitmap API */ /* the bitmap API */
...@@ -284,8 +286,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev); ...@@ -284,8 +286,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev);
/* these are exported */ /* these are exported */
int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
sector_t *lo, sector_t *hi, bool clear_bits);
void md_bitmap_set_pages(struct bitmap *bitmap, unsigned long pages); void md_bitmap_set_pages(struct bitmap *bitmap, unsigned long pages);
void md_bitmap_free(struct bitmap *bitmap); void md_bitmap_free(struct bitmap *bitmap);
void md_bitmap_wait_behind_writes(struct mddev *mddev); void md_bitmap_wait_behind_writes(struct mddev *mddev);
......
...@@ -317,7 +317,7 @@ static void recover_bitmaps(struct md_thread *thread) ...@@ -317,7 +317,7 @@ static void recover_bitmaps(struct md_thread *thread)
str, ret); str, ret);
goto clear_bit; goto clear_bit;
} }
ret = md_bitmap_copy_from_slot(mddev, slot, &lo, &hi, true); ret = mddev->bitmap_ops->copy_from_slot(mddev, slot, &lo, &hi, true);
if (ret) { if (ret) {
pr_err("md-cluster: Could not copy data from bitmap %d\n", slot); pr_err("md-cluster: Could not copy data from bitmap %d\n", slot);
goto clear_bit; goto clear_bit;
...@@ -857,7 +857,7 @@ static int gather_all_resync_info(struct mddev *mddev, int total_slots) ...@@ -857,7 +857,7 @@ static int gather_all_resync_info(struct mddev *mddev, int total_slots)
} }
/* Read the disk bitmap sb and check if it needs recovery */ /* Read the disk bitmap sb and check if it needs recovery */
ret = md_bitmap_copy_from_slot(mddev, i, &lo, &hi, false); ret = mddev->bitmap_ops->copy_from_slot(mddev, i, &lo, &hi, false);
if (ret) { if (ret) {
pr_warn("md-cluster: Could not gather bitmaps from slot %d", i); pr_warn("md-cluster: Could not gather bitmaps from slot %d", i);
lockres_free(bm_lockres); lockres_free(bm_lockres);
...@@ -1600,7 +1600,7 @@ static int gather_bitmaps(struct md_rdev *rdev) ...@@ -1600,7 +1600,7 @@ static int gather_bitmaps(struct md_rdev *rdev)
for (sn = 0; sn < mddev->bitmap_info.nodes; sn++) { for (sn = 0; sn < mddev->bitmap_info.nodes; sn++) {
if (sn == (cinfo->slot_number - 1)) if (sn == (cinfo->slot_number - 1))
continue; continue;
err = md_bitmap_copy_from_slot(mddev, sn, &lo, &hi, false); err = mddev->bitmap_ops->copy_from_slot(mddev, sn, &lo, &hi, false);
if (err) { if (err) {
pr_warn("md-cluster: Could not gather bitmaps from slot %d", sn); pr_warn("md-cluster: Could not gather bitmaps from slot %d", sn);
goto out; goto out;
......
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