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.
Showing the changes to include/linux (1 of 6 files). Show all
Unified · Split
| @@ -3547,4 +3547,15 @@ static inline void simple_fill_fsxattr(struct fsxattr *fa, __u32 xflags) · 3546 unmodified lines | ||
| 3547 | 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 | 3561 | #endif /* _LINUX_FS_H */ |