Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp242212pxa; Fri, 31 Jul 2020 10:47:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+ZhHDuvG87BPr+/dCbc158ywrNDoNHMZHgbOClIU54lF2pg5SHi/M8eEFqBW/BZ5TCo0g X-Received: by 2002:a17:906:c213:: with SMTP id d19mr5419513ejz.291.1596217636295; Fri, 31 Jul 2020 10:47:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596217636; cv=none; d=google.com; s=arc-20160816; b=U/hmztAysWIljQY1fC8kxK+UbfuwjjQvBUb8VFL+QRl1cAyqEbZKpENPB1YLXVDfbM HoYb9+GtyXJ94Xqtx0e76tCqwQZ6/hNlLA0QzrF3U5HkydOVprAoA+7RxAXRdkX8JUgx InP8AGF2ZD+uhsvO+u9EAxKPsdRe66aYoNdhO3GQquZY2I01EIXED6wobnq2X+GIoRjc yej6rR6a/57uCLndCnMfWMPTfoVziSHfeMw/zdRSjGKAM2TXydT8/pHXZcjZHXIM5YzZ 5FZ6CCKjiERxEMqkl8y2E3U63jx4wVh+9q3tzm91CJufD886dmzwWhna6Y+XR1ztgPHq TXNQ== 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=qFPO+Z15nztX6EIfKvMpKcaydKBsQ7RALeC0PvYnrFg=; b=czNFHlny6YUd6A1RF2rPsMxxGIVvYew+5nvnqCJbYNJem/Bzd1MAeOElPskAOEcaGC ZolodmkpsRyIeQUN1IPc5KOjdqtgjVX6NpCLD/YY1HRX+pg7BYt86wVpCKo2ulC32Z2g hoqse9DaOG42DHeP9fuNsRz/wZUyHrUbRGiouqMmalvax0RkzNio2bHhSTGy2R8UVQ2n B0XLbvmVOKdPJPOYum+rPawpvVtdu//g+JlTPCrSi6XQz6KL/j5b96PQez/i1JN6Cgzd V753gsk1kU7poSksg9te/fyF9dNLMhXqDB26sKNnIXMooDq6dMpt9gFVxuCdA2G49fOk PsSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bDxq42QB; 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 n13si5424206eje.393.2020.07.31.10.46.53; Fri, 31 Jul 2020 10:47:16 -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=bDxq42QB; 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 S2387469AbgGaRqT (ORCPT + 99 others); Fri, 31 Jul 2020 13:46:19 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:57908 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387429AbgGaRqT (ORCPT ); Fri, 31 Jul 2020 13:46:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596217578; 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=qFPO+Z15nztX6EIfKvMpKcaydKBsQ7RALeC0PvYnrFg=; b=bDxq42QBiT0nkQXN7Yo2loNlBEvnVVALVFTijsHtyXDMW+79m91oawySvfzXnlgxEjE/QO YNFqqaWvRW3hTwRAxLzJaeQlJc3SwWuhxVzShG13oUsvYono71igDBjOcmd8Tj5r3EFsL/ uxhhNVxAjRBH8hYN+g9X13qt7OKlKKU= 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-347-VdaqVV9jNKyEAvrC9yiT6Q-1; Fri, 31 Jul 2020 13:46:16 -0400 X-MC-Unique: VdaqVV9jNKyEAvrC9yiT6Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7C92618839CD; Fri, 31 Jul 2020 17:46:15 +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 612425BAC3; Fri, 31 Jul 2020 17:46:15 +0000 (UTC) Received: by aion.usersys.redhat.com (Postfix, from userid 1000) id 7857C1A0005; Fri, 31 Jul 2020 13:46:14 -0400 (EDT) From: Scott Mayhew To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH 1/2] nfs: ensure correct writeback errors are returned on close() Date: Fri, 31 Jul 2020 13:46:13 -0400 Message-Id: <20200731174614.1299346-2-smayhew@redhat.com> In-Reply-To: <20200731174614.1299346-1-smayhew@redhat.com> References: <20200731174614.1299346-1-smayhew@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org nfs_wb_all() calls filemap_write_and_wait(), which uses filemap_check_errors() to determine the error to return. filemap_check_errors() only looks at the mapping->flags and will therefore only return either -ENOSPC or -EIO. To ensure that the correct error is returned on close(), nfs{,4}_file_flush() should call file_check_and_advance_wb_err() which looks at the errseq value in mapping->wb_err. Fixes: 6fbda89b257f ("NFS: Replace custom error reporting mechanism with generic one") Signed-off-by: Scott Mayhew --- fs/nfs/file.c | 3 ++- fs/nfs/nfs4file.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/nfs/file.c b/fs/nfs/file.c index f96367a2463e..eeef6580052f 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -148,7 +148,8 @@ nfs_file_flush(struct file *file, fl_owner_t id) return 0; /* Flush writes to the server and return any errors */ - return nfs_wb_all(inode); + nfs_wb_all(inode); + return file_check_and_advance_wb_err(file); } ssize_t diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 8e5d6223ddd3..77bf9c12734c 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -125,7 +125,8 @@ nfs4_file_flush(struct file *file, fl_owner_t id) return filemap_fdatawrite(file->f_mapping); /* Flush writes to the server and return any errors */ - return nfs_wb_all(inode); + nfs_wb_all(inode); + return file_check_and_advance_wb_err(file); } #ifdef CONFIG_NFS_V4_2 -- 2.25.4