--- x/fs/ext4/namei.c +++ y/fs/ext4/namei.c @@ -3780,6 +3780,7 @@ static int ext4_rename(struct mnt_idmap }; int force_reread; int retval; + int old_locked = 0; struct inode *whiteout = NULL; int credits; u8 old_file_type; @@ -3882,6 +3883,7 @@ static int ext4_rename(struct mnt_idmap inode_unlock(old.inode); goto end_rename; } + old_locked = 1; } /* * If we're renaming a file within an inline_data dir and adding or @@ -4008,13 +4010,11 @@ end_rename: ext4_orphan_add(handle, whiteout); } unlock_new_inode(whiteout); - ext4_journal_stop(handle); - iput(whiteout); - } else { - ext4_journal_stop(handle); } - if (old.dir_bh) + if (old_locked) inode_unlock(old.inode); + ext4_journal_stop(handle); + iput(whiteout); release_bh: brelse(old.dir_bh); brelse(old.bh);