add patch add-ext4_is_quota_file
[ext4-patch-queue.git] / ext4_xattr_delete_inode-should-return-accurate-errors
blob37c3a8120224d4169350d8612b530c84a7a79285
1 From: Tahsin Erdogan <tahsin@google.com>
3 ext4: ext4_xattr_delete_inode() should return accurate errors
5 In a few places the function returns without trying to pass the actual
6 error code to the caller. Fix those.
8 Signed-off-by: Tahsin Erdogan <tahsin@google.com>
9 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 ---
11  fs/ext4/xattr.c | 16 ++++++++++------
12  1 file changed, 10 insertions(+), 6 deletions(-)
14 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
15 index 0dfae3f8e209..97d33ecf0818 100644
16 --- a/fs/ext4/xattr.c
17 +++ b/fs/ext4/xattr.c
18 @@ -2026,7 +2026,8 @@ ext4_xattr_delete_inode(handle_t *handle, struct inode *inode,
19                 if (!entry->e_value_inum)
20                         continue;
21                 ea_ino = le32_to_cpu(entry->e_value_inum);
22 -               if (ext4_expand_ino_array(lea_ino_array, ea_ino) != 0) {
23 +               error = ext4_expand_ino_array(lea_ino_array, ea_ino);
24 +               if (error) {
25                         brelse(iloc.bh);
26                         goto cleanup;
27                 }
28 @@ -2037,20 +2038,22 @@ ext4_xattr_delete_inode(handle_t *handle, struct inode *inode,
29  delete_external_ea:
30         if (!EXT4_I(inode)->i_file_acl) {
31                 /* add xattr inode to orphan list */
32 -               ext4_xattr_inode_orphan_add(handle, inode, credits,
33 -                                               *lea_ino_array);
34 +               error = ext4_xattr_inode_orphan_add(handle, inode, credits,
35 +                                                   *lea_ino_array);
36                 goto cleanup;
37         }
38         bh = sb_bread(inode->i_sb, EXT4_I(inode)->i_file_acl);
39         if (!bh) {
40                 EXT4_ERROR_INODE(inode, "block %llu read error",
41                                  EXT4_I(inode)->i_file_acl);
42 +               error = -EIO;
43                 goto cleanup;
44         }
45         if (BHDR(bh)->h_magic != cpu_to_le32(EXT4_XATTR_MAGIC) ||
46             BHDR(bh)->h_blocks != cpu_to_le32(1)) {
47                 EXT4_ERROR_INODE(inode, "bad block %llu",
48                                  EXT4_I(inode)->i_file_acl);
49 +               error = -EFSCORRUPTED;
50                 goto cleanup;
51         }
53 @@ -2059,7 +2062,8 @@ ext4_xattr_delete_inode(handle_t *handle, struct inode *inode,
54                 if (!entry->e_value_inum)
55                         continue;
56                 ea_ino = le32_to_cpu(entry->e_value_inum);
57 -               if (ext4_expand_ino_array(lea_ino_array, ea_ino) != 0)
58 +               error = ext4_expand_ino_array(lea_ino_array, ea_ino);
59 +               if (error)
60                         goto cleanup;
61                 entry->e_value_inum = 0;
62         }
63 @@ -2067,7 +2071,7 @@ ext4_xattr_delete_inode(handle_t *handle, struct inode *inode,
64         /* add xattr inode to orphan list */
65         error = ext4_xattr_inode_orphan_add(handle, inode, credits,
66                                         *lea_ino_array);
67 -       if (error != 0)
68 +       if (error)
69                 goto cleanup;
71         if (!IS_NOQUOTA(inode))
72 @@ -2077,7 +2081,7 @@ ext4_xattr_delete_inode(handle_t *handle, struct inode *inode,
73                 error = ext4_journal_extend(handle, credits);
74                 if (error > 0)
75                         error = ext4_journal_restart(handle, credits);
76 -               if (error != 0) {
77 +               if (error) {
78                         ext4_warning(inode->i_sb,
79                                 "couldn't extend journal (err %d)", error);
80                         goto cleanup;
81 -- 
82 2.13.1.611.g7e3b11ae1-goog