Skip to content

Commit

Permalink
NFS: Fix writepage(s) error handling to not report errors twice
Browse files Browse the repository at this point in the history
If writepage()/writepages() saw an error, but handled it without
reporting it, we should not be re-reporting that error on exit.

Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
Trond Myklebust committed Aug 26, 2019
1 parent 8f54c7a commit 96c4145
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions fs/nfs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,12 +621,12 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio,
WARN_ON_ONCE(test_bit(PG_CLEAN, &req->wb_flags));

/* If there is a fatal error that covers this write, just exit */
ret = 0;
mapping = page_file_mapping(page);
if (test_bit(AS_ENOSPC, &mapping->flags) ||
test_bit(AS_EIO, &mapping->flags))
ret = pgio->pg_error;
if (nfs_error_is_fatal_on_server(ret))
goto out_launder;

ret = 0;
if (!nfs_pageio_add_request(pgio, req)) {
ret = pgio->pg_error;
/*
Expand All @@ -638,6 +638,7 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio,
} else
ret = -EAGAIN;
nfs_redirty_request(req);
pgio->pg_error = 0;
} else
nfs_add_stats(page_file_mapping(page)->host,
NFSIOS_WRITEPAGES, 1);
Expand All @@ -657,7 +658,7 @@ static int nfs_do_writepage(struct page *page, struct writeback_control *wbc,
ret = nfs_page_async_flush(pgio, page);
if (ret == -EAGAIN) {
redirty_page_for_writepage(wbc, page);
ret = 0;
ret = AOP_WRITEPAGE_ACTIVATE;
}
return ret;
}
Expand All @@ -676,10 +677,11 @@ static int nfs_writepage_locked(struct page *page,
nfs_pageio_init_write(&pgio, inode, 0,
false, &nfs_async_write_completion_ops);
err = nfs_do_writepage(page, wbc, &pgio);
pgio.pg_error = 0;
nfs_pageio_complete(&pgio);
if (err < 0)
return err;
if (pgio.pg_error < 0)
if (nfs_error_is_fatal(pgio.pg_error))
return pgio.pg_error;
return 0;
}
Expand All @@ -689,7 +691,8 @@ int nfs_writepage(struct page *page, struct writeback_control *wbc)
int ret;

ret = nfs_writepage_locked(page, wbc);
unlock_page(page);
if (ret != AOP_WRITEPAGE_ACTIVATE)
unlock_page(page);
return ret;
}

Expand All @@ -698,7 +701,8 @@ static int nfs_writepages_callback(struct page *page, struct writeback_control *
int ret;

ret = nfs_do_writepage(page, wbc, data);
unlock_page(page);
if (ret != AOP_WRITEPAGE_ACTIVATE)
unlock_page(page);
return ret;
}

Expand All @@ -724,13 +728,14 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc)
&nfs_async_write_completion_ops);
pgio.pg_io_completion = ioc;
err = write_cache_pages(mapping, wbc, nfs_writepages_callback, &pgio);
pgio.pg_error = 0;
nfs_pageio_complete(&pgio);
nfs_io_completion_put(ioc);

if (err < 0)
goto out_err;
err = pgio.pg_error;
if (err < 0)
if (nfs_error_is_fatal(err))
goto out_err;
return 0;
out_err:
Expand Down

0 comments on commit 96c4145

Please sign in to comment.