ext4_journal_ensure_credits() overwrites whatever error the migration might have run into previously. As a result EXT4_IOC_MIGRATE ioctl will report success, while the actual migration failed. Fix it by using a separate variable to store return value from ext4_journal_ensure_credits(). Signed-off-by: Lukas Czerner --- fs/ext4/migrate.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c index 0d32cfa55785..d2f8f2b6206b 100644 --- a/fs/ext4/migrate.c +++ b/fs/ext4/migrate.c @@ -419,7 +419,7 @@ static int free_ext_block(handle_t *handle, struct inode *inode) int ext4_ext_migrate(struct inode *inode) { handle_t *handle; - int retval = 0, i; + int retval = 0, retval2, i; __le32 *i_data; struct ext4_inode_info *ei; struct inode *tmp_inode = NULL; @@ -578,9 +578,12 @@ int ext4_ext_migrate(struct inode *inode) } /* We mark the tmp_inode dirty via ext4_ext_tree_init. */ - retval = ext4_journal_ensure_credits(handle, 1, 0); - if (retval < 0) + retval2 = ext4_journal_ensure_credits(handle, 1, 0); + if (retval2 < 0) { + if (retval == 0) + retval = retval2; goto out_stop; + } /* * Mark the tmp_inode as of size zero */ -- 2.56.0