diff mbox series

[v2,3/4] ext4: Support setting FMODE_CAN_ATOMIC_WRITE

Message ID ff8a6b81109e4a81ef304eb5b523ed777d62e2a2.1729944406.git.ritesh.list@gmail.com (mailing list archive)
State New
Headers show
Series ext4: Add atomic writes support for DIO | expand

Commit Message

Ritesh Harjani (IBM) Oct. 27, 2024, 6:17 p.m. UTC
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.

Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
 fs/ext4/file.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

John Garry Oct. 29, 2024, 8:56 a.m. UTC | #1
On 27/10/2024 18:17, Ritesh Harjani (IBM) wrote:
> 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.
> 
> Signed-off-by: Ritesh Harjani (IBM)<ritesh.list@gmail.com>

Reviewed-by: John Garry <john.g.garry@oracle.com>
diff mbox series

Patch

diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index a7b9b9751a3f..8116bd78910b 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -898,6 +898,9 @@  static int ext4_file_open(struct inode *inode, struct file *filp)
 			return ret;
 	}
 
+	if (S_ISREG(inode->i_mode) && ext4_can_atomic_write(inode->i_sb))
+		filp->f_mode |= FMODE_CAN_ATOMIC_WRITE;
+
 	filp->f_mode |= FMODE_NOWAIT | FMODE_CAN_ODIRECT;
 	return dquot_file_open(inode, filp);
 }