diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2019-08-20 07:55:16 -0700 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2019-08-20 07:55:16 -0700 |
commit | dc617f29dbe5ef0c8ced65ce62c464af1daaab3d (patch) | |
tree | 3596eb0d334f04f87088c735748bba8e66a71cad /include/linux/fs.h | |
parent | 1638045c36772b47a0765f7dca07cb90267e4942 (diff) | |
download | lwn-dc617f29dbe5ef0c8ced65ce62c464af1daaab3d.tar.gz lwn-dc617f29dbe5ef0c8ced65ce62c464af1daaab3d.zip |
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) fa->fsx_xflags = xflags; } +/* + * Flush file data before changing attributes. Caller must hold any locks + * required to prevent further writes to this file until we're done setting + * flags. + */ +static inline int inode_drain_writes(struct inode *inode) +{ + inode_dio_wait(inode); + return filemap_write_and_wait(inode->i_mapping); +} + #endif /* _LINUX_FS_H */ |