linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iomap: Return zero in case of unsuccessful pagecache invalidation before DIO
@ 2020-05-28 19:21 Goldwyn Rodrigues
  2020-05-29  0:23 ` Darrick J. Wong
  0 siblings, 1 reply; 14+ messages in thread
From: Goldwyn Rodrigues @ 2020-05-28 19:21 UTC (permalink / raw)
  To: linux-fsdevel
  Cc: linux-btrfs, Johannes.Thumshirn, hch, dsterba, darrick.wong, fdmanana


Filesystems such as btrfs are unable to guarantee page invalidation
because pages could be locked as a part of the extent. Return zero
in case a page cache invalidation is unsuccessful so filesystems can
fallback to buffered I/O. This is similar to
generic_file_direct_write().

This takes care of the following invalidation warning during btrfs
mixed buffered and direct I/O using iomap_dio_rw():

Page cache invalidation failure on direct I/O.  Possible data
corruption due to collision with buffered I/O!

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>

diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index e4addfc58107..215315be6233 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -483,9 +483,15 @@ iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
 	 */
 	ret = invalidate_inode_pages2_range(mapping,
 			pos >> PAGE_SHIFT, end >> PAGE_SHIFT);
-	if (ret)
-		dio_warn_stale_pagecache(iocb->ki_filp);
-	ret = 0;
+	/*
+	 * If a page can not be invalidated, return 0 to fall back
+	 * to buffered write.
+	 */
+	if (ret) {
+		if (ret == -EBUSY)
+			ret = 0;
+		goto out_free_dio;
+	}
 
 	if (iov_iter_rw(iter) == WRITE && !wait_for_completion &&
 	    !inode->i_sb->s_dio_done_wq) {

-- 
Goldwyn

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

end of thread, other threads:[~2020-06-04 13:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 19:21 [PATCH] iomap: Return zero in case of unsuccessful pagecache invalidation before DIO Goldwyn Rodrigues
2020-05-29  0:23 ` Darrick J. Wong
2020-05-29 10:55   ` Filipe Manana
2020-05-29 11:31     ` Matthew Wilcox
2020-05-29 11:50       ` Filipe Manana
2020-05-29 12:45         ` Goldwyn Rodrigues
2020-06-01 15:16   ` Goldwyn Rodrigues
2020-06-03 11:23     ` Filipe Manana
2020-06-03 11:32       ` Filipe Manana
2020-06-03 19:02         ` Darrick J. Wong
2020-06-03 19:10           ` Filipe Manana
2020-06-03 19:18             ` Matthew Wilcox
2020-06-03 21:07           ` Goldwyn Rodrigues
2020-06-04 13:55           ` David Sterba

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).