linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iomap: fsync swap files before iterating mappings
@ 2018-06-05 16:16 Darrick J. Wong
  2018-06-05 16:25 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2018-06-05 16:16 UTC (permalink / raw)
  To: linux-xfs
  Cc: Omar Sandoval, linux-fsdevel, Jan Kara, Christoph Hellwig,
	Aleksei Besogonov

From: Darrick J. Wong <darrick.wong@oracle.com>

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: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/iomap.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/iomap.c b/fs/iomap.c
index 206539d369a8..48622bbbd751 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -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 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, 0);
 	if (ret)
 		return ret;
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iomap: fsync swap files before iterating mappings
  2018-06-05 16:16 [PATCH] iomap: fsync swap files before iterating mappings Darrick J. Wong
@ 2018-06-05 16:25 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2018-06-05 16:25 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: linux-xfs, Omar Sandoval, linux-fsdevel, Jan Kara,
	Christoph Hellwig, Aleksei Besogonov

On Tue, Jun 05, 2018 at 09:16:05AM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> 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: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  fs/iomap.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/iomap.c b/fs/iomap.c
> index 206539d369a8..48622bbbd751 100644
> --- a/fs/iomap.c
> +++ b/fs/iomap.c
> @@ -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 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, 0);

datasync semantics should be more than enough, so you can pass 1 here..

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-05 16:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-05 16:16 [PATCH] iomap: fsync swap files before iterating mappings Darrick J. Wong
2018-06-05 16:25 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).