[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>
This commit is contained in:
NeilBrown 2005-06-21 17:17:17 -07:00 коммит произвёл Linus Torvalds
Родитель d80a138c01
Коммит bc7f77de2c
1 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -781,7 +781,9 @@ static int bitmap_init_from_disk(struct bitmap *bitmap)
"recovery\n", bmname(bitmap)); "recovery\n", bmname(bitmap));
bytes = (chunks + 7) / 8; 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)) { if (i_size_read(file->f_mapping->host) < bytes + sizeof(bitmap_super_t)) {
printk(KERN_INFO "%s: bitmap file too short %lu < %lu\n", printk(KERN_INFO "%s: bitmap file too short %lu < %lu\n",
bmname(bitmap), bmname(bitmap),
@ -789,18 +791,16 @@ static int bitmap_init_from_disk(struct bitmap *bitmap)
bytes + sizeof(bitmap_super_t)); bytes + sizeof(bitmap_super_t));
goto out; goto out;
} }
num_pages++;
bitmap->filemap = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL);
if (!bitmap->filemap) {
ret = -ENOMEM; ret = -ENOMEM;
bitmap->filemap = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL);
if (!bitmap->filemap)
goto out; goto out;
}
bitmap->filemap_attr = kmalloc(sizeof(long) * num_pages, GFP_KERNEL); bitmap->filemap_attr = kmalloc(sizeof(long) * num_pages, GFP_KERNEL);
if (!bitmap->filemap_attr) { if (!bitmap->filemap_attr)
ret = -ENOMEM;
goto out; goto out;
}
memset(bitmap->filemap_attr, 0, sizeof(long) * num_pages); memset(bitmap->filemap_attr, 0, sizeof(long) * num_pages);