diff mbox series

[v1,6/7] xfs: Rewrite retried read

Message ID 1543376991-5764-7-git-send-email-allison.henderson@oracle.com (mailing list archive)
State New, archived
Headers show
Series Block/XFS: Support alternative mirror device retry | expand

Commit Message

Allison Henderson Nov. 28, 2018, 3:49 a.m. UTC
If we had to try more than one mirror to get a successful
read, then write that buffer back to correct the bad mirro

Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
---
 fs/xfs/xfs_buf.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Dave Chinner Nov. 28, 2018, 5:17 a.m. UTC | #1
On Tue, Nov 27, 2018 at 08:49:50PM -0700, Allison Henderson wrote:
> If we had to try more than one mirror to get a successful
> read, then write that buffer back to correct the bad mirro
> 
> Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> ---
>  fs/xfs/xfs_buf.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index f102d01..81f6491 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -847,6 +847,14 @@ xfs_buf_read_map(
>  
>  		}
>  retry_done:
> +
> +		/*
> +		 * if we had to try more than one mirror to sucessfully read
> +		 * the buffer, write the buffer back
> +		 */
> +		if (!bp->b_error && i > 0)
> +			xfs_bwrite(bp);
> +

This can go in the case statement on retry and then you don't need
to check for i > 0 or, well, bp->b_error. i.e.

		swtich (bp->b_error) {
		case -EBADCRC:
		case -EIO:
		case -EFSCORRUPTED:
			/* try again from different copy */
			continue;
		0:
			/* good copy, rewrite it to repair bad copy */
			xfs_bwrite(bp);
			/* fallthrough */
		default:
			return bp;
		}

Cheers,

Dave.
Darrick J. Wong Nov. 28, 2018, 5:26 a.m. UTC | #2
On Wed, Nov 28, 2018 at 04:17:19PM +1100, Dave Chinner wrote:
> On Tue, Nov 27, 2018 at 08:49:50PM -0700, Allison Henderson wrote:
> > If we had to try more than one mirror to get a successful
> > read, then write that buffer back to correct the bad mirro
> > 
> > Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> > ---
> >  fs/xfs/xfs_buf.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> > index f102d01..81f6491 100644
> > --- a/fs/xfs/xfs_buf.c
> > +++ b/fs/xfs/xfs_buf.c
> > @@ -847,6 +847,14 @@ xfs_buf_read_map(
> >  
> >  		}
> >  retry_done:
> > +
> > +		/*
> > +		 * if we had to try more than one mirror to sucessfully read
> > +		 * the buffer, write the buffer back
> > +		 */
> > +		if (!bp->b_error && i > 0)
> > +			xfs_bwrite(bp);
> > +
> 
> This can go in the case statement on retry and then you don't need
> to check for i > 0 or, well, bp->b_error. i.e.
> 
> 		swtich (bp->b_error) {
> 		case -EBADCRC:
> 		case -EIO:
> 		case -EFSCORRUPTED:
> 			/* try again from different copy */
> 			continue;
> 		0:
> 			/* good copy, rewrite it to repair bad copy */
> 			xfs_bwrite(bp);

Some day we might want to provide some controls for how long we'll retry
these reads and whether or not we automatically rewrite buffers, since
some administrators might prefer fast fail to get failover started.

(Not now though)

--D

> 			/* fallthrough */
> 		default:
> 			return bp;
> 		}
> 
> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com
Dave Chinner Nov. 28, 2018, 5:40 a.m. UTC | #3
On Tue, Nov 27, 2018 at 09:26:04PM -0800, Darrick J. Wong wrote:
> On Wed, Nov 28, 2018 at 04:17:19PM +1100, Dave Chinner wrote:
> > On Tue, Nov 27, 2018 at 08:49:50PM -0700, Allison Henderson wrote:
> > > If we had to try more than one mirror to get a successful
> > > read, then write that buffer back to correct the bad mirro
> > > 
> > > Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> > > ---
> > >  fs/xfs/xfs_buf.c | 8 ++++++++
> > >  1 file changed, 8 insertions(+)
> > > 
> > > diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> > > index f102d01..81f6491 100644
> > > --- a/fs/xfs/xfs_buf.c
> > > +++ b/fs/xfs/xfs_buf.c
> > > @@ -847,6 +847,14 @@ xfs_buf_read_map(
> > >  
> > >  		}
> > >  retry_done:
> > > +
> > > +		/*
> > > +		 * if we had to try more than one mirror to sucessfully read
> > > +		 * the buffer, write the buffer back
> > > +		 */
> > > +		if (!bp->b_error && i > 0)
> > > +			xfs_bwrite(bp);
> > > +
> > 
> > This can go in the case statement on retry and then you don't need
> > to check for i > 0 or, well, bp->b_error. i.e.
> > 
> > 		swtich (bp->b_error) {
> > 		case -EBADCRC:
> > 		case -EIO:
> > 		case -EFSCORRUPTED:
> > 			/* try again from different copy */
> > 			continue;
> > 		0:
> > 			/* good copy, rewrite it to repair bad copy */
> > 			xfs_bwrite(bp);
> 
> Some day we might want to provide some controls for how long we'll retry
> these reads and whether or not we automatically rewrite buffers, since
> some administrators might prefer fast fail to get failover started.

Sure, but if the recovery code is trewn all through the read code,
it becomes a mess to untangle. isolate the recovery code as much as
possible, that way we can factor it out as it becomes more complex.

> (Not now though)

Which is exactly my point about future recovery complexity.... :P

Cheers,

Dave.
diff mbox series

Patch

diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index f102d01..81f6491 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -847,6 +847,14 @@  xfs_buf_read_map(
 
 		}
 retry_done:
+
+		/*
+		 * if we had to try more than one mirror to sucessfully read
+		 * the buffer, write the buffer back
+		 */
+		if (!bp->b_error && i > 0)
+			xfs_bwrite(bp);
+
 		return bp;
 	}