[6/7] btrfs: flush dirty pages on compressed I/O for dio
diff mbox series

Message ID 20191115161700.12305-7-rgoldwyn@suse.de
State New
Headers show
Series
  • [1/7] fs: Export generic_file_buffered_read()
Related show

Commit Message

Goldwyn Rodrigues Nov. 15, 2019, 4:16 p.m. UTC
From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Port of "41bd9ca459a0 Btrfs: just do dirty page flush for the
inode with compression before direct IO"

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/btrfs/inode.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Christoph Hellwig Nov. 15, 2019, 4:50 p.m. UTC | #1
On Fri, Nov 15, 2019 at 10:16:59AM -0600, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> 
> Port of "41bd9ca459a0 Btrfs: just do dirty page flush for the
> inode with compression before direct IO"

Doesn't this belong into the main patch as well?

Patch
diff mbox series

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 8e55b0d343bd..6654370168ff 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7726,6 +7726,17 @@  static int direct_iomap_begin(struct inode *inode, loff_t start,
 	lockstart = start;
 	lockend = start + len - 1;
 
+	/*
+	 * The generic stuff only does filemap_write_and_wait_range, which
+	 * isn't enough if we've written compressed pages to this area, so
+	 * we need to flush the dirty pages again to make absolutely sure
+	 * that any outstanding dirty pages are on disk.
+	 */
+	if (test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT,
+				&BTRFS_I(inode)->runtime_flags))
+		filemap_fdatawrite_range(inode->i_mapping, lockstart, lockend);
+
+
 	if (current->journal_info) {
 		/*
 		 * Need to pull our outstanding extents and set journal_info to NULL so