From: Eric Sandeen <sandeen@sandeen.net>
To: Dave Chinner <david@fromorbit.com>, xfs@oss.sgi.com
Subject: Re: [PATCH 2/2] libxfs: clear stale buffer errors on write
Date: Thu, 20 Feb 2014 13:09:14 -0600 [thread overview]
Message-ID: <530652DA.7010706@sandeen.net> (raw)
In-Reply-To: <1392875722-4390-3-git-send-email-david@fromorbit.com>
On 2/19/14, 11:55 PM, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> If we've read a buffer and it's had an error (e.g a bad CRC) and the
> caller corrects the problem with the buffer and writes it via
> libxfs_writebuf() without clearing the error on the buffer,
> subsequent reads of the buffer while it is still in cache can see
> that error and fail inappropriately.
>
> xfs/033 demonstrates this error, where phase 3 detects the corrupted
> root inode and clears, but doesn't clear the b_error field. Later in
> phase 6, the code that rebuilds the root directory tries to read the
> root inode and sees a buffer with an error on it, thereby triggering
> a fatal repair failure:
>
> Phase 3 - for each AG...
> - scan and clear agi unlinked lists...
> - process known inodes and perform inode discovery...
> - agno = 0
> xfs_inode_buf_verify: XFS_CORRUPTION_ERROR
> bad magic number 0x0 on inode 64
> ....
> cleared root inode 64
> ....
> Phase 6 - check inode connectivity...
> reinitializing root directory
> xfs_imap_to_bp: xfs_trans_read_buf() returned error 117.
>
> fatal error -- could not iget root inode -- error - 117
> #
>
> Fix this by assuming buffers that are written are clean and correct
> and hence we can zero the b_error field before retiring the buffer
> to the cache.
Thanks;
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
> Reported-by: Eric Sandeen <esandeen@redhat.com>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
> libxfs/rdwr.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
> index 78a9b37..d0ff15b 100644
> --- a/libxfs/rdwr.c
> +++ b/libxfs/rdwr.c
> @@ -890,6 +890,11 @@ libxfs_writebufr(xfs_buf_t *bp)
> int
> libxfs_writebuf_int(xfs_buf_t *bp, int flags)
> {
> + /*
> + * Clear any error hanging over from reading the buffer. This prevents
> + * subsequent reads after this write from seeing stale errors.
> + */
> + bp->b_error = 0;
> bp->b_flags |= (LIBXFS_B_DIRTY | flags);
> return 0;
> }
> @@ -903,6 +908,11 @@ libxfs_writebuf(xfs_buf_t *bp, int flags)
> (long long)LIBXFS_BBTOOFF64(bp->b_bn),
> (long long)bp->b_bn);
> #endif
> + /*
> + * Clear any error hanging over from reading the buffer. This prevents
> + * subsequent reads after this write from seeing stale errors.
> + */
> + bp->b_error = 0;
> bp->b_flags |= (LIBXFS_B_DIRTY | flags);
> libxfs_putbuf(bp);
> return 0;
>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2014-02-20 19:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-20 5:55 [PATCH 0/2] xfs_repair: fix xfs/033 issues Dave Chinner
2014-02-20 5:55 ` [PATCH 1/2] libxfs: contiguous buffers are not discontigous Dave Chinner
2014-02-20 15:38 ` Christoph Hellwig
2014-02-20 19:06 ` Eric Sandeen
2014-02-20 21:39 ` Dave Chinner
2014-02-20 5:55 ` [PATCH 2/2] libxfs: clear stale buffer errors on write Dave Chinner
2014-02-20 15:38 ` Christoph Hellwig
2014-02-20 19:09 ` Eric Sandeen [this message]
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=530652DA.7010706@sandeen.net \
--to=sandeen@sandeen.net \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.