Commit 27832ad3 authored by Yu Kuai's avatar Yu Kuai Committed by Song Liu

md/md-bitmap: add a new helper md_bitmap_set_pages()

Currently md-cluster will set bitmap->counts.pages directly, add a
helper to do this to avoid dereferencing bitmap directly.

Noted that after this patch bitmap is not dereferenced directly anymore
and following patches will move the structure inside md-bitmap.c.
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20240826074452.1490072-11-yukuai1@huaweicloud.comSigned-off-by: default avatarSong Liu <song@kernel.org>
parent 9e4481ce
...@@ -2094,6 +2094,12 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, ...@@ -2094,6 +2094,12 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
} }
EXPORT_SYMBOL_GPL(md_bitmap_copy_from_slot); EXPORT_SYMBOL_GPL(md_bitmap_copy_from_slot);
void md_bitmap_set_pages(struct bitmap *bitmap, unsigned long pages)
{
bitmap->counts.pages = pages;
}
EXPORT_SYMBOL_GPL(md_bitmap_set_pages);
int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats) int md_bitmap_get_stats(struct bitmap *bitmap, struct md_bitmap_stats *stats)
{ {
struct bitmap_storage *storage; struct bitmap_storage *storage;
......
...@@ -285,6 +285,7 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks, ...@@ -285,6 +285,7 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot); struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot);
int md_bitmap_copy_from_slot(struct mddev *mddev, int slot, int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
sector_t *lo, sector_t *hi, bool clear_bits); sector_t *lo, sector_t *hi, bool clear_bits);
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);
......
...@@ -1163,7 +1163,6 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz ...@@ -1163,7 +1163,6 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
for (i = 0; i < mddev->bitmap_info.nodes; i++) { for (i = 0; i < mddev->bitmap_info.nodes; i++) {
struct dlm_lock_resource *bm_lockres; struct dlm_lock_resource *bm_lockres;
struct bitmap_counts *counts;
char str[64]; char str[64];
if (i == md_cluster_ops->slot_number(mddev)) if (i == md_cluster_ops->slot_number(mddev))
...@@ -1175,7 +1174,6 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz ...@@ -1175,7 +1174,6 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
bitmap = NULL; bitmap = NULL;
goto out; goto out;
} }
counts = &bitmap->counts;
rv = md_bitmap_get_stats(bitmap, &stats); rv = md_bitmap_get_stats(bitmap, &stats);
if (rv) if (rv)
...@@ -1193,7 +1191,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz ...@@ -1193,7 +1191,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
bm_lockres->flags |= DLM_LKF_NOQUEUE; bm_lockres->flags |= DLM_LKF_NOQUEUE;
rv = dlm_lock_sync(bm_lockres, DLM_LOCK_PW); rv = dlm_lock_sync(bm_lockres, DLM_LOCK_PW);
if (!rv) if (!rv)
counts->pages = my_pages; md_bitmap_set_pages(bitmap, my_pages);
lockres_free(bm_lockres); lockres_free(bm_lockres);
if (my_pages != stats.pages) if (my_pages != stats.pages)
......
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