From patchwork Tue May 30 11:10:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 9754293 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E16BE602B9 for ; Tue, 30 May 2017 11:10:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6D1628408 for ; Tue, 30 May 2017 11:10:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB76D28485; Tue, 30 May 2017 11:10:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D20228408 for ; Tue, 30 May 2017 11:10:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751415AbdE3LKu (ORCPT ); Tue, 30 May 2017 07:10:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22574 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751406AbdE3LKt (ORCPT ); Tue, 30 May 2017 07:10:49 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1ED108123A; Tue, 30 May 2017 11:10:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1ED108123A Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jlayton@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1ED108123A Received: from tleilax.poochiereds.net (ovpn-120-244.rdu2.redhat.com [10.10.120.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F52F5C8A6; Tue, 30 May 2017 11:10:48 +0000 (UTC) From: Jeff Layton To: Andrew Morton , Ross Zwisler Cc: Jan Kara , NeilBrown , willy@infradead.org, Al Viro , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 1/2] mm: clear any AS_* errors when returning from filemap_write_and_wait{_range} Date: Tue, 30 May 2017 07:10:45 -0400 Message-Id: <20170530111046.8069-2-jlayton@redhat.com> In-Reply-To: <20170530111046.8069-1-jlayton@redhat.com> References: <20170530111046.8069-1-jlayton@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 30 May 2017 11:10:49 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently we don't clear the address space error when there is a -EIO error on fsync due to writeback initiation failure. If initiating writes fails with -EIO and the mapping is already flagged with an AS_EIO or AS_ENOSPC error, then we can end up returning errors on two fsync calls, even when a write between them succeeded (or there was no write). Ensure that we also clear out any mapping errors when initiating writeback fails with -EIO in filemap_write_and_wait and filemap_write_and_wait_range. Suggested-by: Jan Kara Signed-off-by: Jeff Layton --- mm/filemap.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 6f1be573a5e6..39ff92d7ecdd 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -488,7 +488,7 @@ EXPORT_SYMBOL(filemap_fdatawait); int filemap_write_and_wait(struct address_space *mapping) { - int err = 0; + int err; if ((!dax_mapping(mapping) && mapping->nrpages) || (dax_mapping(mapping) && mapping->nrexceptional)) { @@ -503,6 +503,8 @@ int filemap_write_and_wait(struct address_space *mapping) int err2 = filemap_fdatawait(mapping); if (!err) err = err2; + } else { + filemap_check_errors(mapping); } } else { err = filemap_check_errors(mapping); @@ -525,7 +527,7 @@ EXPORT_SYMBOL(filemap_write_and_wait); int filemap_write_and_wait_range(struct address_space *mapping, loff_t lstart, loff_t lend) { - int err = 0; + int err; if ((!dax_mapping(mapping) && mapping->nrpages) || (dax_mapping(mapping) && mapping->nrexceptional)) { @@ -537,6 +539,8 @@ int filemap_write_and_wait_range(struct address_space *mapping, lstart, lend); if (!err) err = err2; + } else { + filemap_check_errors(mapping); } } else { err = filemap_check_errors(mapping);