Commit f4340e93 authored by Trond Myklebust's avatar Trond Myklebust

NFSv4/pnfs: Fix a page lock leak in nfs_pageio_resend()

If the attempt to resend the pages fails, we need to ensure that we
clean up those pages that were not transmitted.

Fixes: d600ad1f ("NFS41: pop some layoutget errors to application")
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
Cc: stable@vger.kernel.org # v4.5+
parent 9821421a
...@@ -1251,20 +1251,22 @@ static void nfs_pageio_complete_mirror(struct nfs_pageio_descriptor *desc, ...@@ -1251,20 +1251,22 @@ static void nfs_pageio_complete_mirror(struct nfs_pageio_descriptor *desc,
int nfs_pageio_resend(struct nfs_pageio_descriptor *desc, int nfs_pageio_resend(struct nfs_pageio_descriptor *desc,
struct nfs_pgio_header *hdr) struct nfs_pgio_header *hdr)
{ {
LIST_HEAD(failed); LIST_HEAD(pages);
desc->pg_io_completion = hdr->io_completion; desc->pg_io_completion = hdr->io_completion;
desc->pg_dreq = hdr->dreq; desc->pg_dreq = hdr->dreq;
while (!list_empty(&hdr->pages)) { list_splice_init(&hdr->pages, &pages);
struct nfs_page *req = nfs_list_entry(hdr->pages.next); while (!list_empty(&pages)) {
struct nfs_page *req = nfs_list_entry(pages.next);
if (!nfs_pageio_add_request(desc, req)) if (!nfs_pageio_add_request(desc, req))
nfs_list_move_request(req, &failed); break;
} }
nfs_pageio_complete(desc); nfs_pageio_complete(desc);
if (!list_empty(&failed)) { if (!list_empty(&pages)) {
list_move(&failed, &hdr->pages); int err = desc->pg_error < 0 ? desc->pg_error : -EIO;
return desc->pg_error < 0 ? desc->pg_error : -EIO; hdr->completion_ops->error_cleanup(&pages, err);
return err;
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment