Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1104931pxa; Thu, 20 Aug 2020 02:35:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGmcvTzX7lRUR0LZ+8vqQD+vEe+OTLV+1xzPswbBvxmUDyJPL6mLWc2lI5GEccUYAfhUeV X-Received: by 2002:a17:907:205c:: with SMTP id pg28mr2298579ejb.22.1597916156862; Thu, 20 Aug 2020 02:35:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597916156; cv=none; d=google.com; s=arc-20160816; b=BtCae5E+xQDLqICyZx6SNkGb+GciES273ndDqBq1uMetnHCpvvCUQgq4PlkVRqoyT2 QQ3MR9GUk2Mr25nTKOpd5JTezacqypKoPJBQkqEesJHdJuYAsYPhqwEEy+wo3Ut9+VPT OvZDdSUPqQWsWCrGBWIgK6z0bJTFVSJBLtdk7TV9KR8HkXoTbyDD622zLMSLUoP3DWuH OKIu1a76MMym4dZIqsI4NYBxGAzljMpH28xIrZN30SaKXanMEacjnnAmv+Jc8mb5o6np 49pMjv4S+nL3r7FVlbhexZfSG+IszU2Sf+A+ZDCbHjuC1MhXnKdIjuyIWiSu9ffdAF1L dB0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NiNLmJ4PUu+xq43fNEsNK0cHhFt0Iymi5PGmQK6MrdU=; b=JcvC+z6q13oWKqMlN39+gfVhY3CrstEpa1I+A3cQPVD1rk1Lpjr7h7eOaMN2N4np7D YFaC09JEgGlWZHDVDSKU3vmAUbN8HczFZDyqfnJOLgkLMXYP/XvlAfm+rWaDY6BKMNtl bmThuDqT0lk8TO3l9hVqOH8eUUvLIduga93c2yfgP0kYBE2YPT84D3/uUO2ZME/JeSPu zGtIomwEfwbAEvl4lzRk9ATlijFbm0btfxFuMvrLJM/Q0Qq4rtGWWv+RfRrEHp3/9/F9 s5b82e+ArMQXGStvUto085Jq/xvyt783yKGPRxPOPh8JE86NvHGMe4yMnbs7PWwYBZdW KPNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PcdJzW9e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t23si993861edc.163.2020.08.20.02.35.33; Thu, 20 Aug 2020 02:35:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PcdJzW9e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728366AbgHTJev (ORCPT + 99 others); Thu, 20 Aug 2020 05:34:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:44492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726974AbgHTJcL (ORCPT ); Thu, 20 Aug 2020 05:32:11 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C964922B3F; Thu, 20 Aug 2020 09:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915930; bh=NnN6YacW0a2xO0gvCRIxh7ybG+jk2VHafX/DGDFWdoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PcdJzW9ebzxprXNRxrTtWOJ64BhD/hIsFM+hj0J9yY0SAHiZ9FNcaOch2sMuHCGQ+ 5BSmOqB4wnAn3pXVGXXjViGuxo68sIXCDM3vg7upX1EGPkQYbDDCTAYx0MKYEMaLnm 9ehuKyVRlZqF6NoGwqI1WRVFmiap7xiX0MXARZ2A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Scott Mayhew , Trond Myklebust , Sasha Levin Subject: [PATCH 5.8 184/232] nfs: nfs_file_write() should check for writeback errors Date: Thu, 20 Aug 2020 11:20:35 +0200 Message-Id: <20200820091621.714245075@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Scott Mayhew [ Upstream commit ce368536dd614452407dc31e2449eb84681a06af ] The NFS_CONTEXT_ERROR_WRITE flag (as well as the check of said flag) was removed by commit 6fbda89b257f. The absence of an error check allows writes to be continually queued up for a server that may no longer be able to handle them. Fix it by adding an error check using the generic error reporting functions. Fixes: 6fbda89b257f ("NFS: Replace custom error reporting mechanism with generic one") Signed-off-by: Scott Mayhew Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/file.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/nfs/file.c b/fs/nfs/file.c index d72496efa17b0..63940a7a70be1 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -590,12 +590,14 @@ static const struct vm_operations_struct nfs_file_vm_ops = { .page_mkwrite = nfs_vm_page_mkwrite, }; -static int nfs_need_check_write(struct file *filp, struct inode *inode) +static int nfs_need_check_write(struct file *filp, struct inode *inode, + int error) { struct nfs_open_context *ctx; ctx = nfs_file_open_context(filp); - if (nfs_ctx_key_to_expire(ctx, inode)) + if (nfs_error_is_fatal_on_server(error) || + nfs_ctx_key_to_expire(ctx, inode)) return 1; return 0; } @@ -606,6 +608,8 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from) struct inode *inode = file_inode(file); unsigned long written = 0; ssize_t result; + errseq_t since; + int error; result = nfs_key_timeout_notify(file, inode); if (result) @@ -630,6 +634,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from) if (iocb->ki_pos > i_size_read(inode)) nfs_revalidate_mapping(inode, file->f_mapping); + since = filemap_sample_wb_err(file->f_mapping); nfs_start_io_write(inode); result = generic_write_checks(iocb, from); if (result > 0) { @@ -648,7 +653,8 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from) goto out; /* Return error values */ - if (nfs_need_check_write(file, inode)) { + error = filemap_check_wb_err(file->f_mapping, since); + if (nfs_need_check_write(file, inode, error)) { int err = nfs_wb_all(inode); if (err < 0) result = err; -- 2.25.1