add jbd2 speedup patches
[ext4-patch-queue.git] / fix-error-return-from-ext4_ext_handle_uninitialized_extents
blob27e6af348bfb1d4d5cd231f8dc5f17cf1f78b95c
1 ext4: fix error return from ext4_ext_handle_uninitialized_extents()
3 From: Eric Whitney <enwlinux@gmail.com>
5 Commit 3779473246 breaks the return of error codes from
6 ext4_ext_handle_uninitialized_extents() in ext4_ext_map_blocks().  A
7 portion of the patch assigns that function's signed integer return
8 value to an unsigned int.  Consequently, negatively valued error codes
9 are lost and can be treated as a bogus allocated block count.
11 Signed-off-by: Eric Whitney <enwlinux@gmail.com>
12 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
13 Cc: stable@vger.kernel.org
14 ---
15  fs/ext4/extents.c | 8 ++++++--
16  1 file changed, 6 insertions(+), 2 deletions(-)
18 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
19 index 74bc2d5..9875fd0 100644
20 --- a/fs/ext4/extents.c
21 +++ b/fs/ext4/extents.c
22 @@ -4128,7 +4128,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
23         struct ext4_extent newex, *ex, *ex2;
24         struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
25         ext4_fsblk_t newblock = 0;
26 -       int free_on_err = 0, err = 0, depth;
27 +       int free_on_err = 0, err = 0, depth, ret;
28         unsigned int allocated = 0, offset = 0;
29         unsigned int allocated_clusters = 0;
30         struct ext4_allocation_request ar;
31 @@ -4189,9 +4189,13 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
32                         if (!ext4_ext_is_uninitialized(ex))
33                                 goto out;
35 -                       allocated = ext4_ext_handle_uninitialized_extents(
36 +                       ret = ext4_ext_handle_uninitialized_extents(
37                                 handle, inode, map, path, flags,
38                                 allocated, newblock);
39 +                       if (ret < 0)
40 +                               err = ret;
41 +                       else
42 +                               allocated = ret;
43                         goto out3;
44                 }
45         }
46 -- 
47 1.8.3.2