Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp723402pxa; Sat, 1 Aug 2020 04:11:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuyf3nN6037eJxklua2Dchg/ifM0QlNw9ZPRBrgrQBUUvPZz5ogl12gf7CR1UmBo+GCb2M X-Received: by 2002:a17:906:af1a:: with SMTP id lx26mr8604784ejb.415.1596280285627; Sat, 01 Aug 2020 04:11:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596280285; cv=none; d=google.com; s=arc-20160816; b=MDrknmDgJGsZKgI2SwTCEyDs9xVn93IqRvU5nrPETFZ4mHcSK30kvq4+ie/Kd7ahQD istzX0GwFhRTDHrMCvaZdWFYUxiZvzJcLjIWX0TZoAkyTSN5YQpRd2OukWEhUYmjR9F5 Z+0jRZ6PyAZcM76JEXr/BbQqTOfEjwMxqBuZ/SkBaDKF4u7F6/y9hv/fWr5lnUrUKY1C OPUFXdi6Q7FkIwh3s61gJu+OdyVKGx4jZ3yD+Jb8PDaFEYXPm0xeUOyBAy7FgjvDpRuy 9eyUubSt18qhdPGctBdCQGy8xYq8WVs5qvrUtH8nYl+YKE3/hr4K2t+4k0T6XH2JUtjn Q7nw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iUDWn7O+gKFLZMJSiLkM1M/5/GiJ3nnxzmIjw/TR8oo=; b=0/Wx7ANCUijVMX+jcIgmF5w4fQ44abTFRJ8spMtqGR4lDpF92XxMSt0PoR+MZ9j5+/ vyXSVTlOpk7ljzZXB3p1X+coPiHJ4r0iI0r9jIFH7cVLhO0OSr1sepPuVMzdOdfYErJ4 j50H9vrUdCbpHoBIH90GRI4l2o45ncuVk27VAHNAmBjK2T/IhAB+tAjBV//Sn/vQ4rCe a2XKfek8wp8c3KdqVnTqiUw52padG6+zVwVGs3tE9lJy+kPDab3clphUA8N+0x+MmK7Y iKcH/4FtmVbGTP77jUFob9ZTx84HTuwUsPDw6hh34txWvTj3AB7L6rDJ/7TPMluHBnI8 rgTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZCICIz+A; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jo4si6868350ejb.455.2020.08.01.04.10.46; Sat, 01 Aug 2020 04:11:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@redhat.com header.s=mimecast20190719 header.b=ZCICIz+A; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728531AbgHALKp (ORCPT + 99 others); Sat, 1 Aug 2020 07:10:45 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:54092 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728418AbgHALKo (ORCPT ); Sat, 1 Aug 2020 07:10:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596280243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iUDWn7O+gKFLZMJSiLkM1M/5/GiJ3nnxzmIjw/TR8oo=; b=ZCICIz+A0VOZm/2l8qhC6XUxTLoqkyN10oAJ8QESLE2/prULfzSHJKPOMVDBhmvyY8iRR/ v8kphvjtm1NEp5mpEa5M4Gt22V2G+VipJfyCj3moq0ThNJ6Nq3DdTZ4LGLjhYi+G/G0K3A Q5QZsTW3rLXxMpH7K9YVIP+KBP6vd4s= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-148-xS_n-wJnO6OmeHCvTaOOWw-1; Sat, 01 Aug 2020 07:10:41 -0400 X-MC-Unique: xS_n-wJnO6OmeHCvTaOOWw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B87A3106B242; Sat, 1 Aug 2020 11:10:40 +0000 (UTC) Received: from aion.usersys.redhat.com (ovpn-115-198.rdu2.redhat.com [10.10.115.198]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6703E6FEEB; Sat, 1 Aug 2020 11:10:40 +0000 (UTC) Received: by aion.usersys.redhat.com (Postfix, from userid 1000) id 92A091A0008; Sat, 1 Aug 2020 07:10:39 -0400 (EDT) From: Scott Mayhew To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 2/2] nfs: nfs_file_write() should check for writeback errors Date: Sat, 1 Aug 2020 07:10:39 -0400 Message-Id: <20200801111039.1407632-3-smayhew@redhat.com> In-Reply-To: <20200801111039.1407632-1-smayhew@redhat.com> References: <20200801111039.1407632-1-smayhew@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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 --- 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 d72496efa17b..63940a7a70be 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.4