Commit 9e4481ce authored by Yu Kuai's avatar Yu Kuai Committed by Song Liu

md/md-cluster: use helper md_bitmap_get_stats() to get pages in resize_bitmaps()

Use the existed helper instead of open coding it, avoid dereferencing
bitmap directly to prepare inventing a new bitmap.
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20240826074452.1490072-10-yukuai1@huaweicloud.comSigned-off-by: default avatarSong Liu <song@kernel.org>
parent a0e7744a
...@@ -1143,13 +1143,16 @@ static int update_bitmap_size(struct mddev *mddev, sector_t size) ...@@ -1143,13 +1143,16 @@ static int update_bitmap_size(struct mddev *mddev, sector_t size)
static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsize) static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsize)
{ {
struct bitmap_counts *counts;
char str[64];
struct dlm_lock_resource *bm_lockres;
struct bitmap *bitmap = mddev->bitmap; struct bitmap *bitmap = mddev->bitmap;
unsigned long my_pages = bitmap->counts.pages; struct md_bitmap_stats stats;
unsigned long my_pages;
int i, rv; int i, rv;
rv = md_bitmap_get_stats(bitmap, &stats);
if (rv)
return rv;
my_pages = stats.pages;
/* /*
* We need to ensure all the nodes can grow to a larger * We need to ensure all the nodes can grow to a larger
* bitmap size before make the reshaping. * bitmap size before make the reshaping.
...@@ -1159,6 +1162,10 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz ...@@ -1159,6 +1162,10 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
return rv; return rv;
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 bitmap_counts *counts;
char str[64];
if (i == md_cluster_ops->slot_number(mddev)) if (i == md_cluster_ops->slot_number(mddev))
continue; continue;
...@@ -1170,6 +1177,9 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz ...@@ -1170,6 +1177,9 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
} }
counts = &bitmap->counts; counts = &bitmap->counts;
rv = md_bitmap_get_stats(bitmap, &stats);
if (rv)
goto out;
/* /*
* If we can hold the bitmap lock of one node then * If we can hold the bitmap lock of one node then
* the slot is not occupied, update the pages. * the slot is not occupied, update the pages.
...@@ -1186,7 +1196,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz ...@@ -1186,7 +1196,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
counts->pages = my_pages; counts->pages = my_pages;
lockres_free(bm_lockres); lockres_free(bm_lockres);
if (my_pages != counts->pages) if (my_pages != stats.pages)
/* /*
* Let's revert the bitmap size if one node * Let's revert the bitmap size if one node
* can't resize bitmap * can't resize bitmap
......
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