summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNeilBrown <neilb@cse.unsw.edu.au>2005-06-21 17:17:17 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-21 19:07:44 -0700
commitbc7f77de2cd81718dd789a2cfe68a7cf1b48f016 (patch)
treea338f066db763fbc29cff388c5a443332ca67739 /drivers
parentd80a138c013f81c1b9383c83983934e34e380a2d (diff)
downloadop-kernel-dev-bc7f77de2cd81718dd789a2cfe68a7cf1b48f016.zip
op-kernel-dev-bc7f77de2cd81718dd789a2cfe68a7cf1b48f016.tar.gz
[PATCH] md: minor code rearrangement in bitmap_init_from_disk
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/bitmap.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index c43fd03..62fac2b 100644
--- a/drivers/md/bitmap.c
+++ b/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);
OpenPOWER on IntegriCloud