public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 02/22] xfs: uncached buffer reads need to return an error
Date: Tue,  6 Nov 2012 16:13:13 +1100	[thread overview]
Message-ID: <1352178813-17216-3-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1352178813-17216-1-git-send-email-david@fromorbit.com>

From: Dave Chinner <dchinner@redhat.com>

With verification being done as an IO completion callback, different
errors can be returned from a read. Uncached reads only return a
buffer or NULL on failure, which means the verification error cannot
be returned to the caller.

Split the error handling for these reads into two - a failure to get
a buffer will still return NULL, but a read error will return a
referenced buffer with b_error set rather than NULL. The caller is
responsible for checking the error state of the buffer returned.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Phil White <pwhite@sgi.com>
---
 fs/xfs/xfs_buf.c     |    9 ++-------
 fs/xfs/xfs_fsops.c   |    5 +++++
 fs/xfs/xfs_mount.c   |    6 ++++++
 fs/xfs/xfs_rtalloc.c |    9 ++++++++-
 4 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 7cab1b3..62b7e89 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -715,8 +715,7 @@ xfs_buf_read_uncached(
 	int			flags,
 	xfs_buf_iodone_t	verify)
 {
-	xfs_buf_t		*bp;
-	int			error;
+	struct xfs_buf		*bp;
 
 	bp = xfs_buf_get_uncached(target, numblks, flags);
 	if (!bp)
@@ -730,11 +729,7 @@ xfs_buf_read_uncached(
 	bp->b_iodone = verify;
 
 	xfsbdstrat(target->bt_mount, bp);
-	error = xfs_buf_iowait(bp);
-	if (error) {
-		xfs_buf_relse(bp);
-		return NULL;
-	}
+	xfs_buf_iowait(bp);
 	return bp;
 }
 
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 917e121..dee14eb 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -149,6 +149,11 @@ xfs_growfs_data_private(
 				XFS_FSS_TO_BB(mp, 1), 0, NULL);
 	if (!bp)
 		return EIO;
+	if (bp->b_error) {
+		int	error = bp->b_error;
+		xfs_buf_relse(bp);
+		return error;
+	}
 	xfs_buf_relse(bp);
 
 	new = nb;	/* use new as a temporary here */
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index d39ad72..dc51e32 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -658,6 +658,12 @@ reread:
 			xfs_warn(mp, "SB buffer read failed");
 		return EIO;
 	}
+	if (bp->b_error) {
+		error = bp->b_error;
+		if (loud)
+			xfs_warn(mp, "SB validate failed");
+		goto release_buf;
+	}
 
 	/*
 	 * Initialize the mount structure from the superblock.
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index b271ed9..98dc670 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -1876,6 +1876,11 @@ xfs_growfs_rt(
 				XFS_FSB_TO_BB(mp, 1), 0, NULL);
 	if (!bp)
 		return EIO;
+	if (bp->b_error) {
+		error = bp->b_error;
+		xfs_buf_relse(bp);
+		return error;
+	}
 	xfs_buf_relse(bp);
 
 	/*
@@ -2221,8 +2226,10 @@ xfs_rtmount_init(
 	bp = xfs_buf_read_uncached(mp->m_rtdev_targp,
 					d - XFS_FSB_TO_BB(mp, 1),
 					XFS_FSB_TO_BB(mp, 1), 0, NULL);
-	if (!bp) {
+	if (!bp || bp->b_error) {
 		xfs_warn(mp, "realtime device size check failed");
+		if (bp)
+			xfs_buf_relse(bp);
 		return EIO;
 	}
 	xfs_buf_relse(bp);
-- 
1.7.10

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

  parent reply	other threads:[~2012-11-06  5:11 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-06  5:13 [PATCH 00/22 V4] xfs: metadata verifiers Dave Chinner
2012-11-06  5:13 ` [PATCH 01/22] xfs: make buffer read verication an IO completion function Dave Chinner
2012-11-06  5:13 ` Dave Chinner [this message]
2012-11-06  5:13 ` [PATCH 03/22] xfs: verify superblocks as they are read from disk Dave Chinner
2012-11-06  5:13 ` [PATCH 04/22] xfs: verify AGF blocks " Dave Chinner
2012-11-06  5:13 ` [PATCH 05/22] xfs: verify AGI " Dave Chinner
2012-11-06  5:13 ` [PATCH 06/22] xfs: verify AGFL " Dave Chinner
2012-11-06  5:13 ` [PATCH 07/22] xfs: verify inode buffers " Dave Chinner
2012-11-06  5:13 ` [PATCH 08/22] xfs: verify btree blocks " Dave Chinner
2012-11-06  5:13 ` [PATCH 09/22] xfs: verify dquot " Dave Chinner
2012-11-06  5:13 ` [PATCH 10/22] xfs: add verifier callback to directory read code Dave Chinner
2012-11-06  5:13 ` [PATCH 11/22] xfs: factor dir2 block read operations Dave Chinner
2012-11-06  5:13 ` [PATCH 12/22] xfs: verify dir2 block format buffers Dave Chinner
2012-11-06  5:13 ` [PATCH 13/22] xfs: factor dir2 free block reading Dave Chinner
2012-11-06  5:13 ` [PATCH 14/22] xfs: factor out dir2 data " Dave Chinner
2012-11-06  5:13 ` [PATCH 15/22] xfs: factor dir2 leaf read Dave Chinner
2012-11-06  5:13 ` [PATCH 16/22] xfs: factor and verify attr leaf reads Dave Chinner
2012-11-06  5:13 ` [PATCH 17/22] xfs: add xfs_da_node verification Dave Chinner
2012-11-06  5:13 ` [PATCH 18/22] xfs: Add verifiers to dir2 data readahead Dave Chinner
2012-11-06  5:13 ` [PATCH 19/22] xfs: add buffer pre-write callback Dave Chinner
2012-11-06  5:13 ` [PATCH 20/22] xfs: add pre-write metadata buffer verifier callbacks Dave Chinner
2012-11-06  5:13 ` [PATCH 21/22] xfs: connect up write verifiers to new buffers Dave Chinner
2012-11-06  5:13 ` [PATCH 22/22] xfs: convert buffer verifiers to an ops structure Dave Chinner
2012-11-07  5:58   ` [PATCH 22/22 V2] " Dave Chinner
2012-11-06 21:04 ` [PATCH 00/22 V4] xfs: metadata verifiers Dave Chinner
2012-11-07  6:05   ` Dave Chinner
2012-11-07 13:17 ` [PATCH 23/22] xfs: buffer type changes in xfs_da_root_join 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=1352178813-17216-3-git-send-email-david@fromorbit.com \
    --to=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