]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ext4: allow ext4_ext_truncate() to return an error
authorTheodore Ts'o <tytso@mit.edu>
Mon, 14 Nov 2016 03:02:28 +0000 (22:02 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 14 Nov 2016 03:02:28 +0000 (22:02 -0500)
Return errors to the caller instead of declaring the file system
corrupted.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Jan Kara <jack@suse.cz>
fs/ext4/ext4.h
fs/ext4/extents.c
fs/ext4/inode.c

index be2282dcde7d293a6b166ccb59cc5e1d6d1d1dd8..54211c7876f85f748ec21e8d4cf9a43af11d55bd 100644 (file)
@@ -3128,7 +3128,7 @@ extern int ext4_ext_writepage_trans_blocks(struct inode *, int);
 extern int ext4_ext_index_trans_blocks(struct inode *inode, int extents);
 extern int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
                               struct ext4_map_blocks *map, int flags);
-extern void ext4_ext_truncate(handle_t *, struct inode *);
+extern int ext4_ext_truncate(handle_t *, struct inode *);
 extern int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
                                 ext4_lblk_t end);
 extern void ext4_ext_init(struct super_block *);
index c930a0110fb4f6ecc19819d1728879277b9e8843..d3b119499c53d881b09a67e15daa7a6f7d6729e5 100644 (file)
@@ -4631,7 +4631,7 @@ out2:
        return err ? err : allocated;
 }
 
-void ext4_ext_truncate(handle_t *handle, struct inode *inode)
+int ext4_ext_truncate(handle_t *handle, struct inode *inode)
 {
        struct super_block *sb = inode->i_sb;
        ext4_lblk_t last_block;
@@ -4645,7 +4645,9 @@ void ext4_ext_truncate(handle_t *handle, struct inode *inode)
 
        /* we have to know where to truncate from in crash case */
        EXT4_I(inode)->i_disksize = inode->i_size;
-       ext4_mark_inode_dirty(handle, inode);
+       err = ext4_mark_inode_dirty(handle, inode);
+       if (err)
+               return err;
 
        last_block = (inode->i_size + sb->s_blocksize - 1)
                        >> EXT4_BLOCK_SIZE_BITS(sb);
@@ -4657,12 +4659,9 @@ retry:
                congestion_wait(BLK_RW_ASYNC, HZ/50);
                goto retry;
        }
-       if (err) {
-               ext4_std_error(inode->i_sb, err);
-               return;
-       }
-       err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1);
-       ext4_std_error(inode->i_sb, err);
+       if (err)
+               return err;
+       return ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1);
 }
 
 static int ext4_alloc_file_blocks(struct file *file, ext4_lblk_t offset,
index 585153057c2aae22ad70e8f4a2f35cc1c2ea1ca6..79f46f4b43b8432a379d99ef00953440732a014c 100644 (file)
@@ -4173,11 +4173,13 @@ int ext4_truncate(struct inode *inode)
        ext4_discard_preallocations(inode);
 
        if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))
-               ext4_ext_truncate(handle, inode);
+               err = ext4_ext_truncate(handle, inode);
        else
                ext4_ind_truncate(handle, inode);
 
        up_write(&ei->i_data_sem);
+       if (err)
+               goto out_stop;
 
        if (IS_SYNC(inode))
                ext4_handle_sync(handle);