ext4: Support setting FMODE_CAN_ATOMIC_WRITE

FS needs to add the fmode capability in order to support atomic writes
during file open (refer kiocb_set_rw_flags()). Set this capability on
a regular file if ext4 can do atomic write.

Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
This commit is contained in:
Ritesh Harjani (IBM) 2024-11-04 16:22:59 -08:00 committed by Darrick J. Wong
parent 43c696f9d0
commit b7987a7d69

View File

@ -898,6 +898,9 @@ static int ext4_file_open(struct inode *inode, struct file *filp)
return ret;
}
if (ext4_inode_can_atomic_write(inode))
filp->f_mode |= FMODE_CAN_ATOMIC_WRITE;
filp->f_mode |= FMODE_NOWAIT | FMODE_CAN_ODIRECT;
return dquot_file_open(inode, filp);
}