Skip to content

Commit f05dafb

Browse files
NeilBrowngregkh
authored andcommitted
md/bitmap: disable bitmap_resize for file-backed bitmaps.
commit e8a27f836f165c26f867ece7f31eb5c811692319 upstream. bitmap_resize() does not work for file-backed bitmaps. The buffer_heads are allocated and initialized when the bitmap is read from the file, but resize doesn't read from the file, it loads from the internal bitmap. When it comes time to write the new bitmap, the bh is non-existent and we crash. The common case when growing an array involves making the array larger, and that normally means making the bitmap larger. Doing that inside the kernel is possible, but would need more code. It is probably easier to require people who use file-backed bitmaps to remove them and re-add after a reshape. So this patch disables the resizing of arrays which have file-backed bitmaps. This is better than crashing. Reported-by: Zhilong Liu <zlliu@suse.com> Fixes: d60b479 ("md/bitmap: add bitmap_resize function to allow bitmap resizing.") Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 30e81e7 commit f05dafb

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/md/bitmap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,6 +1960,11 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
19601960
long pages;
19611961
struct bitmap_page *new_bp;
19621962

1963+
if (bitmap->storage.file && !init) {
1964+
pr_info("md: cannot resize file-based bitmap\n");
1965+
return -EINVAL;
1966+
}
1967+
19631968
if (chunksize == 0) {
19641969
/* If there is enough space, leave the chunk size unchanged,
19651970
* else increase by factor of two until there is enough space.

0 commit comments

Comments
 (0)