Skip to content

Commit

Permalink
nfs: clean up rest of reqs when failing to add one
Browse files Browse the repository at this point in the history
If we fail to set up things before sending anything over wire,
we need to clean up the reqs that are still attached to the
IO descriptor.

Signed-off-by: Peng Tao <tao.peng@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
  • Loading branch information
Peng Tao authored and Trond Myklebust committed Dec 28, 2015
1 parent d600ad1 commit c18b96a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions fs/nfs/pagelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,7 @@ static int nfs_do_recoalesce(struct nfs_pageio_descriptor *desc)
static int nfs_pageio_add_request_mirror(struct nfs_pageio_descriptor *desc,
struct nfs_page *req)
{
struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc);
int ret;

do {
Expand Down Expand Up @@ -1153,7 +1154,7 @@ int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,

nfs_pageio_setup_mirroring(desc, req);
if (desc->pg_error < 0)
return 0;
goto out_failed;

for (midx = 0; midx < desc->pg_mirror_count; midx++) {
if (midx) {
Expand All @@ -1170,7 +1171,8 @@ int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,

if (IS_ERR(dupreq)) {
nfs_page_group_unlock(req);
return 0;
desc->pg_error = PTR_ERR(dupreq);
goto out_failed;
}

nfs_lock_request(dupreq);
Expand All @@ -1183,10 +1185,19 @@ int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,
if (nfs_pgio_has_mirroring(desc))
desc->pg_mirror_idx = midx;
if (!nfs_pageio_add_request_mirror(desc, dupreq))
return 0;
goto out_failed;
}

return 1;

out_failed:
/*
* We might have failed before sending any reqs over wire.
* clean up rest of the reqs in mirror pg_list
*/
if (desc->pg_error)
desc->pg_completion_ops->error_cleanup(&mirror->pg_list);
return 0;
}

/*
Expand Down

0 comments on commit c18b96a

Please sign in to comment.