Skip to content

Commit 8031c3d

Browse files
committed
md/bitmap: copy correct data for bitmap super
raid5 cache could write bitmap superblock before bitmap superblock is initialized. The bitmap superblock is less than 512B. The current code will only copy the superblock to a new page and write the whole 512B, which will zero the the data after the superblock. Unfortunately the data could include bitmap, which we should preserve. The patch will make superblock read do 4k chunk and we always copy the 4k data to new page, so the superblock write will old data to disk and we don't change the bitmap. Reported-by: Song Liu <[email protected]> Reviewed-by: Song Liu <[email protected]> Cc: [email protected] (4.10+) Signed-off-by: Shaohua Li <[email protected]>
1 parent 143c97c commit 8031c3d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/md/bitmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
625625
err = read_sb_page(bitmap->mddev,
626626
offset,
627627
sb_page,
628-
0, sizeof(bitmap_super_t));
628+
0, PAGE_SIZE);
629629
}
630630
if (err)
631631
return err;
@@ -2118,7 +2118,7 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
21182118
if (store.sb_page && bitmap->storage.sb_page)
21192119
memcpy(page_address(store.sb_page),
21202120
page_address(bitmap->storage.sb_page),
2121-
sizeof(bitmap_super_t));
2121+
PAGE_SIZE);
21222122
bitmap_file_unmap(&bitmap->storage);
21232123
bitmap->storage = store;
21242124

0 commit comments

Comments
 (0)