From: J. Bruce Fields Date: Tue, 16 Jan 2018 15:08:00 +0000 (-0500) Subject: NFS: commit direct writes even if they fail partially X-Git-Tag: v4.1.12-124.31.3~252 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=0226948420ecb7590a228f4575c6228e316866fe;p=users%2Fjedix%2Flinux-maple.git NFS: commit direct writes even if they fail partially 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 Cc: stable@vger.kernel.org Signed-off-by: Trond Myklebust (cherry picked from commit 1b8d97b0a837beaf48a8449955b52c650a7114b4) Orabug: 28212440 Signed-off-by: Manjunath Patil Reviewed-by: Calum Mackay Signed-off-by: Brian Maly --- diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 8beeaf06e360..49d1417c896e 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -793,10 +793,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)) {