linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs/ntfs3: check for shutdown in fsync
@ 2025-11-18 13:07 Konstantin Komarov
  2025-11-19  2:51 ` kernel test robot
  2025-11-19  4:07 ` [PATCH] " kernel test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Konstantin Komarov @ 2025-11-18 13:07 UTC (permalink / raw)
  To: ntfs3; +Cc: linux-kernel, linux-fsdevel, Konstantin Komarov

Ensure fsync() returns -EIO when the ntfs3 filesystem is in forced
shutdown, instead of silently succeeding via generic_file_fsync().

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
 fs/ntfs3/file.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index 3b22c7375616..5389b2e17cde 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -1440,6 +1440,18 @@ static ssize_t ntfs_file_splice_write(struct pipe_inode_info *pipe,
 	return iter_file_splice_write(pipe, file, ppos, len, flags);
 }
 
+/*
+ * ntfs_file_fsync - file_operations::fsync
+ */
+int ntfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
+{
+	struct inode *inode = file_inode(file);
+	if (unlikely(ntfs3_forced_shutdown(inode->i_sb)))
+		return -EIO;
+
+	return generic_file_fsync(file, start, end, datasync);
+}
+
 // clang-format off
 const struct inode_operations ntfs_file_inode_operations = {
 	.getattr	= ntfs_getattr,
@@ -1465,6 +1477,7 @@ const struct file_operations ntfs_file_operations = {
 	.fsync		= generic_file_fsync,
 	.fallocate	= ntfs_fallocate,
 	.release	= ntfs_file_release,
+	.fsync		= ntfs_file_fsync,
 };
 
 #if IS_ENABLED(CONFIG_NTFS_FS)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-19  9:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-18 13:07 [PATCH] fs/ntfs3: check for shutdown in fsync Konstantin Komarov
2025-11-19  2:51 ` kernel test robot
2025-11-19  9:10   ` [PATCH v2] " Konstantin Komarov
2025-11-19  4:07 ` [PATCH] " kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).