Skip to content

Commit 1b2ae19

Browse files
fs/ntfs3: check for shutdown in fsync
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>
1 parent bcbb8d0 commit 1b2ae19

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

fs/ntfs3/file.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,18 @@ static ssize_t ntfs_file_splice_write(struct pipe_inode_info *pipe,
14401440
return iter_file_splice_write(pipe, file, ppos, len, flags);
14411441
}
14421442

1443+
/*
1444+
* ntfs_file_fsync - file_operations::fsync
1445+
*/
1446+
static int ntfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
1447+
{
1448+
struct inode *inode = file_inode(file);
1449+
if (unlikely(ntfs3_forced_shutdown(inode->i_sb)))
1450+
return -EIO;
1451+
1452+
return generic_file_fsync(file, start, end, datasync);
1453+
}
1454+
14431455
// clang-format off
14441456
const struct inode_operations ntfs_file_inode_operations = {
14451457
.getattr = ntfs_getattr,
@@ -1462,7 +1474,7 @@ const struct file_operations ntfs_file_operations = {
14621474
.splice_write = ntfs_file_splice_write,
14631475
.mmap_prepare = ntfs_file_mmap_prepare,
14641476
.open = ntfs_file_open,
1465-
.fsync = generic_file_fsync,
1477+
.fsync = ntfs_file_fsync,
14661478
.fallocate = ntfs_fallocate,
14671479
.release = ntfs_file_release,
14681480
};

0 commit comments

Comments
 (0)