aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_btree.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2012-11-12 06:54:01 -0500
committerBen Myers <bpm@sgi.com>2012-11-15 22:34:02 -0500
commitc3f8fc73ac97b76a12692088ef9cace9af8422c0 (patch)
treea90e132507842b7ed8c5d93e0c002e0dc0f99a5c /fs/xfs/xfs_btree.c
parentfb59581404ab7ec5075299065c22cb211a9262a9 (diff)
xfs: make buffer read verication an IO completion function
Add a verifier function callback capability to the buffer read interfaces. This will be used by the callers to supply a function that verifies the contents of the buffer when it is read from disk. This patch does not provide callback functions, but simply modifies the interfaces to allow them to be called. The reason for adding this to the read interfaces is that it is very difficult to tell fom the outside is a buffer was just read from disk or whether we just pulled it out of cache. Supplying a callbck allows the buffer cache to use it's internal knowledge of the buffer to execute it only when the buffer is read from disk. It is intended that the verifier functions will mark the buffer with an EFSCORRUPTED error when verification fails. This allows the reading context to distinguish a verification error from an IO error, and potentially take further actions on the buffer (e.g. attempt repair) based on the error reported. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Phil White <pwhite@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_btree.c')
-rw-r--r--fs/xfs/xfs_btree.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
index 121ea99e615a..7e791160092d 100644
--- a/fs/xfs/xfs_btree.c
+++ b/fs/xfs/xfs_btree.c
@@ -266,9 +266,12 @@ xfs_btree_dup_cursor(
266 for (i = 0; i < new->bc_nlevels; i++) { 266 for (i = 0; i < new->bc_nlevels; i++) {
267 new->bc_ptrs[i] = cur->bc_ptrs[i]; 267 new->bc_ptrs[i] = cur->bc_ptrs[i];
268 new->bc_ra[i] = cur->bc_ra[i]; 268 new->bc_ra[i] = cur->bc_ra[i];
269 if ((bp = cur->bc_bufs[i])) { 269 bp = cur->bc_bufs[i];
270 if ((error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, 270 if (bp) {
271 XFS_BUF_ADDR(bp), mp->m_bsize, 0, &bp))) { 271 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
272 XFS_BUF_ADDR(bp), mp->m_bsize,
273 0, &bp, NULL);
274 if (error) {
272 xfs_btree_del_cursor(new, error); 275 xfs_btree_del_cursor(new, error);
273 *ncur = NULL; 276 *ncur = NULL;
274 return error; 277 return error;
@@ -624,10 +627,10 @@ xfs_btree_read_bufl(
624 627
625 ASSERT(fsbno != NULLFSBLOCK); 628 ASSERT(fsbno != NULLFSBLOCK);
626 d = XFS_FSB_TO_DADDR(mp, fsbno); 629 d = XFS_FSB_TO_DADDR(mp, fsbno);
627 if ((error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, d, 630 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, d,
628 mp->m_bsize, lock, &bp))) { 631 mp->m_bsize, lock, &bp, NULL);
632 if (error)
629 return error; 633 return error;
630 }
631 ASSERT(!xfs_buf_geterror(bp)); 634 ASSERT(!xfs_buf_geterror(bp));
632 if (bp) 635 if (bp)
633 xfs_buf_set_ref(bp, refval); 636 xfs_buf_set_ref(bp, refval);
@@ -650,7 +653,7 @@ xfs_btree_reada_bufl(
650 653
651 ASSERT(fsbno != NULLFSBLOCK); 654 ASSERT(fsbno != NULLFSBLOCK);
652 d = XFS_FSB_TO_DADDR(mp, fsbno); 655 d = XFS_FSB_TO_DADDR(mp, fsbno);
653 xfs_buf_readahead(mp->m_ddev_targp, d, mp->m_bsize * count); 656 xfs_buf_readahead(mp->m_ddev_targp, d, mp->m_bsize * count, NULL);
654} 657}
655 658
656/* 659/*
@@ -670,7 +673,7 @@ xfs_btree_reada_bufs(
670 ASSERT(agno != NULLAGNUMBER); 673 ASSERT(agno != NULLAGNUMBER);
671 ASSERT(agbno != NULLAGBLOCK); 674 ASSERT(agbno != NULLAGBLOCK);
672 d = XFS_AGB_TO_DADDR(mp, agno, agbno); 675 d = XFS_AGB_TO_DADDR(mp, agno, agbno);
673 xfs_buf_readahead(mp->m_ddev_targp, d, mp->m_bsize * count); 676 xfs_buf_readahead(mp->m_ddev_targp, d, mp->m_bsize * count, NULL);
674} 677}
675 678
676STATIC int 679STATIC int
@@ -1013,7 +1016,7 @@ xfs_btree_read_buf_block(
1013 1016
1014 d = xfs_btree_ptr_to_daddr(cur, ptr); 1017 d = xfs_btree_ptr_to_daddr(cur, ptr);
1015 error = xfs_trans_read_buf(mp, cur->bc_tp, mp->m_ddev_targp, d, 1018 error = xfs_trans_read_buf(mp, cur->bc_tp, mp->m_ddev_targp, d,
1016 mp->m_bsize, flags, bpp); 1019 mp->m_bsize, flags, bpp, NULL);
1017 if (error) 1020 if (error)
1018 return error; 1021 return error;
1019 1022