From 11e02718799ed2fc3e283aaa95462570696a3fdf Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 21 Jun 2005 17:17:17 -0700 Subject: [PATCH] --- yaml --- r: 2583 b: refs/heads/master c: bc7f77de2cd81718dd789a2cfe68a7cf1b48f016 h: refs/heads/master i: 2581: 48b4fdda63af415fa5b3d9af684753be62aa7e52 2579: 81c520b8245000f7a7332fdd4cd1f71d478f3304 2575: 3db3459ae159b5e9596ff9c93fac3606feda01a3 v: v3 --- [refs] | 2 +- trunk/drivers/md/bitmap.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index f06b53e646ab..cdcb28890a0c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: d80a138c013f81c1b9383c83983934e34e380a2d +refs/heads/master: bc7f77de2cd81718dd789a2cfe68a7cf1b48f016 diff --git a/trunk/drivers/md/bitmap.c b/trunk/drivers/md/bitmap.c index c43fd031aafe..62fac2b38000 100644 --- a/trunk/drivers/md/bitmap.c +++ b/trunk/drivers/md/bitmap.c @@ -781,7 +781,9 @@ static int bitmap_init_from_disk(struct bitmap *bitmap) "recovery\n", bmname(bitmap)); bytes = (chunks + 7) / 8; - num_pages = (bytes + PAGE_SIZE - 1) / PAGE_SIZE; + + num_pages = (bytes + sizeof(bitmap_super_t) + PAGE_SIZE - 1) / PAGE_SIZE + 1; + if (i_size_read(file->f_mapping->host) < bytes + sizeof(bitmap_super_t)) { printk(KERN_INFO "%s: bitmap file too short %lu < %lu\n", bmname(bitmap), @@ -789,18 +791,16 @@ static int bitmap_init_from_disk(struct bitmap *bitmap) bytes + sizeof(bitmap_super_t)); goto out; } - num_pages++; + + ret = -ENOMEM; + bitmap->filemap = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL); - if (!bitmap->filemap) { - ret = -ENOMEM; + if (!bitmap->filemap) goto out; - } bitmap->filemap_attr = kmalloc(sizeof(long) * num_pages, GFP_KERNEL); - if (!bitmap->filemap_attr) { - ret = -ENOMEM; + if (!bitmap->filemap_attr) goto out; - } memset(bitmap->filemap_attr, 0, sizeof(long) * num_pages);