diff mbox series

[4/5] NFSv4/pnfs: Fix a page lock leak in nfs_pageio_resend()

Message ID 20190813142806.123268-4-trond.myklebust@hammerspace.com (mailing list archive)
State New, archived
Headers show
Series [1/5] NFS: Don't refresh attributes with mounted-on-file information | expand

Commit Message

Trond Myklebust Aug. 13, 2019, 2:28 p.m. UTC
If the attempt to resend the pages fails, we need to ensure that we
clean up those pages that were not transmitted.

Fixes: d600ad1f2bdb ("NFS41: pop some layoutget errors to application")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Cc: stable@vger.kernel.org # v4.5+
---
 fs/nfs/pagelist.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

Sasha Levin Aug. 13, 2019, 5:55 p.m. UTC | #1
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: d600ad1f2bdb NFS41: pop some layoutget errors to application.

The bot has tested the following trees: v5.2.8, v4.19.66, v4.14.138, v4.9.189, v4.4.189.

v5.2.8: Build OK!
v4.19.66: Failed to apply! Possible dependencies:
    078b5fd92c49 ("NFS: Clean up list moves of struct nfs_page")

v4.14.138: Failed to apply! Possible dependencies:
    078b5fd92c49 ("NFS: Clean up list moves of struct nfs_page")

v4.9.189: Failed to apply! Possible dependencies:
    078b5fd92c49 ("NFS: Clean up list moves of struct nfs_page")

v4.4.189: Failed to apply! Possible dependencies:
    078b5fd92c49 ("NFS: Clean up list moves of struct nfs_page")
    6272dcc6beeb ("NFS: Simplify nfs_request_add_commit_list() arguments")
    b20135d0b243 ("NFSv4.1/pNFS: Don't queue up a new commit if the layout segment is invalid")
    c18b96a1b862 ("nfs: clean up rest of reqs when failing to add one")
    f57dcf4c7211 ("NFS: Fix I/O request leakages")
    fe238e601d25 ("NFS: Save struct inode COPYING CREDITS Documentation Kbuild Kconfig MAINTAINERS Makefile README REPORTING-BUGS arch block certs crypto drivers firmware fs include init ipc kernel lib mm net samples scripts security sound tools usr virt inside nfs_commit_info to clarify usage of i_lock")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

--
Thanks,
Sasha
diff mbox series

Patch

diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index ed4e1b07447b..15c254753f88 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -1251,20 +1251,22 @@  static void nfs_pageio_complete_mirror(struct nfs_pageio_descriptor *desc,
 int nfs_pageio_resend(struct nfs_pageio_descriptor *desc,
 		      struct nfs_pgio_header *hdr)
 {
-	LIST_HEAD(failed);
+	LIST_HEAD(pages);
 
 	desc->pg_io_completion = hdr->io_completion;
 	desc->pg_dreq = hdr->dreq;
-	while (!list_empty(&hdr->pages)) {
-		struct nfs_page *req = nfs_list_entry(hdr->pages.next);
+	list_splice_init(&hdr->pages, &pages);
+	while (!list_empty(&pages)) {
+		struct nfs_page *req = nfs_list_entry(pages.next);
 
 		if (!nfs_pageio_add_request(desc, req))
-			nfs_list_move_request(req, &failed);
+			break;
 	}
 	nfs_pageio_complete(desc);
-	if (!list_empty(&failed)) {
-		list_move(&failed, &hdr->pages);
-		return desc->pg_error < 0 ? desc->pg_error : -EIO;
+	if (!list_empty(&pages)) {
+		int err = desc->pg_error < 0 ? desc->pg_error : -EIO;
+		hdr->completion_ops->error_cleanup(&pages, err);
+		return err;
 	}
 	return 0;
 }