public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <aelder@sgi.com>
To: Dave Chinner <david@fromorbit.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 1/7] xfs: ensure sync write errors are returned
Date: Thu, 16 Dec 2010 14:50:49 -0600	[thread overview]
Message-ID: <1292532649.2457.54.camel@doink> (raw)
In-Reply-To: <1292376208-16282-2-git-send-email-david@fromorbit.com>

On Wed, 2010-12-15 at 12:23 +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
> 
> xfs_file_aio_write() only returns the error from synchronous
> flushing of the data and inode if error == 0. At the point where
> error is being checked, it is guaranteed to be > 0. Therefore any

Actually, we have this above the affected code:
        ...
        error = -ret;   
        if (ret <= 0)
                goto out_unlock_internal;

So ret must be positive, therefore error is negative
(the negative of the number of bytes written).  In
other words, we enter this block without having seen
an error.

The return at the end of the function is:
	return -error;

And by the convoluted logic here, that means that the
value of error should be a negative byte count if
successful, or a positive errno otherwise.

And since filemap_write_and_wait_range() returns a
negative errno, your fix doesn't look right to me.

The existing code is wrong and should be fixed, but a
better fix might make the meaning of the variable "error"
a little less weird.

					-Alex

> errors returned by the data or fsync flush will never be returned.
> Fix the checks so we overwrite the current error once and only if an
> error really occurred.
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
>  fs/xfs/linux-2.6/xfs_file.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
> index ba8ad42..e1eaec2 100644
> --- a/fs/xfs/linux-2.6/xfs_file.c
> +++ b/fs/xfs/linux-2.6/xfs_file.c
> @@ -769,7 +769,7 @@ write_retry:
>  			mutex_unlock(&inode->i_mutex);
>  
>  		error2 = filemap_write_and_wait_range(mapping, pos, end);
> -		if (!error)
> +		if (error2)
>  			error = error2;
>  		if (need_i_mutex)
>  			mutex_lock(&inode->i_mutex);
> @@ -777,7 +777,7 @@ write_retry:
>  
>  		error2 = -xfs_file_fsync(file,
>  					 (file->f_flags & __O_SYNC) ? 0 : 1);
> -		if (!error)
> +		if (error2 && error >= 0)
>  			error = error2;
>  	}
>  



_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2010-12-16 20:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-15  1:23 [PATCH 0/7] xfs: serialise unaligned direct IOs Dave Chinner
2010-12-15  1:23 ` [PATCH 1/7] xfs: ensure sync write errors are returned Dave Chinner
2010-12-16 11:57   ` Christoph Hellwig
2010-12-16 21:57     ` Dave Chinner
2010-12-16 20:50   ` Alex Elder [this message]
2010-12-17  6:43     ` Dave Chinner
2010-12-15  1:23 ` [PATCH 2/7] xfs: factor common post-write isize handling code Dave Chinner
2010-12-15  1:23 ` [PATCH 4/7] xfs: split direct IO write path from xfs_file_aio_write Dave Chinner
2010-12-16 12:06   ` Christoph Hellwig
2010-12-17  7:31     ` Dave Chinner
2010-12-20 11:29       ` Christoph Hellwig
2010-12-21  0:51         ` Dave Chinner
2010-12-15  1:23 ` [PATCH 5/7] xfs: split buffered " Dave Chinner
2010-12-15  1:23 ` [PATCH 6/7] xfs: factor common write setup code Dave Chinner
2010-12-15  1:23 ` [PATCH 7/7] xfs: serialise unaligned direct IOs Dave Chinner

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=1292532649.2457.54.camel@doink \
    --to=aelder@sgi.com \
    --cc=david@fromorbit.com \
    --cc=xfs@oss.sgi.com \
    /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