1 ext4: propagate error values from ext4_inline_data_truncate()
3 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 fs/ext4/inline.c | 40 +++++++++++++++++++++++-----------------
7 fs/ext4/inode.c | 4 +++-
8 3 files changed, 27 insertions(+), 19 deletions(-)
10 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
11 index 6bcb9622fdf9..1cd077e02517 100644
14 @@ -3023,7 +3023,7 @@ extern int ext4_inline_data_fiemap(struct inode *inode,
15 extern int ext4_try_to_evict_inline_data(handle_t *handle,
18 -extern void ext4_inline_data_truncate(struct inode *inode, int *has_inline);
19 +extern int ext4_inline_data_truncate(struct inode *inode, int *has_inline);
21 extern int ext4_convert_inline_data(struct inode *inode);
23 diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
24 index 31f98dd04e51..338cfd862adb 100644
25 --- a/fs/ext4/inline.c
26 +++ b/fs/ext4/inline.c
27 @@ -1896,10 +1896,10 @@ int ext4_try_to_evict_inline_data(handle_t *handle,
31 -void ext4_inline_data_truncate(struct inode *inode, int *has_inline)
32 +int ext4_inline_data_truncate(struct inode *inode, int *has_inline)
35 - int inline_size, value_len, needed_blocks, no_expand;
36 + int inline_size, value_len, needed_blocks, no_expand, err = 0;
39 struct ext4_xattr_ibody_find is = {
40 @@ -1914,19 +1914,19 @@ void ext4_inline_data_truncate(struct inode *inode, int *has_inline)
41 needed_blocks = ext4_writepage_trans_blocks(inode);
42 handle = ext4_journal_start(inode, EXT4_HT_INODE, needed_blocks);
45 + return PTR_ERR(handle);
47 ext4_write_lock_xattr(inode, &no_expand);
48 if (!ext4_has_inline_data(inode)) {
50 ext4_journal_stop(handle);
55 - if (ext4_orphan_add(handle, inode))
56 + if ((err = ext4_orphan_add(handle, inode)) != 0)
59 - if (ext4_get_inode_loc(inode, &is.iloc))
60 + if ((err = ext4_get_inode_loc(inode, &is.iloc)) != 0)
63 down_write(&EXT4_I(inode)->i_data_sem);
64 @@ -1937,24 +1937,29 @@ void ext4_inline_data_truncate(struct inode *inode, int *has_inline)
65 if (i_size < inline_size) {
66 /* Clear the content in the xattr space. */
67 if (inline_size > EXT4_MIN_INLINE_DATA_SIZE) {
68 - if (ext4_xattr_ibody_find(inode, &i, &is))
69 + if ((err = ext4_xattr_ibody_find(inode, &i, &is)) != 0)
72 BUG_ON(is.s.not_found);
74 value_len = le32_to_cpu(is.s.here->e_value_size);
75 value = kmalloc(value_len, GFP_NOFS);
82 - if (ext4_xattr_ibody_get(inode, i.name_index, i.name,
84 + err = ext4_xattr_ibody_get(inode, i.name_index,
85 + i.name, value, value_len);
90 i.value_len = i_size > EXT4_MIN_INLINE_DATA_SIZE ?
91 i_size - EXT4_MIN_INLINE_DATA_SIZE : 0;
92 - if (ext4_xattr_ibody_inline_set(handle, inode, &i, &is))
93 + err = ext4_xattr_ibody_inline_set(handle, inode,
99 @@ -1979,13 +1984,14 @@ void ext4_inline_data_truncate(struct inode *inode, int *has_inline)
101 ext4_orphan_del(handle, inode);
103 - inode->i_mtime = inode->i_ctime = current_time(inode);
104 - ext4_mark_inode_dirty(handle, inode);
105 - if (IS_SYNC(inode))
106 - ext4_handle_sync(handle);
109 + inode->i_mtime = inode->i_ctime = current_time(inode);
110 + err = ext4_mark_inode_dirty(handle, inode);
111 + if (IS_SYNC(inode))
112 + ext4_handle_sync(handle);
114 ext4_journal_stop(handle);
119 int ext4_convert_inline_data(struct inode *inode)
120 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
121 index 86dde0667ccc..1e2c881f102d 100644
122 --- a/fs/ext4/inode.c
123 +++ b/fs/ext4/inode.c
124 @@ -4222,7 +4222,9 @@ int ext4_truncate(struct inode *inode)
125 if (ext4_has_inline_data(inode)) {
128 - ext4_inline_data_truncate(inode, &has_inline);
129 + err = ext4_inline_data_truncate(inode, &has_inline);