linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: Jeff Layton <jlayton@redhat.com>,
	viro@zeniv.linux.org.uk, akpm@linux-foundation.org
Cc: 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, 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
Date: Thu, 09 Mar 2017 08:23:43 +1100	[thread overview]
Message-ID: <8760jjv4ww.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <20170308162934.21989-4-jlayton@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2783 bytes --]

On Thu, Mar 09 2017, 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
> 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.

This change appears to assume that filemap_write_and_wait* is only
called from fsync() (or similar) and the return status is always
checked.

A __must_check annotation might be helpful.

It would catch v9_fs_file_lock(), afs_setattr() and others.

While I think your change is probably heading in the right direction,
there seem to be some loose ends still.

Thanks,
NeilBrown


>
> Suggested-by: Jan Kara <jack@suse.cz>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
>  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)) {
>  			int err2 = filemap_fdatawait(mapping);
>  			if (!err)
>  				err = err2;
> +		} else {
> +			/*
> +			 * Clear the error in the address space since we're
> +			 * returning an error here. -EIO takes precedence over
> +			 * everything else though, so we can just discard
> +			 * the return here.
> +			 */
> +			filemap_check_errors(mapping);
>  		}
>  	} else {
>  		err = filemap_check_errors(mapping);
> @@ -537,6 +545,14 @@ int filemap_write_and_wait_range(struct address_space *mapping,
>  						lstart, lend);
>  			if (!err)
>  				err = err2;
> +		} else {
> +			/*
> +			 * Clear the error in the address space since we're
> +			 * returning an error here. -EIO takes precedence over
> +			 * everything else though, so we can just discard
> +			 * the return here.
> +			 */
> +			filemap_check_errors(mapping);
>  		}
>  	} else {
>  		err = filemap_check_errors(mapping);
> -- 
> 2.9.3

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2017-03-08 21:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-08 16:29 [PATCH v2 0/9] mm/fs: get PG_error out of the writeback reporting business Jeff Layton
2017-03-08 16:29 ` [PATCH v2 1/9] mm: fix mapping_set_error call in me_pagecache_dirty Jeff Layton
2017-03-10  0:06   ` Ross Zwisler
2017-03-08 16:29 ` [PATCH v2 2/9] mm: drop "wait" parameter from write_one_page Jeff Layton
2017-03-10  0:07   ` Ross Zwisler
2017-03-08 16:29 ` [PATCH v2 3/9] mm: clear any AS_* errors when returning error on any fsync or close Jeff Layton
2017-03-08 21:23   ` NeilBrown [this message]
2017-03-09  0:10     ` Jeff Layton
2017-03-10  0:09   ` Ross Zwisler
2017-03-10  3:08     ` Jeff Layton
2017-03-08 16:29 ` [PATCH v2 4/9] nilfs2: set the mapping error when calling SetPageError on writeback Jeff Layton
2017-03-08 16:29 ` [PATCH v2 5/9] dax: set error in mapping when writeback fails Jeff Layton
2017-03-10  0:21   ` Ross Zwisler
2017-03-08 16:29 ` [PATCH v2 6/9] mm: set mapping error when launder_pages fails Jeff Layton
2017-03-08 18:01   ` Trond Myklebust
2017-03-08 18:38     ` Jeff Layton
2017-03-08 19:16       ` Trond Myklebust
2017-03-08 21:28     ` NeilBrown
2017-03-08 16:29 ` [PATCH v2 7/9] mm: ensure that we set mapping error if writeout() fails Jeff Layton
2017-03-08 16:29 ` [PATCH v2 8/9] mm: don't TestClearPageError in __filemap_fdatawait_range Jeff Layton
2017-03-08 16:29 ` [PATCH v2 9/9] Documentation: document what to do on a writeback error Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8760jjv4ww.fsf@notabene.neil.brown.name \
    --to=neilb@suse.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=adilger@dilger.ca \
    --cc=akpm@linux-foundation.org \
    --cc=jack@suse.cz \
    --cc=jlayton@redhat.com \
    --cc=konishi.ryusuke@lab.ntt.co.jp \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nilfs@vger.kernel.org \
    --cc=openosd@gmail.com \
    --cc=ross.zwisler@linux.intel.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).