[Devel] [PATCH rh8 6/9] ext4: guarantee rename atomic behavior
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Mar 3 19:31:15 MSK 2021
From: Kirill Tkhai <ktkhai at parallels.com>
Ext4 already performs block allocation on rename, but
it does it after rename completes, so race window is much tighter
but still exits. In order to guarantee atomic behavior let's
force block allocation before actual rename.
http://wiki.parallels.com/index.php/Ext4_writeback
diff-ms-ext4-force-atomic-rename
Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
Signed-off-by: Kirill Tkhai <ktkhai at parallels.com>
khorenko@: conflicts in fs/ext4/namei.c
resolved during rebase to rh7 kernel-3.10.0-229.7.2.el7
(cherry picked from vz7 commit 25e508a4bb83052a8f2311cbca8ff38bdaa22727)
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
fs/ext4/namei.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 953e882b1d61..46391fb93317 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -3562,7 +3562,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
*/
retval = -ENOENT;
if (!old.bh || le32_to_cpu(old.de->inode) != old.inode->i_ino)
- goto end_rename;
+ goto out_release;
new.bh = ext4_find_entry(new.dir, &new.dentry->d_name,
&new.de, &new.inlined);
@@ -3707,6 +3707,9 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
retval = 0;
end_rename:
+ if (handle)
+ ext4_journal_stop(handle);
+out_release:
brelse(old.dir_bh);
brelse(old.bh);
brelse(new.bh);
@@ -3716,8 +3719,6 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
unlock_new_inode(whiteout);
iput(whiteout);
}
- if (handle)
- ext4_journal_stop(handle);
return retval;
}
--
2.28.0
More information about the Devel
mailing list