summaryrefslogtreecommitdiff
path: root/include/linux/fs.h
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-08-20 07:55:16 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2019-08-20 07:55:16 -0700
commitdc617f29dbe5ef0c8ced65ce62c464af1daaab3d (patch)
tree3596eb0d334f04f87088c735748bba8e66a71cad /include/linux/fs.h
parent1638045c36772b47a0765f7dca07cb90267e4942 (diff)
downloadlwn-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.h11
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 */