Patch "NFS: Fix fscache read from NFS after cache error" has been added to the 5.13-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    NFS: Fix fscache read from NFS after cache error

to the 5.13-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     nfs-fix-fscache-read-from-nfs-after-cache-error.patch
and it can be found in the queue-5.13 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit f93376d8a79335b0771d68a9aa30dc8f8eee212f
Author: Dave Wysochanski <dwysocha@xxxxxxxxxx>
Date:   Tue Jun 29 13:13:57 2021 -0400

    NFS: Fix fscache read from NFS after cache error
    
    [ Upstream commit ba512c1bc3232124567a59a3995c773dc79716e8 ]
    
    Earlier commits refactored some NFS read code and removed
    nfs_readpage_async(), but neglected to properly fixup
    nfs_readpage_from_fscache_complete().  The code path is
    only hit when something unusual occurs with the cachefiles
    backing filesystem, such as an IO error or while a cookie
    is being invalidated.
    
    Mark page with PG_checked if fscache IO completes in error,
    unlock the page, and let the VM decide to re-issue based on
    PG_uptodate.  When the VM reissues the readpage, PG_checked
    allows us to skip over fscache and read from the server.
    
    Link: https://marc.info/?l=linux-nfs&m=162498209518739
    Fixes: 1e83b173b266 ("NFS: Add nfs_pageio_complete_read() and remove nfs_readpage_async()")
    Signed-off-by: Dave Wysochanski <dwysocha@xxxxxxxxxx>
    Signed-off-by: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/nfs/fscache.c b/fs/nfs/fscache.c
index c4c021c6ebbd..d743629e05e1 100644
--- a/fs/nfs/fscache.c
+++ b/fs/nfs/fscache.c
@@ -385,12 +385,15 @@ static void nfs_readpage_from_fscache_complete(struct page *page,
 		 "NFS: readpage_from_fscache_complete (0x%p/0x%p/%d)\n",
 		 page, context, error);
 
-	/* if the read completes with an error, we just unlock the page and let
-	 * the VM reissue the readpage */
-	if (!error) {
+	/*
+	 * If the read completes with an error, mark the page with PG_checked,
+	 * unlock the page, and let the VM reissue the readpage.
+	 */
+	if (!error)
 		SetPageUptodate(page);
-		unlock_page(page);
-	}
+	else
+		SetPageChecked(page);
+	unlock_page(page);
 }
 
 /*
@@ -405,6 +408,11 @@ int __nfs_readpage_from_fscache(struct nfs_open_context *ctx,
 		 "NFS: readpage_from_fscache(fsc:%p/p:%p(i:%lx f:%lx)/0x%p)\n",
 		 nfs_i_fscache(inode), page, page->index, page->flags, inode);
 
+	if (PageChecked(page)) {
+		ClearPageChecked(page);
+		return 1;
+	}
+
 	ret = fscache_read_or_alloc_page(nfs_i_fscache(inode),
 					 page,
 					 nfs_readpage_from_fscache_complete,
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index d2b6dce1f99f..4ca50b70a7b0 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -363,13 +363,13 @@ int nfs_readpage(struct file *file, struct page *page)
 	} else
 		desc.ctx = get_nfs_open_context(nfs_file_open_context(file));
 
+	xchg(&desc.ctx->error, 0);
 	if (!IS_SYNC(inode)) {
 		ret = nfs_readpage_from_fscache(desc.ctx, inode, page);
 		if (ret == 0)
-			goto out;
+			goto out_wait;
 	}
 
-	xchg(&desc.ctx->error, 0);
 	nfs_pageio_init_read(&desc.pgio, inode, false,
 			     &nfs_async_read_completion_ops);
 
@@ -379,6 +379,7 @@ int nfs_readpage(struct file *file, struct page *page)
 		nfs_pageio_complete_read(&desc.pgio, inode);
 
 	ret = desc.pgio.pg_error < 0 ? desc.pgio.pg_error : 0;
+out_wait:
 	if (!ret) {
 		ret = wait_on_page_locked_killable(page);
 		if (!PageUptodate(page) && !ret)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux