From: Guoqing Jiang Date: Mon, 2 May 2016 15:50:13 +0000 (-0400) Subject: md-cluster/bitmap: fix wrong calcuation of offset X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=7f86ffed9b5f3f0b1a29108c5e965942b935ec98;p=deliverable%2Flinux.git md-cluster/bitmap: fix wrong calcuation of offset The offset is wrong in bitmap_storage_alloc, we should set it like below in bitmap_init_from_disk(). node_offset = bitmap->cluster_slot * (DIV_ROUND_UP(store->bytes, PAGE_SIZE)); Because 'offset' is only assigned to 'page->index' and that is usually over-written by read_sb_page. So it does not cause problem in general, but it still need to be fixed. Reviewed-by: NeilBrown Signed-off-by: Guoqing Jiang Signed-off-by: Shaohua Li --- diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index ac93d874578a..cf93bb80aff7 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c @@ -759,7 +759,7 @@ static int bitmap_storage_alloc(struct bitmap_storage *store, bytes += sizeof(bitmap_super_t); num_pages = DIV_ROUND_UP(bytes, PAGE_SIZE); - offset = slot_number * (num_pages - 1); + offset = slot_number * num_pages; store->filemap = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL);