[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <921ffd8731b666b8510e56dd1981a995f57873e0.1729825985.git.ritesh.list@gmail.com>
Date: Fri, 25 Oct 2024 09:15:52 +0530
From: "Ritesh Harjani (IBM)" <ritesh.list@...il.com>
To: linux-ext4@...r.kernel.org
Cc: Theodore Ts'o <tytso@....edu>,
Jan Kara <jack@...e.cz>,
"Darrick J . Wong" <djwong@...nel.org>,
Christoph Hellwig <hch@...radead.org>,
John Garry <john.g.garry@...cle.com>,
Ojaswin Mujoo <ojaswin@...ux.ibm.com>,
Dave Chinner <david@...morbit.com>,
linux-kernel@...r.kernel.org,
linux-xfs@...r.kernel.org,
linux-fsdevel@...r.kernel.org,
"Ritesh Harjani (IBM)" <ritesh.list@...il.com>
Subject: [PATCH 3/6] 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()). Let's check if inode can
support atomic writes then enable FMODE_CAN_ATOMIC_WRITE.
Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@...il.com>
---
fs/ext4/ext4.h | 7 +++++++
fs/ext4/file.c | 3 +++
2 files changed, 10 insertions(+)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index a41e56c2c628..78475ff14aa2 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3863,6 +3863,13 @@ static inline int ext4_buffer_uptodate(struct buffer_head *bh)
extern int ext4_block_write_begin(handle_t *handle, struct folio *folio,
loff_t pos, unsigned len,
get_block_t *get_block);
+
+static inline bool ext4_inode_can_atomicwrite(struct inode *inode)
+{
+ return ext4_test_mount_flag(inode->i_sb, EXT4_MF_ATOMIC_WRITE) &&
+ S_ISREG(inode->i_mode);
+}
+
#endif /* __KERNEL__ */
#define EFSBADCRC EBADMSG /* Bad CRC detected */
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index b06c5d34bbd2..f9516121a036 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 (ext4_inode_can_atomicwrite(inode))
+ filp->f_mode |= FMODE_CAN_ATOMIC_WRITE;
+
filp->f_mode |= FMODE_NOWAIT | FMODE_CAN_ODIRECT;
return dquot_file_open(inode, filp);
}
--
2.46.0
Powered by blists - more mailing lists