Skip to content

Commit

Permalink
NFS: commit direct writes even if they fail partially
Browse files Browse the repository at this point in the history
If some of the WRITE calls making up an O_DIRECT write syscall fail,
we neglect to commit, even if some of the WRITEs succeed.

We also depend on the commit code to free the reference count on the
nfs_page taken in the "if (request_commit)" case at the end of
nfs_direct_write_completion().  The problem was originally noticed
because ENOSPC's encountered partway through a write would result in a
closed file being sillyrenamed when it should have been unlinked.

Signed-off-by: J. Bruce Fields <[email protected]>
Cc: [email protected]
Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
J. Bruce Fields authored and trondmypd committed Jan 16, 2018
1 parent f96adf1 commit 1b8d97b
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions fs/nfs/direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -775,10 +775,8 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr)

spin_lock(&dreq->lock);

if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) {
dreq->flags = 0;
if (test_bit(NFS_IOHDR_ERROR, &hdr->flags))
dreq->error = hdr->error;
}
if (dreq->error == 0) {
nfs_direct_good_bytes(dreq, hdr);
if (nfs_write_need_commit(hdr)) {
Expand Down

0 comments on commit 1b8d97b

Please sign in to comment.