Skip to content

Commit

Permalink
NFS: Don't write back further requests if there is a pending write error
Browse files Browse the repository at this point in the history
If the server has already returned a fatal write error that the user
has not yet received on this file, then don't write back the other pages.
Instead, act as if they have been sent, and have returned with the same
error.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
  • Loading branch information
Trond Myklebust committed Apr 25, 2017
1 parent 6aeafd0 commit a659881
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions fs/nfs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,18 @@ static void nfs_write_error_remove_page(struct nfs_page *req)
nfs_release_request(req);
}

static bool
nfs_error_is_fatal_on_server(int err)
{
switch (err) {
case 0:
case -ERESTARTSYS:
case -EINTR:
return false;
}
return nfs_error_is_fatal(err);
}

/*
* Find an associated nfs write request, and prepare to flush it out
* May return an error if the user signalled nfs_wait_on_request().
Expand All @@ -591,6 +603,10 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio,
WARN_ON_ONCE(test_bit(PG_CLEAN, &req->wb_flags));

ret = 0;
/* If there is a fatal error that covers this write, just exit */
if (nfs_error_is_fatal_on_server(req->wb_context->error))
goto out_launder;

if (!nfs_pageio_add_request(pgio, req)) {
ret = pgio->pg_error;
/*
Expand All @@ -600,10 +616,8 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio,
*/
if (nfs_error_is_fatal(ret)) {
nfs_context_set_write_error(req->wb_context, ret);
if (launder) {
nfs_write_error_remove_page(req);
goto out;
}
if (launder)
goto out_launder;
}
nfs_redirty_request(req);
ret = -EAGAIN;
Expand All @@ -612,6 +626,9 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio,
NFSIOS_WRITEPAGES, 1);
out:
return ret;
out_launder:
nfs_write_error_remove_page(req);
return ret;
}

static int nfs_do_writepage(struct page *page, struct writeback_control *wbc,
Expand Down

0 comments on commit a659881

Please sign in to comment.