Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754178AbdCJAJn (ORCPT ); Thu, 9 Mar 2017 19:09:43 -0500 Received: from mga07.intel.com ([134.134.136.100]:26906 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753831AbdCJAJl (ORCPT ); Thu, 9 Mar 2017 19:09:41 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,137,1486454400"; d="scan'208";a="1120697732" Date: Thu, 9 Mar 2017 17:09:39 -0700 From: Ross Zwisler To: Jeff Layton Cc: viro@zeniv.linux.org.uk, akpm@linux-foundation.org, konishi.ryusuke@lab.ntt.co.jp, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-nilfs@vger.kernel.org, ross.zwisler@linux.intel.com, jack@suse.cz, neilb@suse.com, openosd@gmail.com, adilger@dilger.ca, James.Bottomley@HansenPartnership.com Subject: Re: [PATCH v2 3/9] mm: clear any AS_* errors when returning error on any fsync or close Message-ID: <20170310000939.GC30285@linux.intel.com> Mail-Followup-To: Ross Zwisler , Jeff Layton , viro@zeniv.linux.org.uk, akpm@linux-foundation.org, konishi.ryusuke@lab.ntt.co.jp, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-nilfs@vger.kernel.org, jack@suse.cz, neilb@suse.com, openosd@gmail.com, adilger@dilger.ca, James.Bottomley@HansenPartnership.com References: <20170308162934.21989-1-jlayton@redhat.com> <20170308162934.21989-4-jlayton@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170308162934.21989-4-jlayton@redhat.com> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1629 Lines: 42 On Wed, Mar 08, 2017 at 11:29:28AM -0500, Jeff Layton wrote: > Currently we don't clear the address space error when there is a -EIO > error on fsynci, due to writeback initiation failure. If writes fail fsync > with -EIO and the mapping is 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 | 20 ++++++++++++++++++-- > 1 file changed, 18 insertions(+), 2 deletions(-) > > diff --git a/mm/filemap.c b/mm/filemap.c > index 1694623a6289..fc123b9833e1 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)) { > @@ -499,10 +499,18 @@ int filemap_write_and_wait(struct address_space *mapping) > * But the -EIO is special case, it may indicate the worst > * thing (e.g. bug) happened, so we avoid waiting for it. > */ > - if (err != -EIO) { > + if (likely(err != -EIO)) { The above two cleanup changes were made only to filemap_write_and_wait(), but should also probably be done to filemap_write_and_wait_range() to keep them as consistent as possible?