mirror of https://gitee.com/openkylin/linux.git
ext4: add error processing when calling ext4_mb_init_cache in mballoc
Add error processing for ext4_mb_load_buddy when it calls ext4_mb_init_cache. Signed-off-by: Shen Feng <shen@cn.fujitsu.com> Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> Signed-off-by: Mingming Cao <cmm@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit is contained in:
parent
31b481dc7c
commit
fdf6c7a768
|
@ -890,6 +890,7 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
|
||||||
int pnum;
|
int pnum;
|
||||||
int poff;
|
int poff;
|
||||||
struct page *page;
|
struct page *page;
|
||||||
|
int ret;
|
||||||
|
|
||||||
mb_debug("load group %lu\n", group);
|
mb_debug("load group %lu\n", group);
|
||||||
|
|
||||||
|
@ -921,15 +922,21 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
|
||||||
if (page) {
|
if (page) {
|
||||||
BUG_ON(page->mapping != inode->i_mapping);
|
BUG_ON(page->mapping != inode->i_mapping);
|
||||||
if (!PageUptodate(page)) {
|
if (!PageUptodate(page)) {
|
||||||
ext4_mb_init_cache(page, NULL);
|
ret = ext4_mb_init_cache(page, NULL);
|
||||||
|
if (ret) {
|
||||||
|
unlock_page(page);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
mb_cmp_bitmaps(e4b, page_address(page) +
|
mb_cmp_bitmaps(e4b, page_address(page) +
|
||||||
(poff * sb->s_blocksize));
|
(poff * sb->s_blocksize));
|
||||||
}
|
}
|
||||||
unlock_page(page);
|
unlock_page(page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (page == NULL || !PageUptodate(page))
|
if (page == NULL || !PageUptodate(page)) {
|
||||||
|
ret = -EIO;
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
e4b->bd_bitmap_page = page;
|
e4b->bd_bitmap_page = page;
|
||||||
e4b->bd_bitmap = page_address(page) + (poff * sb->s_blocksize);
|
e4b->bd_bitmap = page_address(page) + (poff * sb->s_blocksize);
|
||||||
mark_page_accessed(page);
|
mark_page_accessed(page);
|
||||||
|
@ -945,14 +952,20 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
|
||||||
page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS);
|
page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS);
|
||||||
if (page) {
|
if (page) {
|
||||||
BUG_ON(page->mapping != inode->i_mapping);
|
BUG_ON(page->mapping != inode->i_mapping);
|
||||||
if (!PageUptodate(page))
|
if (!PageUptodate(page)) {
|
||||||
ext4_mb_init_cache(page, e4b->bd_bitmap);
|
ret = ext4_mb_init_cache(page, e4b->bd_bitmap);
|
||||||
|
if (ret) {
|
||||||
|
unlock_page(page);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
}
|
||||||
unlock_page(page);
|
unlock_page(page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (page == NULL || !PageUptodate(page))
|
if (page == NULL || !PageUptodate(page)) {
|
||||||
|
ret = -EIO;
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
e4b->bd_buddy_page = page;
|
e4b->bd_buddy_page = page;
|
||||||
e4b->bd_buddy = page_address(page) + (poff * sb->s_blocksize);
|
e4b->bd_buddy = page_address(page) + (poff * sb->s_blocksize);
|
||||||
mark_page_accessed(page);
|
mark_page_accessed(page);
|
||||||
|
@ -969,7 +982,7 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
|
||||||
page_cache_release(e4b->bd_buddy_page);
|
page_cache_release(e4b->bd_buddy_page);
|
||||||
e4b->bd_buddy = NULL;
|
e4b->bd_buddy = NULL;
|
||||||
e4b->bd_bitmap = NULL;
|
e4b->bd_bitmap = NULL;
|
||||||
return -EIO;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ext4_mb_release_desc(struct ext4_buddy *e4b)
|
static void ext4_mb_release_desc(struct ext4_buddy *e4b)
|
||||||
|
|
Loading…
Reference in New Issue