提交 ddce62f1 编写于 作者: J Jan Kara 提交者: Yang Yingliang

ext4: Move marking of handle as sync to ext4_add_nondir()

mainline inclusion
from mainline-5.5-rc1
commit a9e26328adfa82b1f3c941bc6e3daea47631abce
category: bugfix
bugzilla: 25031
CVE: NA
---------------------------

Every caller of ext4_add_nondir() marks handle as sync if directory has
DIRSYNC set. Move this marking to ext4_add_nondir() so reduce some
duplication.
Signed-off-by: NJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20191105164437.32602-4-jack@suse.czSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
Signed-off-by: Nzhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: NYang Erkun <yangerkun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 489862d3
...@@ -2432,9 +2432,12 @@ static void ext4_dec_count(handle_t *handle, struct inode *inode) ...@@ -2432,9 +2432,12 @@ static void ext4_dec_count(handle_t *handle, struct inode *inode)
static int ext4_add_nondir(handle_t *handle, static int ext4_add_nondir(handle_t *handle,
struct dentry *dentry, struct inode *inode) struct dentry *dentry, struct inode *inode)
{ {
struct inode *dir = d_inode(dentry->d_parent);
int err = ext4_add_entry(handle, dentry, inode); int err = ext4_add_entry(handle, dentry, inode);
if (!err) { if (!err) {
ext4_mark_inode_dirty(handle, inode); ext4_mark_inode_dirty(handle, inode);
if (IS_DIRSYNC(dir))
ext4_handle_sync(handle);
d_instantiate_new(dentry, inode); d_instantiate_new(dentry, inode);
return 0; return 0;
} }
...@@ -2475,8 +2478,6 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, umode_t mode, ...@@ -2475,8 +2478,6 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, umode_t mode,
inode->i_fop = &ext4_file_operations; inode->i_fop = &ext4_file_operations;
ext4_set_aops(inode); ext4_set_aops(inode);
err = ext4_add_nondir(handle, dentry, inode); err = ext4_add_nondir(handle, dentry, inode);
if (!err && IS_DIRSYNC(dir))
ext4_handle_sync(handle);
} }
if (handle) if (handle)
ext4_journal_stop(handle); ext4_journal_stop(handle);
...@@ -2507,8 +2508,6 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry, ...@@ -2507,8 +2508,6 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry,
init_special_inode(inode, inode->i_mode, rdev); init_special_inode(inode, inode->i_mode, rdev);
inode->i_op = &ext4_special_inode_operations; inode->i_op = &ext4_special_inode_operations;
err = ext4_add_nondir(handle, dentry, inode); err = ext4_add_nondir(handle, dentry, inode);
if (!err && IS_DIRSYNC(dir))
ext4_handle_sync(handle);
} }
if (handle) if (handle)
ext4_journal_stop(handle); ext4_journal_stop(handle);
...@@ -3195,9 +3194,6 @@ static int ext4_symlink(struct inode *dir, ...@@ -3195,9 +3194,6 @@ static int ext4_symlink(struct inode *dir,
} }
EXT4_I(inode)->i_disksize = inode->i_size; EXT4_I(inode)->i_disksize = inode->i_size;
err = ext4_add_nondir(handle, dentry, inode); err = ext4_add_nondir(handle, dentry, inode);
if (!err && IS_DIRSYNC(dir))
ext4_handle_sync(handle);
if (handle) if (handle)
ext4_journal_stop(handle); ext4_journal_stop(handle);
goto out_free_encrypted_link; goto out_free_encrypted_link;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册