Commit 117a148f authored by Darrick J. Wong's avatar Darrick J. Wong

iomap: fsync swap files before iterating mappings

Swap files require that all the file mapping metadata be stable on disk.
It is insufficient to flush dirty pages in the page cache because that
won't necessarily result in filesystems pushing all their metadata out
to disk.  Therefore, call fsync from iomap_swapfile_activate.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
parent 89c2e711
...@@ -1387,7 +1387,11 @@ int iomap_swapfile_activate(struct swap_info_struct *sis, ...@@ -1387,7 +1387,11 @@ int iomap_swapfile_activate(struct swap_info_struct *sis,
loff_t len = ALIGN_DOWN(i_size_read(inode), PAGE_SIZE); loff_t len = ALIGN_DOWN(i_size_read(inode), PAGE_SIZE);
loff_t ret; loff_t ret;
ret = filemap_write_and_wait(inode->i_mapping); /*
* Persist all file mapping metadata so that we won't have any
* IOMAP_F_DIRTY iomaps.
*/
ret = vfs_fsync(swap_file, 1);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment