Skip to content

Commit 800701e

Browse files
aalexandrovichopsiff
authored andcommitted
fs/ntfs3: check for shutdown in fsync
[ Upstream commit 1b2ae19 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit d5fb4e2c9bb01f65713dfd5f58be42176411fa56) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent a35f5bc commit 800701e

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
@@ -1375,6 +1375,18 @@ static ssize_t ntfs_file_splice_write(struct pipe_inode_info *pipe,
13751375
return iter_file_splice_write(pipe, file, ppos, len, flags);
13761376
}
13771377

1378+
/*
1379+
* ntfs_file_fsync - file_operations::fsync
1380+
*/
1381+
static int ntfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
1382+
{
1383+
struct inode *inode = file_inode(file);
1384+
if (unlikely(ntfs3_forced_shutdown(inode->i_sb)))
1385+
return -EIO;
1386+
1387+
return generic_file_fsync(file, start, end, datasync);
1388+
}
1389+
13781390
// clang-format off
13791391
const struct inode_operations ntfs_file_inode_operations = {
13801392
.getattr = ntfs_getattr,
@@ -1397,7 +1409,7 @@ const struct file_operations ntfs_file_operations = {
13971409
.splice_write = ntfs_file_splice_write,
13981410
.mmap_prepare = ntfs_file_mmap_prepare,
13991411
.open = ntfs_file_open,
1400-
.fsync = generic_file_fsync,
1412+
.fsync = ntfs_file_fsync,
14011413
.fallocate = ntfs_fallocate,
14021414
.release = ntfs_file_release,
14031415
};

0 commit comments

Comments
 (0)