Add new patches for the next merge window
[ext4-patch-queue.git] / return-ENOMEM-rather-than-EIO
blobd9b3570c431af05e0e84387af1deab31b8754c54
1 ext4: return ENOMEM rather than EIO when find_###_page() fails
3 From: Younger Liu <younger.liucn@gmail.com>
5 Return ENOMEM rather than EIO when find_get_page() fails in
6 ext4_mb_get_buddy_page_lock() and find_or_create_page() fails in
7 ext4_mb_load_buddy().
9 Signed-off-by: Younger Liu <younger.liucn@gmail.com>
10 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
11 ---
12  fs/ext4/mballoc.c |   16 ++++++++++++----
13  1 file changed, 12 insertions(+), 4 deletions(-)
15 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
16 index a888cac..73ccbb3 100644
17 --- a/fs/ext4/mballoc.c
18 +++ b/fs/ext4/mballoc.c
19 @@ -989,7 +989,7 @@ static int ext4_mb_get_buddy_page_lock(struct super_block *sb,
20         poff = block % blocks_per_page;
21         page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS);
22         if (!page)
23 -               return -EIO;
24 +               return -ENOMEM;
25         BUG_ON(page->mapping != inode->i_mapping);
26         e4b->bd_bitmap_page = page;
27         e4b->bd_bitmap = page_address(page) + (poff * sb->s_blocksize);
28 @@ -1003,7 +1003,7 @@ static int ext4_mb_get_buddy_page_lock(struct super_block *sb,
29         pnum = block / blocks_per_page;
30         page = find_or_create_page(inode->i_mapping, pnum, GFP_NOFS);
31         if (!page)
32 -               return -EIO;
33 +               return -ENOMEM;
34         BUG_ON(page->mapping != inode->i_mapping);
35         e4b->bd_buddy_page = page;
36         return 0;
37 @@ -1168,7 +1168,11 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
38                         unlock_page(page);
39                 }
40         }
41 -       if (page == NULL || !PageUptodate(page)) {
42 +       if (page == NULL) {
43 +               ret = -ENOMEM;
44 +               goto err;
45 +       }
46 +       if (!PageUptodate(page)) {
47                 ret = -EIO;
48                 goto err;
49         }
50 @@ -1197,7 +1201,11 @@ ext4_mb_load_buddy(struct super_block *sb, ext4_group_t group,
51                         unlock_page(page);
52                 }
53         }
54 -       if (page == NULL || !PageUptodate(page)) {
55 +       if (page == NULL) {
56 +               ret = -ENOMEM;
57 +               goto err;
58 +       }
59 +       if (!PageUptodate(page)) {
60                 ret = -EIO;
61                 goto err;
62         }
63 -- 
64 1.7.9.5
67 To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
68 the body of a message to majordomo@vger.kernel.org
69 More majordomo info at  http://vger.kernel.org/majordomo-info.html