md/bitmap: md_bitmap_read_sb uses wrong bitmap blocks
authorZhao Heming <heming.zhao@suse.com>
Mon, 5 Oct 2020 16:00:23 +0000 (00:00 +0800)
committerSong Liu <songliubraving@fb.com>
Fri, 9 Oct 2020 05:31:29 +0000 (22:31 -0700)
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@suse.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
drivers/md/md-bitmap.c

index 55b757a..cd9a12c 100644 (file)
@@ -606,8 +606,8 @@ re_read:
        if (bitmap->cluster_slot >= 0) {
                sector_t bm_blocks = bitmap->mddev->resync_max_sectors;
 
-               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));
                /* bits to bytes */
                bm_blocks = ((bm_blocks+7) >> 3) + sizeof(bitmap_super_t);
                /* to 4k blocks */