diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2019-08-20 10:55:16 -0400 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2019-08-20 10:55:16 -0400 |
commit | dc617f29dbe5ef0c8ced65ce62c464af1daaab3d (patch) | |
tree | 3596eb0d334f04f87088c735748bba8e66a71cad /include/linux/fs.h | |
parent | 1638045c36772b47a0765f7dca07cb90267e4942 (diff) |
vfs: don't allow writes to swap files
Don't let userspace write to an active swap file because the kernel
effectively has a long term lease on the storage and things could get
seriously corrupted if we let this happen.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r-- | include/linux/fs.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index 56b8e358af5c..a2e3d446ba8e 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -3547,4 +3547,15 @@ static inline void simple_fill_fsxattr(struct fsxattr *fa, __u32 xflags) | |||
3547 | fa->fsx_xflags = xflags; | 3547 | fa->fsx_xflags = xflags; |
3548 | } | 3548 | } |
3549 | 3549 | ||
3550 | /* | ||
3551 | * Flush file data before changing attributes. Caller must hold any locks | ||
3552 | * required to prevent further writes to this file until we're done setting | ||
3553 | * flags. | ||
3554 | */ | ||
3555 | static inline int inode_drain_writes(struct inode *inode) | ||
3556 | { | ||
3557 | inode_dio_wait(inode); | ||
3558 | return filemap_write_and_wait(inode->i_mapping); | ||
3559 | } | ||
3560 | |||
3550 | #endif /* _LINUX_FS_H */ | 3561 | #endif /* _LINUX_FS_H */ |