very sorry for my mistake. the patch should be change from: ``` - sector_div(bm_blocks, + DIV_ROUND_UP_SECTOR_T(bm_blocks, bitmap->mddev->bitmap_info.chunksize >> 9); ``` to ``` - sector_div(bm_blocks, - bitmap->mddev->bitmap_info.chunksize >> 9); + bm_blocks = DIV_ROUND_UP_SECTOR_T(bm_blocks, + (bitmap->mddev->bitmap_info.chunksize >> 9)); ``` If my patch would be accepted, I will send v2 patch including above lines. On 10/4/20 12:11 AM, Zhao Heming wrote: > The patched code is used to get chunks number, should use > round-up div to replace current sector_div. > The same code is in md_bitmap_resize(): > ``` > chunks = DIV_ROUND_UP_SECTOR_T(blocks, 1 << chunkshift); > ``` > > Signed-off-by: Zhao Heming <heming.zhao@xxxxxxxx> > --- > drivers/md/md-bitmap.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c > index 593fe15..1efd2b4 100644 > --- a/drivers/md/md-bitmap.c > +++ b/drivers/md/md-bitmap.c > @@ -605,7 +605,7 @@ static int md_bitmap_read_sb(struct bitmap *bitmap) > if (bitmap->cluster_slot >= 0) { > sector_t bm_blocks = bitmap->mddev->resync_max_sectors; > > - sector_div(bm_blocks, > + DIV_ROUND_UP_SECTOR_T(bm_blocks, > bitmap->mddev->bitmap_info.chunksize >> 9); > /* bits to bytes */ > bm_blocks = ((bm_blocks+7) >> 3) + sizeof(bitmap_super_t); >