summaryrefslogtreecommitdiff
path: root/include/linux/fs.h
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-08-30 15:44:19 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2019-09-05 17:56:11 -0700
commit4c482a3f8f8e22a182a91601652a44eaeb61139a (patch)
treebb46cfc445791b5004c446c75ed3e7a407cbad48 /include/linux/fs.h
parent59f04e11d617cf533e62a2c0ecfd02dcd98bc7a2 (diff)
vfs: don't allow writes to swap filesimmutable-swapfiles_2019-09-05
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>
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 997a530ff4e9..31f5c6ae1b45 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3553,4 +3553,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 */