2015-07-27 14:34:19

by Trond Myklebust

[permalink] [raw]
Subject: [PATCH 1/2] NFS: Fix a memory leak in nfs_do_recoalesce

If the function exits early, then we must put those requests that were
not processed back onto the &mirror->pg_list so they can be cleaned up
by nfs_pgio_error().

Fixes: a7d42ddb30997 ("nfs: add mirroring support to pgio layer")
Cc: [email protected] # v4.0+
Signed-off-by: Trond Myklebust <[email protected]>
---
fs/nfs/pagelist.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git PATCH v2fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 1da68d3b1eda..8ea5920fb777 100644
--- PATCH v2fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -1109,8 +1109,11 @@ static int nfs_do_recoalesce(struct nfs_pageio_descriptor *desc)
nfs_list_remove_request(req);
if (__nfs_pageio_add_request(desc, req))
continue;
- if (desc->pg_error < 0)
+ if (desc->pg_error < 0) {
+ list_splice_tail(&head, &mirror->pg_list);
+ mirror->pg_recoalesce = 1;
return 0;
+ }
break;
}
} while (mirror->pg_recoalesce);
--
2.4.3



2015-07-27 14:34:20

by Trond Myklebust

[permalink] [raw]
Subject: [PATCH 2/2] NFS: Don't clear desc->pg_moreio in nfs_do_recoalesce()

Recoalescing does not affect whether or not we've already sent off
I/O, and doing so means that we end up sending a bunch of synchronous
for cases where we actually need to be using unstable writes.

Signed-off-by: Trond Myklebust <[email protected]>
---
fs/nfs/pagelist.c | 2 --
1 file changed, 2 deletions(-)

diff --git PATCH v2fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 8ea5920fb777..4984bbe55ff1 100644
--- PATCH v2fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -1100,8 +1100,6 @@ static int nfs_do_recoalesce(struct nfs_pageio_descriptor *desc)
mirror->pg_base = 0;
mirror->pg_recoalesce = 0;

- desc->pg_moreio = 0;
-
while (!list_empty(&head)) {
struct nfs_page *req;

--
2.4.3


2015-07-27 22:45:57

by Weston Andros Adamson

[permalink] [raw]
Subject: Re: [PATCH 1/2] NFS: Fix a memory leak in nfs_do_recoalesce

ACK to both.

Good catch, thanks!

-dros



> On Jul 27, 2015, at 10:34 AM, Trond Myklebust <[email protected]> wrote:
>
> If the function exits early, then we must put those requests that were
> not processed back onto the &mirror->pg_list so they can be cleaned up
> by nfs_pgio_error().
>
> Fixes: a7d42ddb30997 ("nfs: add mirroring support to pgio layer")
> Cc: [email protected] # v4.0+
> Signed-off-by: Trond Myklebust <[email protected]>
> ---
> fs/nfs/pagelist.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git PATCH v2fs/nfs/pagelist.c b/fs/nfs/pagelist.c
> index 1da68d3b1eda..8ea5920fb777 100644
> --- PATCH v2fs/nfs/pagelist.c
> +++ b/fs/nfs/pagelist.c
> @@ -1109,8 +1109,11 @@ static int nfs_do_recoalesce(struct nfs_pageio_descriptor *desc)
> nfs_list_remove_request(req);
> if (__nfs_pageio_add_request(desc, req))
> continue;
> - if (desc->pg_error < 0)
> + if (desc->pg_error < 0) {
> + list_splice_tail(&head, &mirror->pg_list);
> + mirror->pg_recoalesce = 1;
> return 0;
> + }
> break;
> }
> } while (mirror->pg_recoalesce);
> --
> 2.4.3
>