Return-Path: Received: from mail-co1nam03on0133.outbound.protection.outlook.com ([104.47.40.133]:16069 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032398AbeCAPeL (ORCPT ); Thu, 1 Mar 2018 10:34:11 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: "J. Bruce Fields" , Trond Myklebust , Sasha Levin Subject: [added to the 4.1 stable tree] NFS: commit direct writes even if they fail partially Date: Thu, 1 Mar 2018 15:26:03 +0000 Message-ID: <20180301152116.1486-328-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: "J. Bruce Fields" This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 1b8d97b0a837beaf48a8449955b52c650a7114b4 ] 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 Signed-off-by: Sasha Levin --- fs/nfs/direct.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 38678d9a5cc4..cb050d1e8146 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -784,10 +784,8 @@ static void nfs_direct_write_completion(struct nfs_pgi= o_header *hdr) =20 spin_lock(&dreq->lock); =20 - if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) { - dreq->flags =3D 0; + if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) dreq->error =3D hdr->error; - } if (dreq->error =3D=3D 0) { nfs_direct_good_bytes(dreq, hdr); if (nfs_write_need_commit(hdr)) { --=20 2.14.1