Further updates of Documentation/filesystem/ext4.txt
[ext4-patch-queue.git] / ext4-add-error-handling-in-ext4_mb_load_buddy.patch
blobabf2ed72883a36f72e60639a2e98f3da9577efff
1 ext4: add error processing when calling ext4_mb_init_cache in mballoc
3 From: Shen Feng <shen@cn.fujitsu.com>
5 Add error processing for ext4_mb_load_buddy when it calls
6 ext4_mb_init_cache.
8 Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
9 Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
10 Signed-off-by: Mingming Cao <cmm@us.ibm.com>
11 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 ---
13 fs/ext4/mballoc.c | 27 ++++++++++++++++++++-------
14 1 file changed, 20 insertions(+), 7 deletions(-)
16 Index: linux-2.6.26-rc6/fs/ext4/mballoc.c
17 ===================================================================
18 --- linux-2.6.26-rc6.orig/fs/ext4/mballoc.c 2008-06-17 10:43:24.000000000 -0700
19 +++ linux-2.6.26-rc6/fs/ext4/mballoc.c 2008-06-17 10:43:25.000000000 -0700
20 @@ -884,6 +884,7 @@ ext4_mb_load_buddy(struct super_block *s
21 int pnum;
22 int poff;
23 struct page *page;
24 + int ret;
26 mb_debug("load group %lu\n", group);
28 @@ -915,15 +916,21 @@ ext4_mb_load_buddy(struct super_block *s
29 if (page) {
30 BUG_ON(page->mapping != inode->i_mapping);
31 if (!PageUptodate(page)) {
32 - ext4_mb_init_cache(page, NULL);
33 + ret = ext4_mb_init_cache(page, NULL);
34 + if (ret) {
35 + unlock_page(page);
36 + goto err;
37 + }
38 mb_cmp_bitmaps(e4b, page_address(page) +
39 (poff * sb->s_blocksize));
41 unlock_page(page);
44 - if (page == NULL || !PageUptodate(page))
45 + if (page == NULL || !PageUptodate(page)) {
46 + ret = -EIO;
47 goto err;
48 + }
49 e4b->bd_bitmap_page = page;
50 e4b->bd_bitmap = page_address(page) + (poff * sb->s_blocksize);
51 mark_page_accessed(page);
52 @@ -939,14 +946,20 @@ ext4_mb_load_buddy(struct super_block *s
53 page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS);
54 if (page) {
55 BUG_ON(page->mapping != inode->i_mapping);
56 - if (!PageUptodate(page))
57 - ext4_mb_init_cache(page, e4b->bd_bitmap);
59 + if (!PageUptodate(page)) {
60 + ret = ext4_mb_init_cache(page, e4b->bd_bitmap);
61 + if (ret) {
62 + unlock_page(page);
63 + goto err;
64 + }
65 + }
66 unlock_page(page);
69 - if (page == NULL || !PageUptodate(page))
70 + if (page == NULL || !PageUptodate(page)) {
71 + ret = -EIO;
72 goto err;
73 + }
74 e4b->bd_buddy_page = page;
75 e4b->bd_buddy = page_address(page) + (poff * sb->s_blocksize);
76 mark_page_accessed(page);
77 @@ -963,7 +976,7 @@ err:
78 page_cache_release(e4b->bd_buddy_page);
79 e4b->bd_buddy = NULL;
80 e4b->bd_bitmap = NULL;
81 - return -EIO;
82 + return ret;
85 static void ext4_mb_release_desc(struct ext4_buddy *e4b)