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

md/md-bitmap: merge bitmap_write_all() 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.

Also change the parameter from bitmap to mddev, to avoid access
bitmap outside md-bitmap.c as much as possible.
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20240826074452.1490072-22-yukuai1@huaweicloud.comSigned-off-by: default avatarSong Liu <song@kernel.org>
parent ea076ceb
...@@ -1224,22 +1224,21 @@ static int md_bitmap_init_from_disk(struct bitmap *bitmap, sector_t start) ...@@ -1224,22 +1224,21 @@ static int md_bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
return ret; return ret;
} }
void md_bitmap_write_all(struct bitmap *bitmap) /* just flag bitmap pages as needing to be written. */
static void bitmap_write_all(struct mddev *mddev)
{ {
/* We don't actually write all bitmap blocks here,
* just flag them as needing to be written
*/
int i; int i;
struct bitmap *bitmap = mddev->bitmap;
if (!bitmap || !bitmap->storage.filemap) if (!bitmap || !bitmap->storage.filemap)
return; return;
/* Only one copy, so nothing needed */
if (bitmap->storage.file) if (bitmap->storage.file)
/* Only one copy, so nothing needed */
return; return;
for (i = 0; i < bitmap->storage.file_pages; i++) for (i = 0; i < bitmap->storage.file_pages; i++)
set_page_attr(bitmap, i, set_page_attr(bitmap, i, BITMAP_PAGE_NEEDWRITE);
BITMAP_PAGE_NEEDWRITE);
bitmap->allclean = 0; bitmap->allclean = 0;
} }
...@@ -2720,6 +2719,7 @@ static struct bitmap_operations bitmap_ops = { ...@@ -2720,6 +2719,7 @@ static struct bitmap_operations bitmap_ops = {
.load = bitmap_load, .load = bitmap_load,
.destroy = bitmap_destroy, .destroy = bitmap_destroy,
.flush = bitmap_flush, .flush = bitmap_flush,
.write_all = bitmap_write_all,
.update_sb = bitmap_update_sb, .update_sb = bitmap_update_sb,
.get_stats = bitmap_get_stats, .get_stats = bitmap_get_stats,
......
...@@ -251,6 +251,7 @@ struct bitmap_operations { ...@@ -251,6 +251,7 @@ struct bitmap_operations {
int (*load)(struct mddev *mddev); int (*load)(struct mddev *mddev);
void (*destroy)(struct mddev *mddev); void (*destroy)(struct mddev *mddev);
void (*flush)(struct mddev *mddev); void (*flush)(struct mddev *mddev);
void (*write_all)(struct mddev *mddev);
void (*update_sb)(struct bitmap *bitmap); void (*update_sb)(struct bitmap *bitmap);
int (*get_stats)(struct bitmap *bitmap, struct md_bitmap_stats *stats); int (*get_stats)(struct bitmap *bitmap, struct md_bitmap_stats *stats);
...@@ -261,8 +262,6 @@ void mddev_set_bitmap_ops(struct mddev *mddev); ...@@ -261,8 +262,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_write_all(struct bitmap *bitmap);
void md_bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e); void md_bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e);
/* these are exported */ /* these are exported */
......
...@@ -9544,7 +9544,7 @@ static void md_start_sync(struct work_struct *ws) ...@@ -9544,7 +9544,7 @@ static void md_start_sync(struct work_struct *ws)
* stored on all devices. So make sure all bitmap pages get written. * stored on all devices. So make sure all bitmap pages get written.
*/ */
if (spares) if (spares)
md_bitmap_write_all(mddev->bitmap); mddev->bitmap_ops->write_all(mddev);
name = test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) ? name = test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) ?
"reshape" : "resync"; "reshape" : "resync";
......
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