For inodes which has EXT4_INODE_ATOMIC_WRITE flag set, enable FMODE_CAN_ATOMIC_WRITE mode in ext4 file open method for file opened with O_DIRECT. Co-developed-by: Ojaswin Mujoo <ojaswin@xxxxxxxxxxxxx> Signed-off-by: Ojaswin Mujoo <ojaswin@xxxxxxxxxxxxx> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@xxxxxxxxx> --- fs/ext4/file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 8e309a9a0bd6..800fd79e2738 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -913,6 +913,10 @@ static int ext4_file_open(struct inode *inode, struct file *filp) return ret; } + if (ext4_test_inode_flag(inode, EXT4_INODE_ATOMIC_WRITE) && + (filp->f_flags & O_DIRECT)) + filp->f_mode |= FMODE_CAN_ATOMIC_WRITE; + filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC | FMODE_DIO_PARALLEL_WRITE; return dquot_file_open(inode, filp); -- 2.43.0