linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 0/10] xfs: add verifier context structure
@ 2018-12-05 21:01 Eric Sandeen
  2018-12-05 21:02 ` [PATCH 01/10] xfs: change xfs_attr3_rmt_hdr_ok to return bool Eric Sandeen
                   ` (9 more replies)
  0 siblings, 10 replies; 20+ messages in thread
From: Eric Sandeen @ 2018-12-05 21:01 UTC (permalink / raw)
  To: linux-xfs

This patchset adds and uses an "xfs verifier context" structure
in the callchains that lead into metadata verifiers and other
validators.

The high-level goal of this is twofold:

1) It lets us return whatever information we want about the point
   of failure by populating the structure.  We /could/ add file, line,
   function, code address, buffer offset, text description, whatever
   we'd like.  For now it only contains the same info as we have today,
   failaddr and errno.  For many of these options, we could easily
   encapsulate it in a macro used at each failure point.

1a) this hopefully may lead to more consistent error messages that don't
    change depending on the compiler used, etc (which IMHO is a problem
    with failaddr today).

2) By passing the verifier context by reference, we can move the
   verifiers back to booleans, instead of having the somewhat odd
   bool / failaddr_t dichotomy depending on what we're calling.  This
   then lets us condense some of the code.

So now we have macros that let us do things like:

	return XFS_CORRUPTED_RETURN(vc);
or
	return XFS_VERIFIED_RETURN(vc);

which populate the context and return true or false.  We can also
turn things like:

        if (xfs_sb_version_hascrc(&mp->m_sb) &&
            !xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF))
                xfs_verifier_error(bp, -EFSBADCRC, __this_address);
        else {
                fa = xfs_agf_verify(bp);
                if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_ALLOC_READ_AGF))
                        xfs_verifier_error(bp, -EFSCORRUPTED, fa);
        }

into:

       if ((xfs_sb_version_hascrc(&mp->m_sb) &&
                       !xfs_buf_verify_cksum(vc, bp, XFS_AGF_CRC_OFF)) ||
           XFS_TEST_ERROR(!xfs_agf_verify(vc, bp),
                       mp, XFS_ERRTAG_ALLOC_READ_AGF))
                xfs_verifier_error(bp, vc);

(is that better?)
(I've wondered about moving the hascrc check into the verify_cksum f'n)

when the failaddr return is changed to a bool.  Because all of the info
is in vc, we don't have to explicitly pass in the errno because the failure
point set it; this cleans up some other places as well.

There are definitely things to improve; my (ab)use of macros probably
isn't great, we should maybe have a verifier context initializer and
checks that it was used properly (I had one bug in development where
I forgot to set anything into the vc at failure and got back a garbage
errno), it could maybe be pushed into more validators, maybe "context"
is a bad name, etc.  Bikedshed away!

But I wanted to throw this out there to see if people thought it was
worth continuing on, and see what suggestions people have. 
(the first patch or two are cleanups that could go now, I think).

If the general approach seems good, I'll clean it up and then propose
something that may be a bit more consistent but still as useful as the
failaddr approach we have today.

Thanks,
-Eric

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH 01/10] xfs: change xfs_attr3_rmt_hdr_ok to return bool
  2018-12-05 21:01 [PATCH RFC 0/10] xfs: add verifier context structure Eric Sandeen
@ 2018-12-05 21:02 ` Eric Sandeen
  2018-12-07 13:36   ` Brian Foster
  2018-12-17 18:23   ` Darrick J. Wong
  2018-12-05 21:03 ` [PATCH 02/10] xfs: make checksum verifiers consistently return bools Eric Sandeen
                   ` (8 subsequent siblings)
  9 siblings, 2 replies; 20+ messages in thread
From: Eric Sandeen @ 2018-12-05 21:02 UTC (permalink / raw)
  To: Eric Sandeen, linux-xfs

xfs_attr3_rmt_hdr_ok is only checked for true/false and the caller
does nothing with the returned failaddr, so make it a bool.

(its usage and naming lend itself to a bool too, i.e. test (!ok))

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 fs/xfs/libxfs/xfs_attr_remote.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index d89363c6b523..f86680e08613 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -53,7 +53,7 @@ xfs_attr3_rmt_blocks(
  * does CRC, location and bounds checking, the unpacking function checks the
  * attribute parameters and owner.
  */
-static xfs_failaddr_t
+static bool
 xfs_attr3_rmt_hdr_ok(
 	void			*ptr,
 	xfs_ino_t		ino,
@@ -64,16 +64,16 @@ xfs_attr3_rmt_hdr_ok(
 	struct xfs_attr3_rmt_hdr *rmt = ptr;
 
 	if (bno != be64_to_cpu(rmt->rm_blkno))
-		return __this_address;
+		return false;
 	if (offset != be32_to_cpu(rmt->rm_offset))
-		return __this_address;
+		return false;
 	if (size != be32_to_cpu(rmt->rm_bytes))
-		return __this_address;
+		return false;
 	if (ino != be64_to_cpu(rmt->rm_owner))
-		return __this_address;
+		return false;
 
 	/* ok */
-	return NULL;
+	return true;
 }
 
 static xfs_failaddr_t
@@ -287,7 +287,7 @@ xfs_attr_rmtval_copyout(
 		byte_cnt = min(*valuelen, byte_cnt);
 
 		if (xfs_sb_version_hascrc(&mp->m_sb)) {
-			if (xfs_attr3_rmt_hdr_ok(src, ino, *offset,
+			if (!xfs_attr3_rmt_hdr_ok(src, ino, *offset,
 						  byte_cnt, bno)) {
 				xfs_alert(mp,
 "remote attribute header mismatch bno/off/len/owner (0x%llx/0x%x/Ox%x/0x%llx)",
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 02/10] xfs: make checksum verifiers consistently return bools
  2018-12-05 21:01 [PATCH RFC 0/10] xfs: add verifier context structure Eric Sandeen
  2018-12-05 21:02 ` [PATCH 01/10] xfs: change xfs_attr3_rmt_hdr_ok to return bool Eric Sandeen
@ 2018-12-05 21:03 ` Eric Sandeen
  2018-12-07 13:36   ` Brian Foster
  2018-12-17 18:24   ` Darrick J. Wong
  2018-12-05 21:03 ` [PATCH 03/10] xfs: pass a verifier context down verifier callchains Eric Sandeen
                   ` (7 subsequent siblings)
  9 siblings, 2 replies; 20+ messages in thread
From: Eric Sandeen @ 2018-12-05 21:03 UTC (permalink / raw)
  To: Eric Sandeen, linux-xfs

xfs_verify_cksum returns the result of a comparison, so make it
a bool. xfs_buf_verify_cksum calls it, so make it a bool as well.
Other callers up the callchain from here are already bools.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 fs/xfs/libxfs/xfs_cksum.h | 2 +-
 fs/xfs/xfs_buf.h          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_cksum.h b/fs/xfs/libxfs/xfs_cksum.h
index 999a290cfd72..1e3802a99867 100644
--- a/fs/xfs/libxfs/xfs_cksum.h
+++ b/fs/xfs/libxfs/xfs_cksum.h
@@ -71,7 +71,7 @@ xfs_update_cksum(char *buffer, size_t length, unsigned long cksum_offset)
 /*
  * Helper to verify the checksum for a buffer.
  */
-static inline int
+static inline bool
 xfs_verify_cksum(char *buffer, size_t length, unsigned long cksum_offset)
 {
 	uint32_t crc = xfs_start_cksum_safe(buffer, length, cksum_offset);
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index b9f5511ea998..5015255b5ede 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -359,7 +359,7 @@ static inline void xfs_buf_relse(xfs_buf_t *bp)
 	xfs_buf_rele(bp);
 }
 
-static inline int
+static inline bool
 xfs_buf_verify_cksum(struct xfs_buf *bp, unsigned long cksum_offset)
 {
 	return xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length),
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 03/10] xfs: pass a verifier context down verifier callchains
  2018-12-05 21:01 [PATCH RFC 0/10] xfs: add verifier context structure Eric Sandeen
  2018-12-05 21:02 ` [PATCH 01/10] xfs: change xfs_attr3_rmt_hdr_ok to return bool Eric Sandeen
  2018-12-05 21:03 ` [PATCH 02/10] xfs: make checksum verifiers consistently return bools Eric Sandeen
@ 2018-12-05 21:03 ` Eric Sandeen
  2018-12-17 18:29   ` Darrick J. Wong
  2018-12-05 21:04 ` [PATCH 04/10] xfs: pass a verifier context to crc validation functions Eric Sandeen
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Eric Sandeen @ 2018-12-05 21:03 UTC (permalink / raw)
  To: Eric Sandeen, linux-xfs

In order to get more context about a verifier failure, create a new
xfs verifier context (xfs_vc) type and pass it all the way down verifier
callchains to where we might return a failaddr_t.  This will eventually
let us return more information, for example line number or buffer offset,
etc.

At this point it contains only a failaddr member which is not yet used.

struct xfs_vc {
       xfs_failaddr_t  fa;
};

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 fs/xfs/libxfs/xfs_alloc.c          | 14 +++++++---
 fs/xfs/libxfs/xfs_alloc_btree.c    | 15 ++++++-----
 fs/xfs/libxfs/xfs_attr_leaf.c      |  8 ++++--
 fs/xfs/libxfs/xfs_attr_leaf.h      |  2 +-
 fs/xfs/libxfs/xfs_attr_remote.c    | 13 ++++++---
 fs/xfs/libxfs/xfs_bmap.c           |  4 ++-
 fs/xfs/libxfs/xfs_bmap.h           |  2 +-
 fs/xfs/libxfs/xfs_bmap_btree.c     | 11 +++++---
 fs/xfs/libxfs/xfs_btree.c          | 13 +++++++--
 fs/xfs/libxfs/xfs_btree.h          | 14 +++++-----
 fs/xfs/libxfs/xfs_da_btree.c       | 20 ++++++++------
 fs/xfs/libxfs/xfs_dir2_block.c     |  9 ++++---
 fs/xfs/libxfs/xfs_dir2_data.c      | 31 +++++++++++++++-------
 fs/xfs/libxfs/xfs_dir2_leaf.c      | 42 +++++++++++++++++++-----------
 fs/xfs/libxfs/xfs_dir2_node.c      | 17 ++++++++----
 fs/xfs/libxfs/xfs_dir2_priv.h      |  6 ++---
 fs/xfs/libxfs/xfs_dir2_sf.c        |  1 +
 fs/xfs/libxfs/xfs_dquot_buf.c      | 19 +++++++++-----
 fs/xfs/libxfs/xfs_ialloc.c         |  7 +++--
 fs/xfs/libxfs/xfs_ialloc_btree.c   | 13 +++++----
 fs/xfs/libxfs/xfs_inode_buf.c      | 28 +++++++++++++-------
 fs/xfs/libxfs/xfs_inode_buf.h      |  6 ++---
 fs/xfs/libxfs/xfs_inode_fork.c     | 13 +++++----
 fs/xfs/libxfs/xfs_inode_fork.h     |  6 ++---
 fs/xfs/libxfs/xfs_quota_defs.h     |  4 +--
 fs/xfs/libxfs/xfs_refcount_btree.c | 13 +++++----
 fs/xfs/libxfs/xfs_rmap_btree.c     | 13 +++++----
 fs/xfs/libxfs/xfs_rtbitmap.c       |  2 ++
 fs/xfs/libxfs/xfs_sb.c             |  5 +++-
 fs/xfs/libxfs/xfs_shared.h         |  2 +-
 fs/xfs/libxfs/xfs_symlink_remote.c |  8 ++++--
 fs/xfs/libxfs/xfs_types.h          |  4 +++
 fs/xfs/scrub/btree.c               |  5 ++--
 fs/xfs/scrub/common.c              |  3 ++-
 fs/xfs/scrub/dabtree.c             | 15 ++++++-----
 fs/xfs/scrub/inode.c               |  6 +++--
 fs/xfs/scrub/repair.c              |  4 ++-
 fs/xfs/xfs_buf.c                   | 12 ++++++---
 fs/xfs/xfs_buf.h                   |  6 ++---
 fs/xfs/xfs_dquot.c                 |  3 ++-
 fs/xfs/xfs_inode.c                 |  5 ++--
 fs/xfs/xfs_log_recover.c           |  6 +++--
 fs/xfs/xfs_qm.c                    |  3 ++-
 43 files changed, 284 insertions(+), 149 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index e1c0c0d2f1b0..59b8ab08dabd 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -553,6 +553,7 @@ xfs_alloc_fixup_trees(
 
 static xfs_failaddr_t
 xfs_agfl_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -594,6 +595,7 @@ xfs_agfl_verify(
 
 static void
 xfs_agfl_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -611,7 +613,7 @@ xfs_agfl_read_verify(
 	if (!xfs_buf_verify_cksum(bp, XFS_AGFL_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_agfl_verify(bp);
+		fa = xfs_agfl_verify(vc, bp);
 		if (fa)
 			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 	}
@@ -619,6 +621,7 @@ xfs_agfl_read_verify(
 
 static void
 xfs_agfl_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -629,7 +632,7 @@ xfs_agfl_write_verify(
 	if (!xfs_sb_version_hascrc(&mp->m_sb))
 		return;
 
-	fa = xfs_agfl_verify(bp);
+	fa = xfs_agfl_verify(vc, bp);
 	if (fa) {
 		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 		return;
@@ -2575,6 +2578,7 @@ xfs_alloc_put_freelist(
 
 static xfs_failaddr_t
 xfs_agf_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -2631,6 +2635,7 @@ xfs_agf_verify(
 
 static void
 xfs_agf_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -2640,7 +2645,7 @@ xfs_agf_read_verify(
 	    !xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_agf_verify(bp);
+		fa = xfs_agf_verify(vc, bp);
 		if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_ALLOC_READ_AGF))
 			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 	}
@@ -2648,13 +2653,14 @@ xfs_agf_read_verify(
 
 static void
 xfs_agf_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	xfs_failaddr_t		fa;
 
-	fa = xfs_agf_verify(bp);
+	fa = xfs_agf_verify(vc, bp);
 	if (fa) {
 		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 		return;
diff --git a/fs/xfs/libxfs/xfs_alloc_btree.c b/fs/xfs/libxfs/xfs_alloc_btree.c
index 4e59cc8a2802..2e9353a76a58 100644
--- a/fs/xfs/libxfs/xfs_alloc_btree.c
+++ b/fs/xfs/libxfs/xfs_alloc_btree.c
@@ -290,6 +290,7 @@ xfs_cntbt_diff_two_keys(
 
 static xfs_failaddr_t
 xfs_allocbt_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -313,7 +314,7 @@ xfs_allocbt_verify(
 	level = be16_to_cpu(block->bb_level);
 	switch (block->bb_magic) {
 	case cpu_to_be32(XFS_ABTB_CRC_MAGIC):
-		fa = xfs_btree_sblock_v5hdr_verify(bp);
+		fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
 		if (fa)
 			return fa;
 		/* fall through */
@@ -325,7 +326,7 @@ xfs_allocbt_verify(
 			return __this_address;
 		break;
 	case cpu_to_be32(XFS_ABTC_CRC_MAGIC):
-		fa = xfs_btree_sblock_v5hdr_verify(bp);
+		fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
 		if (fa)
 			return fa;
 		/* fall through */
@@ -340,19 +341,20 @@ xfs_allocbt_verify(
 		return __this_address;
 	}
 
-	return xfs_btree_sblock_verify(bp, mp->m_alloc_mxr[level != 0]);
+	return xfs_btree_sblock_verify(vc, bp, mp->m_alloc_mxr[level != 0]);
 }
 
 static void
 xfs_allocbt_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	xfs_failaddr_t	fa;
 
-	if (!xfs_btree_sblock_verify_crc(bp))
+	if (!xfs_btree_sblock_verify_crc(vc, bp))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_allocbt_verify(bp);
+		fa = xfs_allocbt_verify(vc, bp);
 		if (fa)
 			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 	}
@@ -363,11 +365,12 @@ xfs_allocbt_read_verify(
 
 static void
 xfs_allocbt_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	xfs_failaddr_t	fa;
 
-	fa = xfs_allocbt_verify(bp);
+	fa = xfs_allocbt_verify(vc, bp);
 	if (fa) {
 		trace_xfs_btree_corrupt(bp, _RET_IP_);
 		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index 2652d00842d6..5b146c909389 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -237,6 +237,7 @@ xfs_attr3_leaf_hdr_to_disk(
 
 static xfs_failaddr_t
 xfs_attr3_leaf_verify(
+	struct xfs_vc			*vc,
 	struct xfs_buf			*bp)
 {
 	struct xfs_attr3_icleaf_hdr	ichdr;
@@ -322,6 +323,7 @@ xfs_attr3_leaf_verify(
 
 static void
 xfs_attr3_leaf_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -329,7 +331,7 @@ xfs_attr3_leaf_write_verify(
 	struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr;
 	xfs_failaddr_t		fa;
 
-	fa = xfs_attr3_leaf_verify(bp);
+	fa = xfs_attr3_leaf_verify(vc, bp);
 	if (fa) {
 		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 		return;
@@ -352,6 +354,7 @@ xfs_attr3_leaf_write_verify(
  */
 static void
 xfs_attr3_leaf_read_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -361,7 +364,7 @@ xfs_attr3_leaf_read_verify(
 	     !xfs_buf_verify_cksum(bp, XFS_ATTR3_LEAF_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_attr3_leaf_verify(bp);
+		fa = xfs_attr3_leaf_verify(vc, bp);
 		if (fa)
 			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 	}
@@ -905,6 +908,7 @@ xfs_attr_shortform_allfit(
 /* Verify the consistency of an inline attribute fork. */
 xfs_failaddr_t
 xfs_attr_shortform_verify(
+	struct xfs_vc			*vc,
 	struct xfs_inode		*ip)
 {
 	struct xfs_attr_shortform	*sfp;
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.h b/fs/xfs/libxfs/xfs_attr_leaf.h
index 7b74e18becff..afe09eec66aa 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.h
+++ b/fs/xfs/libxfs/xfs_attr_leaf.h
@@ -41,7 +41,7 @@ int	xfs_attr_shortform_to_leaf(struct xfs_da_args *args,
 int	xfs_attr_shortform_remove(struct xfs_da_args *args);
 int	xfs_attr_shortform_allfit(struct xfs_buf *bp, struct xfs_inode *dp);
 int	xfs_attr_shortform_bytesfit(struct xfs_inode *dp, int bytes);
-xfs_failaddr_t xfs_attr_shortform_verify(struct xfs_inode *ip);
+xfs_failaddr_t xfs_attr_shortform_verify(struct xfs_vc *vc, struct xfs_inode *ip);
 void	xfs_attr_fork_remove(struct xfs_inode *ip, struct xfs_trans *tp);
 
 /*
diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index f86680e08613..e8d629de2cf5 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -78,6 +78,7 @@ xfs_attr3_rmt_hdr_ok(
 
 static xfs_failaddr_t
 xfs_attr3_rmt_verify(
+	struct xfs_vc		*vc,
 	struct xfs_mount	*mp,
 	void			*ptr,
 	int			fsbsize,
@@ -106,6 +107,7 @@ xfs_attr3_rmt_verify(
 
 static int
 __xfs_attr3_rmt_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp,
 	bool		check_crc,
 	xfs_failaddr_t	*failaddr)
@@ -131,7 +133,7 @@ __xfs_attr3_rmt_read_verify(
 			*failaddr = __this_address;
 			return -EFSBADCRC;
 		}
-		*failaddr = xfs_attr3_rmt_verify(mp, ptr, blksize, bno);
+		*failaddr = xfs_attr3_rmt_verify(vc, mp, ptr, blksize, bno);
 		if (*failaddr)
 			return -EFSCORRUPTED;
 		len -= blksize;
@@ -149,29 +151,32 @@ __xfs_attr3_rmt_read_verify(
 
 static void
 xfs_attr3_rmt_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	xfs_failaddr_t	fa;
 	int		error;
 
-	error = __xfs_attr3_rmt_read_verify(bp, true, &fa);
+	error = __xfs_attr3_rmt_read_verify(vc, bp, true, &fa);
 	if (error)
 		xfs_verifier_error(bp, error, fa);
 }
 
 static xfs_failaddr_t
 xfs_attr3_rmt_verify_struct(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	xfs_failaddr_t	fa;
 	int		error;
 
-	error = __xfs_attr3_rmt_read_verify(bp, false, &fa);
+	error = __xfs_attr3_rmt_read_verify(vc, bp, false, &fa);
 	return error ? fa : NULL;
 }
 
 static void
 xfs_attr3_rmt_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -193,7 +198,7 @@ xfs_attr3_rmt_write_verify(
 	while (len > 0) {
 		struct xfs_attr3_rmt_hdr *rmt = (struct xfs_attr3_rmt_hdr *)ptr;
 
-		fa = xfs_attr3_rmt_verify(mp, ptr, blksize, bno);
+		fa = xfs_attr3_rmt_verify(vc, mp, ptr, blksize, bno);
 		if (fa) {
 			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 			return;
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 19e921d1586f..fe0e0a1df5b1 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1249,10 +1249,11 @@ xfs_iread_extents(
 		 */
 		frp = XFS_BMBT_REC_ADDR(mp, block, 1);
 		for (j = 0; j < num_recs; j++, frp++, i++) {
+			struct xfs_vc	vc = { 0 };
 			xfs_failaddr_t	fa;
 
 			xfs_bmbt_disk_get_all(frp, &new);
-			fa = xfs_bmap_validate_extent(ip, whichfork, &new);
+			fa = xfs_bmap_validate_extent(&vc, ip, whichfork, &new);
 			if (fa) {
 				error = -EFSCORRUPTED;
 				xfs_inode_verifier_error(ip, error,
@@ -6101,6 +6102,7 @@ xfs_bmap_finish_one(
 /* Check that an inode's extent does not have invalid flags or bad ranges. */
 xfs_failaddr_t
 xfs_bmap_validate_extent(
+	struct xfs_vc		*vc,
 	struct xfs_inode	*ip,
 	int			whichfork,
 	struct xfs_bmbt_irec	*irec)
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
index 488dc8860fd7..a586568cdfb9 100644
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -273,7 +273,7 @@ static inline int xfs_bmap_fork_to_state(int whichfork)
 	}
 }
 
-xfs_failaddr_t xfs_bmap_validate_extent(struct xfs_inode *ip, int whichfork,
+xfs_failaddr_t xfs_bmap_validate_extent(struct xfs_vc *vc, struct xfs_inode *ip, int whichfork,
 		struct xfs_bmbt_irec *irec);
 
 int	xfs_bmapi_remap(struct xfs_trans *tp, struct xfs_inode *ip,
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index cdb74d2e2a43..4c8e97709704 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -409,6 +409,7 @@ xfs_bmbt_diff_two_keys(
 
 static xfs_failaddr_t
 xfs_bmbt_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -422,7 +423,7 @@ xfs_bmbt_verify(
 		 * XXX: need a better way of verifying the owner here. Right now
 		 * just make sure there has been one set.
 		 */
-		fa = xfs_btree_lblock_v5hdr_verify(bp, XFS_RMAP_OWN_UNKNOWN);
+		fa = xfs_btree_lblock_v5hdr_verify(vc, bp, XFS_RMAP_OWN_UNKNOWN);
 		if (fa)
 			return fa;
 		/* fall through */
@@ -443,11 +444,12 @@ xfs_bmbt_verify(
 	if (level > max(mp->m_bm_maxlevels[0], mp->m_bm_maxlevels[1]))
 		return __this_address;
 
-	return xfs_btree_lblock_verify(bp, mp->m_bmap_dmxr[level != 0]);
+	return xfs_btree_lblock_verify(vc, bp, mp->m_bmap_dmxr[level != 0]);
 }
 
 static void
 xfs_bmbt_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	xfs_failaddr_t	fa;
@@ -455,7 +457,7 @@ xfs_bmbt_read_verify(
 	if (!xfs_btree_lblock_verify_crc(bp))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_bmbt_verify(bp);
+		fa = xfs_bmbt_verify(vc, bp);
 		if (fa)
 			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 	}
@@ -466,11 +468,12 @@ xfs_bmbt_read_verify(
 
 static void
 xfs_bmbt_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	xfs_failaddr_t	fa;
 
-	fa = xfs_bmbt_verify(bp);
+	fa = xfs_bmbt_verify(vc, bp);
 	if (fa) {
 		trace_xfs_btree_corrupt(bp, _RET_IP_);
 		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index bbdae2b4559f..755ac16e90c5 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -58,6 +58,7 @@ xfs_btree_magic(
  */
 xfs_failaddr_t
 __xfs_btree_check_lblock(
+	struct xfs_vc		*vc,
 	struct xfs_btree_cur	*cur,
 	struct xfs_btree_block	*block,
 	int			level,
@@ -105,9 +106,10 @@ xfs_btree_check_lblock(
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = cur->bc_mp;
+	struct xfs_vc		vc = { 0 };
 	xfs_failaddr_t		fa;
 
-	fa = __xfs_btree_check_lblock(cur, block, level, bp);
+	fa = __xfs_btree_check_lblock(&vc, cur, block, level, bp);
 	if (unlikely(XFS_TEST_ERROR(fa != NULL, mp,
 			XFS_ERRTAG_BTREE_CHECK_LBLOCK))) {
 		if (bp)
@@ -124,6 +126,7 @@ xfs_btree_check_lblock(
  */
 xfs_failaddr_t
 __xfs_btree_check_sblock(
+	struct xfs_vc		*vc,
 	struct xfs_btree_cur	*cur,
 	struct xfs_btree_block	*block,
 	int			level,
@@ -169,9 +172,10 @@ xfs_btree_check_sblock(
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = cur->bc_mp;
+	struct xfs_vc		vc = { 0 };
 	xfs_failaddr_t		fa;
 
-	fa = __xfs_btree_check_sblock(cur, block, level, bp);
+	fa = __xfs_btree_check_sblock(&vc, cur, block, level, bp);
 	if (unlikely(XFS_TEST_ERROR(fa != NULL, mp,
 			XFS_ERRTAG_BTREE_CHECK_SBLOCK))) {
 		if (bp)
@@ -323,6 +327,7 @@ xfs_btree_sblock_calc_crc(
 
 bool
 xfs_btree_sblock_verify_crc(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_btree_block  *block = XFS_BUF_TO_BLOCK(bp);
@@ -4430,6 +4435,7 @@ xfs_btree_change_owner(
 /* Verify the v5 fields of a long-format btree block. */
 xfs_failaddr_t
 xfs_btree_lblock_v5hdr_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp,
 	uint64_t		owner)
 {
@@ -4451,6 +4457,7 @@ xfs_btree_lblock_v5hdr_verify(
 /* Verify a long-format btree block. */
 xfs_failaddr_t
 xfs_btree_lblock_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp,
 	unsigned int		max_recs)
 {
@@ -4482,6 +4489,7 @@ xfs_btree_lblock_verify(
  */
 xfs_failaddr_t
 xfs_btree_sblock_v5hdr_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -4507,6 +4515,7 @@ xfs_btree_sblock_v5hdr_verify(
  */
 xfs_failaddr_t
 xfs_btree_sblock_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp,
 	unsigned int		max_recs)
 {
diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
index e3b3e9dce5da..86cc17f1bf3f 100644
--- a/fs/xfs/libxfs/xfs_btree.h
+++ b/fs/xfs/libxfs/xfs_btree.h
@@ -243,9 +243,9 @@ typedef struct xfs_btree_cur
  * Internal long and short btree block checks.  They return NULL if the
  * block is ok or the address of the failed check otherwise.
  */
-xfs_failaddr_t __xfs_btree_check_lblock(struct xfs_btree_cur *cur,
+xfs_failaddr_t __xfs_btree_check_lblock(struct xfs_vc *vc, struct xfs_btree_cur *cur,
 		struct xfs_btree_block *block, int level, struct xfs_buf *bp);
-xfs_failaddr_t __xfs_btree_check_sblock(struct xfs_btree_cur *cur,
+xfs_failaddr_t __xfs_btree_check_sblock(struct xfs_vc *vc, struct xfs_btree_cur *cur,
 		struct xfs_btree_block *block, int level, struct xfs_buf *bp);
 
 /*
@@ -417,7 +417,7 @@ int xfs_btree_change_owner(struct xfs_btree_cur *cur, uint64_t new_owner,
 void xfs_btree_lblock_calc_crc(struct xfs_buf *);
 bool xfs_btree_lblock_verify_crc(struct xfs_buf *);
 void xfs_btree_sblock_calc_crc(struct xfs_buf *);
-bool xfs_btree_sblock_verify_crc(struct xfs_buf *);
+bool xfs_btree_sblock_verify_crc(struct xfs_vc *vc, struct xfs_buf *);
 
 /*
  * Internal btree helpers also used by xfs_bmap.c.
@@ -457,12 +457,12 @@ static inline int xfs_btree_get_level(struct xfs_btree_block *block)
 #define	XFS_FILBLKS_MIN(a,b)	min_t(xfs_filblks_t, (a), (b))
 #define	XFS_FILBLKS_MAX(a,b)	max_t(xfs_filblks_t, (a), (b))
 
-xfs_failaddr_t xfs_btree_sblock_v5hdr_verify(struct xfs_buf *bp);
-xfs_failaddr_t xfs_btree_sblock_verify(struct xfs_buf *bp,
+xfs_failaddr_t xfs_btree_sblock_v5hdr_verify(struct xfs_vc *vc, struct xfs_buf *bp);
+xfs_failaddr_t xfs_btree_sblock_verify(struct xfs_vc *vc, struct xfs_buf *bp,
 		unsigned int max_recs);
-xfs_failaddr_t xfs_btree_lblock_v5hdr_verify(struct xfs_buf *bp,
+xfs_failaddr_t xfs_btree_lblock_v5hdr_verify(struct xfs_vc *vc, struct xfs_buf *bp,
 		uint64_t owner);
-xfs_failaddr_t xfs_btree_lblock_verify(struct xfs_buf *bp,
+xfs_failaddr_t xfs_btree_lblock_verify(struct xfs_vc *vc, struct xfs_buf *bp,
 		unsigned int max_recs);
 
 uint xfs_btree_compute_maxlevels(uint *limits, unsigned long len);
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 376bee94b5dd..38862a0990d4 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -118,6 +118,7 @@ xfs_da_state_free(xfs_da_state_t *state)
 
 static xfs_failaddr_t
 xfs_da3_node_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -167,14 +168,15 @@ xfs_da3_node_verify(
 
 static void
 xfs_da3_node_write_verify(
-	struct xfs_buf	*bp)
+	struct xfs_vc		*vc,
+	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
 	xfs_failaddr_t		fa;
 
-	fa = xfs_da3_node_verify(bp);
+	fa = xfs_da3_node_verify(vc, bp);
 	if (fa) {
 		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 		return;
@@ -197,6 +199,7 @@ xfs_da3_node_write_verify(
  */
 static void
 xfs_da3_node_read_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_da_blkinfo	*info = bp->b_addr;
@@ -211,19 +214,19 @@ xfs_da3_node_read_verify(
 			}
 			/* fall through */
 		case XFS_DA_NODE_MAGIC:
-			fa = xfs_da3_node_verify(bp);
+			fa = xfs_da3_node_verify(vc, bp);
 			if (fa)
 				xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 			return;
 		case XFS_ATTR_LEAF_MAGIC:
 		case XFS_ATTR3_LEAF_MAGIC:
 			bp->b_ops = &xfs_attr3_leaf_buf_ops;
-			bp->b_ops->verify_read(bp);
+			bp->b_ops->verify_read(vc, bp);
 			return;
 		case XFS_DIR2_LEAFN_MAGIC:
 		case XFS_DIR3_LEAFN_MAGIC:
 			bp->b_ops = &xfs_dir3_leafn_buf_ops;
-			bp->b_ops->verify_read(bp);
+			bp->b_ops->verify_read(vc, bp);
 			return;
 		default:
 			xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
@@ -234,6 +237,7 @@ xfs_da3_node_read_verify(
 /* Verify the structure of a da3 block. */
 static xfs_failaddr_t
 xfs_da3_node_verify_struct(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_da_blkinfo	*info = bp->b_addr;
@@ -241,15 +245,15 @@ xfs_da3_node_verify_struct(
 	switch (be16_to_cpu(info->magic)) {
 	case XFS_DA3_NODE_MAGIC:
 	case XFS_DA_NODE_MAGIC:
-		return xfs_da3_node_verify(bp);
+		return xfs_da3_node_verify(vc, bp);
 	case XFS_ATTR_LEAF_MAGIC:
 	case XFS_ATTR3_LEAF_MAGIC:
 		bp->b_ops = &xfs_attr3_leaf_buf_ops;
-		return bp->b_ops->verify_struct(bp);
+		return bp->b_ops->verify_struct(vc, bp);
 	case XFS_DIR2_LEAFN_MAGIC:
 	case XFS_DIR3_LEAFN_MAGIC:
 		bp->b_ops = &xfs_dir3_leafn_buf_ops;
-		return bp->b_ops->verify_struct(bp);
+		return bp->b_ops->verify_struct(vc, bp);
 	default:
 		return __this_address;
 	}
diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
index 30ed5919da72..65ba4eccce8b 100644
--- a/fs/xfs/libxfs/xfs_dir2_block.c
+++ b/fs/xfs/libxfs/xfs_dir2_block.c
@@ -48,6 +48,7 @@ xfs_dir_startup(void)
 
 static xfs_failaddr_t
 xfs_dir3_block_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -66,11 +67,12 @@ xfs_dir3_block_verify(
 		if (hdr3->magic != cpu_to_be32(XFS_DIR2_BLOCK_MAGIC))
 			return __this_address;
 	}
-	return __xfs_dir3_data_check(NULL, bp);
+	return __xfs_dir3_data_check(vc, NULL, bp);
 }
 
 static void
 xfs_dir3_block_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -80,7 +82,7 @@ xfs_dir3_block_read_verify(
 	     !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_dir3_block_verify(bp);
+		fa = xfs_dir3_block_verify(vc, bp);
 		if (fa)
 			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 	}
@@ -88,6 +90,7 @@ xfs_dir3_block_read_verify(
 
 static void
 xfs_dir3_block_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -95,7 +98,7 @@ xfs_dir3_block_write_verify(
 	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;
 	xfs_failaddr_t		fa;
 
-	fa = xfs_dir3_block_verify(bp);
+	fa = xfs_dir3_block_verify(vc, bp);
 	if (fa) {
 		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 		return;
diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
index 01162c62ec8f..6530621d8144 100644
--- a/fs/xfs/libxfs/xfs_dir2_data.c
+++ b/fs/xfs/libxfs/xfs_dir2_data.c
@@ -22,6 +22,7 @@
 #include "xfs_log.h"
 
 static xfs_failaddr_t xfs_dir2_data_freefind_verify(
+		struct xfs_vc *vc,
 		struct xfs_dir2_data_hdr *hdr, struct xfs_dir2_data_free *bf,
 		struct xfs_dir2_data_unused *dup,
 		struct xfs_dir2_data_free **bf_ent);
@@ -33,6 +34,7 @@ static xfs_failaddr_t xfs_dir2_data_freefind_verify(
  */
 xfs_failaddr_t
 __xfs_dir3_data_check(
+	struct xfs_vc		*vc,		/* verifier context */
 	struct xfs_inode	*dp,		/* incore inode pointer */
 	struct xfs_buf		*bp)		/* data block's buffer */
 {
@@ -149,7 +151,7 @@ __xfs_dir3_data_check(
 			if (be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)) !=
 			    (char *)dup - (char *)hdr)
 				return __this_address;
-			fa = xfs_dir2_data_freefind_verify(hdr, bf, dup, &dfp);
+			fa = xfs_dir2_data_freefind_verify(vc, hdr, bf, dup, &dfp);
 			if (fa)
 				return fa;
 			if (dfp) {
@@ -233,9 +235,10 @@ xfs_dir3_data_check(
 	struct xfs_inode	*dp,
 	struct xfs_buf		*bp)
 {
+	struct xfs_vc		vc = { 0 };
 	xfs_failaddr_t		fa;
 
-	fa = __xfs_dir3_data_check(dp, bp);
+	fa = __xfs_dir3_data_check(&vc, dp, bp);
 	if (!fa)
 		return;
 	xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, dp->i_mount,
@@ -247,6 +250,7 @@ xfs_dir3_data_check(
 
 static xfs_failaddr_t
 xfs_dir3_data_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -265,7 +269,7 @@ xfs_dir3_data_verify(
 		if (hdr3->magic != cpu_to_be32(XFS_DIR2_DATA_MAGIC))
 			return __this_address;
 	}
-	return __xfs_dir3_data_check(NULL, bp);
+	return __xfs_dir3_data_check(vc, NULL, bp);
 }
 
 /*
@@ -275,6 +279,7 @@ xfs_dir3_data_verify(
  */
 static void
 xfs_dir3_data_reada_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_dir2_data_hdr *hdr = bp->b_addr;
@@ -283,12 +288,12 @@ xfs_dir3_data_reada_verify(
 	case cpu_to_be32(XFS_DIR2_BLOCK_MAGIC):
 	case cpu_to_be32(XFS_DIR3_BLOCK_MAGIC):
 		bp->b_ops = &xfs_dir3_block_buf_ops;
-		bp->b_ops->verify_read(bp);
+		bp->b_ops->verify_read(vc, bp);
 		return;
 	case cpu_to_be32(XFS_DIR2_DATA_MAGIC):
 	case cpu_to_be32(XFS_DIR3_DATA_MAGIC):
 		bp->b_ops = &xfs_dir3_data_buf_ops;
-		bp->b_ops->verify_read(bp);
+		bp->b_ops->verify_read(vc, bp);
 		return;
 	default:
 		xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
@@ -298,6 +303,7 @@ xfs_dir3_data_reada_verify(
 
 static void
 xfs_dir3_data_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -307,7 +313,7 @@ xfs_dir3_data_read_verify(
 	    !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_dir3_data_verify(bp);
+		fa = xfs_dir3_data_verify(vc, bp);
 		if (fa)
 			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 	}
@@ -315,6 +321,7 @@ xfs_dir3_data_read_verify(
 
 static void
 xfs_dir3_data_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -322,7 +329,7 @@ xfs_dir3_data_write_verify(
 	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;
 	xfs_failaddr_t		fa;
 
-	fa = xfs_dir3_data_verify(bp);
+	fa = xfs_dir3_data_verify(vc, bp);
 	if (fa) {
 		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 		return;
@@ -384,6 +391,7 @@ xfs_dir3_data_readahead(
  */
 static xfs_failaddr_t
 xfs_dir2_data_freefind_verify(
+	struct xfs_vc			*vc,
 	struct xfs_dir2_data_hdr	*hdr,
 	struct xfs_dir2_data_free	*bf,
 	struct xfs_dir2_data_unused	*dup,
@@ -957,6 +965,7 @@ xfs_dir2_data_make_free(
 /* Check our free data for obvious signs of corruption. */
 static inline xfs_failaddr_t
 xfs_dir2_data_check_free(
+	struct xfs_vc			*vc,
 	struct xfs_dir2_data_hdr	*hdr,
 	struct xfs_dir2_data_unused	*dup,
 	xfs_dir2_data_aoff_t		offset,
@@ -982,6 +991,7 @@ xfs_dir2_data_check_free(
 /* Sanity-check a new bestfree entry. */
 static inline xfs_failaddr_t
 xfs_dir2_data_check_new_free(
+	struct xfs_vc			*vc,
 	struct xfs_dir2_data_hdr	*hdr,
 	struct xfs_dir2_data_free	*dfp,
 	struct xfs_dir2_data_unused	*newdup)
@@ -1013,6 +1023,7 @@ xfs_dir2_data_use_free(
 	xfs_dir2_data_unused_t	*newdup;	/* new unused entry */
 	xfs_dir2_data_unused_t	*newdup2;	/* another new unused entry */
 	struct xfs_dir2_data_free *bf;
+	struct xfs_vc		vc = { 0 };
 	xfs_failaddr_t		fa;
 	int			matchback;	/* matches end of freespace */
 	int			matchfront;	/* matches start of freespace */
@@ -1020,7 +1031,7 @@ xfs_dir2_data_use_free(
 	int			oldlen;		/* old unused entry's length */
 
 	hdr = bp->b_addr;
-	fa = xfs_dir2_data_check_free(hdr, dup, offset, len);
+	fa = xfs_dir2_data_check_free(&vc, hdr, dup, offset, len);
 	if (fa)
 		goto corrupt;
 	/*
@@ -1067,7 +1078,7 @@ xfs_dir2_data_use_free(
 			xfs_dir2_data_freeremove(hdr, bf, dfp, needlogp);
 			dfp = xfs_dir2_data_freeinsert(hdr, bf, newdup,
 						       needlogp);
-			fa = xfs_dir2_data_check_new_free(hdr, dfp, newdup);
+			fa = xfs_dir2_data_check_new_free(&vc, hdr, dfp, newdup);
 			if (fa)
 				goto corrupt;
 			/*
@@ -1095,7 +1106,7 @@ xfs_dir2_data_use_free(
 			xfs_dir2_data_freeremove(hdr, bf, dfp, needlogp);
 			dfp = xfs_dir2_data_freeinsert(hdr, bf, newdup,
 						       needlogp);
-			fa = xfs_dir2_data_check_new_free(hdr, dfp, newdup);
+			fa = xfs_dir2_data_check_new_free(&vc, hdr, dfp, newdup);
 			if (fa)
 				goto corrupt;
 			/*
diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
index 1728a3e6f5cf..1122a639b603 100644
--- a/fs/xfs/libxfs/xfs_dir2_leaf.c
+++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
@@ -40,6 +40,7 @@ static void xfs_dir3_leaf_log_tail(struct xfs_da_args *args,
 #ifdef DEBUG
 static xfs_failaddr_t
 xfs_dir3_leaf1_check(
+	struct xfs_vc		*vc,
 	struct xfs_inode	*dp,
 	struct xfs_buf		*bp)
 {
@@ -55,7 +56,7 @@ xfs_dir3_leaf1_check(
 	} else if (leafhdr.magic != XFS_DIR2_LEAF1_MAGIC)
 		return __this_address;
 
-	return xfs_dir3_leaf_check_int(dp->i_mount, dp, &leafhdr, leaf);
+	return xfs_dir3_leaf_check_int(vc, dp->i_mount, dp, &leafhdr, leaf);
 }
 
 static inline void
@@ -63,9 +64,10 @@ xfs_dir3_leaf_check(
 	struct xfs_inode	*dp,
 	struct xfs_buf		*bp)
 {
+	struct xfs_vc		vc = { 0 };
 	xfs_failaddr_t		fa;
 
-	fa = xfs_dir3_leaf1_check(dp, bp);
+	fa = xfs_dir3_leaf1_check(&vc, dp, bp);
 	if (!fa)
 		return;
 	xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, dp->i_mount,
@@ -79,6 +81,7 @@ xfs_dir3_leaf_check(
 
 xfs_failaddr_t
 xfs_dir3_leaf_check_int(
+	struct xfs_vc		*vc,
 	struct xfs_mount	*mp,
 	struct xfs_inode	*dp,
 	struct xfs_dir3_icleaf_hdr *hdr,
@@ -142,6 +145,7 @@ xfs_dir3_leaf_check_int(
  */
 static xfs_failaddr_t
 xfs_dir3_leaf_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp,
 	uint16_t		magic)
 {
@@ -170,13 +174,14 @@ xfs_dir3_leaf_verify(
 			return __this_address;
 	}
 
-	return xfs_dir3_leaf_check_int(mp, NULL, NULL, leaf);
+	return xfs_dir3_leaf_check_int(vc, mp, NULL, NULL, leaf);
 }
 
 static void
 __read_verify(
-	struct xfs_buf  *bp,
-	uint16_t	magic)
+	struct xfs_vc		*vc,
+	struct xfs_buf  	*bp,
+	uint16_t		magic)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	xfs_failaddr_t		fa;
@@ -185,7 +190,7 @@ __read_verify(
 	     !xfs_buf_verify_cksum(bp, XFS_DIR3_LEAF_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_dir3_leaf_verify(bp, magic);
+		fa = xfs_dir3_leaf_verify(vc, bp, magic);
 		if (fa)
 			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 	}
@@ -193,15 +198,16 @@ __read_verify(
 
 static void
 __write_verify(
-	struct xfs_buf  *bp,
-	uint16_t	magic)
+	struct xfs_vc		*vc,
+	struct xfs_buf  	*bp,
+	uint16_t		magic)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr;
 	xfs_failaddr_t		fa;
 
-	fa = xfs_dir3_leaf_verify(bp, magic);
+	fa = xfs_dir3_leaf_verify(vc, bp, magic);
 	if (fa) {
 		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 		return;
@@ -218,44 +224,50 @@ __write_verify(
 
 static xfs_failaddr_t
 xfs_dir3_leaf1_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	return xfs_dir3_leaf_verify(bp, XFS_DIR2_LEAF1_MAGIC);
+	return xfs_dir3_leaf_verify(vc, bp, XFS_DIR2_LEAF1_MAGIC);
 }
 
 static void
 xfs_dir3_leaf1_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	__read_verify(bp, XFS_DIR2_LEAF1_MAGIC);
+	__read_verify(vc, bp, XFS_DIR2_LEAF1_MAGIC);
 }
 
 static void
 xfs_dir3_leaf1_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	__write_verify(bp, XFS_DIR2_LEAF1_MAGIC);
+	__write_verify(vc, bp, XFS_DIR2_LEAF1_MAGIC);
 }
 
 static xfs_failaddr_t
 xfs_dir3_leafn_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	return xfs_dir3_leaf_verify(bp, XFS_DIR2_LEAFN_MAGIC);
+	return xfs_dir3_leaf_verify(vc, bp, XFS_DIR2_LEAFN_MAGIC);
 }
 
 static void
 xfs_dir3_leafn_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	__read_verify(bp, XFS_DIR2_LEAFN_MAGIC);
+	__read_verify(vc, bp, XFS_DIR2_LEAFN_MAGIC);
 }
 
 static void
 xfs_dir3_leafn_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	__write_verify(bp, XFS_DIR2_LEAFN_MAGIC);
+	__write_verify(vc, bp, XFS_DIR2_LEAFN_MAGIC);
 }
 
 const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops = {
diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index f1bb3434f51c..70f54145d0b0 100644
--- a/fs/xfs/libxfs/xfs_dir2_node.c
+++ b/fs/xfs/libxfs/xfs_dir2_node.c
@@ -43,6 +43,7 @@ static int xfs_dir2_node_addname_int(xfs_da_args_t *args,
 #ifdef DEBUG
 static xfs_failaddr_t
 xfs_dir3_leafn_check(
+	struct xfs_vc		*vc,
 	struct xfs_inode	*dp,
 	struct xfs_buf		*bp)
 {
@@ -58,7 +59,7 @@ xfs_dir3_leafn_check(
 	} else if (leafhdr.magic != XFS_DIR2_LEAFN_MAGIC)
 		return __this_address;
 
-	return xfs_dir3_leaf_check_int(dp->i_mount, dp, &leafhdr, leaf);
+	return xfs_dir3_leaf_check_int(vc, dp->i_mount, dp, &leafhdr, leaf);
 }
 
 static inline void
@@ -66,9 +67,10 @@ xfs_dir3_leaf_check(
 	struct xfs_inode	*dp,
 	struct xfs_buf		*bp)
 {
+	struct xfs_vc		vc = { 0 };
 	xfs_failaddr_t		fa;
 
-	fa = xfs_dir3_leafn_check(dp, bp);
+	fa = xfs_dir3_leafn_check(&vc, dp, bp);
 	if (!fa)
 		return;
 	xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, dp->i_mount,
@@ -82,6 +84,7 @@ xfs_dir3_leaf_check(
 
 static xfs_failaddr_t
 xfs_dir3_free_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -110,6 +113,7 @@ xfs_dir3_free_verify(
 
 static void
 xfs_dir3_free_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -119,7 +123,7 @@ xfs_dir3_free_read_verify(
 	    !xfs_buf_verify_cksum(bp, XFS_DIR3_FREE_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_dir3_free_verify(bp);
+		fa = xfs_dir3_free_verify(vc, bp);
 		if (fa)
 			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 	}
@@ -127,6 +131,7 @@ xfs_dir3_free_read_verify(
 
 static void
 xfs_dir3_free_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -134,7 +139,7 @@ xfs_dir3_free_write_verify(
 	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;
 	xfs_failaddr_t		fa;
 
-	fa = xfs_dir3_free_verify(bp);
+	fa = xfs_dir3_free_verify(vc, bp);
 	if (fa) {
 		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 		return;
@@ -159,6 +164,7 @@ const struct xfs_buf_ops xfs_dir3_free_buf_ops = {
 /* Everything ok in the free block header? */
 static xfs_failaddr_t
 xfs_dir3_free_header_check(
+	struct xfs_vc		*vc,
 	struct xfs_inode	*dp,
 	xfs_dablk_t		fbno,
 	struct xfs_buf		*bp)
@@ -201,6 +207,7 @@ __xfs_dir3_free_read(
 	xfs_daddr_t		mappedbno,
 	struct xfs_buf		**bpp)
 {
+	struct xfs_vc		vc = { 0 };
 	xfs_failaddr_t		fa;
 	int			err;
 
@@ -210,7 +217,7 @@ __xfs_dir3_free_read(
 		return err;
 
 	/* Check things that we can't do in the verifier. */
-	fa = xfs_dir3_free_header_check(dp, fbno, *bpp);
+	fa = xfs_dir3_free_header_check(&vc, dp, fbno, *bpp);
 	if (fa) {
 		xfs_verifier_error(*bpp, -EFSCORRUPTED, fa);
 		xfs_trans_brelse(tp, *bpp);
diff --git a/fs/xfs/libxfs/xfs_dir2_priv.h b/fs/xfs/libxfs/xfs_dir2_priv.h
index 59f9fb2241a5..c8d5dc67e02b 100644
--- a/fs/xfs/libxfs/xfs_dir2_priv.h
+++ b/fs/xfs/libxfs/xfs_dir2_priv.h
@@ -32,7 +32,7 @@ extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
 #define	xfs_dir3_data_check(dp,bp)
 #endif
 
-extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_inode *dp,
+extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_vc *vc, struct xfs_inode *dp,
 		struct xfs_buf *bp);
 extern int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp,
 		xfs_dablk_t bno, xfs_daddr_t mapped_bno, struct xfs_buf **bpp);
@@ -78,7 +78,7 @@ xfs_dir3_leaf_find_entry(struct xfs_dir3_icleaf_hdr *leafhdr,
 		int lowstale, int highstale, int *lfloglow, int *lfloghigh);
 extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state);
 
-extern xfs_failaddr_t xfs_dir3_leaf_check_int(struct xfs_mount *mp,
+extern xfs_failaddr_t xfs_dir3_leaf_check_int(struct xfs_vc *vc, struct xfs_mount *mp,
 		struct xfs_inode *dp, struct xfs_dir3_icleaf_hdr *hdr,
 		struct xfs_dir2_leaf *leaf);
 
@@ -117,7 +117,7 @@ extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino);
 extern int xfs_dir2_sf_lookup(struct xfs_da_args *args);
 extern int xfs_dir2_sf_removename(struct xfs_da_args *args);
 extern int xfs_dir2_sf_replace(struct xfs_da_args *args);
-extern xfs_failaddr_t xfs_dir2_sf_verify(struct xfs_inode *ip);
+extern xfs_failaddr_t xfs_dir2_sf_verify(struct xfs_vc *vc, struct xfs_inode *ip);
 
 /* xfs_dir2_readdir.c */
 extern int xfs_readdir(struct xfs_trans *tp, struct xfs_inode *dp,
diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
index 585dfdb7b6b6..ea47b403c1c1 100644
--- a/fs/xfs/libxfs/xfs_dir2_sf.c
+++ b/fs/xfs/libxfs/xfs_dir2_sf.c
@@ -618,6 +618,7 @@ xfs_dir2_sf_check(
 /* Verify the consistency of an inline directory. */
 xfs_failaddr_t
 xfs_dir2_sf_verify(
+	struct xfs_vc			*vc,
 	struct xfs_inode		*ip)
 {
 	struct xfs_mount		*mp = ip->i_mount;
diff --git a/fs/xfs/libxfs/xfs_dquot_buf.c b/fs/xfs/libxfs/xfs_dquot_buf.c
index d293f371dd54..0dc0a8d7ffc4 100644
--- a/fs/xfs/libxfs/xfs_dquot_buf.c
+++ b/fs/xfs/libxfs/xfs_dquot_buf.c
@@ -37,6 +37,7 @@ xfs_calc_dquots_per_chunk(
 
 xfs_failaddr_t
 xfs_dquot_verify(
+	struct xfs_vc	 *vc,
 	struct xfs_mount *mp,
 	xfs_disk_dquot_t *ddq,
 	xfs_dqid_t	 id,
@@ -95,6 +96,7 @@ xfs_dquot_verify(
 
 xfs_failaddr_t
 xfs_dqblk_verify(
+	struct xfs_vc		*vc,
 	struct xfs_mount	*mp,
 	struct xfs_dqblk	*dqb,
 	xfs_dqid_t	 	id,
@@ -104,7 +106,7 @@ xfs_dqblk_verify(
 	    !uuid_equal(&dqb->dd_uuid, &mp->m_sb.sb_meta_uuid))
 		return __this_address;
 
-	return xfs_dquot_verify(mp, &dqb->dd_diskdq, id, type);
+	return xfs_dquot_verify(vc, mp, &dqb->dd_diskdq, id, type);
 }
 
 /*
@@ -174,6 +176,7 @@ xfs_dquot_buf_verify_crc(
 
 STATIC xfs_failaddr_t
 xfs_dquot_buf_verify(
+	struct xfs_vc		*vc,
 	struct xfs_mount	*mp,
 	struct xfs_buf		*bp,
 	bool			readahead)
@@ -209,7 +212,7 @@ xfs_dquot_buf_verify(
 		if (i == 0)
 			id = be32_to_cpu(ddq->d_id);
 
-		fa = xfs_dqblk_verify(mp, &dqb[i], id + i, 0);
+		fa = xfs_dqblk_verify(vc, mp, &dqb[i], id + i, 0);
 		if (fa) {
 			if (!readahead)
 				xfs_buf_verifier_error(bp, -EFSCORRUPTED,
@@ -224,22 +227,24 @@ xfs_dquot_buf_verify(
 
 static xfs_failaddr_t
 xfs_dquot_buf_verify_struct(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 
-	return xfs_dquot_buf_verify(mp, bp, false);
+	return xfs_dquot_buf_verify(vc, mp, bp, false);
 }
 
 static void
 xfs_dquot_buf_read_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 
 	if (!xfs_dquot_buf_verify_crc(mp, bp, false))
 		return;
-	xfs_dquot_buf_verify(mp, bp, false);
+	xfs_dquot_buf_verify(vc, mp, bp, false);
 }
 
 /*
@@ -250,12 +255,13 @@ xfs_dquot_buf_read_verify(
  */
 static void
 xfs_dquot_buf_readahead_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 
 	if (!xfs_dquot_buf_verify_crc(mp, bp, true) ||
-	    xfs_dquot_buf_verify(mp, bp, true) != NULL) {
+	    xfs_dquot_buf_verify(vc, mp, bp, true) != NULL) {
 		xfs_buf_ioerror(bp, -EIO);
 		bp->b_flags &= ~XBF_DONE;
 	}
@@ -268,11 +274,12 @@ xfs_dquot_buf_readahead_verify(
  */
 static void
 xfs_dquot_buf_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 
-	xfs_dquot_buf_verify(mp, bp, false);
+	xfs_dquot_buf_verify(vc, mp, bp, false);
 }
 
 const struct xfs_buf_ops xfs_dquot_buf_ops = {
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index a8f6db735d5d..1b2b3b63b207 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -2497,6 +2497,7 @@ xfs_ialloc_log_agi(
 
 static xfs_failaddr_t
 xfs_agi_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -2549,6 +2550,7 @@ xfs_agi_verify(
 
 static void
 xfs_agi_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -2558,7 +2560,7 @@ xfs_agi_read_verify(
 	    !xfs_buf_verify_cksum(bp, XFS_AGI_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_agi_verify(bp);
+		fa = xfs_agi_verify(vc, bp);
 		if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_IALLOC_READ_AGI))
 			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 	}
@@ -2566,13 +2568,14 @@ xfs_agi_read_verify(
 
 static void
 xfs_agi_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	xfs_failaddr_t		fa;
 
-	fa = xfs_agi_verify(bp);
+	fa = xfs_agi_verify(vc, bp);
 	if (fa) {
 		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 		return;
diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
index 7fbf8af0b159..02d7dd5c265c 100644
--- a/fs/xfs/libxfs/xfs_ialloc_btree.c
+++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
@@ -256,6 +256,7 @@ xfs_inobt_diff_two_keys(
 
 static xfs_failaddr_t
 xfs_inobt_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -276,7 +277,7 @@ xfs_inobt_verify(
 	switch (block->bb_magic) {
 	case cpu_to_be32(XFS_IBT_CRC_MAGIC):
 	case cpu_to_be32(XFS_FIBT_CRC_MAGIC):
-		fa = xfs_btree_sblock_v5hdr_verify(bp);
+		fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
 		if (fa)
 			return fa;
 		/* fall through */
@@ -292,19 +293,20 @@ xfs_inobt_verify(
 	if (level >= mp->m_in_maxlevels)
 		return __this_address;
 
-	return xfs_btree_sblock_verify(bp, mp->m_inobt_mxr[level != 0]);
+	return xfs_btree_sblock_verify(vc, bp, mp->m_inobt_mxr[level != 0]);
 }
 
 static void
 xfs_inobt_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	xfs_failaddr_t	fa;
 
-	if (!xfs_btree_sblock_verify_crc(bp))
+	if (!xfs_btree_sblock_verify_crc(vc, bp))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_inobt_verify(bp);
+		fa = xfs_inobt_verify(vc, bp);
 		if (fa)
 			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 	}
@@ -315,11 +317,12 @@ xfs_inobt_read_verify(
 
 static void
 xfs_inobt_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	xfs_failaddr_t	fa;
 
-	fa = xfs_inobt_verify(bp);
+	fa = xfs_inobt_verify(vc, bp);
 	if (fa) {
 		trace_xfs_btree_corrupt(bp, _RET_IP_);
 		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 09d9c8cfa4a0..7d9b4ea6eba9 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -77,6 +77,7 @@ xfs_dinode_good_version(
  */
 static void
 xfs_inode_buf_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp,
 	bool		readahead)
 {
@@ -126,23 +127,26 @@ xfs_inode_buf_verify(
 
 static void
 xfs_inode_buf_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	xfs_inode_buf_verify(bp, false);
+	xfs_inode_buf_verify(vc, bp, false);
 }
 
 static void
 xfs_inode_buf_readahead_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	xfs_inode_buf_verify(bp, true);
+	xfs_inode_buf_verify(vc, bp, true);
 }
 
 static void
 xfs_inode_buf_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	xfs_inode_buf_verify(bp, false);
+	xfs_inode_buf_verify(vc, bp, false);
 }
 
 const struct xfs_buf_ops xfs_inode_buf_ops = {
@@ -376,6 +380,7 @@ xfs_log_dinode_to_disk(
 
 static xfs_failaddr_t
 xfs_dinode_verify_fork(
+	struct xfs_vc		*vc,
 	struct xfs_dinode	*dip,
 	struct xfs_mount	*mp,
 	int			whichfork)
@@ -417,6 +422,7 @@ xfs_dinode_verify_fork(
 
 static xfs_failaddr_t
 xfs_dinode_verify_forkoff(
+	struct xfs_vc		*vc,
 	struct xfs_dinode	*dip,
 	struct xfs_mount	*mp)
 {
@@ -442,6 +448,7 @@ xfs_dinode_verify_forkoff(
 
 xfs_failaddr_t
 xfs_dinode_verify(
+	struct xfs_vc		*vc,
 	struct xfs_mount	*mp,
 	xfs_ino_t		ino,
 	struct xfs_dinode	*dip)
@@ -496,7 +503,7 @@ xfs_dinode_verify(
 		return __this_address;
 
 	/* check for illegal values of forkoff */
-	fa = xfs_dinode_verify_forkoff(dip, mp);
+	fa = xfs_dinode_verify_forkoff(vc, dip, mp);
 	if (fa)
 		return fa;
 
@@ -512,7 +519,7 @@ xfs_dinode_verify(
 	case S_IFREG:
 	case S_IFLNK:
 	case S_IFDIR:
-		fa = xfs_dinode_verify_fork(dip, mp, XFS_DATA_FORK);
+		fa = xfs_dinode_verify_fork(vc, dip, mp, XFS_DATA_FORK);
 		if (fa)
 			return fa;
 		break;
@@ -524,7 +531,7 @@ xfs_dinode_verify(
 	}
 
 	if (XFS_DFORK_Q(dip)) {
-		fa = xfs_dinode_verify_fork(dip, mp, XFS_ATTR_FORK);
+		fa = xfs_dinode_verify_fork(vc, dip, mp, XFS_ATTR_FORK);
 		if (fa)
 			return fa;
 	} else {
@@ -546,7 +553,7 @@ xfs_dinode_verify(
 	}
 
 	/* extent size hint validation */
-	fa = xfs_inode_validate_extsize(mp, be32_to_cpu(dip->di_extsize),
+	fa = xfs_inode_validate_extsize(vc, mp, be32_to_cpu(dip->di_extsize),
 			mode, flags);
 	if (fa)
 		return fa;
@@ -575,7 +582,7 @@ xfs_dinode_verify(
 		return __this_address;
 
 	/* COW extent size hint validation */
-	fa = xfs_inode_validate_cowextsize(mp, be32_to_cpu(dip->di_cowextsize),
+	fa = xfs_inode_validate_cowextsize(vc, mp, be32_to_cpu(dip->di_cowextsize),
 			mode, flags, flags2);
 	if (fa)
 		return fa;
@@ -620,6 +627,7 @@ xfs_iread(
 {
 	xfs_buf_t	*bp;
 	xfs_dinode_t	*dip;
+	struct xfs_vc	vc = { 0 };
 	xfs_failaddr_t	fa;
 	int		error;
 
@@ -649,7 +657,7 @@ xfs_iread(
 		return error;
 
 	/* even unallocated inodes are verified */
-	fa = xfs_dinode_verify(mp, ip->i_ino, dip);
+	fa = xfs_dinode_verify(&vc, mp, ip->i_ino, dip);
 	if (fa) {
 		xfs_inode_verifier_error(ip, -EFSCORRUPTED, "dinode", dip,
 				sizeof(*dip), fa);
@@ -728,6 +736,7 @@ xfs_iread(
  */
 xfs_failaddr_t
 xfs_inode_validate_extsize(
+	struct xfs_vc			*vc,
 	struct xfs_mount		*mp,
 	uint32_t			extsize,
 	uint16_t			mode,
@@ -785,6 +794,7 @@ xfs_inode_validate_extsize(
  */
 xfs_failaddr_t
 xfs_inode_validate_cowextsize(
+	struct xfs_vc			*vc,
 	struct xfs_mount		*mp,
 	uint32_t			cowextsize,
 	uint16_t			mode,
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index ab0f84165317..fceea886275f 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -70,11 +70,11 @@ void	xfs_inobp_check(struct xfs_mount *, struct xfs_buf *);
 #define	xfs_inobp_check(mp, bp)
 #endif /* DEBUG */
 
-xfs_failaddr_t xfs_dinode_verify(struct xfs_mount *mp, xfs_ino_t ino,
+xfs_failaddr_t xfs_dinode_verify(struct xfs_vc *vc, struct xfs_mount *mp, xfs_ino_t ino,
 			   struct xfs_dinode *dip);
-xfs_failaddr_t xfs_inode_validate_extsize(struct xfs_mount *mp,
+xfs_failaddr_t xfs_inode_validate_extsize(struct xfs_vc *vc, struct xfs_mount *mp,
 		uint32_t extsize, uint16_t mode, uint16_t flags);
-xfs_failaddr_t xfs_inode_validate_cowextsize(struct xfs_mount *mp,
+xfs_failaddr_t xfs_inode_validate_cowextsize(struct xfs_vc *vc, struct xfs_mount *mp,
 		uint32_t cowextsize, uint16_t mode, uint16_t flags,
 		uint64_t flags2);
 
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index f9acf1d436f6..49dd81b0728f 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -233,10 +233,11 @@ xfs_iformat_extents(
 
 		xfs_iext_first(ifp, &icur);
 		for (i = 0; i < nex; i++, dp++) {
+			struct xfs_vc	vc = { 0 };
 			xfs_failaddr_t	fa;
 
 			xfs_bmbt_disk_get_all(dp, &new);
-			fa = xfs_bmap_validate_extent(ip, whichfork, &new);
+			fa = xfs_bmap_validate_extent(&vc, ip, whichfork, &new);
 			if (fa) {
 				xfs_inode_verifier_error(ip, -EFSCORRUPTED,
 						"xfs_iformat_extents(2)",
@@ -562,7 +563,7 @@ xfs_iextents_copy(
 	for_each_xfs_iext(ifp, &icur, &rec) {
 		if (isnullstartblock(rec.br_startblock))
 			continue;
-		ASSERT(xfs_bmap_validate_extent(ip, whichfork, &rec) == NULL);
+		ASSERT(xfs_bmap_validate_extent(NULL, ip, whichfork, &rec) == NULL);
 		xfs_bmbt_disk_set_all(dp, &rec);
 		trace_xfs_write_extent(ip, &icur, state, _RET_IP_);
 		copied += sizeof(struct xfs_bmbt_rec);
@@ -701,6 +702,7 @@ struct xfs_ifork_ops xfs_default_ifork_ops = {
 /* Verify the inline contents of the data fork of an inode. */
 xfs_failaddr_t
 xfs_ifork_verify_data(
+	struct xfs_vc		*vc,
 	struct xfs_inode	*ip,
 	struct xfs_ifork_ops	*ops)
 {
@@ -711,9 +713,9 @@ xfs_ifork_verify_data(
 	/* Check the inline data fork if there is one. */
 	switch (VFS_I(ip)->i_mode & S_IFMT) {
 	case S_IFDIR:
-		return ops->verify_dir(ip);
+		return ops->verify_dir(vc, ip);
 	case S_IFLNK:
-		return ops->verify_symlink(ip);
+		return ops->verify_symlink(vc, ip);
 	default:
 		return NULL;
 	}
@@ -722,6 +724,7 @@ xfs_ifork_verify_data(
 /* Verify the inline contents of the attr fork of an inode. */
 xfs_failaddr_t
 xfs_ifork_verify_attr(
+	struct xfs_vc		*vc,
 	struct xfs_inode	*ip,
 	struct xfs_ifork_ops	*ops)
 {
@@ -730,5 +733,5 @@ xfs_ifork_verify_attr(
 		return NULL;
 	if (!XFS_IFORK_PTR(ip, XFS_ATTR_FORK))
 		return __this_address;
-	return ops->verify_attr(ip);
+	return ops->verify_attr(vc, ip);
 }
diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h
index 60361d2d74a1..b2f67389304c 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.h
+++ b/fs/xfs/libxfs/xfs_inode_fork.h
@@ -174,7 +174,7 @@ extern struct kmem_zone	*xfs_ifork_zone;
 
 extern void xfs_ifork_init_cow(struct xfs_inode *ip);
 
-typedef xfs_failaddr_t (*xfs_ifork_verifier_t)(struct xfs_inode *);
+typedef xfs_failaddr_t (*xfs_ifork_verifier_t)(struct xfs_vc *vc, struct xfs_inode *);
 
 struct xfs_ifork_ops {
 	xfs_ifork_verifier_t	verify_symlink;
@@ -183,9 +183,9 @@ struct xfs_ifork_ops {
 };
 extern struct xfs_ifork_ops	xfs_default_ifork_ops;
 
-xfs_failaddr_t xfs_ifork_verify_data(struct xfs_inode *ip,
+xfs_failaddr_t xfs_ifork_verify_data(struct xfs_vc *vc, struct xfs_inode *ip,
 		struct xfs_ifork_ops *ops);
-xfs_failaddr_t xfs_ifork_verify_attr(struct xfs_inode *ip,
+xfs_failaddr_t xfs_ifork_verify_attr(struct xfs_vc *vc, struct xfs_inode *ip,
 		struct xfs_ifork_ops *ops);
 
 #endif	/* __XFS_INODE_FORK_H__ */
diff --git a/fs/xfs/libxfs/xfs_quota_defs.h b/fs/xfs/libxfs/xfs_quota_defs.h
index 4bfdd5f4c6af..d6af05e0a6f1 100644
--- a/fs/xfs/libxfs/xfs_quota_defs.h
+++ b/fs/xfs/libxfs/xfs_quota_defs.h
@@ -137,9 +137,9 @@ typedef uint16_t	xfs_qwarncnt_t;
 		(XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA)
 #define XFS_QMOPT_RESBLK_MASK	(XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS)
 
-extern xfs_failaddr_t xfs_dquot_verify(struct xfs_mount *mp,
+extern xfs_failaddr_t xfs_dquot_verify(struct xfs_vc *vc, struct xfs_mount *mp,
 		struct xfs_disk_dquot *ddq, xfs_dqid_t id, uint type);
-extern xfs_failaddr_t xfs_dqblk_verify(struct xfs_mount *mp,
+extern xfs_failaddr_t xfs_dqblk_verify(struct xfs_vc *vc, struct xfs_mount *mp,
 		struct xfs_dqblk *dqb, xfs_dqid_t id, uint type);
 extern int xfs_calc_dquots_per_chunk(unsigned int nbblks);
 extern int xfs_dqblk_repair(struct xfs_mount *mp, struct xfs_dqblk *dqb,
diff --git a/fs/xfs/libxfs/xfs_refcount_btree.c b/fs/xfs/libxfs/xfs_refcount_btree.c
index 1aaa01c97517..125b536538ec 100644
--- a/fs/xfs/libxfs/xfs_refcount_btree.c
+++ b/fs/xfs/libxfs/xfs_refcount_btree.c
@@ -203,6 +203,7 @@ xfs_refcountbt_diff_two_keys(
 
 STATIC xfs_failaddr_t
 xfs_refcountbt_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -216,7 +217,7 @@ xfs_refcountbt_verify(
 
 	if (!xfs_sb_version_hasreflink(&mp->m_sb))
 		return __this_address;
-	fa = xfs_btree_sblock_v5hdr_verify(bp);
+	fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
 	if (fa)
 		return fa;
 
@@ -227,19 +228,20 @@ xfs_refcountbt_verify(
 	} else if (level >= mp->m_refc_maxlevels)
 		return __this_address;
 
-	return xfs_btree_sblock_verify(bp, mp->m_refc_mxr[level != 0]);
+	return xfs_btree_sblock_verify(vc, bp, mp->m_refc_mxr[level != 0]);
 }
 
 STATIC void
 xfs_refcountbt_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	xfs_failaddr_t	fa;
 
-	if (!xfs_btree_sblock_verify_crc(bp))
+	if (!xfs_btree_sblock_verify_crc(vc, bp))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_refcountbt_verify(bp);
+		fa = xfs_refcountbt_verify(vc, bp);
 		if (fa)
 			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 	}
@@ -250,11 +252,12 @@ xfs_refcountbt_read_verify(
 
 STATIC void
 xfs_refcountbt_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	xfs_failaddr_t	fa;
 
-	fa = xfs_refcountbt_verify(bp);
+	fa = xfs_refcountbt_verify(vc, bp);
 	if (fa) {
 		trace_xfs_btree_corrupt(bp, _RET_IP_);
 		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
diff --git a/fs/xfs/libxfs/xfs_rmap_btree.c b/fs/xfs/libxfs/xfs_rmap_btree.c
index f79cf040d745..f8828854ca2f 100644
--- a/fs/xfs/libxfs/xfs_rmap_btree.c
+++ b/fs/xfs/libxfs/xfs_rmap_btree.c
@@ -290,6 +290,7 @@ xfs_rmapbt_diff_two_keys(
 
 static xfs_failaddr_t
 xfs_rmapbt_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -315,7 +316,7 @@ xfs_rmapbt_verify(
 
 	if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
 		return __this_address;
-	fa = xfs_btree_sblock_v5hdr_verify(bp);
+	fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
 	if (fa)
 		return fa;
 
@@ -326,19 +327,20 @@ xfs_rmapbt_verify(
 	} else if (level >= mp->m_rmap_maxlevels)
 		return __this_address;
 
-	return xfs_btree_sblock_verify(bp, mp->m_rmap_mxr[level != 0]);
+	return xfs_btree_sblock_verify(vc, bp, mp->m_rmap_mxr[level != 0]);
 }
 
 static void
 xfs_rmapbt_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	xfs_failaddr_t	fa;
 
-	if (!xfs_btree_sblock_verify_crc(bp))
+	if (!xfs_btree_sblock_verify_crc(vc, bp))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_rmapbt_verify(bp);
+		fa = xfs_rmapbt_verify(vc, bp);
 		if (fa)
 			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 	}
@@ -349,11 +351,12 @@ xfs_rmapbt_read_verify(
 
 static void
 xfs_rmapbt_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	xfs_failaddr_t	fa;
 
-	fa = xfs_rmapbt_verify(bp);
+	fa = xfs_rmapbt_verify(vc, bp);
 	if (fa) {
 		trace_xfs_btree_corrupt(bp, _RET_IP_);
 		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
index b228c821bae6..6a0a953553b9 100644
--- a/fs/xfs/libxfs/xfs_rtbitmap.c
+++ b/fs/xfs/libxfs/xfs_rtbitmap.c
@@ -36,6 +36,7 @@
  */
 static void
 xfs_rtbuf_verify_read(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	return;
@@ -43,6 +44,7 @@ xfs_rtbuf_verify_read(
 
 static void
 xfs_rtbuf_verify_write(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	return;
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index b5a82acd7dfe..0f8197c368a9 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -681,6 +681,7 @@ xfs_sb_to_disk(
  */
 static void
 xfs_sb_read_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_sb		sb;
@@ -732,13 +733,14 @@ xfs_sb_read_verify(
  */
 static void
 xfs_sb_quiet_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_dsb	*dsb = XFS_BUF_TO_SBP(bp);
 
 	if (dsb->sb_magicnum == cpu_to_be32(XFS_SB_MAGIC)) {
 		/* XFS filesystem, verify noisily! */
-		xfs_sb_read_verify(bp);
+		xfs_sb_read_verify(vc, bp);
 		return;
 	}
 	/* quietly fail */
@@ -747,6 +749,7 @@ xfs_sb_quiet_read_verify(
 
 static void
 xfs_sb_write_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_sb		sb;
diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h
index 1c5debe748f0..c10d02addaa1 100644
--- a/fs/xfs/libxfs/xfs_shared.h
+++ b/fs/xfs/libxfs/xfs_shared.h
@@ -132,6 +132,6 @@ bool xfs_symlink_hdr_ok(xfs_ino_t ino, uint32_t offset,
 			uint32_t size, struct xfs_buf *bp);
 void xfs_symlink_local_to_remote(struct xfs_trans *tp, struct xfs_buf *bp,
 				 struct xfs_inode *ip, struct xfs_ifork *ifp);
-xfs_failaddr_t xfs_symlink_shortform_verify(struct xfs_inode *ip);
+xfs_failaddr_t xfs_symlink_shortform_verify(struct xfs_vc *vc, struct xfs_inode *ip);
 
 #endif /* __XFS_SHARED_H__ */
diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c
index 95374ab2dee7..e0ff80797942 100644
--- a/fs/xfs/libxfs/xfs_symlink_remote.c
+++ b/fs/xfs/libxfs/xfs_symlink_remote.c
@@ -88,6 +88,7 @@ xfs_symlink_hdr_ok(
 
 static xfs_failaddr_t
 xfs_symlink_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -114,6 +115,7 @@ xfs_symlink_verify(
 
 static void
 xfs_symlink_read_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -126,7 +128,7 @@ xfs_symlink_read_verify(
 	if (!xfs_buf_verify_cksum(bp, XFS_SYMLINK_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_symlink_verify(bp);
+		fa = xfs_symlink_verify(vc, bp);
 		if (fa)
 			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 	}
@@ -134,6 +136,7 @@ xfs_symlink_read_verify(
 
 static void
 xfs_symlink_write_verify(
+	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -144,7 +147,7 @@ xfs_symlink_write_verify(
 	if (!xfs_sb_version_hascrc(&mp->m_sb))
 		return;
 
-	fa = xfs_symlink_verify(bp);
+	fa = xfs_symlink_verify(vc, bp);
 	if (fa) {
 		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
 		return;
@@ -202,6 +205,7 @@ xfs_symlink_local_to_remote(
 /* Verify the consistency of an inline symlink. */
 xfs_failaddr_t
 xfs_symlink_shortform_verify(
+	struct xfs_vc		*vc,
 	struct xfs_inode	*ip)
 {
 	char			*sfp;
diff --git a/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h
index b9e6c89284c3..6c27103522a9 100644
--- a/fs/xfs/libxfs/xfs_types.h
+++ b/fs/xfs/libxfs/xfs_types.h
@@ -41,6 +41,10 @@ typedef int64_t		xfs_sfiloff_t;	/* signed block number in a file */
  */
 typedef void *		xfs_failaddr_t;
 
+struct xfs_vc {
+	xfs_failaddr_t	fa;
+};
+
 /*
  * Null values for the types.
  */
diff --git a/fs/xfs/scrub/btree.c b/fs/xfs/scrub/btree.c
index 4ae959f7ad2c..8780dcb479de 100644
--- a/fs/xfs/scrub/btree.c
+++ b/fs/xfs/scrub/btree.c
@@ -490,6 +490,7 @@ xchk_btree_get_block(
 	struct xfs_btree_block	**pblock,
 	struct xfs_buf		**pbp)
 {
+	struct xfs_vc		vc = { 0 };
 	xfs_failaddr_t		failed_at;
 	int			error;
 
@@ -503,10 +504,10 @@ xchk_btree_get_block(
 
 	xfs_btree_get_block(bs->cur, level, pbp);
 	if (bs->cur->bc_flags & XFS_BTREE_LONG_PTRS)
-		failed_at = __xfs_btree_check_lblock(bs->cur, *pblock,
+		failed_at = __xfs_btree_check_lblock(&vc, bs->cur, *pblock,
 				level, *pbp);
 	else
-		failed_at = __xfs_btree_check_sblock(bs->cur, *pblock,
+		failed_at = __xfs_btree_check_sblock(&vc, bs->cur, *pblock,
 				 level, *pbp);
 	if (failed_at) {
 		xchk_btree_set_corrupt(bs->sc, bs->cur, level);
diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c
index 346b02abccf7..1571e66e657a 100644
--- a/fs/xfs/scrub/common.c
+++ b/fs/xfs/scrub/common.c
@@ -791,6 +791,7 @@ xchk_buffer_recheck(
 	struct xfs_scrub	*sc,
 	struct xfs_buf		*bp)
 {
+	struct xfs_vc		vc = { 0 };
 	xfs_failaddr_t		fa;
 
 	if (bp->b_ops == NULL) {
@@ -801,7 +802,7 @@ xchk_buffer_recheck(
 		xchk_set_incomplete(sc);
 		return;
 	}
-	fa = bp->b_ops->verify_struct(bp);
+	fa = bp->b_ops->verify_struct(&vc, bp);
 	if (!fa)
 		return;
 	sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
diff --git a/fs/xfs/scrub/dabtree.c b/fs/xfs/scrub/dabtree.c
index f1260b4bfdee..4626a208d132 100644
--- a/fs/xfs/scrub/dabtree.c
+++ b/fs/xfs/scrub/dabtree.c
@@ -177,6 +177,7 @@ xchk_da_btree_ptr_ok(
  */
 static void
 xchk_da_btree_read_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_da_blkinfo	*info = bp->b_addr;
@@ -185,7 +186,7 @@ xchk_da_btree_read_verify(
 	case XFS_DIR2_LEAF1_MAGIC:
 	case XFS_DIR3_LEAF1_MAGIC:
 		bp->b_ops = &xfs_dir3_leaf1_buf_ops;
-		bp->b_ops->verify_read(bp);
+		bp->b_ops->verify_read(vc, bp);
 		return;
 	default:
 		/*
@@ -193,12 +194,13 @@ xchk_da_btree_read_verify(
 		 * DA*_NODE, ATTR*_LEAF, and DIR*_LEAFN blocks.
 		 */
 		bp->b_ops = &xfs_da3_node_buf_ops;
-		bp->b_ops->verify_read(bp);
+		bp->b_ops->verify_read(vc, bp);
 		return;
 	}
 }
 static void
 xchk_da_btree_write_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_da_blkinfo	*info = bp->b_addr;
@@ -207,7 +209,7 @@ xchk_da_btree_write_verify(
 	case XFS_DIR2_LEAF1_MAGIC:
 	case XFS_DIR3_LEAF1_MAGIC:
 		bp->b_ops = &xfs_dir3_leaf1_buf_ops;
-		bp->b_ops->verify_write(bp);
+		bp->b_ops->verify_write(vc, bp);
 		return;
 	default:
 		/*
@@ -215,12 +217,13 @@ xchk_da_btree_write_verify(
 		 * DA*_NODE, ATTR*_LEAF, and DIR*_LEAFN blocks.
 		 */
 		bp->b_ops = &xfs_da3_node_buf_ops;
-		bp->b_ops->verify_write(bp);
+		bp->b_ops->verify_write(vc, bp);
 		return;
 	}
 }
 static void *
 xchk_da_btree_verify(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_da_blkinfo	*info = bp->b_addr;
@@ -229,10 +232,10 @@ xchk_da_btree_verify(
 	case XFS_DIR2_LEAF1_MAGIC:
 	case XFS_DIR3_LEAF1_MAGIC:
 		bp->b_ops = &xfs_dir3_leaf1_buf_ops;
-		return bp->b_ops->verify_struct(bp);
+		return bp->b_ops->verify_struct(vc, bp);
 	default:
 		bp->b_ops = &xfs_da3_node_buf_ops;
-		return bp->b_ops->verify_struct(bp);
+		return bp->b_ops->verify_struct(vc, bp);
 	}
 }
 
diff --git a/fs/xfs/scrub/inode.c b/fs/xfs/scrub/inode.c
index e386c9b0b4ab..f8c6869b8fc6 100644
--- a/fs/xfs/scrub/inode.c
+++ b/fs/xfs/scrub/inode.c
@@ -83,9 +83,10 @@ xchk_inode_extsize(
 	uint16_t		mode,
 	uint16_t		flags)
 {
+	struct xfs_vc		vc = { 0 };
 	xfs_failaddr_t		fa;
 
-	fa = xfs_inode_validate_extsize(sc->mp, be32_to_cpu(dip->di_extsize),
+	fa = xfs_inode_validate_extsize(&vc, sc->mp, be32_to_cpu(dip->di_extsize),
 			mode, flags);
 	if (fa)
 		xchk_ino_set_corrupt(sc, ino);
@@ -106,9 +107,10 @@ xchk_inode_cowextsize(
 	uint16_t		flags,
 	uint64_t		flags2)
 {
+	struct xfs_vc		vc = { 0 };
 	xfs_failaddr_t		fa;
 
-	fa = xfs_inode_validate_cowextsize(sc->mp,
+	fa = xfs_inode_validate_cowextsize(&vc, sc->mp,
 			be32_to_cpu(dip->di_cowextsize), mode, flags,
 			flags2);
 	if (fa)
diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c
index 4fc0a5ea7673..dc9b5762d1ac 100644
--- a/fs/xfs/scrub/repair.c
+++ b/fs/xfs/scrub/repair.c
@@ -766,11 +766,13 @@ xrep_findroot_block(
 		if (bp->b_ops != fab->buf_ops)
 			goto out;
 	} else {
+		struct xfs_vc	vc = { 0 };
+
 		ASSERT(!xfs_trans_buf_is_dirty(bp));
 		if (!uuid_equal(&btblock->bb_u.s.bb_uuid,
 				&mp->m_sb.sb_meta_uuid))
 			goto out;
-		fab->buf_ops->verify_read(bp);
+		fab->buf_ops->verify_read(&vc, bp);
 		if (bp->b_error) {
 			bp->b_error = 0;
 			goto out;
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index b21ea2ba768d..b46e22c7a8c8 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -786,6 +786,8 @@ xfs_buf_ensure_ops(
 	struct xfs_buf		*bp,
 	const struct xfs_buf_ops *ops)
 {
+	struct xfs_vc	vc = { 0 };
+
 	ASSERT(bp->b_flags & XBF_DONE);
 	ASSERT(bp->b_error == 0);
 
@@ -793,7 +795,7 @@ xfs_buf_ensure_ops(
 		return 0;
 
 	bp->b_ops = ops;
-	bp->b_ops->verify_read(bp);
+	bp->b_ops->verify_read(&vc, bp);
 	if (bp->b_error)
 		bp->b_flags &= ~XBF_DONE;
 	return bp->b_error;
@@ -1228,8 +1230,10 @@ xfs_buf_ioend(
 
 	/* Only validate buffers that were read without errors */
 	if (read && !bp->b_error && bp->b_ops) {
+		struct xfs_vc	vc = { 0 };
+
 		ASSERT(!bp->b_iodone);
-		bp->b_ops->verify_read(bp);
+		bp->b_ops->verify_read(&vc, bp);
 	}
 
 	if (!bp->b_error)
@@ -1447,7 +1451,9 @@ _xfs_buf_ioapply(
 		 * the IO should not be dispatched.
 		 */
 		if (bp->b_ops) {
-			bp->b_ops->verify_write(bp);
+			struct xfs_vc	vc = { 0 };
+
+			bp->b_ops->verify_write(&vc, bp);
 			if (bp->b_error) {
 				xfs_force_shutdown(bp->b_target->bt_mount,
 						   SHUTDOWN_CORRUPT_INCORE);
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 5015255b5ede..d1c6c92b7104 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -125,9 +125,9 @@ struct xfs_buf_map {
 
 struct xfs_buf_ops {
 	char *name;
-	void (*verify_read)(struct xfs_buf *);
-	void (*verify_write)(struct xfs_buf *);
-	xfs_failaddr_t (*verify_struct)(struct xfs_buf *bp);
+	void (*verify_read)(struct xfs_vc *vc, struct xfs_buf *);
+	void (*verify_write)(struct xfs_vc *vc, struct xfs_buf *);
+	xfs_failaddr_t (*verify_struct)(struct xfs_vc *vc, struct xfs_buf *bp);
 };
 
 typedef struct xfs_buf {
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 87e6dd5326d5..14b386c584b6 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -1074,6 +1074,7 @@ xfs_qm_dqflush(
 	struct xfs_buf		*bp;
 	struct xfs_dqblk	*dqb;
 	struct xfs_disk_dquot	*ddqp;
+	struct xfs_vc		vc = { 0 };
 	xfs_failaddr_t		fa;
 	int			error;
 
@@ -1122,7 +1123,7 @@ xfs_qm_dqflush(
 	/*
 	 * A simple sanity check in case we got a corrupted dquot.
 	 */
-	fa = xfs_dqblk_verify(mp, dqb, be32_to_cpu(ddqp->d_id), 0);
+	fa = xfs_dqblk_verify(&vc, mp, dqb, be32_to_cpu(ddqp->d_id), 0);
 	if (fa) {
 		xfs_alert(mp, "corrupt dquot ID 0x%x in memory at %pS",
 				be32_to_cpu(ddqp->d_id), fa);
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 05db9540e459..d2fd4d4b7864 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -3416,9 +3416,10 @@ xfs_inode_verify_forks(
 	struct xfs_inode	*ip)
 {
 	struct xfs_ifork	*ifp;
+	struct xfs_vc		vc = { 0 };
 	xfs_failaddr_t		fa;
 
-	fa = xfs_ifork_verify_data(ip, &xfs_default_ifork_ops);
+	fa = xfs_ifork_verify_data(&vc, ip, &xfs_default_ifork_ops);
 	if (fa) {
 		ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
 		xfs_inode_verifier_error(ip, -EFSCORRUPTED, "data fork",
@@ -3426,7 +3427,7 @@ xfs_inode_verify_forks(
 		return false;
 	}
 
-	fa = xfs_ifork_verify_attr(ip, &xfs_default_ifork_ops);
+	fa = xfs_ifork_verify_attr(&vc, ip, &xfs_default_ifork_ops);
 	if (fa) {
 		ifp = XFS_IFORK_PTR(ip, XFS_ATTR_FORK);
 		xfs_inode_verifier_error(ip, -EFSCORRUPTED, "attr fork",
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 1fc9e9042e0e..bcafd3961d20 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2650,6 +2650,7 @@ xlog_recover_do_reg_buffer(
 	int			i;
 	int			bit;
 	int			nbits;
+	struct xfs_vc		vc = { 0 };
 	xfs_failaddr_t		fa;
 
 	trace_xfs_log_recover_buf_reg_buf(mp->m_log, buf_f);
@@ -2699,7 +2700,7 @@ xlog_recover_do_reg_buffer(
 					item->ri_buf[i].i_len, __func__);
 				goto next;
 			}
-			fa = xfs_dquot_verify(mp, item->ri_buf[i].i_addr,
+			fa = xfs_dquot_verify(&vc, mp, item->ri_buf[i].i_addr,
 					       -1, 0);
 			if (fa) {
 				xfs_alert(mp,
@@ -3308,6 +3309,7 @@ xlog_recover_dquot_pass2(
 	xfs_mount_t		*mp = log->l_mp;
 	xfs_buf_t		*bp;
 	struct xfs_disk_dquot	*ddq, *recddq;
+	struct xfs_vc		vc = { 0 };
 	xfs_failaddr_t		fa;
 	int			error;
 	xfs_dq_logformat_t	*dq_f;
@@ -3351,7 +3353,7 @@ xlog_recover_dquot_pass2(
 	 */
 	dq_f = item->ri_buf[0].i_addr;
 	ASSERT(dq_f);
-	fa = xfs_dquot_verify(mp, recddq, dq_f->qlf_id, 0);
+	fa = xfs_dquot_verify(&vc, mp, recddq, dq_f->qlf_id, 0);
 	if (fa) {
 		xfs_alert(mp, "corrupt dquot ID 0x%x in log at %pS",
 				dq_f->qlf_id, fa);
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 52ed7904df10..09cd6e971074 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -833,6 +833,7 @@ xfs_qm_reset_dqcounts(
 {
 	struct xfs_dqblk	*dqb;
 	int			j;
+	struct xfs_vc		vc = { 0 };
 	xfs_failaddr_t		fa;
 
 	trace_xfs_reset_dqcounts(bp, _RET_IP_);
@@ -858,7 +859,7 @@ xfs_qm_reset_dqcounts(
 		 * find uninitialised dquot blks. See comment in
 		 * xfs_dquot_verify.
 		 */
-		fa = xfs_dqblk_verify(mp, &dqb[j], id + j, type);
+		fa = xfs_dqblk_verify(&vc, mp, &dqb[j], id + j, type);
 		if (fa)
 			xfs_dqblk_repair(mp, &dqb[j], id + j, type);
 
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 04/10] xfs: pass a verifier context to crc validation functions
  2018-12-05 21:01 [PATCH RFC 0/10] xfs: add verifier context structure Eric Sandeen
                   ` (2 preceding siblings ...)
  2018-12-05 21:03 ` [PATCH 03/10] xfs: pass a verifier context down verifier callchains Eric Sandeen
@ 2018-12-05 21:04 ` Eric Sandeen
  2018-12-05 21:05 ` [PATCH 05/10] xfs: define new macros to set verifier context on return Eric Sandeen
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Eric Sandeen @ 2018-12-05 21:04 UTC (permalink / raw)
  To: Eric Sandeen, linux-xfs

Pass the new verifier context to crc checking funtions as well.

Still not used at this point in the series.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 fs/xfs/libxfs/xfs_alloc.c          | 4 ++--
 fs/xfs/libxfs/xfs_attr_leaf.c      | 2 +-
 fs/xfs/libxfs/xfs_attr_remote.c    | 2 +-
 fs/xfs/libxfs/xfs_bmap_btree.c     | 2 +-
 fs/xfs/libxfs/xfs_btree.c          | 5 +++--
 fs/xfs/libxfs/xfs_btree.h          | 2 +-
 fs/xfs/libxfs/xfs_cksum.h          | 3 ++-
 fs/xfs/libxfs/xfs_da_btree.c       | 2 +-
 fs/xfs/libxfs/xfs_dir2_block.c     | 2 +-
 fs/xfs/libxfs/xfs_dir2_data.c      | 2 +-
 fs/xfs/libxfs/xfs_dir2_leaf.c      | 2 +-
 fs/xfs/libxfs/xfs_dir2_node.c      | 2 +-
 fs/xfs/libxfs/xfs_dquot_buf.c      | 3 ++-
 fs/xfs/libxfs/xfs_ialloc.c         | 2 +-
 fs/xfs/libxfs/xfs_inode_buf.c      | 2 +-
 fs/xfs/libxfs/xfs_sb.c             | 2 +-
 fs/xfs/libxfs/xfs_symlink_remote.c | 2 +-
 fs/xfs/xfs_buf.h                   | 5 +++--
 18 files changed, 25 insertions(+), 21 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 59b8ab08dabd..15312fb37c02 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -610,7 +610,7 @@ xfs_agfl_read_verify(
 	if (!xfs_sb_version_hascrc(&mp->m_sb))
 		return;
 
-	if (!xfs_buf_verify_cksum(bp, XFS_AGFL_CRC_OFF))
+	if (!xfs_buf_verify_cksum(vc, bp, XFS_AGFL_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
 		fa = xfs_agfl_verify(vc, bp);
@@ -2642,7 +2642,7 @@ xfs_agf_read_verify(
 	xfs_failaddr_t	fa;
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
-	    !xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF))
+	    !xfs_buf_verify_cksum(vc, bp, XFS_AGF_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
 		fa = xfs_agf_verify(vc, bp);
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index 5b146c909389..d7909e45800c 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -361,7 +361,7 @@ xfs_attr3_leaf_read_verify(
 	xfs_failaddr_t		fa;
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
-	     !xfs_buf_verify_cksum(bp, XFS_ATTR3_LEAF_CRC_OFF))
+	     !xfs_buf_verify_cksum(vc, bp, XFS_ATTR3_LEAF_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
 		fa = xfs_attr3_leaf_verify(vc, bp);
diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index e8d629de2cf5..96a1b67f4fb9 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -129,7 +129,7 @@ __xfs_attr3_rmt_read_verify(
 
 	while (len > 0) {
 		if (check_crc &&
-		    !xfs_verify_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF)) {
+		    !xfs_verify_cksum(vc, ptr, blksize, XFS_ATTR3_RMT_CRC_OFF)) {
 			*failaddr = __this_address;
 			return -EFSBADCRC;
 		}
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index 4c8e97709704..3cc9c6610c05 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -454,7 +454,7 @@ xfs_bmbt_read_verify(
 {
 	xfs_failaddr_t	fa;
 
-	if (!xfs_btree_lblock_verify_crc(bp))
+	if (!xfs_btree_lblock_verify_crc(vc, bp))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
 		fa = xfs_bmbt_verify(vc, bp);
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index 755ac16e90c5..a618e0251a55 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -289,6 +289,7 @@ xfs_btree_lblock_calc_crc(
 
 bool
 xfs_btree_lblock_verify_crc(
+	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_btree_block	*block = XFS_BUF_TO_BLOCK(bp);
@@ -297,7 +298,7 @@ xfs_btree_lblock_verify_crc(
 	if (xfs_sb_version_hascrc(&mp->m_sb)) {
 		if (!xfs_log_check_lsn(mp, be64_to_cpu(block->bb_u.l.bb_lsn)))
 			return false;
-		return xfs_buf_verify_cksum(bp, XFS_BTREE_LBLOCK_CRC_OFF);
+		return xfs_buf_verify_cksum(vc, bp, XFS_BTREE_LBLOCK_CRC_OFF);
 	}
 
 	return true;
@@ -336,7 +337,7 @@ xfs_btree_sblock_verify_crc(
 	if (xfs_sb_version_hascrc(&mp->m_sb)) {
 		if (!xfs_log_check_lsn(mp, be64_to_cpu(block->bb_u.s.bb_lsn)))
 			return false;
-		return xfs_buf_verify_cksum(bp, XFS_BTREE_SBLOCK_CRC_OFF);
+		return xfs_buf_verify_cksum(vc, bp, XFS_BTREE_SBLOCK_CRC_OFF);
 	}
 
 	return true;
diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
index 86cc17f1bf3f..a585293798f3 100644
--- a/fs/xfs/libxfs/xfs_btree.h
+++ b/fs/xfs/libxfs/xfs_btree.h
@@ -415,7 +415,7 @@ int xfs_btree_change_owner(struct xfs_btree_cur *cur, uint64_t new_owner,
  * btree block CRC helpers
  */
 void xfs_btree_lblock_calc_crc(struct xfs_buf *);
-bool xfs_btree_lblock_verify_crc(struct xfs_buf *);
+bool xfs_btree_lblock_verify_crc(struct xfs_vc *vc, struct xfs_buf *);
 void xfs_btree_sblock_calc_crc(struct xfs_buf *);
 bool xfs_btree_sblock_verify_crc(struct xfs_vc *vc, struct xfs_buf *);
 
diff --git a/fs/xfs/libxfs/xfs_cksum.h b/fs/xfs/libxfs/xfs_cksum.h
index 1e3802a99867..888ef9ec4c57 100644
--- a/fs/xfs/libxfs/xfs_cksum.h
+++ b/fs/xfs/libxfs/xfs_cksum.h
@@ -72,7 +72,8 @@ xfs_update_cksum(char *buffer, size_t length, unsigned long cksum_offset)
  * Helper to verify the checksum for a buffer.
  */
 static inline bool
-xfs_verify_cksum(char *buffer, size_t length, unsigned long cksum_offset)
+xfs_verify_cksum(struct xfs_vc *vc, char *buffer, size_t length,
+		 unsigned long cksum_offset)
 {
 	uint32_t crc = xfs_start_cksum_safe(buffer, length, cksum_offset);
 
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 38862a0990d4..eb19d6aa85ca 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -207,7 +207,7 @@ xfs_da3_node_read_verify(
 
 	switch (be16_to_cpu(info->magic)) {
 		case XFS_DA3_NODE_MAGIC:
-			if (!xfs_buf_verify_cksum(bp, XFS_DA3_NODE_CRC_OFF)) {
+			if (!xfs_buf_verify_cksum(vc, bp, XFS_DA3_NODE_CRC_OFF)) {
 				xfs_verifier_error(bp, -EFSBADCRC,
 						__this_address);
 				break;
diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
index 65ba4eccce8b..53cc0e151a75 100644
--- a/fs/xfs/libxfs/xfs_dir2_block.c
+++ b/fs/xfs/libxfs/xfs_dir2_block.c
@@ -79,7 +79,7 @@ xfs_dir3_block_read_verify(
 	xfs_failaddr_t		fa;
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
-	     !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF))
+	     !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_DATA_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
 		fa = xfs_dir3_block_verify(vc, bp);
diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
index 6530621d8144..661615f253b2 100644
--- a/fs/xfs/libxfs/xfs_dir2_data.c
+++ b/fs/xfs/libxfs/xfs_dir2_data.c
@@ -310,7 +310,7 @@ xfs_dir3_data_read_verify(
 	xfs_failaddr_t		fa;
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
-	    !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF))
+	    !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_DATA_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
 		fa = xfs_dir3_data_verify(vc, bp);
diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
index 1122a639b603..a225dcdc11c8 100644
--- a/fs/xfs/libxfs/xfs_dir2_leaf.c
+++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
@@ -187,7 +187,7 @@ __read_verify(
 	xfs_failaddr_t		fa;
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
-	     !xfs_buf_verify_cksum(bp, XFS_DIR3_LEAF_CRC_OFF))
+	     !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_LEAF_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
 		fa = xfs_dir3_leaf_verify(vc, bp, magic);
diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index 70f54145d0b0..8174e469b14f 100644
--- a/fs/xfs/libxfs/xfs_dir2_node.c
+++ b/fs/xfs/libxfs/xfs_dir2_node.c
@@ -120,7 +120,7 @@ xfs_dir3_free_read_verify(
 	xfs_failaddr_t		fa;
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
-	    !xfs_buf_verify_cksum(bp, XFS_DIR3_FREE_CRC_OFF))
+	    !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_FREE_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
 		fa = xfs_dir3_free_verify(vc, bp);
diff --git a/fs/xfs/libxfs/xfs_dquot_buf.c b/fs/xfs/libxfs/xfs_dquot_buf.c
index 0dc0a8d7ffc4..bbc63656a6d2 100644
--- a/fs/xfs/libxfs/xfs_dquot_buf.c
+++ b/fs/xfs/libxfs/xfs_dquot_buf.c
@@ -147,6 +147,7 @@ xfs_dquot_buf_verify_crc(
 {
 	struct xfs_dqblk	*d = (struct xfs_dqblk *)bp->b_addr;
 	int			ndquots;
+	struct xfs_vc		vc;
 	int			i;
 
 	if (!xfs_sb_version_hascrc(&mp->m_sb))
@@ -163,7 +164,7 @@ xfs_dquot_buf_verify_crc(
 		ndquots = xfs_calc_dquots_per_chunk(bp->b_length);
 
 	for (i = 0; i < ndquots; i++, d++) {
-		if (!xfs_verify_cksum((char *)d, sizeof(struct xfs_dqblk),
+		if (!xfs_verify_cksum(&vc, (char *)d, sizeof(struct xfs_dqblk),
 				 XFS_DQUOT_CRC_OFF)) {
 			if (!readahead)
 				xfs_buf_verifier_error(bp, -EFSBADCRC, __func__,
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 1b2b3b63b207..a204112c8c90 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -2557,7 +2557,7 @@ xfs_agi_read_verify(
 	xfs_failaddr_t	fa;
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
-	    !xfs_buf_verify_cksum(bp, XFS_AGI_CRC_OFF))
+	    !xfs_buf_verify_cksum(vc, bp, XFS_AGI_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
 		fa = xfs_agi_verify(vc, bp);
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index 7d9b4ea6eba9..d7a8199d5f36 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -466,7 +466,7 @@ xfs_dinode_verify(
 	if (dip->di_version >= 3) {
 		if (!xfs_sb_version_hascrc(&mp->m_sb))
 			return __this_address;
-		if (!xfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize,
+		if (!xfs_verify_cksum(vc, (char *)dip, mp->m_sb.sb_inodesize,
 				      XFS_DINODE_CRC_OFF))
 			return __this_address;
 		if (be64_to_cpu(dip->di_ino) != ino)
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index 0f8197c368a9..07e866103dc2 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -698,7 +698,7 @@ xfs_sb_read_verify(
 						XFS_SB_VERSION_5) ||
 	     dsb->sb_crc != 0)) {
 
-		if (!xfs_buf_verify_cksum(bp, XFS_SB_CRC_OFF)) {
+		if (!xfs_buf_verify_cksum(vc, bp, XFS_SB_CRC_OFF)) {
 			/* Only fail bad secondaries on a known V5 filesystem */
 			if (bp->b_bn == XFS_SB_DADDR ||
 			    xfs_sb_version_hascrc(&mp->m_sb)) {
diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c
index e0ff80797942..0405f17aae6f 100644
--- a/fs/xfs/libxfs/xfs_symlink_remote.c
+++ b/fs/xfs/libxfs/xfs_symlink_remote.c
@@ -125,7 +125,7 @@ xfs_symlink_read_verify(
 	if (!xfs_sb_version_hascrc(&mp->m_sb))
 		return;
 
-	if (!xfs_buf_verify_cksum(bp, XFS_SYMLINK_CRC_OFF))
+	if (!xfs_buf_verify_cksum(vc, bp, XFS_SYMLINK_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
 		fa = xfs_symlink_verify(vc, bp);
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index d1c6c92b7104..e7e1e070f76e 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -360,9 +360,10 @@ static inline void xfs_buf_relse(xfs_buf_t *bp)
 }
 
 static inline bool
-xfs_buf_verify_cksum(struct xfs_buf *bp, unsigned long cksum_offset)
+xfs_buf_verify_cksum(struct xfs_vc *vc, struct xfs_buf *bp,
+		     unsigned long cksum_offset)
 {
-	return xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length),
+	return xfs_verify_cksum(vc, bp->b_addr, BBTOB(bp->b_length),
 				cksum_offset);
 }
 
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 05/10] xfs: define new macros to set verifier context on return
  2018-12-05 21:01 [PATCH RFC 0/10] xfs: add verifier context structure Eric Sandeen
                   ` (3 preceding siblings ...)
  2018-12-05 21:04 ` [PATCH 04/10] xfs: pass a verifier context to crc validation functions Eric Sandeen
@ 2018-12-05 21:05 ` Eric Sandeen
  2018-12-05 21:06 ` [PATCH 06/10] xfs: teach xfs_btree_[sl]block_verify_crc to populate verifier context Eric Sandeen
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Eric Sandeen @ 2018-12-05 21:05 UTC (permalink / raw)
  To: Eric Sandeen, linux-xfs

New XFS_CORRUPTED_RETURN and XFS_VERIFIED_RETURN macros to set
either __this_address or NULL into the verifier failaddr, and
return the same value as well so that caller logic is unchanged
for now.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 fs/xfs/libxfs/xfs_alloc.c          |  33 +++++----
 fs/xfs/libxfs/xfs_alloc_btree.c    |  10 +--
 fs/xfs/libxfs/xfs_attr_leaf.c      |  48 ++++++-------
 fs/xfs/libxfs/xfs_attr_remote.c    |  16 ++---
 fs/xfs/libxfs/xfs_bmap.c           |  14 ++--
 fs/xfs/libxfs/xfs_bmap_btree.c     |   4 +-
 fs/xfs/libxfs/xfs_btree.c          |  70 +++++++++----------
 fs/xfs/libxfs/xfs_da_btree.c       |  22 +++---
 fs/xfs/libxfs/xfs_dir2_block.c     |  10 +--
 fs/xfs/libxfs/xfs_dir2_data.c      |  96 +++++++++++++-------------
 fs/xfs/libxfs/xfs_dir2_leaf.c      |  24 +++----
 fs/xfs/libxfs/xfs_dir2_node.c      |  30 ++++-----
 fs/xfs/libxfs/xfs_dir2_sf.c        |  24 +++----
 fs/xfs/libxfs/xfs_dquot_buf.c      |  24 +++----
 fs/xfs/libxfs/xfs_ialloc.c         |  18 ++---
 fs/xfs/libxfs/xfs_ialloc_btree.c   |   4 +-
 fs/xfs/libxfs/xfs_inode_buf.c      | 104 ++++++++++++++---------------
 fs/xfs/libxfs/xfs_inode_fork.c     |   8 +--
 fs/xfs/libxfs/xfs_refcount_btree.c |   8 +--
 fs/xfs/libxfs/xfs_rmap_btree.c     |   8 +--
 fs/xfs/libxfs/xfs_symlink_remote.c |  26 ++++----
 fs/xfs/libxfs/xfs_types.h          |   3 +
 22 files changed, 303 insertions(+), 301 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 15312fb37c02..36073ac260af 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -567,12 +567,12 @@ xfs_agfl_verify(
 	 * can't verify just those entries are valid.
 	 */
 	if (!xfs_sb_version_hascrc(&mp->m_sb))
-		return NULL;
+		return XFS_VERIFIED_RETURN(vc);
 
 	if (!uuid_equal(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (be32_to_cpu(agfl->agfl_magicnum) != XFS_AGFL_MAGIC)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	/*
 	 * during growfs operations, the perag is not fully initialised,
 	 * so we can't use it for any useful checking. growfs ensures we can't
@@ -580,17 +580,17 @@ xfs_agfl_verify(
 	 * so we can detect and avoid this problem.
 	 */
 	if (bp->b_pag && be32_to_cpu(agfl->agfl_seqno) != bp->b_pag->pag_agno)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	for (i = 0; i < xfs_agfl_size(mp); i++) {
 		if (be32_to_cpu(agfl->agfl_bno[i]) != NULLAGBLOCK &&
 		    be32_to_cpu(agfl->agfl_bno[i]) >= mp->m_sb.sb_agblocks)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 
 	if (!xfs_log_check_lsn(mp, be64_to_cpu(XFS_BUF_TO_AGFL(bp)->agfl_lsn)))
-		return __this_address;
-	return NULL;
+		return XFS_CORRUPTED_RETURN(vc);
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 static void
@@ -2586,10 +2586,10 @@ xfs_agf_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb)) {
 		if (!uuid_equal(&agf->agf_uuid, &mp->m_sb.sb_meta_uuid))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (!xfs_log_check_lsn(mp,
 				be64_to_cpu(XFS_BUF_TO_AGF(bp)->agf_lsn)))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 
 	if (!(agf->agf_magicnum == cpu_to_be32(XFS_AGF_MAGIC) &&
@@ -2598,18 +2598,18 @@ xfs_agf_verify(
 	      be32_to_cpu(agf->agf_flfirst) < xfs_agfl_size(mp) &&
 	      be32_to_cpu(agf->agf_fllast) < xfs_agfl_size(mp) &&
 	      be32_to_cpu(agf->agf_flcount) <= xfs_agfl_size(mp)))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]) < 1 ||
 	    be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]) < 1 ||
 	    be32_to_cpu(agf->agf_levels[XFS_BTNUM_BNO]) > XFS_BTREE_MAXLEVELS ||
 	    be32_to_cpu(agf->agf_levels[XFS_BTNUM_CNT]) > XFS_BTREE_MAXLEVELS)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (xfs_sb_version_hasrmapbt(&mp->m_sb) &&
 	    (be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]) < 1 ||
 	     be32_to_cpu(agf->agf_levels[XFS_BTNUM_RMAP]) > XFS_BTREE_MAXLEVELS))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/*
 	 * during growfs operations, the perag is not fully initialised,
@@ -2618,19 +2618,18 @@ xfs_agf_verify(
 	 * so we can detect and avoid this problem.
 	 */
 	if (bp->b_pag && be32_to_cpu(agf->agf_seqno) != bp->b_pag->pag_agno)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (xfs_sb_version_haslazysbcount(&mp->m_sb) &&
 	    be32_to_cpu(agf->agf_btreeblks) > be32_to_cpu(agf->agf_length))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (xfs_sb_version_hasreflink(&mp->m_sb) &&
 	    (be32_to_cpu(agf->agf_refcount_level) < 1 ||
 	     be32_to_cpu(agf->agf_refcount_level) > XFS_BTREE_MAXLEVELS))
-		return __this_address;
-
-	return NULL;
+		return XFS_CORRUPTED_RETURN(vc);
 
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 static void
diff --git a/fs/xfs/libxfs/xfs_alloc_btree.c b/fs/xfs/libxfs/xfs_alloc_btree.c
index 2e9353a76a58..e8c4d142c419 100644
--- a/fs/xfs/libxfs/xfs_alloc_btree.c
+++ b/fs/xfs/libxfs/xfs_alloc_btree.c
@@ -321,9 +321,9 @@ xfs_allocbt_verify(
 	case cpu_to_be32(XFS_ABTB_MAGIC):
 		if (pag && pag->pagf_init) {
 			if (level >= pag->pagf_levels[XFS_BTNUM_BNOi])
-				return __this_address;
+				return XFS_CORRUPTED_RETURN(vc);
 		} else if (level >= mp->m_ag_maxlevels)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		break;
 	case cpu_to_be32(XFS_ABTC_CRC_MAGIC):
 		fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
@@ -333,12 +333,12 @@ xfs_allocbt_verify(
 	case cpu_to_be32(XFS_ABTC_MAGIC):
 		if (pag && pag->pagf_init) {
 			if (level >= pag->pagf_levels[XFS_BTNUM_CNTi])
-				return __this_address;
+				return XFS_CORRUPTED_RETURN(vc);
 		} else if (level >= mp->m_ag_maxlevels)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		break;
 	default:
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	}
 
 	return xfs_btree_sblock_verify(vc, bp, mp->m_alloc_mxr[level != 0]);
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index d7909e45800c..cf09952a3939 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -253,17 +253,17 @@ xfs_attr3_leaf_verify(
 		struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
 
 		if (ichdr.magic != XFS_ATTR3_LEAF_MAGIC)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 
 		if (!uuid_equal(&hdr3->info.uuid, &mp->m_sb.sb_meta_uuid))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (be64_to_cpu(hdr3->info.blkno) != bp->b_bn)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->info.lsn)))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	} else {
 		if (ichdr.magic != XFS_ATTR_LEAF_MAGIC)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 	/*
 	 * In recovery there is a transient state where count == 0 is valid
@@ -271,22 +271,22 @@ xfs_attr3_leaf_verify(
 	 * if the attr didn't fit in shortform.
 	 */
 	if (!xfs_log_in_recovery(mp) && ichdr.count == 0)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/*
 	 * firstused is the block offset of the first name info structure.
 	 * Make sure it doesn't go off the block or crash into the header.
 	 */
 	if (ichdr.firstused > mp->m_attr_geo->blksize)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (ichdr.firstused < xfs_attr3_leaf_hdr_size(leaf))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* Make sure the entries array doesn't crash into the name info. */
 	entries = xfs_attr3_leaf_entryp(bp->b_addr);
 	if ((char *)&entries[ichdr.count] >
 	    (char *)bp->b_addr + ichdr.firstused)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* XXX: need to range check rest of attr header values */
 	/* XXX: hash order check? */
@@ -302,23 +302,23 @@ xfs_attr3_leaf_verify(
 	 */
 	for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; i++) {
 		if (ichdr.freemap[i].base > mp->m_attr_geo->blksize)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (ichdr.freemap[i].base & 0x3)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (ichdr.freemap[i].size > mp->m_attr_geo->blksize)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (ichdr.freemap[i].size & 0x3)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 
 		/* be care of 16 bit overflows here */
 		end = (uint32_t)ichdr.freemap[i].base + ichdr.freemap[i].size;
 		if (end < ichdr.freemap[i].base)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (end > mp->m_attr_geo->blksize)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 static void
@@ -928,7 +928,7 @@ xfs_attr_shortform_verify(
 	 * Give up if the attribute is way too short.
 	 */
 	if (size < sizeof(struct xfs_attr_sf_hdr))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	endp = (char *)sfp + size;
 
@@ -941,11 +941,11 @@ xfs_attr_shortform_verify(
 		 * within the data buffer.
 		 */
 		if (((char *)sfep + sizeof(*sfep)) >= endp)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 
 		/* Don't allow names with known bad length. */
 		if (sfep->namelen == 0)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 
 		/*
 		 * Check that the variable-length part of the structure is
@@ -954,7 +954,7 @@ xfs_attr_shortform_verify(
 		 */
 		next_sfep = XFS_ATTR_SF_NEXTENTRY(sfep);
 		if ((char *)next_sfep > endp)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 
 		/*
 		 * Check for unknown flags.  Short form doesn't support
@@ -962,7 +962,7 @@ xfs_attr_shortform_verify(
 		 * mask here.
 		 */
 		if (sfep->flags & ~XFS_ATTR_NSP_ONDISK_MASK)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 
 		/*
 		 * Check for invalid namespace combinations.  We only allow
@@ -970,14 +970,14 @@ xfs_attr_shortform_verify(
 		 * bits (i.e. hweight) here.
 		 */
 		if (hweight8(sfep->flags & XFS_ATTR_NSP_ONDISK_MASK) > 1)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 
 		sfep = next_sfep;
 	}
 	if ((void *)sfep != (void *)endp)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 /*
diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index 96a1b67f4fb9..2b038458f4ae 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -87,22 +87,22 @@ xfs_attr3_rmt_verify(
 	struct xfs_attr3_rmt_hdr *rmt = ptr;
 
 	if (!xfs_sb_version_hascrc(&mp->m_sb))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (rmt->rm_magic != cpu_to_be32(XFS_ATTR3_RMT_MAGIC))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (!uuid_equal(&rmt->rm_uuid, &mp->m_sb.sb_meta_uuid))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (be64_to_cpu(rmt->rm_blkno) != bno)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (be32_to_cpu(rmt->rm_bytes) > fsbsize - sizeof(*rmt))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (be32_to_cpu(rmt->rm_offset) +
 				be32_to_cpu(rmt->rm_bytes) > XFS_XATTR_SIZE_MAX)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (rmt->rm_owner == 0)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 static int
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index fe0e0a1df5b1..0340f9e2e0e7 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -6115,19 +6115,19 @@ xfs_bmap_validate_extent(
 	endfsb = irec->br_startblock + irec->br_blockcount - 1;
 	if (isrt) {
 		if (!xfs_verify_rtbno(mp, irec->br_startblock))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (!xfs_verify_rtbno(mp, endfsb))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	} else {
 		if (!xfs_verify_fsbno(mp, irec->br_startblock))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (!xfs_verify_fsbno(mp, endfsb))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (XFS_FSB_TO_AGNO(mp, irec->br_startblock) !=
 		    XFS_FSB_TO_AGNO(mp, endfsb))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 	if (irec->br_state != XFS_EXT_NORM && whichfork != XFS_DATA_FORK)
-		return __this_address;
-	return NULL;
+		return XFS_CORRUPTED_RETURN(vc);
+	return XFS_VERIFIED_RETURN(vc);
 }
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index 3cc9c6610c05..27b9056ba87a 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -430,7 +430,7 @@ xfs_bmbt_verify(
 	case cpu_to_be32(XFS_BMAP_MAGIC):
 		break;
 	default:
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	}
 
 	/*
@@ -442,7 +442,7 @@ xfs_bmbt_verify(
 	 */
 	level = be16_to_cpu(block->bb_level);
 	if (level > max(mp->m_bm_maxlevels[0], mp->m_bm_maxlevels[1]))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	return xfs_btree_lblock_verify(vc, bp, mp->m_bmap_dmxr[level != 0]);
 }
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index a618e0251a55..d4728f70fcc3 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -70,31 +70,31 @@ __xfs_btree_check_lblock(
 
 	if (crc) {
 		if (!uuid_equal(&block->bb_u.l.bb_uuid, &mp->m_sb.sb_meta_uuid))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (block->bb_u.l.bb_blkno !=
 		    cpu_to_be64(bp ? bp->b_bn : XFS_BUF_DADDR_NULL))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (block->bb_u.l.bb_pad != cpu_to_be32(0))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 
 	if (be32_to_cpu(block->bb_magic) != xfs_btree_magic(crc, btnum))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (be16_to_cpu(block->bb_level) != level)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (be16_to_cpu(block->bb_numrecs) >
 	    cur->bc_ops->get_maxrecs(cur, level))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (block->bb_u.l.bb_leftsib != cpu_to_be64(NULLFSBLOCK) &&
 	    !xfs_btree_check_lptr(cur, be64_to_cpu(block->bb_u.l.bb_leftsib),
 			level + 1))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (block->bb_u.l.bb_rightsib != cpu_to_be64(NULLFSBLOCK) &&
 	    !xfs_btree_check_lptr(cur, be64_to_cpu(block->bb_u.l.bb_rightsib),
 			level + 1))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 /* Check a long btree block header. */
@@ -138,29 +138,29 @@ __xfs_btree_check_sblock(
 
 	if (crc) {
 		if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (block->bb_u.s.bb_blkno !=
 		    cpu_to_be64(bp ? bp->b_bn : XFS_BUF_DADDR_NULL))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 
 	if (be32_to_cpu(block->bb_magic) != xfs_btree_magic(crc, btnum))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (be16_to_cpu(block->bb_level) != level)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (be16_to_cpu(block->bb_numrecs) >
 	    cur->bc_ops->get_maxrecs(cur, level))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (block->bb_u.s.bb_leftsib != cpu_to_be32(NULLAGBLOCK) &&
 	    !xfs_btree_check_sptr(cur, be32_to_cpu(block->bb_u.s.bb_leftsib),
 			level + 1))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (block->bb_u.s.bb_rightsib != cpu_to_be32(NULLAGBLOCK) &&
 	    !xfs_btree_check_sptr(cur, be32_to_cpu(block->bb_u.s.bb_rightsib),
 			level + 1))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 /* Check a short btree block header. */
@@ -4444,15 +4444,15 @@ xfs_btree_lblock_v5hdr_verify(
 	struct xfs_btree_block	*block = XFS_BUF_TO_BLOCK(bp);
 
 	if (!xfs_sb_version_hascrc(&mp->m_sb))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (!uuid_equal(&block->bb_u.l.bb_uuid, &mp->m_sb.sb_meta_uuid))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (block->bb_u.l.bb_blkno != cpu_to_be64(bp->b_bn))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (owner != XFS_RMAP_OWN_UNKNOWN &&
 	    be64_to_cpu(block->bb_u.l.bb_owner) != owner)
-		return __this_address;
-	return NULL;
+		return XFS_CORRUPTED_RETURN(vc);
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 /* Verify a long-format btree block. */
@@ -4467,17 +4467,17 @@ xfs_btree_lblock_verify(
 
 	/* numrecs verification */
 	if (be16_to_cpu(block->bb_numrecs) > max_recs)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* sibling pointer verification */
 	if (block->bb_u.l.bb_leftsib != cpu_to_be64(NULLFSBLOCK) &&
 	    !xfs_verify_fsbno(mp, be64_to_cpu(block->bb_u.l.bb_leftsib)))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (block->bb_u.l.bb_rightsib != cpu_to_be64(NULLFSBLOCK) &&
 	    !xfs_verify_fsbno(mp, be64_to_cpu(block->bb_u.l.bb_rightsib)))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 /**
@@ -4498,14 +4498,14 @@ xfs_btree_sblock_v5hdr_verify(
 	struct xfs_perag	*pag = bp->b_pag;
 
 	if (!xfs_sb_version_hascrc(&mp->m_sb))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (!uuid_equal(&block->bb_u.s.bb_uuid, &mp->m_sb.sb_meta_uuid))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (block->bb_u.s.bb_blkno != cpu_to_be64(bp->b_bn))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (pag && be32_to_cpu(block->bb_u.s.bb_owner) != pag->pag_agno)
-		return __this_address;
-	return NULL;
+		return XFS_CORRUPTED_RETURN(vc);
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 /**
@@ -4526,18 +4526,18 @@ xfs_btree_sblock_verify(
 
 	/* numrecs verification */
 	if (be16_to_cpu(block->bb_numrecs) > max_recs)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* sibling pointer verification */
 	agno = xfs_daddr_to_agno(mp, XFS_BUF_ADDR(bp));
 	if (block->bb_u.s.bb_leftsib != cpu_to_be32(NULLAGBLOCK) &&
 	    !xfs_verify_agbno(mp, agno, be32_to_cpu(block->bb_u.s.bb_leftsib)))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (block->bb_u.s.bb_rightsib != cpu_to_be32(NULLAGBLOCK) &&
 	    !xfs_verify_agbno(mp, agno, be32_to_cpu(block->bb_u.s.bb_rightsib)))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 /*
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index eb19d6aa85ca..f7510bf5f505 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -134,24 +134,24 @@ xfs_da3_node_verify(
 		struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
 
 		if (ichdr.magic != XFS_DA3_NODE_MAGIC)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 
 		if (!uuid_equal(&hdr3->info.uuid, &mp->m_sb.sb_meta_uuid))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (be64_to_cpu(hdr3->info.blkno) != bp->b_bn)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->info.lsn)))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	} else {
 		if (ichdr.magic != XFS_DA_NODE_MAGIC)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 	if (ichdr.level == 0)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (ichdr.level > XFS_DA_NODE_MAXDEPTH)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (ichdr.count == 0)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/*
 	 * we don't know if the node is for and attribute or directory tree,
@@ -159,11 +159,11 @@ xfs_da3_node_verify(
 	 */
 	if (ichdr.count > mp->m_dir_geo->node_ents &&
 	    ichdr.count > mp->m_attr_geo->node_ents)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* XXX: hash order check? */
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 static void
@@ -255,7 +255,7 @@ xfs_da3_node_verify_struct(
 		bp->b_ops = &xfs_dir3_leafn_buf_ops;
 		return bp->b_ops->verify_struct(vc, bp);
 	default:
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	}
 }
 
diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
index 53cc0e151a75..12ae8c4285b2 100644
--- a/fs/xfs/libxfs/xfs_dir2_block.c
+++ b/fs/xfs/libxfs/xfs_dir2_block.c
@@ -56,16 +56,16 @@ xfs_dir3_block_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb)) {
 		if (hdr3->magic != cpu_to_be32(XFS_DIR3_BLOCK_MAGIC))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (be64_to_cpu(hdr3->blkno) != bp->b_bn)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->lsn)))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	} else {
 		if (hdr3->magic != cpu_to_be32(XFS_DIR2_BLOCK_MAGIC))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 	return __xfs_dir3_data_check(vc, NULL, bp);
 }
diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
index 661615f253b2..574fe8ba7144 100644
--- a/fs/xfs/libxfs/xfs_dir2_data.c
+++ b/fs/xfs/libxfs/xfs_dir2_data.c
@@ -74,7 +74,7 @@ __xfs_dir3_data_check(
 	 */
 	if ((dp && !S_ISDIR(VFS_I(dp)->i_mode)) ||
 	    ops != xfs_dir_get_ops(mp, NULL))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	hdr = bp->b_addr;
 	p = (char *)ops->data_entry_p(hdr);
@@ -94,17 +94,17 @@ __xfs_dir3_data_check(
 		 */
 		if (be32_to_cpu(btp->count) >=
 		    ((char *)btp - p) / sizeof(struct xfs_dir2_leaf_entry))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		break;
 	case cpu_to_be32(XFS_DIR3_DATA_MAGIC):
 	case cpu_to_be32(XFS_DIR2_DATA_MAGIC):
 		break;
 	default:
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	}
 	endp = xfs_dir3_data_endp(geo, hdr);
 	if (!endp)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/*
 	 * Account for zero bestfree entries.
@@ -113,24 +113,24 @@ __xfs_dir3_data_check(
 	count = lastfree = freeseen = 0;
 	if (!bf[0].length) {
 		if (bf[0].offset)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		freeseen |= 1 << 0;
 	}
 	if (!bf[1].length) {
 		if (bf[1].offset)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		freeseen |= 1 << 1;
 	}
 	if (!bf[2].length) {
 		if (bf[2].offset)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		freeseen |= 1 << 2;
 	}
 
 	if (be16_to_cpu(bf[0].length) < be16_to_cpu(bf[1].length))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (be16_to_cpu(bf[1].length) < be16_to_cpu(bf[2].length))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	/*
 	 * Loop over the data/unused entries.
 	 */
@@ -145,24 +145,24 @@ __xfs_dir3_data_check(
 			xfs_failaddr_t	fa;
 
 			if (lastfree != 0)
-				return __this_address;
+				return XFS_CORRUPTED_RETURN(vc);
 			if (endp < p + be16_to_cpu(dup->length))
-				return __this_address;
+				return XFS_CORRUPTED_RETURN(vc);
 			if (be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)) !=
 			    (char *)dup - (char *)hdr)
-				return __this_address;
+				return XFS_CORRUPTED_RETURN(vc);
 			fa = xfs_dir2_data_freefind_verify(vc, hdr, bf, dup, &dfp);
 			if (fa)
 				return fa;
 			if (dfp) {
 				i = (int)(dfp - bf);
 				if ((freeseen & (1 << i)) != 0)
-					return __this_address;
+					return XFS_CORRUPTED_RETURN(vc);
 				freeseen |= 1 << i;
 			} else {
 				if (be16_to_cpu(dup->length) >
 				    be16_to_cpu(bf[2].length))
-					return __this_address;
+					return XFS_CORRUPTED_RETURN(vc);
 			}
 			p += be16_to_cpu(dup->length);
 			lastfree = 1;
@@ -176,16 +176,16 @@ __xfs_dir3_data_check(
 		 */
 		dep = (xfs_dir2_data_entry_t *)p;
 		if (dep->namelen == 0)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (xfs_dir_ino_validate(mp, be64_to_cpu(dep->inumber)))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (endp < p + ops->data_entsize(dep->namelen))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (be16_to_cpu(*ops->data_entry_tag_p(dep)) !=
 		    (char *)dep - (char *)hdr)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (ops->data_get_ftype(dep) >= XFS_DIR3_FT_MAX)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		count++;
 		lastfree = 0;
 		if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
@@ -202,7 +202,7 @@ __xfs_dir3_data_check(
 					break;
 			}
 			if (i >= be32_to_cpu(btp->count))
-				return __this_address;
+				return XFS_CORRUPTED_RETURN(vc);
 		}
 		p += ops->data_entsize(dep->namelen);
 	}
@@ -210,7 +210,7 @@ __xfs_dir3_data_check(
 	 * Need to have seen all the entries and all the bestfree slots.
 	 */
 	if (freeseen != 7)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
 	    hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) {
 		for (i = stale = 0; i < be32_to_cpu(btp->count); i++) {
@@ -219,14 +219,14 @@ __xfs_dir3_data_check(
 				stale++;
 			if (i > 0 && be32_to_cpu(lep[i].hashval) <
 				     be32_to_cpu(lep[i - 1].hashval))
-				return __this_address;
+				return XFS_CORRUPTED_RETURN(vc);
 		}
 		if (count != be32_to_cpu(btp->count) - be32_to_cpu(btp->stale))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (stale != be32_to_cpu(btp->stale))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 #ifdef DEBUG
@@ -258,16 +258,16 @@ xfs_dir3_data_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb)) {
 		if (hdr3->magic != cpu_to_be32(XFS_DIR3_DATA_MAGIC))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (be64_to_cpu(hdr3->blkno) != bp->b_bn)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->lsn)))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	} else {
 		if (hdr3->magic != cpu_to_be32(XFS_DIR2_DATA_MAGIC))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 	return __xfs_dir3_data_check(vc, NULL, bp);
 }
@@ -413,36 +413,36 @@ xfs_dir2_data_freefind_verify(
 	for (dfp = &bf[0]; dfp < &bf[XFS_DIR2_DATA_FD_COUNT]; dfp++) {
 		if (!dfp->offset) {
 			if (dfp->length)
-				return __this_address;
+				return XFS_CORRUPTED_RETURN(vc);
 			seenzero = true;
 			continue;
 		}
 		if (seenzero)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (be16_to_cpu(dfp->offset) == off) {
 			matched = true;
 			if (dfp->length != dup->length)
-				return __this_address;
+				return XFS_CORRUPTED_RETURN(vc);
 		} else if (be16_to_cpu(dfp->offset) > off) {
 			if (off + be16_to_cpu(dup->length) >
 					be16_to_cpu(dfp->offset))
-				return __this_address;
+				return XFS_CORRUPTED_RETURN(vc);
 		} else {
 			if (be16_to_cpu(dfp->offset) +
 					be16_to_cpu(dfp->length) > off)
-				return __this_address;
+				return XFS_CORRUPTED_RETURN(vc);
 		}
 		if (!matched &&
 		    be16_to_cpu(dfp->length) < be16_to_cpu(dup->length))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (dfp > &bf[0] &&
 		    be16_to_cpu(dfp[-1].length) < be16_to_cpu(dfp[0].length))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 
 	/* Looks ok so far; now try to match up with a bestfree entry. */
 	*bf_ent = xfs_dir2_data_freefind(hdr, bf, dup);
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 /*
@@ -975,17 +975,17 @@ xfs_dir2_data_check_free(
 	    hdr->magic != cpu_to_be32(XFS_DIR3_DATA_MAGIC) &&
 	    hdr->magic != cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) &&
 	    hdr->magic != cpu_to_be32(XFS_DIR3_BLOCK_MAGIC))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (be16_to_cpu(dup->freetag) != XFS_DIR2_DATA_FREE_TAG)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (offset < (char *)dup - (char *)hdr)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (offset + len > (char *)dup + be16_to_cpu(dup->length) - (char *)hdr)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if ((char *)dup - (char *)hdr !=
 			be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)))
-		return __this_address;
-	return NULL;
+		return XFS_CORRUPTED_RETURN(vc);
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 /* Sanity-check a new bestfree entry. */
@@ -997,12 +997,12 @@ xfs_dir2_data_check_new_free(
 	struct xfs_dir2_data_unused	*newdup)
 {
 	if (dfp == NULL)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (dfp->length != newdup->length)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (be16_to_cpu(dfp->offset) != (char *)newdup - (char *)hdr)
-		return __this_address;
-	return NULL;
+		return XFS_CORRUPTED_RETURN(vc);
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 /*
diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
index a225dcdc11c8..4488b898ca97 100644
--- a/fs/xfs/libxfs/xfs_dir2_leaf.c
+++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
@@ -52,9 +52,9 @@ xfs_dir3_leaf1_check(
 	if (leafhdr.magic == XFS_DIR3_LEAF1_MAGIC) {
 		struct xfs_dir3_leaf_hdr *leaf3 = bp->b_addr;
 		if (be64_to_cpu(leaf3->info.blkno) != bp->b_bn)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	} else if (leafhdr.magic != XFS_DIR2_LEAF1_MAGIC)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	return xfs_dir3_leaf_check_int(vc, dp->i_mount, dp, &leafhdr, leaf);
 }
@@ -115,27 +115,27 @@ xfs_dir3_leaf_check_int(
 	 * We can deduce a value for that from di_size.
 	 */
 	if (hdr->count > ops->leaf_max_ents(geo))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* Leaves and bests don't overlap in leaf format. */
 	if ((hdr->magic == XFS_DIR2_LEAF1_MAGIC ||
 	     hdr->magic == XFS_DIR3_LEAF1_MAGIC) &&
 	    (char *)&ents[hdr->count] > (char *)xfs_dir2_leaf_bests_p(ltp))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* Check hash value order, count stale entries.  */
 	for (i = stale = 0; i < hdr->count; i++) {
 		if (i + 1 < hdr->count) {
 			if (be32_to_cpu(ents[i].hashval) >
 					be32_to_cpu(ents[i + 1].hashval))
-				return __this_address;
+				return XFS_CORRUPTED_RETURN(vc);
 		}
 		if (ents[i].address == cpu_to_be32(XFS_DIR2_NULL_DATAPTR))
 			stale++;
 	}
 	if (hdr->stale != stale)
-		return __this_address;
-	return NULL;
+		return XFS_CORRUPTED_RETURN(vc);
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 /*
@@ -162,16 +162,16 @@ xfs_dir3_leaf_verify(
 							 : XFS_DIR3_LEAFN_MAGIC;
 
 		if (leaf3->info.hdr.magic != cpu_to_be16(magic3))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (!uuid_equal(&leaf3->info.uuid, &mp->m_sb.sb_meta_uuid))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (be64_to_cpu(leaf3->info.blkno) != bp->b_bn)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (!xfs_log_check_lsn(mp, be64_to_cpu(leaf3->info.lsn)))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	} else {
 		if (leaf->hdr.info.magic != cpu_to_be16(magic))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 
 	return xfs_dir3_leaf_check_int(vc, mp, NULL, NULL, leaf);
diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index 8174e469b14f..1920caa65895 100644
--- a/fs/xfs/libxfs/xfs_dir2_node.c
+++ b/fs/xfs/libxfs/xfs_dir2_node.c
@@ -55,9 +55,9 @@ xfs_dir3_leafn_check(
 	if (leafhdr.magic == XFS_DIR3_LEAFN_MAGIC) {
 		struct xfs_dir3_leaf_hdr *leaf3 = bp->b_addr;
 		if (be64_to_cpu(leaf3->info.blkno) != bp->b_bn)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	} else if (leafhdr.magic != XFS_DIR2_LEAFN_MAGIC)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	return xfs_dir3_leaf_check_int(vc, dp->i_mount, dp, &leafhdr, leaf);
 }
@@ -94,21 +94,21 @@ xfs_dir3_free_verify(
 		struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
 
 		if (hdr3->magic != cpu_to_be32(XFS_DIR3_FREE_MAGIC))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (!uuid_equal(&hdr3->uuid, &mp->m_sb.sb_meta_uuid))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (be64_to_cpu(hdr3->blkno) != bp->b_bn)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->lsn)))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	} else {
 		if (hdr->magic != cpu_to_be32(XFS_DIR2_FREE_MAGIC))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 
 	/* XXX: should bounds check the xfs_dir3_icfree_hdr here */
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 static void
@@ -181,22 +181,22 @@ xfs_dir3_free_header_check(
 		struct xfs_dir3_free_hdr *hdr3 = bp->b_addr;
 
 		if (be32_to_cpu(hdr3->firstdb) != firstdb)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (be32_to_cpu(hdr3->nvalid) > maxbests)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (be32_to_cpu(hdr3->nvalid) < be32_to_cpu(hdr3->nused))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	} else {
 		struct xfs_dir2_free_hdr *hdr = bp->b_addr;
 
 		if (be32_to_cpu(hdr->firstdb) != firstdb)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (be32_to_cpu(hdr->nvalid) > maxbests)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (be32_to_cpu(hdr->nvalid) < be32_to_cpu(hdr->nused))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 static int
diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
index ea47b403c1c1..659243991b61 100644
--- a/fs/xfs/libxfs/xfs_dir2_sf.c
+++ b/fs/xfs/libxfs/xfs_dir2_sf.c
@@ -652,7 +652,7 @@ xfs_dir2_sf_verify(
 	 */
 	if (size <= offsetof(struct xfs_dir2_sf_hdr, parent) ||
 	    size < xfs_dir2_sf_hdr_size(sfp->i8count))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	endp = (char *)sfp + size;
 
@@ -661,7 +661,7 @@ xfs_dir2_sf_verify(
 	i8count = ino > XFS_DIR2_MAX_SHORT_INUM;
 	error = xfs_dir_ino_validate(mp, ino);
 	if (error)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	offset = dops->data_first_offset;
 
 	/* Check all reported entries */
@@ -673,11 +673,11 @@ xfs_dir2_sf_verify(
 		 * within the data buffer.
 		 */
 		if (((char *)sfep + sizeof(*sfep)) >= endp)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 
 		/* Don't allow names with known bad length. */
 		if (sfep->namelen == 0)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 
 		/*
 		 * Check that the variable-length part of the structure is
@@ -686,23 +686,23 @@ xfs_dir2_sf_verify(
 		 */
 		next_sfep = dops->sf_nextentry(sfp, sfep);
 		if (endp < (char *)next_sfep)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 
 		/* Check that the offsets always increase. */
 		if (xfs_dir2_sf_get_offset(sfep) < offset)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 
 		/* Check the inode number. */
 		ino = dops->sf_get_ino(sfp, sfep);
 		i8count += ino > XFS_DIR2_MAX_SHORT_INUM;
 		error = xfs_dir_ino_validate(mp, ino);
 		if (error)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 
 		/* Check the file type. */
 		filetype = dops->sf_get_ftype(sfep);
 		if (filetype >= XFS_DIR3_FT_MAX)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 
 		offset = xfs_dir2_sf_get_offset(sfep) +
 				dops->data_entsize(sfep->namelen);
@@ -710,16 +710,16 @@ xfs_dir2_sf_verify(
 		sfep = next_sfep;
 	}
 	if (i8count != sfp->i8count)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if ((void *)sfep != (void *)endp)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* Make sure this whole thing ought to be in local format. */
 	if (offset + (sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) +
 	    (uint)sizeof(xfs_dir2_block_tail_t) > mp->m_dir_geo->blksize)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 /*
diff --git a/fs/xfs/libxfs/xfs_dquot_buf.c b/fs/xfs/libxfs/xfs_dquot_buf.c
index bbc63656a6d2..0b7c76c5f3e1 100644
--- a/fs/xfs/libxfs/xfs_dquot_buf.c
+++ b/fs/xfs/libxfs/xfs_dquot_buf.c
@@ -59,39 +59,39 @@ xfs_dquot_verify(
 	 * any quota information. Just don't complain about bad dquot blks.
 	 */
 	if (ddq->d_magic != cpu_to_be16(XFS_DQUOT_MAGIC))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (ddq->d_version != XFS_DQUOT_VERSION)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (type && ddq->d_flags != type)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (ddq->d_flags != XFS_DQ_USER &&
 	    ddq->d_flags != XFS_DQ_PROJ &&
 	    ddq->d_flags != XFS_DQ_GROUP)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (id != -1 && id != be32_to_cpu(ddq->d_id))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (!ddq->d_id)
-		return NULL;
+		return XFS_VERIFIED_RETURN(vc);
 
 	if (ddq->d_blk_softlimit &&
 	    be64_to_cpu(ddq->d_bcount) > be64_to_cpu(ddq->d_blk_softlimit) &&
 	    !ddq->d_btimer)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (ddq->d_ino_softlimit &&
 	    be64_to_cpu(ddq->d_icount) > be64_to_cpu(ddq->d_ino_softlimit) &&
 	    !ddq->d_itimer)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (ddq->d_rtb_softlimit &&
 	    be64_to_cpu(ddq->d_rtbcount) > be64_to_cpu(ddq->d_rtb_softlimit) &&
 	    !ddq->d_rtbtimer)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 xfs_failaddr_t
@@ -104,7 +104,7 @@ xfs_dqblk_verify(
 {
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	    !uuid_equal(&dqb->dd_uuid, &mp->m_sb.sb_meta_uuid))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	return xfs_dquot_verify(vc, mp, &dqb->dd_diskdq, id, type);
 }
@@ -223,7 +223,7 @@ xfs_dquot_buf_verify(
 		}
 	}
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 static xfs_failaddr_t
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index a204112c8c90..f24abdc20d3b 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -2506,28 +2506,28 @@ xfs_agi_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb)) {
 		if (!uuid_equal(&agi->agi_uuid, &mp->m_sb.sb_meta_uuid))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (!xfs_log_check_lsn(mp,
 				be64_to_cpu(XFS_BUF_TO_AGI(bp)->agi_lsn)))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 
 	/*
 	 * Validate the magic number of the agi block.
 	 */
 	if (agi->agi_magicnum != cpu_to_be32(XFS_AGI_MAGIC))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (!XFS_AGI_GOOD_VERSION(be32_to_cpu(agi->agi_versionnum)))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (be32_to_cpu(agi->agi_level) < 1 ||
 	    be32_to_cpu(agi->agi_level) > XFS_BTREE_MAXLEVELS)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (xfs_sb_version_hasfinobt(&mp->m_sb) &&
 	    (be32_to_cpu(agi->agi_free_level) < 1 ||
 	     be32_to_cpu(agi->agi_free_level) > XFS_BTREE_MAXLEVELS))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/*
 	 * during growfs operations, the perag is not fully initialised,
@@ -2536,16 +2536,16 @@ xfs_agi_verify(
 	 * so we can detect and avoid this problem.
 	 */
 	if (bp->b_pag && be32_to_cpu(agi->agi_seqno) != bp->b_pag->pag_agno)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	for (i = 0; i < XFS_AGI_UNLINKED_BUCKETS; i++) {
 		if (agi->agi_unlinked[i] == cpu_to_be32(NULLAGINO))
 			continue;
 		if (!xfs_verify_ino(mp, be32_to_cpu(agi->agi_unlinked[i])))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 static void
diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
index 02d7dd5c265c..a3902165aac5 100644
--- a/fs/xfs/libxfs/xfs_ialloc_btree.c
+++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
@@ -285,13 +285,13 @@ xfs_inobt_verify(
 	case cpu_to_be32(XFS_FIBT_MAGIC):
 		break;
 	default:
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	}
 
 	/* level verification */
 	level = be16_to_cpu(block->bb_level);
 	if (level >= mp->m_in_maxlevels)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	return xfs_btree_sblock_verify(vc, bp, mp->m_inobt_mxr[level != 0]);
 }
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index d7a8199d5f36..a04f75f2885f 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -394,30 +394,30 @@ xfs_dinode_verify_fork(
 		 */
 		if (whichfork == XFS_DATA_FORK) {
 			if (S_ISREG(be16_to_cpu(dip->di_mode)))
-				return __this_address;
+				return XFS_CORRUPTED_RETURN(vc);
 			if (be64_to_cpu(dip->di_size) >
 					XFS_DFORK_SIZE(dip, mp, whichfork))
-				return __this_address;
+				return XFS_CORRUPTED_RETURN(vc);
 		}
 		if (di_nextents)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		break;
 	case XFS_DINODE_FMT_EXTENTS:
 		if (di_nextents > XFS_DFORK_MAXEXT(dip, mp, whichfork))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		break;
 	case XFS_DINODE_FMT_BTREE:
 		if (whichfork == XFS_ATTR_FORK) {
 			if (di_nextents > MAXAEXTNUM)
-				return __this_address;
+				return XFS_CORRUPTED_RETURN(vc);
 		} else if (di_nextents > MAXEXTNUM) {
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		}
 		break;
 	default:
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	}
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 static xfs_failaddr_t
@@ -427,23 +427,23 @@ xfs_dinode_verify_forkoff(
 	struct xfs_mount	*mp)
 {
 	if (!XFS_DFORK_Q(dip))
-		return NULL;
+		return XFS_VERIFIED_RETURN(vc);
 
 	switch (dip->di_format)  {
 	case XFS_DINODE_FMT_DEV:
 		if (dip->di_forkoff != (roundup(sizeof(xfs_dev_t), 8) >> 3))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		break;
 	case XFS_DINODE_FMT_LOCAL:	/* fall through ... */
 	case XFS_DINODE_FMT_EXTENTS:    /* fall through ... */
 	case XFS_DINODE_FMT_BTREE:
 		if (dip->di_forkoff >= (XFS_LITINO(mp, dip->di_version) >> 3))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		break;
 	default:
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	}
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 xfs_failaddr_t
@@ -460,47 +460,47 @@ xfs_dinode_verify(
 	uint64_t		di_size;
 
 	if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* Verify v3 integrity information first */
 	if (dip->di_version >= 3) {
 		if (!xfs_sb_version_hascrc(&mp->m_sb))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (!xfs_verify_cksum(vc, (char *)dip, mp->m_sb.sb_inodesize,
 				      XFS_DINODE_CRC_OFF))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (be64_to_cpu(dip->di_ino) != ino)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		if (!uuid_equal(&dip->di_uuid, &mp->m_sb.sb_meta_uuid))
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 
 	/* don't allow invalid i_size */
 	di_size = be64_to_cpu(dip->di_size);
 	if (di_size & (1ULL << 63))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	mode = be16_to_cpu(dip->di_mode);
 	if (mode && xfs_mode_to_ftype(mode) == XFS_DIR3_FT_UNKNOWN)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* No zero-length symlinks/dirs. */
 	if ((S_ISLNK(mode) || S_ISDIR(mode)) && di_size == 0)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* Fork checks carried over from xfs_iformat_fork */
 	if (mode &&
 	    be32_to_cpu(dip->di_nextents) + be16_to_cpu(dip->di_anextents) >
 			be64_to_cpu(dip->di_nblocks))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (mode && XFS_DFORK_BOFF(dip) > mp->m_sb.sb_inodesize)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	flags = be16_to_cpu(dip->di_flags);
 
 	if (mode && (flags & XFS_DIFLAG_REALTIME) && !mp->m_rtdev_targp)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* check for illegal values of forkoff */
 	fa = xfs_dinode_verify_forkoff(vc, dip, mp);
@@ -514,7 +514,7 @@ xfs_dinode_verify(
 	case S_IFBLK:
 	case S_IFSOCK:
 		if (dip->di_format != XFS_DINODE_FMT_DEV)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		break;
 	case S_IFREG:
 	case S_IFLNK:
@@ -527,7 +527,7 @@ xfs_dinode_verify(
 		/* Uninitialized inode ok. */
 		break;
 	default:
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	}
 
 	if (XFS_DFORK_Q(dip)) {
@@ -546,10 +546,10 @@ xfs_dinode_verify(
 		case XFS_DINODE_FMT_EXTENTS:
 			break;
 		default:
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 		}
 		if (dip->di_anextents)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	}
 
 	/* extent size hint validation */
@@ -560,26 +560,26 @@ xfs_dinode_verify(
 
 	/* only version 3 or greater inodes are extensively verified here */
 	if (dip->di_version < 3)
-		return NULL;
+		return XFS_VERIFIED_RETURN(vc);
 
 	flags2 = be64_to_cpu(dip->di_flags2);
 
 	/* don't allow reflink/cowextsize if we don't have reflink */
 	if ((flags2 & (XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE)) &&
 	     !xfs_sb_version_hasreflink(&mp->m_sb))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* only regular files get reflink */
 	if ((flags2 & XFS_DIFLAG2_REFLINK) && (mode & S_IFMT) != S_IFREG)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* don't let reflink and realtime mix */
 	if ((flags2 & XFS_DIFLAG2_REFLINK) && (flags & XFS_DIFLAG_REALTIME))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* don't let reflink and dax mix */
 	if ((flags2 & XFS_DIFLAG2_REFLINK) && (flags2 & XFS_DIFLAG2_DAX))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* COW extent size hint validation */
 	fa = xfs_inode_validate_cowextsize(vc, mp, be32_to_cpu(dip->di_cowextsize),
@@ -587,7 +587,7 @@ xfs_dinode_verify(
 	if (fa)
 		return fa;
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 void
@@ -759,31 +759,31 @@ xfs_inode_validate_extsize(
 		blocksize_bytes = mp->m_sb.sb_blocksize;
 
 	if ((hint_flag || inherit_flag) && !(S_ISDIR(mode) || S_ISREG(mode)))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (hint_flag && !S_ISREG(mode))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (inherit_flag && !S_ISDIR(mode))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if ((hint_flag || inherit_flag) && extsize == 0)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* free inodes get flags set to zero but extsize remains */
 	if (mode && !(hint_flag || inherit_flag) && extsize != 0)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (extsize_bytes % blocksize_bytes)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (extsize > MAXEXTLEN)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (!rt_flag && extsize > mp->m_sb.sb_agblocks / 2)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 /*
@@ -810,29 +810,29 @@ xfs_inode_validate_cowextsize(
 	cowextsize_bytes = XFS_FSB_TO_B(mp, cowextsize);
 
 	if (hint_flag && !xfs_sb_version_hasreflink(&mp->m_sb))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (hint_flag && !(S_ISDIR(mode) || S_ISREG(mode)))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (hint_flag && cowextsize == 0)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* free inodes get flags set to zero but cowextsize remains */
 	if (mode && !hint_flag && cowextsize != 0)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (hint_flag && rt_flag)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (cowextsize_bytes % mp->m_sb.sb_blocksize)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (cowextsize > MAXEXTLEN)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (cowextsize > mp->m_sb.sb_agblocks / 2)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index 49dd81b0728f..78ee502d856e 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -708,7 +708,7 @@ xfs_ifork_verify_data(
 {
 	/* Non-local data fork, we're done. */
 	if (ip->i_d.di_format != XFS_DINODE_FMT_LOCAL)
-		return NULL;
+		return XFS_VERIFIED_RETURN(vc);
 
 	/* Check the inline data fork if there is one. */
 	switch (VFS_I(ip)->i_mode & S_IFMT) {
@@ -717,7 +717,7 @@ xfs_ifork_verify_data(
 	case S_IFLNK:
 		return ops->verify_symlink(vc, ip);
 	default:
-		return NULL;
+		return XFS_VERIFIED_RETURN(vc);
 	}
 }
 
@@ -730,8 +730,8 @@ xfs_ifork_verify_attr(
 {
 	/* There has to be an attr fork allocated if aformat is local. */
 	if (ip->i_d.di_aformat != XFS_DINODE_FMT_LOCAL)
-		return NULL;
+		return XFS_VERIFIED_RETURN(vc);
 	if (!XFS_IFORK_PTR(ip, XFS_ATTR_FORK))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	return ops->verify_attr(vc, ip);
 }
diff --git a/fs/xfs/libxfs/xfs_refcount_btree.c b/fs/xfs/libxfs/xfs_refcount_btree.c
index 125b536538ec..409ae8c08380 100644
--- a/fs/xfs/libxfs/xfs_refcount_btree.c
+++ b/fs/xfs/libxfs/xfs_refcount_btree.c
@@ -213,10 +213,10 @@ xfs_refcountbt_verify(
 	unsigned int		level;
 
 	if (block->bb_magic != cpu_to_be32(XFS_REFC_CRC_MAGIC))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (!xfs_sb_version_hasreflink(&mp->m_sb))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
 	if (fa)
 		return fa;
@@ -224,9 +224,9 @@ xfs_refcountbt_verify(
 	level = be16_to_cpu(block->bb_level);
 	if (pag && pag->pagf_init) {
 		if (level >= pag->pagf_refcount_level)
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	} else if (level >= mp->m_refc_maxlevels)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	return xfs_btree_sblock_verify(vc, bp, mp->m_refc_mxr[level != 0]);
 }
diff --git a/fs/xfs/libxfs/xfs_rmap_btree.c b/fs/xfs/libxfs/xfs_rmap_btree.c
index f8828854ca2f..e9265c8c1cea 100644
--- a/fs/xfs/libxfs/xfs_rmap_btree.c
+++ b/fs/xfs/libxfs/xfs_rmap_btree.c
@@ -312,10 +312,10 @@ xfs_rmapbt_verify(
 	 * in this case.
 	 */
 	if (block->bb_magic != cpu_to_be32(XFS_RMAP_CRC_MAGIC))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
 	if (fa)
 		return fa;
@@ -323,9 +323,9 @@ xfs_rmapbt_verify(
 	level = be16_to_cpu(block->bb_level);
 	if (pag && pag->pagf_init) {
 		if (level >= pag->pagf_levels[XFS_BTNUM_RMAPi])
-			return __this_address;
+			return XFS_CORRUPTED_RETURN(vc);
 	} else if (level >= mp->m_rmap_maxlevels)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	return xfs_btree_sblock_verify(vc, bp, mp->m_rmap_mxr[level != 0]);
 }
diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c
index 0405f17aae6f..9141a1635dac 100644
--- a/fs/xfs/libxfs/xfs_symlink_remote.c
+++ b/fs/xfs/libxfs/xfs_symlink_remote.c
@@ -95,22 +95,22 @@ xfs_symlink_verify(
 	struct xfs_dsymlink_hdr	*dsl = bp->b_addr;
 
 	if (!xfs_sb_version_hascrc(&mp->m_sb))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (dsl->sl_magic != cpu_to_be32(XFS_SYMLINK_MAGIC))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (!uuid_equal(&dsl->sl_uuid, &mp->m_sb.sb_meta_uuid))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (bp->b_bn != be64_to_cpu(dsl->sl_blkno))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (be32_to_cpu(dsl->sl_offset) +
 				be32_to_cpu(dsl->sl_bytes) >= XFS_SYMLINK_MAXLEN)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (dsl->sl_owner == 0)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 	if (!xfs_log_check_lsn(mp, be64_to_cpu(dsl->sl_lsn)))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
-	return NULL;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 static void
@@ -221,18 +221,18 @@ xfs_symlink_shortform_verify(
 
 	/* Zero length symlinks can exist while we're deleting a remote one. */
 	if (size == 0)
-		return NULL;
+		return XFS_VERIFIED_RETURN(vc);
 
 	/* No negative sizes or overly long symlink targets. */
 	if (size < 0 || size > XFS_SYMLINK_MAXLEN)
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* No NULLs in the target either. */
 	if (memchr(sfp, 0, size - 1))
-		return __this_address;
+		return XFS_CORRUPTED_RETURN(vc);
 
 	/* We /did/ null-terminate the buffer, right? */
 	if (*endp != 0)
-		return __this_address;
-	return NULL;
+		return XFS_CORRUPTED_RETURN(vc);
+	return XFS_VERIFIED_RETURN(vc);
 }
diff --git a/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h
index 6c27103522a9..d39c7e28ad00 100644
--- a/fs/xfs/libxfs/xfs_types.h
+++ b/fs/xfs/libxfs/xfs_types.h
@@ -45,6 +45,9 @@ struct xfs_vc {
 	xfs_failaddr_t	fa;
 };
 
+#define XFS_CORRUPTED_RETURN(vc) ({(vc)->fa = __this_address; __this_address;})
+#define XFS_VERIFIED_RETURN(vc) ({(vc)->fa = NULL; NULL;})
+
 /*
  * Null values for the types.
  */
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 06/10] xfs: teach xfs_btree_[sl]block_verify_crc to populate verifier context
  2018-12-05 21:01 [PATCH RFC 0/10] xfs: add verifier context structure Eric Sandeen
                   ` (4 preceding siblings ...)
  2018-12-05 21:05 ` [PATCH 05/10] xfs: define new macros to set verifier context on return Eric Sandeen
@ 2018-12-05 21:06 ` Eric Sandeen
  2018-12-05 21:08 ` [PATCH 07/10] xfs: change all verifiers to return booleans Eric Sandeen
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Eric Sandeen @ 2018-12-05 21:06 UTC (permalink / raw)
  To: Eric Sandeen, linux-xfs

Rather than simply returning true/false, populate the verifier
context as well.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 fs/xfs/libxfs/xfs_btree.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index d4728f70fcc3..0b88cb04a719 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -297,11 +297,11 @@ xfs_btree_lblock_verify_crc(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb)) {
 		if (!xfs_log_check_lsn(mp, be64_to_cpu(block->bb_u.l.bb_lsn)))
-			return false;
+			return XFS_CORRUPTED_RETURN(vc);
 		return xfs_buf_verify_cksum(vc, bp, XFS_BTREE_LBLOCK_CRC_OFF);
 	}
 
-	return true;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 /*
@@ -336,11 +336,11 @@ xfs_btree_sblock_verify_crc(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb)) {
 		if (!xfs_log_check_lsn(mp, be64_to_cpu(block->bb_u.s.bb_lsn)))
-			return false;
+			return XFS_CORRUPTED_RETURN(vc);
 		return xfs_buf_verify_cksum(vc, bp, XFS_BTREE_SBLOCK_CRC_OFF);
 	}
 
-	return true;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 static int
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 07/10] xfs: change all verifiers to return booleans
  2018-12-05 21:01 [PATCH RFC 0/10] xfs: add verifier context structure Eric Sandeen
                   ` (5 preceding siblings ...)
  2018-12-05 21:06 ` [PATCH 06/10] xfs: teach xfs_btree_[sl]block_verify_crc to populate verifier context Eric Sandeen
@ 2018-12-05 21:08 ` Eric Sandeen
  2018-12-05 21:09 ` [PATCH 08/10] xfs: set failaddr into vc for checksum failures Eric Sandeen
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Eric Sandeen @ 2018-12-05 21:08 UTC (permalink / raw)
  To: Eric Sandeen, linux-xfs

Switch verifiers back to returning booleans (true for verified) to
be consistent with the crc checkers.  Failure address information is
now stored in the xfs verifier context vc->fa which is passed to
error handling functions such as xfs_verifier_error() on failure.

The actual switch to boolean return is done in the 
XFS_VERIFIED_RETURN/XFS_CORRUPTED_RETURN macros.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 fs/xfs/libxfs/xfs_alloc.c          | 29 +++++++----------
 fs/xfs/libxfs/xfs_alloc_btree.c    | 27 ++++++----------
 fs/xfs/libxfs/xfs_attr_leaf.c      | 16 ++++------
 fs/xfs/libxfs/xfs_attr_leaf.h      |  2 +-
 fs/xfs/libxfs/xfs_attr_remote.c    | 15 ++++-----
 fs/xfs/libxfs/xfs_bmap.c           |  8 ++---
 fs/xfs/libxfs/xfs_bmap.h           |  4 +--
 fs/xfs/libxfs/xfs_bmap_btree.c     | 22 ++++---------
 fs/xfs/libxfs/xfs_btree.c          | 34 ++++++++++----------
 fs/xfs/libxfs/xfs_btree.h          | 16 +++++-----
 fs/xfs/libxfs/xfs_da_btree.c       | 16 ++++------
 fs/xfs/libxfs/xfs_dir2_block.c     | 14 +++-----
 fs/xfs/libxfs/xfs_dir2_data.c      | 51 +++++++++++-------------------
 fs/xfs/libxfs/xfs_dir2_leaf.c      | 28 +++++++---------
 fs/xfs/libxfs/xfs_dir2_node.c      | 30 +++++++-----------
 fs/xfs/libxfs/xfs_dir2_priv.h      |  6 ++--
 fs/xfs/libxfs/xfs_dir2_sf.c        |  2 +-
 fs/xfs/libxfs/xfs_dquot_buf.c      | 18 +++++------
 fs/xfs/libxfs/xfs_ialloc.c         | 15 ++++-----
 fs/xfs/libxfs/xfs_ialloc_btree.c   | 22 ++++---------
 fs/xfs/libxfs/xfs_inode_buf.c      | 46 +++++++++++----------------
 fs/xfs/libxfs/xfs_inode_buf.h      |  6 ++--
 fs/xfs/libxfs/xfs_inode_fork.c     | 13 ++++----
 fs/xfs/libxfs/xfs_inode_fork.h     |  6 ++--
 fs/xfs/libxfs/xfs_quota_defs.h     |  4 +--
 fs/xfs/libxfs/xfs_refcount_btree.c | 22 ++++---------
 fs/xfs/libxfs/xfs_rmap_btree.c     | 22 ++++---------
 fs/xfs/libxfs/xfs_shared.h         |  2 +-
 fs/xfs/libxfs/xfs_symlink_remote.c | 16 ++++------
 fs/xfs/libxfs/xfs_types.h          |  4 +--
 fs/xfs/scrub/btree.c               | 23 ++++++++------
 fs/xfs/scrub/common.c              |  6 ++--
 fs/xfs/scrub/dabtree.c             |  2 +-
 fs/xfs/scrub/inode.c               | 12 +++----
 fs/xfs/xfs_buf.h                   |  2 +-
 fs/xfs/xfs_dquot.c                 |  6 ++--
 fs/xfs/xfs_inode.c                 | 11 +++----
 fs/xfs/xfs_log_recover.c           | 16 +++-------
 fs/xfs/xfs_qm.c                    |  4 +--
 39 files changed, 236 insertions(+), 362 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 36073ac260af..b9e3c69490eb 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -551,7 +551,7 @@ xfs_alloc_fixup_trees(
 	return 0;
 }
 
-static xfs_failaddr_t
+static bool
 xfs_agfl_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
@@ -599,7 +599,6 @@ xfs_agfl_read_verify(
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
-	xfs_failaddr_t	fa;
 
 	/*
 	 * There is no verification of non-crc AGFLs because mkfs does not
@@ -613,9 +612,8 @@ xfs_agfl_read_verify(
 	if (!xfs_buf_verify_cksum(vc, bp, XFS_AGFL_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_agfl_verify(vc, bp);
-		if (fa)
-			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		if (!xfs_agfl_verify(vc, bp))
+			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 	}
 }
 
@@ -626,15 +624,13 @@ xfs_agfl_write_verify(
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
-	xfs_failaddr_t		fa;
 
 	/* no verification of non-crc AGFLs */
 	if (!xfs_sb_version_hascrc(&mp->m_sb))
 		return;
 
-	fa = xfs_agfl_verify(vc, bp);
-	if (fa) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+	if (!xfs_agfl_verify(vc, bp)) {
+		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 		return;
 	}
 
@@ -2576,7 +2572,7 @@ xfs_alloc_put_freelist(
 	return 0;
 }
 
-static xfs_failaddr_t
+static bool
 xfs_agf_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
@@ -2638,15 +2634,14 @@ xfs_agf_read_verify(
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
-	xfs_failaddr_t	fa;
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	    !xfs_buf_verify_cksum(vc, bp, XFS_AGF_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_agf_verify(vc, bp);
-		if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_ALLOC_READ_AGF))
-			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		if (XFS_TEST_ERROR(!xfs_agf_verify(vc, bp),
+				   mp, XFS_ERRTAG_ALLOC_READ_AGF))
+			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 	}
 }
 
@@ -2657,11 +2652,9 @@ xfs_agf_write_verify(
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
-	xfs_failaddr_t		fa;
 
-	fa = xfs_agf_verify(vc, bp);
-	if (fa) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+	if (!xfs_agf_verify(vc, bp)) {
+		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 		return;
 	}
 
diff --git a/fs/xfs/libxfs/xfs_alloc_btree.c b/fs/xfs/libxfs/xfs_alloc_btree.c
index e8c4d142c419..87d96e66d4ca 100644
--- a/fs/xfs/libxfs/xfs_alloc_btree.c
+++ b/fs/xfs/libxfs/xfs_alloc_btree.c
@@ -288,7 +288,7 @@ xfs_cntbt_diff_two_keys(
 		be32_to_cpu(k2->alloc.ar_startblock);
 }
 
-static xfs_failaddr_t
+static bool
 xfs_allocbt_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
@@ -296,7 +296,6 @@ xfs_allocbt_verify(
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_btree_block	*block = XFS_BUF_TO_BLOCK(bp);
 	struct xfs_perag	*pag = bp->b_pag;
-	xfs_failaddr_t		fa;
 	unsigned int		level;
 
 	/*
@@ -314,9 +313,8 @@ xfs_allocbt_verify(
 	level = be16_to_cpu(block->bb_level);
 	switch (block->bb_magic) {
 	case cpu_to_be32(XFS_ABTB_CRC_MAGIC):
-		fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
-		if (fa)
-			return fa;
+		if (!xfs_btree_sblock_v5hdr_verify(vc, bp))
+			return false;
 		/* fall through */
 	case cpu_to_be32(XFS_ABTB_MAGIC):
 		if (pag && pag->pagf_init) {
@@ -326,9 +324,8 @@ xfs_allocbt_verify(
 			return XFS_CORRUPTED_RETURN(vc);
 		break;
 	case cpu_to_be32(XFS_ABTC_CRC_MAGIC):
-		fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
-		if (fa)
-			return fa;
+		if (!xfs_btree_sblock_v5hdr_verify(vc, bp))
+			return false;
 		/* fall through */
 	case cpu_to_be32(XFS_ABTC_MAGIC):
 		if (pag && pag->pagf_init) {
@@ -349,14 +346,11 @@ xfs_allocbt_read_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	xfs_failaddr_t	fa;
-
 	if (!xfs_btree_sblock_verify_crc(vc, bp))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_allocbt_verify(vc, bp);
-		if (fa)
-			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		if (!xfs_allocbt_verify(vc, bp))
+			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 	}
 
 	if (bp->b_error)
@@ -368,12 +362,9 @@ xfs_allocbt_write_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	xfs_failaddr_t	fa;
-
-	fa = xfs_allocbt_verify(vc, bp);
-	if (fa) {
+	if (!xfs_allocbt_verify(vc, bp)) {
 		trace_xfs_btree_corrupt(bp, _RET_IP_);
-		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 		return;
 	}
 	xfs_btree_sblock_calc_crc(bp);
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index cf09952a3939..724b13f61da6 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -235,7 +235,7 @@ xfs_attr3_leaf_hdr_to_disk(
 	}
 }
 
-static xfs_failaddr_t
+static bool
 xfs_attr3_leaf_verify(
 	struct xfs_vc			*vc,
 	struct xfs_buf			*bp)
@@ -329,11 +329,9 @@ xfs_attr3_leaf_write_verify(
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr;
-	xfs_failaddr_t		fa;
 
-	fa = xfs_attr3_leaf_verify(vc, bp);
-	if (fa) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+	if (!xfs_attr3_leaf_verify(vc, bp)) {
+		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 		return;
 	}
 
@@ -358,15 +356,13 @@ xfs_attr3_leaf_read_verify(
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
-	xfs_failaddr_t		fa;
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	     !xfs_buf_verify_cksum(vc, bp, XFS_ATTR3_LEAF_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_attr3_leaf_verify(vc, bp);
-		if (fa)
-			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		if (!xfs_attr3_leaf_verify(vc, bp))
+			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 	}
 }
 
@@ -906,7 +902,7 @@ xfs_attr_shortform_allfit(
 }
 
 /* Verify the consistency of an inline attribute fork. */
-xfs_failaddr_t
+bool
 xfs_attr_shortform_verify(
 	struct xfs_vc			*vc,
 	struct xfs_inode		*ip)
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.h b/fs/xfs/libxfs/xfs_attr_leaf.h
index afe09eec66aa..cb8e44976514 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.h
+++ b/fs/xfs/libxfs/xfs_attr_leaf.h
@@ -41,7 +41,7 @@ int	xfs_attr_shortform_to_leaf(struct xfs_da_args *args,
 int	xfs_attr_shortform_remove(struct xfs_da_args *args);
 int	xfs_attr_shortform_allfit(struct xfs_buf *bp, struct xfs_inode *dp);
 int	xfs_attr_shortform_bytesfit(struct xfs_inode *dp, int bytes);
-xfs_failaddr_t xfs_attr_shortform_verify(struct xfs_vc *vc, struct xfs_inode *ip);
+bool	xfs_attr_shortform_verify(struct xfs_vc *vc, struct xfs_inode *ip);
 void	xfs_attr_fork_remove(struct xfs_inode *ip, struct xfs_trans *tp);
 
 /*
diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index 2b038458f4ae..9987330424e9 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -76,7 +76,7 @@ xfs_attr3_rmt_hdr_ok(
 	return true;
 }
 
-static xfs_failaddr_t
+static bool
 xfs_attr3_rmt_verify(
 	struct xfs_vc		*vc,
 	struct xfs_mount	*mp,
@@ -133,9 +133,10 @@ __xfs_attr3_rmt_read_verify(
 			*failaddr = __this_address;
 			return -EFSBADCRC;
 		}
-		*failaddr = xfs_attr3_rmt_verify(vc, mp, ptr, blksize, bno);
-		if (*failaddr)
+		if (!xfs_attr3_rmt_verify(vc, mp, ptr, blksize, bno)) {
+			*failaddr = vc->fa;
 			return -EFSCORRUPTED;
+		}
 		len -= blksize;
 		ptr += blksize;
 		bno += BTOBB(blksize);
@@ -162,7 +163,7 @@ xfs_attr3_rmt_read_verify(
 		xfs_verifier_error(bp, error, fa);
 }
 
-static xfs_failaddr_t
+static bool
 xfs_attr3_rmt_verify_struct(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
@@ -180,7 +181,6 @@ xfs_attr3_rmt_write_verify(
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
-	xfs_failaddr_t	fa;
 	int		blksize = mp->m_attr_geo->blksize;
 	char		*ptr;
 	int		len;
@@ -198,9 +198,8 @@ xfs_attr3_rmt_write_verify(
 	while (len > 0) {
 		struct xfs_attr3_rmt_hdr *rmt = (struct xfs_attr3_rmt_hdr *)ptr;
 
-		fa = xfs_attr3_rmt_verify(vc, mp, ptr, blksize, bno);
-		if (fa) {
-			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		if (!xfs_attr3_rmt_verify(vc, mp, ptr, blksize, bno)) {
+			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 			return;
 		}
 
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 0340f9e2e0e7..d34e48d7ef8c 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1250,15 +1250,13 @@ xfs_iread_extents(
 		frp = XFS_BMBT_REC_ADDR(mp, block, 1);
 		for (j = 0; j < num_recs; j++, frp++, i++) {
 			struct xfs_vc	vc = { 0 };
-			xfs_failaddr_t	fa;
 
 			xfs_bmbt_disk_get_all(frp, &new);
-			fa = xfs_bmap_validate_extent(&vc, ip, whichfork, &new);
-			if (fa) {
+			if (!xfs_bmap_validate_extent(&vc, ip, whichfork, &new)) {
 				error = -EFSCORRUPTED;
 				xfs_inode_verifier_error(ip, error,
 						"xfs_iread_extents(2)",
-						frp, sizeof(*frp), fa);
+						frp, sizeof(*frp), vc.fa);
 				goto out_brelse;
 			}
 			xfs_iext_insert(ip, &icur, &new, state);
@@ -6100,7 +6098,7 @@ xfs_bmap_finish_one(
 }
 
 /* Check that an inode's extent does not have invalid flags or bad ranges. */
-xfs_failaddr_t
+bool
 xfs_bmap_validate_extent(
 	struct xfs_vc		*vc,
 	struct xfs_inode	*ip,
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
index a586568cdfb9..bbc318331e77 100644
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
@@ -273,8 +273,8 @@ static inline int xfs_bmap_fork_to_state(int whichfork)
 	}
 }
 
-xfs_failaddr_t xfs_bmap_validate_extent(struct xfs_vc *vc, struct xfs_inode *ip, int whichfork,
-		struct xfs_bmbt_irec *irec);
+bool	xfs_bmap_validate_extent(struct xfs_vc *vc, struct xfs_inode *ip,
+		int whichfork, struct xfs_bmbt_irec *irec);
 
 int	xfs_bmapi_remap(struct xfs_trans *tp, struct xfs_inode *ip,
 		xfs_fileoff_t bno, xfs_filblks_t len, xfs_fsblock_t startblock,
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index 27b9056ba87a..fc4ea15ca6c1 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -407,14 +407,13 @@ xfs_bmbt_diff_two_keys(
 			  be64_to_cpu(k2->bmbt.br_startoff);
 }
 
-static xfs_failaddr_t
+static bool
 xfs_bmbt_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_btree_block	*block = XFS_BUF_TO_BLOCK(bp);
-	xfs_failaddr_t		fa;
 	unsigned int		level;
 
 	switch (block->bb_magic) {
@@ -423,9 +422,8 @@ xfs_bmbt_verify(
 		 * XXX: need a better way of verifying the owner here. Right now
 		 * just make sure there has been one set.
 		 */
-		fa = xfs_btree_lblock_v5hdr_verify(vc, bp, XFS_RMAP_OWN_UNKNOWN);
-		if (fa)
-			return fa;
+		if (!xfs_btree_lblock_v5hdr_verify(vc, bp, XFS_RMAP_OWN_UNKNOWN))
+			return false;
 		/* fall through */
 	case cpu_to_be32(XFS_BMAP_MAGIC):
 		break;
@@ -452,14 +450,11 @@ xfs_bmbt_read_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	xfs_failaddr_t	fa;
-
 	if (!xfs_btree_lblock_verify_crc(vc, bp))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_bmbt_verify(vc, bp);
-		if (fa)
-			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		if (!xfs_bmbt_verify(vc, bp))
+			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 	}
 
 	if (bp->b_error)
@@ -471,12 +466,9 @@ xfs_bmbt_write_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	xfs_failaddr_t	fa;
-
-	fa = xfs_bmbt_verify(vc, bp);
-	if (fa) {
+	if (!xfs_bmbt_verify(vc, bp)) {
 		trace_xfs_btree_corrupt(bp, _RET_IP_);
-		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 		return;
 	}
 	xfs_btree_lblock_calc_crc(bp);
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index 0b88cb04a719..89c53124759c 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -53,10 +53,10 @@ xfs_btree_magic(
 }
 
 /*
- * Check a long btree block header.  Return the address of the failing check,
- * or NULL if everything is ok.
+ * Check a long btree block header.  Return false for a failing check,
+ * or true if everything is ok.
  */
-xfs_failaddr_t
+bool
 __xfs_btree_check_lblock(
 	struct xfs_vc		*vc,
 	struct xfs_btree_cur	*cur,
@@ -107,11 +107,10 @@ xfs_btree_check_lblock(
 {
 	struct xfs_mount	*mp = cur->bc_mp;
 	struct xfs_vc		vc = { 0 };
-	xfs_failaddr_t		fa;
 
-	fa = __xfs_btree_check_lblock(&vc, cur, block, level, bp);
-	if (unlikely(XFS_TEST_ERROR(fa != NULL, mp,
-			XFS_ERRTAG_BTREE_CHECK_LBLOCK))) {
+	if (unlikely(XFS_TEST_ERROR(
+			!(__xfs_btree_check_lblock(&vc, cur, block, level, bp)),
+			mp, XFS_ERRTAG_BTREE_CHECK_LBLOCK))) {
 		if (bp)
 			trace_xfs_btree_corrupt(bp, _RET_IP_);
 		XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp);
@@ -121,10 +120,10 @@ xfs_btree_check_lblock(
 }
 
 /*
- * Check a short btree block header.  Return the address of the failing check,
- * or NULL if everything is ok.
+ * Check a short btree block header.  Return false for a failing check,
+ * or true if everything is ok.
  */
-xfs_failaddr_t
+bool
 __xfs_btree_check_sblock(
 	struct xfs_vc		*vc,
 	struct xfs_btree_cur	*cur,
@@ -173,11 +172,10 @@ xfs_btree_check_sblock(
 {
 	struct xfs_mount	*mp = cur->bc_mp;
 	struct xfs_vc		vc = { 0 };
-	xfs_failaddr_t		fa;
 
-	fa = __xfs_btree_check_sblock(&vc, cur, block, level, bp);
-	if (unlikely(XFS_TEST_ERROR(fa != NULL, mp,
-			XFS_ERRTAG_BTREE_CHECK_SBLOCK))) {
+	if (unlikely(XFS_TEST_ERROR(
+			!(__xfs_btree_check_sblock(&vc, cur, block, level, bp)),
+			mp, XFS_ERRTAG_BTREE_CHECK_SBLOCK))) {
 		if (bp)
 			trace_xfs_btree_corrupt(bp, _RET_IP_);
 		XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, mp);
@@ -4434,7 +4432,7 @@ xfs_btree_change_owner(
 }
 
 /* Verify the v5 fields of a long-format btree block. */
-xfs_failaddr_t
+bool
 xfs_btree_lblock_v5hdr_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp,
@@ -4456,7 +4454,7 @@ xfs_btree_lblock_v5hdr_verify(
 }
 
 /* Verify a long-format btree block. */
-xfs_failaddr_t
+bool
 xfs_btree_lblock_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp,
@@ -4488,7 +4486,7 @@ xfs_btree_lblock_verify(
  * @max_recs: pointer to the m_*_mxr max records field in the xfs mount
  * @pag_max_level: pointer to the per-ag max level field
  */
-xfs_failaddr_t
+bool
 xfs_btree_sblock_v5hdr_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
@@ -4514,7 +4512,7 @@ xfs_btree_sblock_v5hdr_verify(
  * @bp: buffer containing the btree block
  * @max_recs: maximum records allowed in this btree node
  */
-xfs_failaddr_t
+bool
 xfs_btree_sblock_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp,
diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
index a585293798f3..db69909b56a1 100644
--- a/fs/xfs/libxfs/xfs_btree.h
+++ b/fs/xfs/libxfs/xfs_btree.h
@@ -240,12 +240,12 @@ typedef struct xfs_btree_cur
 #define	XFS_BUF_TO_BLOCK(bp)	((struct xfs_btree_block *)((bp)->b_addr))
 
 /*
- * Internal long and short btree block checks.  They return NULL if the
- * block is ok or the address of the failed check otherwise.
+ * Internal long and short btree block checks.  They return true if the
+ * block is ok or false otherwise.
  */
-xfs_failaddr_t __xfs_btree_check_lblock(struct xfs_vc *vc, struct xfs_btree_cur *cur,
+bool __xfs_btree_check_lblock(struct xfs_vc *vc, struct xfs_btree_cur *cur,
 		struct xfs_btree_block *block, int level, struct xfs_buf *bp);
-xfs_failaddr_t __xfs_btree_check_sblock(struct xfs_vc *vc, struct xfs_btree_cur *cur,
+bool __xfs_btree_check_sblock(struct xfs_vc *vc, struct xfs_btree_cur *cur,
 		struct xfs_btree_block *block, int level, struct xfs_buf *bp);
 
 /*
@@ -457,12 +457,12 @@ static inline int xfs_btree_get_level(struct xfs_btree_block *block)
 #define	XFS_FILBLKS_MIN(a,b)	min_t(xfs_filblks_t, (a), (b))
 #define	XFS_FILBLKS_MAX(a,b)	max_t(xfs_filblks_t, (a), (b))
 
-xfs_failaddr_t xfs_btree_sblock_v5hdr_verify(struct xfs_vc *vc, struct xfs_buf *bp);
-xfs_failaddr_t xfs_btree_sblock_verify(struct xfs_vc *vc, struct xfs_buf *bp,
+bool xfs_btree_sblock_v5hdr_verify(struct xfs_vc *vc, struct xfs_buf *bp);
+bool xfs_btree_sblock_verify(struct xfs_vc *vc, struct xfs_buf *bp,
 		unsigned int max_recs);
-xfs_failaddr_t xfs_btree_lblock_v5hdr_verify(struct xfs_vc *vc, struct xfs_buf *bp,
+bool xfs_btree_lblock_v5hdr_verify(struct xfs_vc *vc, struct xfs_buf *bp,
 		uint64_t owner);
-xfs_failaddr_t xfs_btree_lblock_verify(struct xfs_vc *vc, struct xfs_buf *bp,
+bool xfs_btree_lblock_verify(struct xfs_vc *vc, struct xfs_buf *bp,
 		unsigned int max_recs);
 
 uint xfs_btree_compute_maxlevels(uint *limits, unsigned long len);
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index f7510bf5f505..0b4f084766e3 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -116,7 +116,7 @@ xfs_da_state_free(xfs_da_state_t *state)
 	kmem_zone_free(xfs_da_state_zone, state);
 }
 
-static xfs_failaddr_t
+static bool
 xfs_da3_node_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
@@ -174,11 +174,9 @@ xfs_da3_node_write_verify(
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
-	xfs_failaddr_t		fa;
 
-	fa = xfs_da3_node_verify(vc, bp);
-	if (fa) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+	if (!xfs_da3_node_verify(vc, bp)) {
+		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 		return;
 	}
 
@@ -203,7 +201,6 @@ xfs_da3_node_read_verify(
 	struct xfs_buf		*bp)
 {
 	struct xfs_da_blkinfo	*info = bp->b_addr;
-	xfs_failaddr_t		fa;
 
 	switch (be16_to_cpu(info->magic)) {
 		case XFS_DA3_NODE_MAGIC:
@@ -214,9 +211,8 @@ xfs_da3_node_read_verify(
 			}
 			/* fall through */
 		case XFS_DA_NODE_MAGIC:
-			fa = xfs_da3_node_verify(vc, bp);
-			if (fa)
-				xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+			if (!xfs_da3_node_verify(vc, bp))
+				xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 			return;
 		case XFS_ATTR_LEAF_MAGIC:
 		case XFS_ATTR3_LEAF_MAGIC:
@@ -235,7 +231,7 @@ xfs_da3_node_read_verify(
 }
 
 /* Verify the structure of a da3 block. */
-static xfs_failaddr_t
+static bool
 xfs_da3_node_verify_struct(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
index 12ae8c4285b2..534d5fcf13b3 100644
--- a/fs/xfs/libxfs/xfs_dir2_block.c
+++ b/fs/xfs/libxfs/xfs_dir2_block.c
@@ -46,7 +46,7 @@ xfs_dir_startup(void)
 	xfs_dir_hash_dotdot = xfs_da_hashname((unsigned char *)"..", 2);
 }
 
-static xfs_failaddr_t
+static bool
 xfs_dir3_block_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
@@ -76,15 +76,13 @@ xfs_dir3_block_read_verify(
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
-	xfs_failaddr_t		fa;
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	     !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_DATA_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_dir3_block_verify(vc, bp);
-		if (fa)
-			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		if (!xfs_dir3_block_verify(vc, bp))
+			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 	}
 }
 
@@ -96,11 +94,9 @@ xfs_dir3_block_write_verify(
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;
-	xfs_failaddr_t		fa;
 
-	fa = xfs_dir3_block_verify(vc, bp);
-	if (fa) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+	if (!xfs_dir3_block_verify(vc, bp)) {
+		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 		return;
 	}
 
diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
index 574fe8ba7144..a215c7adb480 100644
--- a/fs/xfs/libxfs/xfs_dir2_data.c
+++ b/fs/xfs/libxfs/xfs_dir2_data.c
@@ -21,7 +21,7 @@
 #include "xfs_cksum.h"
 #include "xfs_log.h"
 
-static xfs_failaddr_t xfs_dir2_data_freefind_verify(
+static bool xfs_dir2_data_freefind_verify(
 		struct xfs_vc *vc,
 		struct xfs_dir2_data_hdr *hdr, struct xfs_dir2_data_free *bf,
 		struct xfs_dir2_data_unused *dup,
@@ -30,9 +30,9 @@ static xfs_failaddr_t xfs_dir2_data_freefind_verify(
 /*
  * Check the consistency of the data block.
  * The input can also be a block-format directory.
- * Return NULL if the buffer is good, otherwise the address of the error.
+ * Return true if the buffer is good, otherwise false.
  */
-xfs_failaddr_t
+bool
 __xfs_dir3_data_check(
 	struct xfs_vc		*vc,		/* verifier context */
 	struct xfs_inode	*dp,		/* incore inode pointer */
@@ -142,8 +142,6 @@ __xfs_dir3_data_check(
 		 * doesn't need to be there.
 		 */
 		if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
-			xfs_failaddr_t	fa;
-
 			if (lastfree != 0)
 				return XFS_CORRUPTED_RETURN(vc);
 			if (endp < p + be16_to_cpu(dup->length))
@@ -151,9 +149,8 @@ __xfs_dir3_data_check(
 			if (be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)) !=
 			    (char *)dup - (char *)hdr)
 				return XFS_CORRUPTED_RETURN(vc);
-			fa = xfs_dir2_data_freefind_verify(vc, hdr, bf, dup, &dfp);
-			if (fa)
-				return fa;
+			if (!xfs_dir2_data_freefind_verify(vc, hdr, bf, dup, &dfp))
+				return false;
 			if (dfp) {
 				i = (int)(dfp - bf);
 				if ((freeseen & (1 << i)) != 0)
@@ -236,19 +233,17 @@ xfs_dir3_data_check(
 	struct xfs_buf		*bp)
 {
 	struct xfs_vc		vc = { 0 };
-	xfs_failaddr_t		fa;
 
-	fa = __xfs_dir3_data_check(&vc, dp, bp);
-	if (!fa)
+	if (__xfs_dir3_data_check(&vc, dp, bp))
 		return;
 	xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, dp->i_mount,
 			bp->b_addr, BBTOB(bp->b_length), __FILE__, __LINE__,
-			fa);
+			vc.fa);
 	ASSERT(0);
 }
 #endif
 
-static xfs_failaddr_t
+static bool
 xfs_dir3_data_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
@@ -307,15 +302,13 @@ xfs_dir3_data_read_verify(
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
-	xfs_failaddr_t		fa;
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	    !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_DATA_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_dir3_data_verify(vc, bp);
-		if (fa)
-			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		if (!xfs_dir3_data_verify(vc, bp))
+			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 	}
 }
 
@@ -327,11 +320,9 @@ xfs_dir3_data_write_verify(
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;
-	xfs_failaddr_t		fa;
 
-	fa = xfs_dir3_data_verify(vc, bp);
-	if (fa) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+	if (!xfs_dir3_data_verify(vc, bp)) {
+		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 		return;
 	}
 
@@ -389,7 +380,7 @@ xfs_dir3_data_readahead(
  * Find the bestfree entry that exactly coincides with unused directory space
  * or a verifier error because the bestfree data are bad.
  */
-static xfs_failaddr_t
+static bool
 xfs_dir2_data_freefind_verify(
 	struct xfs_vc			*vc,
 	struct xfs_dir2_data_hdr	*hdr,
@@ -963,7 +954,7 @@ xfs_dir2_data_make_free(
 }
 
 /* Check our free data for obvious signs of corruption. */
-static inline xfs_failaddr_t
+static inline bool
 xfs_dir2_data_check_free(
 	struct xfs_vc			*vc,
 	struct xfs_dir2_data_hdr	*hdr,
@@ -989,7 +980,7 @@ xfs_dir2_data_check_free(
 }
 
 /* Sanity-check a new bestfree entry. */
-static inline xfs_failaddr_t
+static inline bool
 xfs_dir2_data_check_new_free(
 	struct xfs_vc			*vc,
 	struct xfs_dir2_data_hdr	*hdr,
@@ -1024,15 +1015,13 @@ xfs_dir2_data_use_free(
 	xfs_dir2_data_unused_t	*newdup2;	/* another new unused entry */
 	struct xfs_dir2_data_free *bf;
 	struct xfs_vc		vc = { 0 };
-	xfs_failaddr_t		fa;
 	int			matchback;	/* matches end of freespace */
 	int			matchfront;	/* matches start of freespace */
 	int			needscan;	/* need to regen bestfree */
 	int			oldlen;		/* old unused entry's length */
 
 	hdr = bp->b_addr;
-	fa = xfs_dir2_data_check_free(&vc, hdr, dup, offset, len);
-	if (fa)
+	if (!xfs_dir2_data_check_free(&vc, hdr, dup, offset, len))
 		goto corrupt;
 	/*
 	 * Look up the entry in the bestfree table.
@@ -1078,8 +1067,7 @@ xfs_dir2_data_use_free(
 			xfs_dir2_data_freeremove(hdr, bf, dfp, needlogp);
 			dfp = xfs_dir2_data_freeinsert(hdr, bf, newdup,
 						       needlogp);
-			fa = xfs_dir2_data_check_new_free(&vc, hdr, dfp, newdup);
-			if (fa)
+			if (!xfs_dir2_data_check_new_free(&vc, hdr, dfp, newdup))
 				goto corrupt;
 			/*
 			 * If we got inserted at the last slot,
@@ -1106,8 +1094,7 @@ xfs_dir2_data_use_free(
 			xfs_dir2_data_freeremove(hdr, bf, dfp, needlogp);
 			dfp = xfs_dir2_data_freeinsert(hdr, bf, newdup,
 						       needlogp);
-			fa = xfs_dir2_data_check_new_free(&vc, hdr, dfp, newdup);
-			if (fa)
+			if (!xfs_dir2_data_check_new_free(&vc, hdr, dfp, newdup))
 				goto corrupt;
 			/*
 			 * If we got inserted at the last slot,
@@ -1157,7 +1144,7 @@ xfs_dir2_data_use_free(
 	return 0;
 corrupt:
 	xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, args->dp->i_mount,
-			hdr, sizeof(*hdr), __FILE__, __LINE__, fa);
+			hdr, sizeof(*hdr), __FILE__, __LINE__, vc.fa);
 	return -EFSCORRUPTED;
 }
 
diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
index 4488b898ca97..e757e1f950e4 100644
--- a/fs/xfs/libxfs/xfs_dir2_leaf.c
+++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
@@ -38,7 +38,7 @@ static void xfs_dir3_leaf_log_tail(struct xfs_da_args *args,
  * Pop an assert if something is wrong.
  */
 #ifdef DEBUG
-static xfs_failaddr_t
+static bool
 xfs_dir3_leaf1_check(
 	struct xfs_vc		*vc,
 	struct xfs_inode	*dp,
@@ -65,21 +65,19 @@ xfs_dir3_leaf_check(
 	struct xfs_buf		*bp)
 {
 	struct xfs_vc		vc = { 0 };
-	xfs_failaddr_t		fa;
 
-	fa = xfs_dir3_leaf1_check(&vc, dp, bp);
-	if (!fa)
+	if (xfs_dir3_leaf1_check(&vc, dp, bp))
 		return;
 	xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, dp->i_mount,
 			bp->b_addr, BBTOB(bp->b_length), __FILE__, __LINE__,
-			fa);
+			vc.fa);
 	ASSERT(0);
 }
 #else
 #define	xfs_dir3_leaf_check(dp, bp)
 #endif
 
-xfs_failaddr_t
+bool
 xfs_dir3_leaf_check_int(
 	struct xfs_vc		*vc,
 	struct xfs_mount	*mp,
@@ -143,7 +141,7 @@ xfs_dir3_leaf_check_int(
  * kernels we don't get assertion failures in xfs_dir3_leaf_hdr_from_disk() due
  * to incorrect magic numbers.
  */
-static xfs_failaddr_t
+static bool
 xfs_dir3_leaf_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp,
@@ -184,15 +182,13 @@ __read_verify(
 	uint16_t		magic)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
-	xfs_failaddr_t		fa;
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	     !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_LEAF_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_dir3_leaf_verify(vc, bp, magic);
-		if (fa)
-			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		if (!xfs_dir3_leaf_verify(vc, bp, magic))
+			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 	}
 }
 
@@ -205,11 +201,9 @@ __write_verify(
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr;
-	xfs_failaddr_t		fa;
 
-	fa = xfs_dir3_leaf_verify(vc, bp, magic);
-	if (fa) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+	if (!xfs_dir3_leaf_verify(vc, bp, magic)) {
+		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 		return;
 	}
 
@@ -222,7 +216,7 @@ __write_verify(
 	xfs_buf_update_cksum(bp, XFS_DIR3_LEAF_CRC_OFF);
 }
 
-static xfs_failaddr_t
+static bool
 xfs_dir3_leaf1_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
@@ -246,7 +240,7 @@ xfs_dir3_leaf1_write_verify(
 	__write_verify(vc, bp, XFS_DIR2_LEAF1_MAGIC);
 }
 
-static xfs_failaddr_t
+static bool
 xfs_dir3_leafn_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index 1920caa65895..8105544c44fb 100644
--- a/fs/xfs/libxfs/xfs_dir2_node.c
+++ b/fs/xfs/libxfs/xfs_dir2_node.c
@@ -41,7 +41,7 @@ static int xfs_dir2_node_addname_int(xfs_da_args_t *args,
  * Check internal consistency of a leafn block.
  */
 #ifdef DEBUG
-static xfs_failaddr_t
+static bool
 xfs_dir3_leafn_check(
 	struct xfs_vc		*vc,
 	struct xfs_inode	*dp,
@@ -68,21 +68,19 @@ xfs_dir3_leaf_check(
 	struct xfs_buf		*bp)
 {
 	struct xfs_vc		vc = { 0 };
-	xfs_failaddr_t		fa;
 
-	fa = xfs_dir3_leafn_check(&vc, dp, bp);
-	if (!fa)
+	if (xfs_dir3_leafn_check(&vc, dp, bp))
 		return;
 	xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, dp->i_mount,
 			bp->b_addr, BBTOB(bp->b_length), __FILE__, __LINE__,
-			fa);
+			vc.fa);
 	ASSERT(0);
 }
 #else
 #define	xfs_dir3_leaf_check(dp, bp)
 #endif
 
-static xfs_failaddr_t
+static bool
 xfs_dir3_free_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
@@ -117,15 +115,13 @@ xfs_dir3_free_read_verify(
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
-	xfs_failaddr_t		fa;
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	    !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_FREE_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_dir3_free_verify(vc, bp);
-		if (fa)
-			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		if (!xfs_dir3_free_verify(vc, bp))
+			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 	}
 }
 
@@ -137,11 +133,9 @@ xfs_dir3_free_write_verify(
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
 	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;
-	xfs_failaddr_t		fa;
 
-	fa = xfs_dir3_free_verify(vc, bp);
-	if (fa) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+	if (!xfs_dir3_free_verify(vc, bp)) {
+		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 		return;
 	}
 
@@ -162,7 +156,7 @@ const struct xfs_buf_ops xfs_dir3_free_buf_ops = {
 };
 
 /* Everything ok in the free block header? */
-static xfs_failaddr_t
+static bool
 xfs_dir3_free_header_check(
 	struct xfs_vc		*vc,
 	struct xfs_inode	*dp,
@@ -208,7 +202,6 @@ __xfs_dir3_free_read(
 	struct xfs_buf		**bpp)
 {
 	struct xfs_vc		vc = { 0 };
-	xfs_failaddr_t		fa;
 	int			err;
 
 	err = xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp,
@@ -217,9 +210,8 @@ __xfs_dir3_free_read(
 		return err;
 
 	/* Check things that we can't do in the verifier. */
-	fa = xfs_dir3_free_header_check(&vc, dp, fbno, *bpp);
-	if (fa) {
-		xfs_verifier_error(*bpp, -EFSCORRUPTED, fa);
+	if (!xfs_dir3_free_header_check(&vc, dp, fbno, *bpp)) {
+		xfs_verifier_error(*bpp, -EFSCORRUPTED, vc.fa);
 		xfs_trans_brelse(tp, *bpp);
 		return -EFSCORRUPTED;
 	}
diff --git a/fs/xfs/libxfs/xfs_dir2_priv.h b/fs/xfs/libxfs/xfs_dir2_priv.h
index c8d5dc67e02b..53c1a77f291b 100644
--- a/fs/xfs/libxfs/xfs_dir2_priv.h
+++ b/fs/xfs/libxfs/xfs_dir2_priv.h
@@ -32,7 +32,7 @@ extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
 #define	xfs_dir3_data_check(dp,bp)
 #endif
 
-extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_vc *vc, struct xfs_inode *dp,
+extern bool __xfs_dir3_data_check(struct xfs_vc *vc, struct xfs_inode *dp,
 		struct xfs_buf *bp);
 extern int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp,
 		xfs_dablk_t bno, xfs_daddr_t mapped_bno, struct xfs_buf **bpp);
@@ -78,7 +78,7 @@ xfs_dir3_leaf_find_entry(struct xfs_dir3_icleaf_hdr *leafhdr,
 		int lowstale, int highstale, int *lfloglow, int *lfloghigh);
 extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state);
 
-extern xfs_failaddr_t xfs_dir3_leaf_check_int(struct xfs_vc *vc, struct xfs_mount *mp,
+extern bool xfs_dir3_leaf_check_int(struct xfs_vc *vc, struct xfs_mount *mp,
 		struct xfs_inode *dp, struct xfs_dir3_icleaf_hdr *hdr,
 		struct xfs_dir2_leaf *leaf);
 
@@ -117,7 +117,7 @@ extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino);
 extern int xfs_dir2_sf_lookup(struct xfs_da_args *args);
 extern int xfs_dir2_sf_removename(struct xfs_da_args *args);
 extern int xfs_dir2_sf_replace(struct xfs_da_args *args);
-extern xfs_failaddr_t xfs_dir2_sf_verify(struct xfs_vc *vc, struct xfs_inode *ip);
+extern bool xfs_dir2_sf_verify(struct xfs_vc *vc, struct xfs_inode *ip);
 
 /* xfs_dir2_readdir.c */
 extern int xfs_readdir(struct xfs_trans *tp, struct xfs_inode *dp,
diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
index 659243991b61..3645234df4bb 100644
--- a/fs/xfs/libxfs/xfs_dir2_sf.c
+++ b/fs/xfs/libxfs/xfs_dir2_sf.c
@@ -616,7 +616,7 @@ xfs_dir2_sf_check(
 #endif	/* DEBUG */
 
 /* Verify the consistency of an inline directory. */
-xfs_failaddr_t
+bool
 xfs_dir2_sf_verify(
 	struct xfs_vc			*vc,
 	struct xfs_inode		*ip)
diff --git a/fs/xfs/libxfs/xfs_dquot_buf.c b/fs/xfs/libxfs/xfs_dquot_buf.c
index 0b7c76c5f3e1..16838ac0de71 100644
--- a/fs/xfs/libxfs/xfs_dquot_buf.c
+++ b/fs/xfs/libxfs/xfs_dquot_buf.c
@@ -35,7 +35,7 @@ xfs_calc_dquots_per_chunk(
  * smaller xfs_disk_dquot structure available.
  */
 
-xfs_failaddr_t
+bool
 xfs_dquot_verify(
 	struct xfs_vc	 *vc,
 	struct xfs_mount *mp,
@@ -94,7 +94,7 @@ xfs_dquot_verify(
 	return XFS_VERIFIED_RETURN(vc);
 }
 
-xfs_failaddr_t
+bool
 xfs_dqblk_verify(
 	struct xfs_vc		*vc,
 	struct xfs_mount	*mp,
@@ -175,7 +175,7 @@ xfs_dquot_buf_verify_crc(
 	return true;
 }
 
-STATIC xfs_failaddr_t
+STATIC bool
 xfs_dquot_buf_verify(
 	struct xfs_vc		*vc,
 	struct xfs_mount	*mp,
@@ -183,7 +183,6 @@ xfs_dquot_buf_verify(
 	bool			readahead)
 {
 	struct xfs_dqblk	*dqb = bp->b_addr;
-	xfs_failaddr_t		fa;
 	xfs_dqid_t		id = 0;
 	int			ndquots;
 	int			i;
@@ -213,20 +212,19 @@ xfs_dquot_buf_verify(
 		if (i == 0)
 			id = be32_to_cpu(ddq->d_id);
 
-		fa = xfs_dqblk_verify(vc, mp, &dqb[i], id + i, 0);
-		if (fa) {
+		if (!xfs_dqblk_verify(vc, mp, &dqb[i], id + i, 0)) {
 			if (!readahead)
 				xfs_buf_verifier_error(bp, -EFSCORRUPTED,
 					__func__, &dqb[i],
-					sizeof(struct xfs_dqblk), fa);
-			return fa;
+					sizeof(struct xfs_dqblk), vc->fa);
+			return false;
 		}
 	}
 
 	return XFS_VERIFIED_RETURN(vc);
 }
 
-static xfs_failaddr_t
+static  bool
 xfs_dquot_buf_verify_struct(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
@@ -262,7 +260,7 @@ xfs_dquot_buf_readahead_verify(
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 
 	if (!xfs_dquot_buf_verify_crc(mp, bp, true) ||
-	    xfs_dquot_buf_verify(vc, mp, bp, true) != NULL) {
+	    !xfs_dquot_buf_verify(vc, mp, bp, true)) {
 		xfs_buf_ioerror(bp, -EIO);
 		bp->b_flags &= ~XBF_DONE;
 	}
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index f24abdc20d3b..32fb58c929f0 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -2495,7 +2495,7 @@ xfs_ialloc_log_agi(
 	}
 }
 
-static xfs_failaddr_t
+static bool
 xfs_agi_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
@@ -2554,15 +2554,14 @@ xfs_agi_read_verify(
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
-	xfs_failaddr_t	fa;
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	    !xfs_buf_verify_cksum(vc, bp, XFS_AGI_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_agi_verify(vc, bp);
-		if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_IALLOC_READ_AGI))
-			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		if (XFS_TEST_ERROR(!xfs_agi_verify(vc, bp),
+				   mp, XFS_ERRTAG_IALLOC_READ_AGI))
+			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 	}
 }
 
@@ -2573,11 +2572,9 @@ xfs_agi_write_verify(
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
-	xfs_failaddr_t		fa;
 
-	fa = xfs_agi_verify(vc, bp);
-	if (fa) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+	if (!xfs_agi_verify(vc, bp)) {
+		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 		return;
 	}
 
diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
index a3902165aac5..30a1fcf24767 100644
--- a/fs/xfs/libxfs/xfs_ialloc_btree.c
+++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
@@ -254,14 +254,13 @@ xfs_inobt_diff_two_keys(
 			  be32_to_cpu(k2->inobt.ir_startino);
 }
 
-static xfs_failaddr_t
+static bool
 xfs_inobt_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_btree_block	*block = XFS_BUF_TO_BLOCK(bp);
-	xfs_failaddr_t		fa;
 	unsigned int		level;
 
 	/*
@@ -277,9 +276,8 @@ xfs_inobt_verify(
 	switch (block->bb_magic) {
 	case cpu_to_be32(XFS_IBT_CRC_MAGIC):
 	case cpu_to_be32(XFS_FIBT_CRC_MAGIC):
-		fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
-		if (fa)
-			return fa;
+		if (!xfs_btree_sblock_v5hdr_verify(vc, bp))
+			return false;
 		/* fall through */
 	case cpu_to_be32(XFS_IBT_MAGIC):
 	case cpu_to_be32(XFS_FIBT_MAGIC):
@@ -301,14 +299,11 @@ xfs_inobt_read_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	xfs_failaddr_t	fa;
-
 	if (!xfs_btree_sblock_verify_crc(vc, bp))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_inobt_verify(vc, bp);
-		if (fa)
-			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		if (!xfs_inobt_verify(vc, bp))
+			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 	}
 
 	if (bp->b_error)
@@ -320,12 +315,9 @@ xfs_inobt_write_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	xfs_failaddr_t	fa;
-
-	fa = xfs_inobt_verify(vc, bp);
-	if (fa) {
+	if (!xfs_inobt_verify(vc, bp)) {
 		trace_xfs_btree_corrupt(bp, _RET_IP_);
-		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 		return;
 	}
 	xfs_btree_sblock_calc_crc(bp);
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index a04f75f2885f..0e3d7ed938c5 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -378,7 +378,7 @@ xfs_log_dinode_to_disk(
 	}
 }
 
-static xfs_failaddr_t
+static bool
 xfs_dinode_verify_fork(
 	struct xfs_vc		*vc,
 	struct xfs_dinode	*dip,
@@ -420,7 +420,7 @@ xfs_dinode_verify_fork(
 	return XFS_VERIFIED_RETURN(vc);
 }
 
-static xfs_failaddr_t
+static bool
 xfs_dinode_verify_forkoff(
 	struct xfs_vc		*vc,
 	struct xfs_dinode	*dip,
@@ -446,14 +446,13 @@ xfs_dinode_verify_forkoff(
 	return XFS_VERIFIED_RETURN(vc);
 }
 
-xfs_failaddr_t
+bool
 xfs_dinode_verify(
 	struct xfs_vc		*vc,
 	struct xfs_mount	*mp,
 	xfs_ino_t		ino,
 	struct xfs_dinode	*dip)
 {
-	xfs_failaddr_t		fa;
 	uint16_t		mode;
 	uint16_t		flags;
 	uint64_t		flags2;
@@ -503,9 +502,8 @@ xfs_dinode_verify(
 		return XFS_CORRUPTED_RETURN(vc);
 
 	/* check for illegal values of forkoff */
-	fa = xfs_dinode_verify_forkoff(vc, dip, mp);
-	if (fa)
-		return fa;
+	if (!xfs_dinode_verify_forkoff(vc, dip, mp))
+		return false;
 
 	/* Do we have appropriate data fork formats for the mode? */
 	switch (mode & S_IFMT) {
@@ -519,9 +517,8 @@ xfs_dinode_verify(
 	case S_IFREG:
 	case S_IFLNK:
 	case S_IFDIR:
-		fa = xfs_dinode_verify_fork(vc, dip, mp, XFS_DATA_FORK);
-		if (fa)
-			return fa;
+		if (!xfs_dinode_verify_fork(vc, dip, mp, XFS_DATA_FORK))
+			return false;
 		break;
 	case 0:
 		/* Uninitialized inode ok. */
@@ -531,9 +528,8 @@ xfs_dinode_verify(
 	}
 
 	if (XFS_DFORK_Q(dip)) {
-		fa = xfs_dinode_verify_fork(vc, dip, mp, XFS_ATTR_FORK);
-		if (fa)
-			return fa;
+		if (!xfs_dinode_verify_fork(vc, dip, mp, XFS_ATTR_FORK))
+			return false;
 	} else {
 		/*
 		 * If there is no fork offset, this may be a freshly-made inode
@@ -553,10 +549,9 @@ xfs_dinode_verify(
 	}
 
 	/* extent size hint validation */
-	fa = xfs_inode_validate_extsize(vc, mp, be32_to_cpu(dip->di_extsize),
-			mode, flags);
-	if (fa)
-		return fa;
+	if (!xfs_inode_validate_extsize(vc, mp, be32_to_cpu(dip->di_extsize),
+			mode, flags))
+		return false;
 
 	/* only version 3 or greater inodes are extensively verified here */
 	if (dip->di_version < 3)
@@ -582,10 +577,9 @@ xfs_dinode_verify(
 		return XFS_CORRUPTED_RETURN(vc);
 
 	/* COW extent size hint validation */
-	fa = xfs_inode_validate_cowextsize(vc, mp, be32_to_cpu(dip->di_cowextsize),
-			mode, flags, flags2);
-	if (fa)
-		return fa;
+	if (!xfs_inode_validate_cowextsize(vc, mp, be32_to_cpu(dip->di_cowextsize),
+			mode, flags, flags2))
+		return false;
 
 	return XFS_VERIFIED_RETURN(vc);
 }
@@ -628,7 +622,6 @@ xfs_iread(
 	xfs_buf_t	*bp;
 	xfs_dinode_t	*dip;
 	struct xfs_vc	vc = { 0 };
-	xfs_failaddr_t	fa;
 	int		error;
 
 	/*
@@ -657,10 +650,9 @@ xfs_iread(
 		return error;
 
 	/* even unallocated inodes are verified */
-	fa = xfs_dinode_verify(&vc, mp, ip->i_ino, dip);
-	if (fa) {
+	if (!xfs_dinode_verify(&vc, mp, ip->i_ino, dip)) {
 		xfs_inode_verifier_error(ip, -EFSCORRUPTED, "dinode", dip,
-				sizeof(*dip), fa);
+				sizeof(*dip), vc.fa);
 		error = -EFSCORRUPTED;
 		goto out_brelse;
 	}
@@ -734,7 +726,7 @@ xfs_iread(
  * The rules are documented at xfs_ioctl_setattr_check_extsize().
  * These functions must be kept in sync with each other.
  */
-xfs_failaddr_t
+bool
 xfs_inode_validate_extsize(
 	struct xfs_vc			*vc,
 	struct xfs_mount		*mp,
@@ -792,7 +784,7 @@ xfs_inode_validate_extsize(
  * The rules are documented at xfs_ioctl_setattr_check_cowextsize().
  * These functions must be kept in sync with each other.
  */
-xfs_failaddr_t
+bool
 xfs_inode_validate_cowextsize(
 	struct xfs_vc			*vc,
 	struct xfs_mount		*mp,
diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
index fceea886275f..7dfb09360f3e 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.h
+++ b/fs/xfs/libxfs/xfs_inode_buf.h
@@ -70,11 +70,11 @@ void	xfs_inobp_check(struct xfs_mount *, struct xfs_buf *);
 #define	xfs_inobp_check(mp, bp)
 #endif /* DEBUG */
 
-xfs_failaddr_t xfs_dinode_verify(struct xfs_vc *vc, struct xfs_mount *mp, xfs_ino_t ino,
+bool xfs_dinode_verify(struct xfs_vc *vc, struct xfs_mount *mp, xfs_ino_t ino,
 			   struct xfs_dinode *dip);
-xfs_failaddr_t xfs_inode_validate_extsize(struct xfs_vc *vc, struct xfs_mount *mp,
+bool xfs_inode_validate_extsize(struct xfs_vc *vc, struct xfs_mount *mp,
 		uint32_t extsize, uint16_t mode, uint16_t flags);
-xfs_failaddr_t xfs_inode_validate_cowextsize(struct xfs_vc *vc, struct xfs_mount *mp,
+bool xfs_inode_validate_cowextsize(struct xfs_vc *vc, struct xfs_mount *mp,
 		uint32_t cowextsize, uint16_t mode, uint16_t flags,
 		uint64_t flags2);
 
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
index 78ee502d856e..14ce22222073 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
@@ -234,14 +234,12 @@ xfs_iformat_extents(
 		xfs_iext_first(ifp, &icur);
 		for (i = 0; i < nex; i++, dp++) {
 			struct xfs_vc	vc = { 0 };
-			xfs_failaddr_t	fa;
 
 			xfs_bmbt_disk_get_all(dp, &new);
-			fa = xfs_bmap_validate_extent(&vc, ip, whichfork, &new);
-			if (fa) {
+			if (!xfs_bmap_validate_extent(&vc, ip, whichfork, &new)) {
 				xfs_inode_verifier_error(ip, -EFSCORRUPTED,
 						"xfs_iformat_extents(2)",
-						dp, sizeof(*dp), fa);
+						dp, sizeof(*dp), vc.fa);
 				return -EFSCORRUPTED;
 			}
 
@@ -556,6 +554,7 @@ xfs_iextents_copy(
 	struct xfs_iext_cursor	icur;
 	struct xfs_bmbt_irec	rec;
 	int			copied = 0;
+	struct xfs_vc		vc = { 0 };
 
 	ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL | XFS_ILOCK_SHARED));
 	ASSERT(ifp->if_bytes > 0);
@@ -563,7 +562,7 @@ xfs_iextents_copy(
 	for_each_xfs_iext(ifp, &icur, &rec) {
 		if (isnullstartblock(rec.br_startblock))
 			continue;
-		ASSERT(xfs_bmap_validate_extent(NULL, ip, whichfork, &rec) == NULL);
+		ASSERT(xfs_bmap_validate_extent(&vc, ip, whichfork, &rec));
 		xfs_bmbt_disk_set_all(dp, &rec);
 		trace_xfs_write_extent(ip, &icur, state, _RET_IP_);
 		copied += sizeof(struct xfs_bmbt_rec);
@@ -700,7 +699,7 @@ struct xfs_ifork_ops xfs_default_ifork_ops = {
 };
 
 /* Verify the inline contents of the data fork of an inode. */
-xfs_failaddr_t
+bool
 xfs_ifork_verify_data(
 	struct xfs_vc		*vc,
 	struct xfs_inode	*ip,
@@ -722,7 +721,7 @@ xfs_ifork_verify_data(
 }
 
 /* Verify the inline contents of the attr fork of an inode. */
-xfs_failaddr_t
+bool
 xfs_ifork_verify_attr(
 	struct xfs_vc		*vc,
 	struct xfs_inode	*ip,
diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h
index b2f67389304c..422cd7d59045 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.h
+++ b/fs/xfs/libxfs/xfs_inode_fork.h
@@ -174,7 +174,7 @@ extern struct kmem_zone	*xfs_ifork_zone;
 
 extern void xfs_ifork_init_cow(struct xfs_inode *ip);
 
-typedef xfs_failaddr_t (*xfs_ifork_verifier_t)(struct xfs_vc *vc, struct xfs_inode *);
+typedef bool (*xfs_ifork_verifier_t)(struct xfs_vc *vc, struct xfs_inode *);
 
 struct xfs_ifork_ops {
 	xfs_ifork_verifier_t	verify_symlink;
@@ -183,9 +183,9 @@ struct xfs_ifork_ops {
 };
 extern struct xfs_ifork_ops	xfs_default_ifork_ops;
 
-xfs_failaddr_t xfs_ifork_verify_data(struct xfs_vc *vc, struct xfs_inode *ip,
+bool xfs_ifork_verify_data(struct xfs_vc *vc, struct xfs_inode *ip,
 		struct xfs_ifork_ops *ops);
-xfs_failaddr_t xfs_ifork_verify_attr(struct xfs_vc *vc, struct xfs_inode *ip,
+bool xfs_ifork_verify_attr(struct xfs_vc *vc, struct xfs_inode *ip,
 		struct xfs_ifork_ops *ops);
 
 #endif	/* __XFS_INODE_FORK_H__ */
diff --git a/fs/xfs/libxfs/xfs_quota_defs.h b/fs/xfs/libxfs/xfs_quota_defs.h
index d6af05e0a6f1..fa26d21820bc 100644
--- a/fs/xfs/libxfs/xfs_quota_defs.h
+++ b/fs/xfs/libxfs/xfs_quota_defs.h
@@ -137,9 +137,9 @@ typedef uint16_t	xfs_qwarncnt_t;
 		(XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA)
 #define XFS_QMOPT_RESBLK_MASK	(XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS)
 
-extern xfs_failaddr_t xfs_dquot_verify(struct xfs_vc *vc, struct xfs_mount *mp,
+extern bool xfs_dquot_verify(struct xfs_vc *vc, struct xfs_mount *mp,
 		struct xfs_disk_dquot *ddq, xfs_dqid_t id, uint type);
-extern xfs_failaddr_t xfs_dqblk_verify(struct xfs_vc *vc, struct xfs_mount *mp,
+extern bool xfs_dqblk_verify(struct xfs_vc *vc, struct xfs_mount *mp,
 		struct xfs_dqblk *dqb, xfs_dqid_t id, uint type);
 extern int xfs_calc_dquots_per_chunk(unsigned int nbblks);
 extern int xfs_dqblk_repair(struct xfs_mount *mp, struct xfs_dqblk *dqb,
diff --git a/fs/xfs/libxfs/xfs_refcount_btree.c b/fs/xfs/libxfs/xfs_refcount_btree.c
index 409ae8c08380..4b4c80fd3d6c 100644
--- a/fs/xfs/libxfs/xfs_refcount_btree.c
+++ b/fs/xfs/libxfs/xfs_refcount_btree.c
@@ -201,7 +201,7 @@ xfs_refcountbt_diff_two_keys(
 			  be32_to_cpu(k2->refc.rc_startblock);
 }
 
-STATIC xfs_failaddr_t
+STATIC bool
 xfs_refcountbt_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
@@ -209,7 +209,6 @@ xfs_refcountbt_verify(
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_btree_block	*block = XFS_BUF_TO_BLOCK(bp);
 	struct xfs_perag	*pag = bp->b_pag;
-	xfs_failaddr_t		fa;
 	unsigned int		level;
 
 	if (block->bb_magic != cpu_to_be32(XFS_REFC_CRC_MAGIC))
@@ -217,9 +216,8 @@ xfs_refcountbt_verify(
 
 	if (!xfs_sb_version_hasreflink(&mp->m_sb))
 		return XFS_CORRUPTED_RETURN(vc);
-	fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
-	if (fa)
-		return fa;
+	if (!xfs_btree_sblock_v5hdr_verify(vc, bp))
+		return false;
 
 	level = be16_to_cpu(block->bb_level);
 	if (pag && pag->pagf_init) {
@@ -236,14 +234,11 @@ xfs_refcountbt_read_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	xfs_failaddr_t	fa;
-
 	if (!xfs_btree_sblock_verify_crc(vc, bp))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_refcountbt_verify(vc, bp);
-		if (fa)
-			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		if (!xfs_refcountbt_verify(vc, bp))
+			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 	}
 
 	if (bp->b_error)
@@ -255,12 +250,9 @@ xfs_refcountbt_write_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	xfs_failaddr_t	fa;
-
-	fa = xfs_refcountbt_verify(vc, bp);
-	if (fa) {
+	if (!xfs_refcountbt_verify(vc, bp)) {
 		trace_xfs_btree_corrupt(bp, _RET_IP_);
-		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 		return;
 	}
 	xfs_btree_sblock_calc_crc(bp);
diff --git a/fs/xfs/libxfs/xfs_rmap_btree.c b/fs/xfs/libxfs/xfs_rmap_btree.c
index e9265c8c1cea..ed0022fb03f6 100644
--- a/fs/xfs/libxfs/xfs_rmap_btree.c
+++ b/fs/xfs/libxfs/xfs_rmap_btree.c
@@ -288,7 +288,7 @@ xfs_rmapbt_diff_two_keys(
 	return 0;
 }
 
-static xfs_failaddr_t
+static bool
 xfs_rmapbt_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
@@ -296,7 +296,6 @@ xfs_rmapbt_verify(
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 	struct xfs_btree_block	*block = XFS_BUF_TO_BLOCK(bp);
 	struct xfs_perag	*pag = bp->b_pag;
-	xfs_failaddr_t		fa;
 	unsigned int		level;
 
 	/*
@@ -316,9 +315,8 @@ xfs_rmapbt_verify(
 
 	if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
 		return XFS_CORRUPTED_RETURN(vc);
-	fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
-	if (fa)
-		return fa;
+	if (!xfs_btree_sblock_v5hdr_verify(vc, bp))
+		return false;
 
 	level = be16_to_cpu(block->bb_level);
 	if (pag && pag->pagf_init) {
@@ -335,14 +333,11 @@ xfs_rmapbt_read_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	xfs_failaddr_t	fa;
-
 	if (!xfs_btree_sblock_verify_crc(vc, bp))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_rmapbt_verify(vc, bp);
-		if (fa)
-			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		if (!xfs_rmapbt_verify(vc, bp))
+			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 	}
 
 	if (bp->b_error)
@@ -354,12 +349,9 @@ xfs_rmapbt_write_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	xfs_failaddr_t	fa;
-
-	fa = xfs_rmapbt_verify(vc, bp);
-	if (fa) {
+	if (!xfs_rmapbt_verify(vc, bp)) {
 		trace_xfs_btree_corrupt(bp, _RET_IP_);
-		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 		return;
 	}
 	xfs_btree_sblock_calc_crc(bp);
diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h
index c10d02addaa1..984753b49639 100644
--- a/fs/xfs/libxfs/xfs_shared.h
+++ b/fs/xfs/libxfs/xfs_shared.h
@@ -132,6 +132,6 @@ bool xfs_symlink_hdr_ok(xfs_ino_t ino, uint32_t offset,
 			uint32_t size, struct xfs_buf *bp);
 void xfs_symlink_local_to_remote(struct xfs_trans *tp, struct xfs_buf *bp,
 				 struct xfs_inode *ip, struct xfs_ifork *ifp);
-xfs_failaddr_t xfs_symlink_shortform_verify(struct xfs_vc *vc, struct xfs_inode *ip);
+bool xfs_symlink_shortform_verify(struct xfs_vc *vc, struct xfs_inode *ip);
 
 #endif /* __XFS_SHARED_H__ */
diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c
index 9141a1635dac..401398d0235a 100644
--- a/fs/xfs/libxfs/xfs_symlink_remote.c
+++ b/fs/xfs/libxfs/xfs_symlink_remote.c
@@ -86,7 +86,7 @@ xfs_symlink_hdr_ok(
 	return true;
 }
 
-static xfs_failaddr_t
+static bool
 xfs_symlink_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
@@ -119,7 +119,6 @@ xfs_symlink_read_verify(
 	struct xfs_buf	*bp)
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
-	xfs_failaddr_t	fa;
 
 	/* no verification of non-crc buffers */
 	if (!xfs_sb_version_hascrc(&mp->m_sb))
@@ -128,9 +127,8 @@ xfs_symlink_read_verify(
 	if (!xfs_buf_verify_cksum(vc, bp, XFS_SYMLINK_CRC_OFF))
 		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
 	else {
-		fa = xfs_symlink_verify(vc, bp);
-		if (fa)
-			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+		if (!xfs_symlink_verify(vc, bp))
+			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 	}
 }
 
@@ -141,15 +139,13 @@ xfs_symlink_write_verify(
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
-	xfs_failaddr_t		fa;
 
 	/* no verification of non-crc buffers */
 	if (!xfs_sb_version_hascrc(&mp->m_sb))
 		return;
 
-	fa = xfs_symlink_verify(vc, bp);
-	if (fa) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+	if (!xfs_symlink_verify(vc, bp)) {
+		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
 		return;
 	}
 
@@ -203,7 +199,7 @@ xfs_symlink_local_to_remote(
 }
 
 /* Verify the consistency of an inline symlink. */
-xfs_failaddr_t
+bool
 xfs_symlink_shortform_verify(
 	struct xfs_vc		*vc,
 	struct xfs_inode	*ip)
diff --git a/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h
index d39c7e28ad00..29b0d354d9b7 100644
--- a/fs/xfs/libxfs/xfs_types.h
+++ b/fs/xfs/libxfs/xfs_types.h
@@ -45,8 +45,8 @@ struct xfs_vc {
 	xfs_failaddr_t	fa;
 };
 
-#define XFS_CORRUPTED_RETURN(vc) ({(vc)->fa = __this_address; __this_address;})
-#define XFS_VERIFIED_RETURN(vc) ({(vc)->fa = NULL; NULL;})
+#define XFS_CORRUPTED_RETURN(vc) ({(vc)->fa = __this_address; false;})
+#define XFS_VERIFIED_RETURN(vc) ({(vc)->fa = NULL; true;})
 
 /*
  * Null values for the types.
diff --git a/fs/xfs/scrub/btree.c b/fs/xfs/scrub/btree.c
index 8780dcb479de..a04824a992d3 100644
--- a/fs/xfs/scrub/btree.c
+++ b/fs/xfs/scrub/btree.c
@@ -491,7 +491,6 @@ xchk_btree_get_block(
 	struct xfs_buf		**pbp)
 {
 	struct xfs_vc		vc = { 0 };
-	xfs_failaddr_t		failed_at;
 	int			error;
 
 	*pblock = NULL;
@@ -503,16 +502,20 @@ xchk_btree_get_block(
 		return error;
 
 	xfs_btree_get_block(bs->cur, level, pbp);
-	if (bs->cur->bc_flags & XFS_BTREE_LONG_PTRS)
-		failed_at = __xfs_btree_check_lblock(&vc, bs->cur, *pblock,
-				level, *pbp);
-	else
-		failed_at = __xfs_btree_check_sblock(&vc, bs->cur, *pblock,
-				 level, *pbp);
-	if (failed_at) {
-		xchk_btree_set_corrupt(bs->sc, bs->cur, level);
-		return 0;
+	if (bs->cur->bc_flags & XFS_BTREE_LONG_PTRS) {
+		if (!__xfs_btree_check_lblock(&vc, bs->cur, *pblock,
+				level, *pbp)) {
+			xchk_btree_set_corrupt(bs->sc, bs->cur, level);
+			return 0;
+		}
+	} else {
+		if (!__xfs_btree_check_sblock(&vc, bs->cur, *pblock,
+				 level, *pbp)) {
+			xchk_btree_set_corrupt(bs->sc, bs->cur, level);
+			return 0;
+		}
 	}
+
 	if (*pbp)
 		xchk_buffer_recheck(bs->sc, *pbp);
 
diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c
index 1571e66e657a..2796add960b0 100644
--- a/fs/xfs/scrub/common.c
+++ b/fs/xfs/scrub/common.c
@@ -792,7 +792,6 @@ xchk_buffer_recheck(
 	struct xfs_buf		*bp)
 {
 	struct xfs_vc		vc = { 0 };
-	xfs_failaddr_t		fa;
 
 	if (bp->b_ops == NULL) {
 		xchk_block_set_corrupt(sc, bp);
@@ -802,11 +801,10 @@ xchk_buffer_recheck(
 		xchk_set_incomplete(sc);
 		return;
 	}
-	fa = bp->b_ops->verify_struct(&vc, bp);
-	if (!fa)
+	if (bp->b_ops->verify_struct(&vc, bp))
 		return;
 	sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
-	trace_xchk_block_error(sc, bp->b_bn, fa);
+	trace_xchk_block_error(sc, bp->b_bn, vc.fa);
 }
 
 /*
diff --git a/fs/xfs/scrub/dabtree.c b/fs/xfs/scrub/dabtree.c
index 4626a208d132..aacdb3b0b783 100644
--- a/fs/xfs/scrub/dabtree.c
+++ b/fs/xfs/scrub/dabtree.c
@@ -221,7 +221,7 @@ xchk_da_btree_write_verify(
 		return;
 	}
 }
-static void *
+static bool
 xchk_da_btree_verify(
 	struct xfs_vc		*vc,
 	struct xfs_buf		*bp)
diff --git a/fs/xfs/scrub/inode.c b/fs/xfs/scrub/inode.c
index f8c6869b8fc6..0159c554cb93 100644
--- a/fs/xfs/scrub/inode.c
+++ b/fs/xfs/scrub/inode.c
@@ -84,11 +84,9 @@ xchk_inode_extsize(
 	uint16_t		flags)
 {
 	struct xfs_vc		vc = { 0 };
-	xfs_failaddr_t		fa;
 
-	fa = xfs_inode_validate_extsize(&vc, sc->mp, be32_to_cpu(dip->di_extsize),
-			mode, flags);
-	if (fa)
+	if (!xfs_inode_validate_extsize(&vc, sc->mp, be32_to_cpu(dip->di_extsize),
+			mode, flags))
 		xchk_ino_set_corrupt(sc, ino);
 }
 
@@ -108,12 +106,10 @@ xchk_inode_cowextsize(
 	uint64_t		flags2)
 {
 	struct xfs_vc		vc = { 0 };
-	xfs_failaddr_t		fa;
 
-	fa = xfs_inode_validate_cowextsize(&vc, sc->mp,
+	if (!xfs_inode_validate_cowextsize(&vc, sc->mp,
 			be32_to_cpu(dip->di_cowextsize), mode, flags,
-			flags2);
-	if (fa)
+			flags2))
 		xchk_ino_set_corrupt(sc, ino);
 }
 
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index e7e1e070f76e..fb85973ea7ca 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -127,7 +127,7 @@ struct xfs_buf_ops {
 	char *name;
 	void (*verify_read)(struct xfs_vc *vc, struct xfs_buf *);
 	void (*verify_write)(struct xfs_vc *vc, struct xfs_buf *);
-	xfs_failaddr_t (*verify_struct)(struct xfs_vc *vc, struct xfs_buf *bp);
+	bool (*verify_struct)(struct xfs_vc *vc, struct xfs_buf *bp);
 };
 
 typedef struct xfs_buf {
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 14b386c584b6..a780263c5616 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -1075,7 +1075,6 @@ xfs_qm_dqflush(
 	struct xfs_dqblk	*dqb;
 	struct xfs_disk_dquot	*ddqp;
 	struct xfs_vc		vc = { 0 };
-	xfs_failaddr_t		fa;
 	int			error;
 
 	ASSERT(XFS_DQ_IS_LOCKED(dqp));
@@ -1123,10 +1122,9 @@ xfs_qm_dqflush(
 	/*
 	 * A simple sanity check in case we got a corrupted dquot.
 	 */
-	fa = xfs_dqblk_verify(&vc, mp, dqb, be32_to_cpu(ddqp->d_id), 0);
-	if (fa) {
+	if (!xfs_dqblk_verify(&vc, mp, dqb, be32_to_cpu(ddqp->d_id), 0)) {
 		xfs_alert(mp, "corrupt dquot ID 0x%x in memory at %pS",
-				be32_to_cpu(ddqp->d_id), fa);
+				be32_to_cpu(ddqp->d_id), vc.fa);
 		xfs_buf_relse(bp);
 		xfs_dqfunlock(dqp);
 		xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index d2fd4d4b7864..007bb1926d56 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -3417,22 +3417,19 @@ xfs_inode_verify_forks(
 {
 	struct xfs_ifork	*ifp;
 	struct xfs_vc		vc = { 0 };
-	xfs_failaddr_t		fa;
 
-	fa = xfs_ifork_verify_data(&vc, ip, &xfs_default_ifork_ops);
-	if (fa) {
+	if (!xfs_ifork_verify_data(&vc, ip, &xfs_default_ifork_ops)) {
 		ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
 		xfs_inode_verifier_error(ip, -EFSCORRUPTED, "data fork",
-				ifp->if_u1.if_data, ifp->if_bytes, fa);
+				ifp->if_u1.if_data, ifp->if_bytes, vc.fa);
 		return false;
 	}
 
-	fa = xfs_ifork_verify_attr(&vc, ip, &xfs_default_ifork_ops);
-	if (fa) {
+	if (!xfs_ifork_verify_attr(&vc, ip, &xfs_default_ifork_ops)) {
 		ifp = XFS_IFORK_PTR(ip, XFS_ATTR_FORK);
 		xfs_inode_verifier_error(ip, -EFSCORRUPTED, "attr fork",
 				ifp ? ifp->if_u1.if_data : NULL,
-				ifp ? ifp->if_bytes : 0, fa);
+				ifp ? ifp->if_bytes : 0, vc.fa);
 		return false;
 	}
 	return true;
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index bcafd3961d20..8262b5edbfd9 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2651,7 +2651,6 @@ xlog_recover_do_reg_buffer(
 	int			bit;
 	int			nbits;
 	struct xfs_vc		vc = { 0 };
-	xfs_failaddr_t		fa;
 
 	trace_xfs_log_recover_buf_reg_buf(mp->m_log, buf_f);
 
@@ -2686,7 +2685,6 @@ xlog_recover_do_reg_buffer(
 		 * the first dquot in the buffer should do. XXXThis is
 		 * probably a good thing to do for other buf types also.
 		 */
-		fa = NULL;
 		if (buf_f->blf_flags &
 		   (XFS_BLF_UDQUOT_BUF|XFS_BLF_PDQUOT_BUF|XFS_BLF_GDQUOT_BUF)) {
 			if (item->ri_buf[i].i_addr == NULL) {
@@ -2700,12 +2698,11 @@ xlog_recover_do_reg_buffer(
 					item->ri_buf[i].i_len, __func__);
 				goto next;
 			}
-			fa = xfs_dquot_verify(&vc, mp, item->ri_buf[i].i_addr,
-					       -1, 0);
-			if (fa) {
+			if (!xfs_dquot_verify(&vc, mp, item->ri_buf[i].i_addr,
+					       -1, 0)) {
 				xfs_alert(mp,
 	"dquot corrupt at %pS trying to replay into block 0x%llx",
-					fa, bp->b_bn);
+					vc.fa, bp->b_bn);
 				goto next;
 			}
 		}
@@ -3310,12 +3307,10 @@ xlog_recover_dquot_pass2(
 	xfs_buf_t		*bp;
 	struct xfs_disk_dquot	*ddq, *recddq;
 	struct xfs_vc		vc = { 0 };
-	xfs_failaddr_t		fa;
 	int			error;
 	xfs_dq_logformat_t	*dq_f;
 	uint			type;
 
-
 	/*
 	 * Filesystems are required to send in quota flags at mount time.
 	 */
@@ -3353,10 +3348,9 @@ xlog_recover_dquot_pass2(
 	 */
 	dq_f = item->ri_buf[0].i_addr;
 	ASSERT(dq_f);
-	fa = xfs_dquot_verify(&vc, mp, recddq, dq_f->qlf_id, 0);
-	if (fa) {
+	if (!xfs_dquot_verify(&vc, mp, recddq, dq_f->qlf_id, 0)) {
 		xfs_alert(mp, "corrupt dquot ID 0x%x in log at %pS",
-				dq_f->qlf_id, fa);
+				dq_f->qlf_id, vc.fa);
 		return -EIO;
 	}
 	ASSERT(dq_f->qlf_len == 1);
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 09cd6e971074..b61b21599157 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -834,7 +834,6 @@ xfs_qm_reset_dqcounts(
 	struct xfs_dqblk	*dqb;
 	int			j;
 	struct xfs_vc		vc = { 0 };
-	xfs_failaddr_t		fa;
 
 	trace_xfs_reset_dqcounts(bp, _RET_IP_);
 
@@ -859,8 +858,7 @@ xfs_qm_reset_dqcounts(
 		 * find uninitialised dquot blks. See comment in
 		 * xfs_dquot_verify.
 		 */
-		fa = xfs_dqblk_verify(&vc, mp, &dqb[j], id + j, type);
-		if (fa)
+		if (!xfs_dqblk_verify(&vc, mp, &dqb[j], id + j, type))
 			xfs_dqblk_repair(mp, &dqb[j], id + j, type);
 
 		/*
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 08/10] xfs: set failaddr into vc for checksum failures
  2018-12-05 21:01 [PATCH RFC 0/10] xfs: add verifier context structure Eric Sandeen
                   ` (6 preceding siblings ...)
  2018-12-05 21:08 ` [PATCH 07/10] xfs: change all verifiers to return booleans Eric Sandeen
@ 2018-12-05 21:09 ` Eric Sandeen
  2018-12-07 13:37   ` Brian Foster
  2018-12-05 21:11 ` [PATCH 09/10] xfs: add errno to verifier context and populate it Eric Sandeen
  2018-12-05 21:11 ` [PATCH 10/10] xfs: condense crc and verifier checks where possible Eric Sandeen
  9 siblings, 1 reply; 20+ messages in thread
From: Eric Sandeen @ 2018-12-05 21:09 UTC (permalink / raw)
  To: Eric Sandeen, linux-xfs

Modify CRC checking functions to set __this_address into the
verifier context failaddr vc->fa using new macro XFS_BADCRC_RETURN,
and pass that to failure handlers as well.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 fs/xfs/libxfs/xfs_alloc.c          |  4 ++--
 fs/xfs/libxfs/xfs_alloc_btree.c    |  2 +-
 fs/xfs/libxfs/xfs_attr_leaf.c      |  2 +-
 fs/xfs/libxfs/xfs_bmap_btree.c     |  2 +-
 fs/xfs/libxfs/xfs_cksum.h          |  5 ++++-
 fs/xfs/libxfs/xfs_da_btree.c       |  3 +--
 fs/xfs/libxfs/xfs_dir2_block.c     |  2 +-
 fs/xfs/libxfs/xfs_dir2_data.c      |  2 +-
 fs/xfs/libxfs/xfs_dir2_leaf.c      |  2 +-
 fs/xfs/libxfs/xfs_dir2_node.c      |  2 +-
 fs/xfs/libxfs/xfs_ialloc.c         |  2 +-
 fs/xfs/libxfs/xfs_ialloc_btree.c   |  2 +-
 fs/xfs/libxfs/xfs_refcount_btree.c |  2 +-
 fs/xfs/libxfs/xfs_rmap_btree.c     |  2 +-
 fs/xfs/libxfs/xfs_symlink_remote.c |  2 +-
 fs/xfs/libxfs/xfs_types.h          | 12 ++++++++++--
 fs/xfs/xfs_linux.h                 |  7 -------
 17 files changed, 29 insertions(+), 26 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index b9e3c69490eb..14611b12220a 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -610,7 +610,7 @@ xfs_agfl_read_verify(
 		return;
 
 	if (!xfs_buf_verify_cksum(vc, bp, XFS_AGFL_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
 	else {
 		if (!xfs_agfl_verify(vc, bp))
 			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
@@ -2637,7 +2637,7 @@ xfs_agf_read_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	    !xfs_buf_verify_cksum(vc, bp, XFS_AGF_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
 	else {
 		if (XFS_TEST_ERROR(!xfs_agf_verify(vc, bp),
 				   mp, XFS_ERRTAG_ALLOC_READ_AGF))
diff --git a/fs/xfs/libxfs/xfs_alloc_btree.c b/fs/xfs/libxfs/xfs_alloc_btree.c
index 87d96e66d4ca..40040505794a 100644
--- a/fs/xfs/libxfs/xfs_alloc_btree.c
+++ b/fs/xfs/libxfs/xfs_alloc_btree.c
@@ -347,7 +347,7 @@ xfs_allocbt_read_verify(
 	struct xfs_buf	*bp)
 {
 	if (!xfs_btree_sblock_verify_crc(vc, bp))
-		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
 	else {
 		if (!xfs_allocbt_verify(vc, bp))
 			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index 724b13f61da6..a69ff26a4558 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -359,7 +359,7 @@ xfs_attr3_leaf_read_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	     !xfs_buf_verify_cksum(vc, bp, XFS_ATTR3_LEAF_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
 	else {
 		if (!xfs_attr3_leaf_verify(vc, bp))
 			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index fc4ea15ca6c1..485b207f715f 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -451,7 +451,7 @@ xfs_bmbt_read_verify(
 	struct xfs_buf	*bp)
 {
 	if (!xfs_btree_lblock_verify_crc(vc, bp))
-		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
 	else {
 		if (!xfs_bmbt_verify(vc, bp))
 			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
diff --git a/fs/xfs/libxfs/xfs_cksum.h b/fs/xfs/libxfs/xfs_cksum.h
index 888ef9ec4c57..ea4a2474e64b 100644
--- a/fs/xfs/libxfs/xfs_cksum.h
+++ b/fs/xfs/libxfs/xfs_cksum.h
@@ -77,7 +77,10 @@ xfs_verify_cksum(struct xfs_vc *vc, char *buffer, size_t length,
 {
 	uint32_t crc = xfs_start_cksum_safe(buffer, length, cksum_offset);
 
-	return *(__le32 *)(buffer + cksum_offset) == xfs_end_cksum(crc);
+	if (*(__le32 *)(buffer + cksum_offset) != xfs_end_cksum(crc))
+		return XFS_BADCRC_RETURN(vc);
+
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 #endif /* _XFS_CKSUM_H */
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 0b4f084766e3..b26ae562c8c7 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -205,8 +205,7 @@ xfs_da3_node_read_verify(
 	switch (be16_to_cpu(info->magic)) {
 		case XFS_DA3_NODE_MAGIC:
 			if (!xfs_buf_verify_cksum(vc, bp, XFS_DA3_NODE_CRC_OFF)) {
-				xfs_verifier_error(bp, -EFSBADCRC,
-						__this_address);
+				xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
 				break;
 			}
 			/* fall through */
diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
index 534d5fcf13b3..4f0cd0dbc564 100644
--- a/fs/xfs/libxfs/xfs_dir2_block.c
+++ b/fs/xfs/libxfs/xfs_dir2_block.c
@@ -79,7 +79,7 @@ xfs_dir3_block_read_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	     !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_DATA_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
 	else {
 		if (!xfs_dir3_block_verify(vc, bp))
 			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
index a215c7adb480..ad78bfd5eea6 100644
--- a/fs/xfs/libxfs/xfs_dir2_data.c
+++ b/fs/xfs/libxfs/xfs_dir2_data.c
@@ -305,7 +305,7 @@ xfs_dir3_data_read_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	    !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_DATA_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
 	else {
 		if (!xfs_dir3_data_verify(vc, bp))
 			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
index e757e1f950e4..ad1af1eeda53 100644
--- a/fs/xfs/libxfs/xfs_dir2_leaf.c
+++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
@@ -185,7 +185,7 @@ __read_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	     !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_LEAF_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
 	else {
 		if (!xfs_dir3_leaf_verify(vc, bp, magic))
 			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index 8105544c44fb..784534734485 100644
--- a/fs/xfs/libxfs/xfs_dir2_node.c
+++ b/fs/xfs/libxfs/xfs_dir2_node.c
@@ -118,7 +118,7 @@ xfs_dir3_free_read_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	    !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_FREE_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
 	else {
 		if (!xfs_dir3_free_verify(vc, bp))
 			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 32fb58c929f0..71745ec0d92f 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -2557,7 +2557,7 @@ xfs_agi_read_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	    !xfs_buf_verify_cksum(vc, bp, XFS_AGI_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
 	else {
 		if (XFS_TEST_ERROR(!xfs_agi_verify(vc, bp),
 				   mp, XFS_ERRTAG_IALLOC_READ_AGI))
diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
index 30a1fcf24767..a0bb695944e9 100644
--- a/fs/xfs/libxfs/xfs_ialloc_btree.c
+++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
@@ -300,7 +300,7 @@ xfs_inobt_read_verify(
 	struct xfs_buf	*bp)
 {
 	if (!xfs_btree_sblock_verify_crc(vc, bp))
-		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
 	else {
 		if (!xfs_inobt_verify(vc, bp))
 			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
diff --git a/fs/xfs/libxfs/xfs_refcount_btree.c b/fs/xfs/libxfs/xfs_refcount_btree.c
index 4b4c80fd3d6c..748074c5ebeb 100644
--- a/fs/xfs/libxfs/xfs_refcount_btree.c
+++ b/fs/xfs/libxfs/xfs_refcount_btree.c
@@ -235,7 +235,7 @@ xfs_refcountbt_read_verify(
 	struct xfs_buf	*bp)
 {
 	if (!xfs_btree_sblock_verify_crc(vc, bp))
-		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
 	else {
 		if (!xfs_refcountbt_verify(vc, bp))
 			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
diff --git a/fs/xfs/libxfs/xfs_rmap_btree.c b/fs/xfs/libxfs/xfs_rmap_btree.c
index ed0022fb03f6..6d2eba7b44bc 100644
--- a/fs/xfs/libxfs/xfs_rmap_btree.c
+++ b/fs/xfs/libxfs/xfs_rmap_btree.c
@@ -334,7 +334,7 @@ xfs_rmapbt_read_verify(
 	struct xfs_buf	*bp)
 {
 	if (!xfs_btree_sblock_verify_crc(vc, bp))
-		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
 	else {
 		if (!xfs_rmapbt_verify(vc, bp))
 			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c
index 401398d0235a..d6516068bbe7 100644
--- a/fs/xfs/libxfs/xfs_symlink_remote.c
+++ b/fs/xfs/libxfs/xfs_symlink_remote.c
@@ -125,7 +125,7 @@ xfs_symlink_read_verify(
 		return;
 
 	if (!xfs_buf_verify_cksum(vc, bp, XFS_SYMLINK_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
 	else {
 		if (!xfs_symlink_verify(vc, bp))
 			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
diff --git a/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h
index 29b0d354d9b7..ab045e8dfcb9 100644
--- a/fs/xfs/libxfs/xfs_types.h
+++ b/fs/xfs/libxfs/xfs_types.h
@@ -45,8 +45,16 @@ struct xfs_vc {
 	xfs_failaddr_t	fa;
 };
 
-#define XFS_CORRUPTED_RETURN(vc) ({(vc)->fa = __this_address; false;})
-#define XFS_VERIFIED_RETURN(vc) ({(vc)->fa = NULL; true;})
+/*
+ * Return the address of a label.  Use barrier() so that the optimizer
+ * won't reorder code to refactor the error jumpouts into a single
+ * return, which throws off the reported address.
+ */
+#define __this_address ({ __label__ __here; __here: barrier(); &&__here; })
+ 
+#define XFS_CORRUPTED_RETURN(vc)	({(vc)->fa = __this_address; false;})
+#define XFS_BADCRC_RETURN(vc)		({(vc)->fa = __this_address; false;})
+#define XFS_VERIFIED_RETURN(vc)		({(vc)->fa = NULL; true;})
 
 /*
  * Null values for the types.
diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
index edbd5a210df2..4141e70bb3fa 100644
--- a/fs/xfs/xfs_linux.h
+++ b/fs/xfs/xfs_linux.h
@@ -131,13 +131,6 @@ typedef __u32			xfs_nlink_t;
 #define SYNCHRONIZE()	barrier()
 #define __return_address __builtin_return_address(0)
 
-/*
- * Return the address of a label.  Use barrier() so that the optimizer
- * won't reorder code to refactor the error jumpouts into a single
- * return, which throws off the reported address.
- */
-#define __this_address	({ __label__ __here; __here: barrier(); &&__here; })
-
 #define XFS_PROJID_DEFAULT	0
 
 #define howmany(x, y)	(((x)+((y)-1))/(y))
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 09/10] xfs: add errno to verifier context and populate it
  2018-12-05 21:01 [PATCH RFC 0/10] xfs: add verifier context structure Eric Sandeen
                   ` (7 preceding siblings ...)
  2018-12-05 21:09 ` [PATCH 08/10] xfs: set failaddr into vc for checksum failures Eric Sandeen
@ 2018-12-05 21:11 ` Eric Sandeen
  2018-12-07 13:41   ` Brian Foster
  2018-12-05 21:11 ` [PATCH 10/10] xfs: condense crc and verifier checks where possible Eric Sandeen
  9 siblings, 1 reply; 20+ messages in thread
From: Eric Sandeen @ 2018-12-05 21:11 UTC (permalink / raw)
  To: Eric Sandeen, linux-xfs

Add errno to verifier context and set it on verifier failures;
now rather than passing errno and vc->fa to xfs_verifier_error,
we pass vc directly and let xfs_verifier_error suss out the
errno and failaddr.

Also make 3 new macros, XFS_CORRUPTED, XFS_BADCRC, and
XFS_VERIFIED which set errno and failaddr into the verifier context
without returning.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 fs/xfs/libxfs/xfs_alloc.c          | 12 ++++----
 fs/xfs/libxfs/xfs_alloc_btree.c    |  6 ++--
 fs/xfs/libxfs/xfs_attr_leaf.c      |  6 ++--
 fs/xfs/libxfs/xfs_attr_remote.c    | 49 ++++++++++++------------------
 fs/xfs/libxfs/xfs_bmap_btree.c     |  6 ++--
 fs/xfs/libxfs/xfs_da_btree.c       |  9 +++---
 fs/xfs/libxfs/xfs_dir2_block.c     |  6 ++--
 fs/xfs/libxfs/xfs_dir2_data.c      |  9 +++---
 fs/xfs/libxfs/xfs_dir2_leaf.c      |  6 ++--
 fs/xfs/libxfs/xfs_dir2_node.c      |  8 ++---
 fs/xfs/libxfs/xfs_ialloc.c         |  6 ++--
 fs/xfs/libxfs/xfs_ialloc_btree.c   |  6 ++--
 fs/xfs/libxfs/xfs_refcount_btree.c |  6 ++--
 fs/xfs/libxfs/xfs_rmap_btree.c     |  6 ++--
 fs/xfs/libxfs/xfs_sb.c             | 14 ++++++---
 fs/xfs/libxfs/xfs_symlink_remote.c |  6 ++--
 fs/xfs/libxfs/xfs_types.h          | 16 ++++++++--
 fs/xfs/xfs_error.c                 |  7 ++---
 fs/xfs/xfs_error.h                 |  3 +-
 19 files changed, 96 insertions(+), 91 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 14611b12220a..213a3078113c 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -610,10 +610,10 @@ xfs_agfl_read_verify(
 		return;
 
 	if (!xfs_buf_verify_cksum(vc, bp, XFS_AGFL_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
+		xfs_verifier_error(bp, vc);
 	else {
 		if (!xfs_agfl_verify(vc, bp))
-			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+			xfs_verifier_error(bp, vc);
 	}
 }
 
@@ -630,7 +630,7 @@ xfs_agfl_write_verify(
 		return;
 
 	if (!xfs_agfl_verify(vc, bp)) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+		xfs_verifier_error(bp, vc);
 		return;
 	}
 
@@ -2637,11 +2637,11 @@ xfs_agf_read_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	    !xfs_buf_verify_cksum(vc, bp, XFS_AGF_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
+		xfs_verifier_error(bp, vc);
 	else {
 		if (XFS_TEST_ERROR(!xfs_agf_verify(vc, bp),
 				   mp, XFS_ERRTAG_ALLOC_READ_AGF))
-			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+			xfs_verifier_error(bp, vc);
 	}
 }
 
@@ -2654,7 +2654,7 @@ xfs_agf_write_verify(
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
 
 	if (!xfs_agf_verify(vc, bp)) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+		xfs_verifier_error(bp, vc);
 		return;
 	}
 
diff --git a/fs/xfs/libxfs/xfs_alloc_btree.c b/fs/xfs/libxfs/xfs_alloc_btree.c
index 40040505794a..9f56821b49af 100644
--- a/fs/xfs/libxfs/xfs_alloc_btree.c
+++ b/fs/xfs/libxfs/xfs_alloc_btree.c
@@ -347,10 +347,10 @@ xfs_allocbt_read_verify(
 	struct xfs_buf	*bp)
 {
 	if (!xfs_btree_sblock_verify_crc(vc, bp))
-		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
+		xfs_verifier_error(bp, vc);
 	else {
 		if (!xfs_allocbt_verify(vc, bp))
-			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+			xfs_verifier_error(bp, vc);
 	}
 
 	if (bp->b_error)
@@ -364,7 +364,7 @@ xfs_allocbt_write_verify(
 {
 	if (!xfs_allocbt_verify(vc, bp)) {
 		trace_xfs_btree_corrupt(bp, _RET_IP_);
-		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+		xfs_verifier_error(bp, vc);
 		return;
 	}
 	xfs_btree_sblock_calc_crc(bp);
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index a69ff26a4558..34958aa7fe5f 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -331,7 +331,7 @@ xfs_attr3_leaf_write_verify(
 	struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr;
 
 	if (!xfs_attr3_leaf_verify(vc, bp)) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+		xfs_verifier_error(bp, vc);
 		return;
 	}
 
@@ -359,10 +359,10 @@ xfs_attr3_leaf_read_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	     !xfs_buf_verify_cksum(vc, bp, XFS_ATTR3_LEAF_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
+		xfs_verifier_error(bp, vc);
 	else {
 		if (!xfs_attr3_leaf_verify(vc, bp))
-			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+			xfs_verifier_error(bp, vc);
 	}
 }
 
diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index 9987330424e9..8c29745afa5c 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -105,12 +105,11 @@ xfs_attr3_rmt_verify(
 	return XFS_VERIFIED_RETURN(vc);
 }
 
-static int
+static bool
 __xfs_attr3_rmt_read_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp,
-	bool		check_crc,
-	xfs_failaddr_t	*failaddr)
+	bool		check_crc)
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
 	char		*ptr;
@@ -120,7 +119,7 @@ __xfs_attr3_rmt_read_verify(
 
 	/* no verification of non-crc buffers */
 	if (!xfs_sb_version_hascrc(&mp->m_sb))
-		return 0;
+		return XFS_VERIFIED_RETURN(vc);
 
 	ptr = bp->b_addr;
 	bno = bp->b_bn;
@@ -130,24 +129,19 @@ __xfs_attr3_rmt_read_verify(
 	while (len > 0) {
 		if (check_crc &&
 		    !xfs_verify_cksum(vc, ptr, blksize, XFS_ATTR3_RMT_CRC_OFF)) {
-			*failaddr = __this_address;
-			return -EFSBADCRC;
-		}
-		if (!xfs_attr3_rmt_verify(vc, mp, ptr, blksize, bno)) {
-			*failaddr = vc->fa;
-			return -EFSCORRUPTED;
+			return XFS_BADCRC_RETURN(vc);
 		}
+		if (!xfs_attr3_rmt_verify(vc, mp, ptr, blksize, bno))
+			return XFS_CORRUPTED_RETURN(vc);
 		len -= blksize;
 		ptr += blksize;
 		bno += BTOBB(blksize);
 	}
 
-	if (len != 0) {
-		*failaddr = __this_address;
-		return -EFSCORRUPTED;
-	}
+	if (len != 0)
+		return XFS_CORRUPTED_RETURN(vc);
 
-	return 0;
+	return XFS_VERIFIED_RETURN(vc);
 }
 
 static void
@@ -155,12 +149,8 @@ xfs_attr3_rmt_read_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	xfs_failaddr_t	fa;
-	int		error;
-
-	error = __xfs_attr3_rmt_read_verify(vc, bp, true, &fa);
-	if (error)
-		xfs_verifier_error(bp, error, fa);
+	if (!__xfs_attr3_rmt_read_verify(vc, bp, true))
+		xfs_verifier_error(bp, vc);
 }
 
 static bool
@@ -168,11 +158,7 @@ xfs_attr3_rmt_verify_struct(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	xfs_failaddr_t	fa;
-	int		error;
-
-	error = __xfs_attr3_rmt_read_verify(vc, bp, false, &fa);
-	return error ? fa : NULL;
+	return __xfs_attr3_rmt_read_verify(vc, bp, false);
 }
 
 static void
@@ -199,7 +185,7 @@ xfs_attr3_rmt_write_verify(
 		struct xfs_attr3_rmt_hdr *rmt = (struct xfs_attr3_rmt_hdr *)ptr;
 
 		if (!xfs_attr3_rmt_verify(vc, mp, ptr, blksize, bno)) {
-			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+			xfs_verifier_error(bp, vc);
 			return;
 		}
 
@@ -208,7 +194,8 @@ xfs_attr3_rmt_write_verify(
 		 * xfs_attr3_rmt_hdr_set() for the explanation.
 		 */
 		if (rmt->rm_lsn != cpu_to_be64(NULLCOMMITLSN)) {
-			xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
+			XFS_CORRUPTED(vc);
+			xfs_verifier_error(bp, vc);
 			return;
 		}
 		xfs_update_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF);
@@ -218,8 +205,10 @@ xfs_attr3_rmt_write_verify(
 		bno += BTOBB(blksize);
 	}
 
-	if (len != 0)
-		xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
+	if (len != 0) {
+		XFS_CORRUPTED(vc);
+		xfs_verifier_error(bp, vc);
+	}
 }
 
 const struct xfs_buf_ops xfs_attr3_rmt_buf_ops = {
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
index 485b207f715f..44c98c35dd3a 100644
--- a/fs/xfs/libxfs/xfs_bmap_btree.c
+++ b/fs/xfs/libxfs/xfs_bmap_btree.c
@@ -451,10 +451,10 @@ xfs_bmbt_read_verify(
 	struct xfs_buf	*bp)
 {
 	if (!xfs_btree_lblock_verify_crc(vc, bp))
-		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
+		xfs_verifier_error(bp, vc);
 	else {
 		if (!xfs_bmbt_verify(vc, bp))
-			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+			xfs_verifier_error(bp, vc);
 	}
 
 	if (bp->b_error)
@@ -468,7 +468,7 @@ xfs_bmbt_write_verify(
 {
 	if (!xfs_bmbt_verify(vc, bp)) {
 		trace_xfs_btree_corrupt(bp, _RET_IP_);
-		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+		xfs_verifier_error(bp, vc);
 		return;
 	}
 	xfs_btree_lblock_calc_crc(bp);
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index b26ae562c8c7..a800dbbd5c88 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -176,7 +176,7 @@ xfs_da3_node_write_verify(
 	struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
 
 	if (!xfs_da3_node_verify(vc, bp)) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+		xfs_verifier_error(bp, vc);
 		return;
 	}
 
@@ -205,13 +205,13 @@ xfs_da3_node_read_verify(
 	switch (be16_to_cpu(info->magic)) {
 		case XFS_DA3_NODE_MAGIC:
 			if (!xfs_buf_verify_cksum(vc, bp, XFS_DA3_NODE_CRC_OFF)) {
-				xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
+				xfs_verifier_error(bp, vc);
 				break;
 			}
 			/* fall through */
 		case XFS_DA_NODE_MAGIC:
 			if (!xfs_da3_node_verify(vc, bp))
-				xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+				xfs_verifier_error(bp, vc);
 			return;
 		case XFS_ATTR_LEAF_MAGIC:
 		case XFS_ATTR3_LEAF_MAGIC:
@@ -224,7 +224,8 @@ xfs_da3_node_read_verify(
 			bp->b_ops->verify_read(vc, bp);
 			return;
 		default:
-			xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
+			XFS_CORRUPTED(vc);
+			xfs_verifier_error(bp, vc);
 			break;
 	}
 }
diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
index 4f0cd0dbc564..46db4a7269d8 100644
--- a/fs/xfs/libxfs/xfs_dir2_block.c
+++ b/fs/xfs/libxfs/xfs_dir2_block.c
@@ -79,10 +79,10 @@ xfs_dir3_block_read_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	     !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_DATA_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
+		xfs_verifier_error(bp, vc);
 	else {
 		if (!xfs_dir3_block_verify(vc, bp))
-			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+			xfs_verifier_error(bp, vc);
 	}
 }
 
@@ -96,7 +96,7 @@ xfs_dir3_block_write_verify(
 	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;
 
 	if (!xfs_dir3_block_verify(vc, bp)) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+		xfs_verifier_error(bp, vc);
 		return;
 	}
 
diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
index ad78bfd5eea6..9904571a76d0 100644
--- a/fs/xfs/libxfs/xfs_dir2_data.c
+++ b/fs/xfs/libxfs/xfs_dir2_data.c
@@ -291,7 +291,8 @@ xfs_dir3_data_reada_verify(
 		bp->b_ops->verify_read(vc, bp);
 		return;
 	default:
-		xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
+		XFS_CORRUPTED(vc);
+		xfs_verifier_error(bp, vc);
 		break;
 	}
 }
@@ -305,10 +306,10 @@ xfs_dir3_data_read_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	    !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_DATA_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
+		xfs_verifier_error(bp, vc);
 	else {
 		if (!xfs_dir3_data_verify(vc, bp))
-			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+			xfs_verifier_error(bp, vc);
 	}
 }
 
@@ -322,7 +323,7 @@ xfs_dir3_data_write_verify(
 	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;
 
 	if (!xfs_dir3_data_verify(vc, bp)) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+		xfs_verifier_error(bp, vc);
 		return;
 	}
 
diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
index ad1af1eeda53..aa423cd57bd7 100644
--- a/fs/xfs/libxfs/xfs_dir2_leaf.c
+++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
@@ -185,10 +185,10 @@ __read_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	     !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_LEAF_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
+		xfs_verifier_error(bp, vc);
 	else {
 		if (!xfs_dir3_leaf_verify(vc, bp, magic))
-			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+			xfs_verifier_error(bp, vc);
 	}
 }
 
@@ -203,7 +203,7 @@ __write_verify(
 	struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr;
 
 	if (!xfs_dir3_leaf_verify(vc, bp, magic)) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+		xfs_verifier_error(bp, vc);
 		return;
 	}
 
diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index 784534734485..8a78233bff9d 100644
--- a/fs/xfs/libxfs/xfs_dir2_node.c
+++ b/fs/xfs/libxfs/xfs_dir2_node.c
@@ -118,10 +118,10 @@ xfs_dir3_free_read_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	    !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_FREE_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
+		xfs_verifier_error(bp, vc);
 	else {
 		if (!xfs_dir3_free_verify(vc, bp))
-			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+			xfs_verifier_error(bp, vc);
 	}
 }
 
@@ -135,7 +135,7 @@ xfs_dir3_free_write_verify(
 	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;
 
 	if (!xfs_dir3_free_verify(vc, bp)) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+		xfs_verifier_error(bp, vc);
 		return;
 	}
 
@@ -211,7 +211,7 @@ __xfs_dir3_free_read(
 
 	/* Check things that we can't do in the verifier. */
 	if (!xfs_dir3_free_header_check(&vc, dp, fbno, *bpp)) {
-		xfs_verifier_error(*bpp, -EFSCORRUPTED, vc.fa);
+		xfs_verifier_error(*bpp, &vc);
 		xfs_trans_brelse(tp, *bpp);
 		return -EFSCORRUPTED;
 	}
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 71745ec0d92f..99df9cb8161e 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -2557,11 +2557,11 @@ xfs_agi_read_verify(
 
 	if (xfs_sb_version_hascrc(&mp->m_sb) &&
 	    !xfs_buf_verify_cksum(vc, bp, XFS_AGI_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
+		xfs_verifier_error(bp, vc);
 	else {
 		if (XFS_TEST_ERROR(!xfs_agi_verify(vc, bp),
 				   mp, XFS_ERRTAG_IALLOC_READ_AGI))
-			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+			xfs_verifier_error(bp, vc);
 	}
 }
 
@@ -2574,7 +2574,7 @@ xfs_agi_write_verify(
 	struct xfs_buf_log_item	*bip = bp->b_log_item;
 
 	if (!xfs_agi_verify(vc, bp)) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+		xfs_verifier_error(bp, vc);
 		return;
 	}
 
diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
index a0bb695944e9..e1d5551aa57d 100644
--- a/fs/xfs/libxfs/xfs_ialloc_btree.c
+++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
@@ -300,10 +300,10 @@ xfs_inobt_read_verify(
 	struct xfs_buf	*bp)
 {
 	if (!xfs_btree_sblock_verify_crc(vc, bp))
-		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
+		xfs_verifier_error(bp, vc);
 	else {
 		if (!xfs_inobt_verify(vc, bp))
-			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+			xfs_verifier_error(bp, vc);
 	}
 
 	if (bp->b_error)
@@ -317,7 +317,7 @@ xfs_inobt_write_verify(
 {
 	if (!xfs_inobt_verify(vc, bp)) {
 		trace_xfs_btree_corrupt(bp, _RET_IP_);
-		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+		xfs_verifier_error(bp, vc);
 		return;
 	}
 	xfs_btree_sblock_calc_crc(bp);
diff --git a/fs/xfs/libxfs/xfs_refcount_btree.c b/fs/xfs/libxfs/xfs_refcount_btree.c
index 748074c5ebeb..de921233202d 100644
--- a/fs/xfs/libxfs/xfs_refcount_btree.c
+++ b/fs/xfs/libxfs/xfs_refcount_btree.c
@@ -235,10 +235,10 @@ xfs_refcountbt_read_verify(
 	struct xfs_buf	*bp)
 {
 	if (!xfs_btree_sblock_verify_crc(vc, bp))
-		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
+		xfs_verifier_error(bp, vc);
 	else {
 		if (!xfs_refcountbt_verify(vc, bp))
-			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+			xfs_verifier_error(bp, vc);
 	}
 
 	if (bp->b_error)
@@ -252,7 +252,7 @@ xfs_refcountbt_write_verify(
 {
 	if (!xfs_refcountbt_verify(vc, bp)) {
 		trace_xfs_btree_corrupt(bp, _RET_IP_);
-		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+		xfs_verifier_error(bp, vc);
 		return;
 	}
 	xfs_btree_sblock_calc_crc(bp);
diff --git a/fs/xfs/libxfs/xfs_rmap_btree.c b/fs/xfs/libxfs/xfs_rmap_btree.c
index 6d2eba7b44bc..4e5449681686 100644
--- a/fs/xfs/libxfs/xfs_rmap_btree.c
+++ b/fs/xfs/libxfs/xfs_rmap_btree.c
@@ -334,10 +334,10 @@ xfs_rmapbt_read_verify(
 	struct xfs_buf	*bp)
 {
 	if (!xfs_btree_sblock_verify_crc(vc, bp))
-		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
+		xfs_verifier_error(bp, vc);
 	else {
 		if (!xfs_rmapbt_verify(vc, bp))
-			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+			xfs_verifier_error(bp, vc);
 	}
 
 	if (bp->b_error)
@@ -351,7 +351,7 @@ xfs_rmapbt_write_verify(
 {
 	if (!xfs_rmapbt_verify(vc, bp)) {
 		trace_xfs_btree_corrupt(bp, _RET_IP_);
-		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+		xfs_verifier_error(bp, vc);
 		return;
 	}
 	xfs_btree_sblock_calc_crc(bp);
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index 07e866103dc2..50726c54c2ca 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -719,9 +719,13 @@ xfs_sb_read_verify(
 	error = xfs_validate_sb_read(mp, &sb);
 
 out_error:
-	if (error == -EFSCORRUPTED || error == -EFSBADCRC)
-		xfs_verifier_error(bp, error, __this_address);
-	else if (error)
+	if (error == -EFSCORRUPTED) {
+		XFS_CORRUPTED(vc);
+		xfs_verifier_error(bp, vc);
+	} else if (error == -EFSBADCRC) {
+		XFS_BADCRC(vc);
+		xfs_verifier_error(bp, vc);
+	} else if (error)
 		xfs_buf_ioerror(bp, error);
 }
 
@@ -779,7 +783,9 @@ xfs_sb_write_verify(
 	return;
 
 out_error:
-	xfs_verifier_error(bp, error, __this_address);
+	vc->fa = __this_address;
+	vc->errno = error;
+	xfs_verifier_error(bp, vc);
 }
 
 const struct xfs_buf_ops xfs_sb_buf_ops = {
diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c
index d6516068bbe7..0c708fb92e89 100644
--- a/fs/xfs/libxfs/xfs_symlink_remote.c
+++ b/fs/xfs/libxfs/xfs_symlink_remote.c
@@ -125,10 +125,10 @@ xfs_symlink_read_verify(
 		return;
 
 	if (!xfs_buf_verify_cksum(vc, bp, XFS_SYMLINK_CRC_OFF))
-		xfs_verifier_error(bp, -EFSBADCRC, vc->fa);
+		xfs_verifier_error(bp, vc);
 	else {
 		if (!xfs_symlink_verify(vc, bp))
-			xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+			xfs_verifier_error(bp, vc);
 	}
 }
 
@@ -145,7 +145,7 @@ xfs_symlink_write_verify(
 		return;
 
 	if (!xfs_symlink_verify(vc, bp)) {
-		xfs_verifier_error(bp, -EFSCORRUPTED, vc->fa);
+		xfs_verifier_error(bp, vc);
 		return;
 	}
 
diff --git a/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h
index ab045e8dfcb9..4f0b8c73b599 100644
--- a/fs/xfs/libxfs/xfs_types.h
+++ b/fs/xfs/libxfs/xfs_types.h
@@ -41,7 +41,13 @@ typedef int64_t		xfs_sfiloff_t;	/* signed block number in a file */
  */
 typedef void *		xfs_failaddr_t;
 
+#ifndef EFSCORRUPTED
+#define EFSCORRUPTED    EUCLEAN         /* Filesystem is corrupted */
+#define EFSBADCRC       EBADMSG         /* Bad CRC detected */
+#endif
+
 struct xfs_vc {
+	int		errno;
 	xfs_failaddr_t	fa;
 };
 
@@ -51,10 +57,14 @@ struct xfs_vc {
  * return, which throws off the reported address.
  */
 #define __this_address ({ __label__ __here; __here: barrier(); &&__here; })
+
+#define XFS_CORRUPTED(vc)	({(vc)->fa = __this_address; (vc)->errno = -EFSCORRUPTED;})
+#define XFS_BADCRC(vc)		({(vc)->fa = __this_address; (vc)->errno = -EFSBADCRC;})
+#define XFS_VERIFIED(vc)	({(vc)->fa = NULL; (vc)->errno = 0;})
  
-#define XFS_CORRUPTED_RETURN(vc)	({(vc)->fa = __this_address; false;})
-#define XFS_BADCRC_RETURN(vc)		({(vc)->fa = __this_address; false;})
-#define XFS_VERIFIED_RETURN(vc)		({(vc)->fa = NULL; true;})
+#define XFS_CORRUPTED_RETURN(vc)	({(vc)->fa = __this_address; (vc)->errno = -EFSCORRUPTED; false;})
+#define XFS_BADCRC_RETURN(vc)		({(vc)->fa = __this_address; (vc)->errno = -EFSBADCRC; false;})
+#define XFS_VERIFIED_RETURN(vc)		({(vc)->fa = NULL; (vc)->errno = 0;  true;})
 
 /*
  * Null values for the types.
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index 9866f542e77b..4d305287823c 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -381,11 +381,10 @@ xfs_buf_verifier_error(
 void
 xfs_verifier_error(
 	struct xfs_buf		*bp,
-	int			error,
-	xfs_failaddr_t		failaddr)
+	struct xfs_vc		*vc)
 {
-	return xfs_buf_verifier_error(bp, error, "", xfs_buf_offset(bp, 0),
-			XFS_CORRUPTION_DUMP_LEN, failaddr);
+	return xfs_buf_verifier_error(bp, vc->errno, "", xfs_buf_offset(bp, 0),
+			XFS_CORRUPTION_DUMP_LEN, vc->fa);
 }
 
 /*
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
index 246d3e989c6c..9b0ac387007d 100644
--- a/fs/xfs/xfs_error.h
+++ b/fs/xfs/xfs_error.h
@@ -18,8 +18,7 @@ extern void xfs_corruption_error(const char *tag, int level,
 extern void xfs_buf_verifier_error(struct xfs_buf *bp, int error,
 			const char *name, void *buf, size_t bufsz,
 			xfs_failaddr_t failaddr);
-extern void xfs_verifier_error(struct xfs_buf *bp, int error,
-			xfs_failaddr_t failaddr);
+extern void xfs_verifier_error(struct xfs_buf *bp, struct xfs_vc *vc);
 extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
 			const char *name, void *buf, size_t bufsz,
 			xfs_failaddr_t failaddr);
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 10/10] xfs: condense crc and verifier checks where possible
  2018-12-05 21:01 [PATCH RFC 0/10] xfs: add verifier context structure Eric Sandeen
                   ` (8 preceding siblings ...)
  2018-12-05 21:11 ` [PATCH 09/10] xfs: add errno to verifier context and populate it Eric Sandeen
@ 2018-12-05 21:11 ` Eric Sandeen
  9 siblings, 0 replies; 20+ messages in thread
From: Eric Sandeen @ 2018-12-05 21:11 UTC (permalink / raw)
  To: Eric Sandeen, linux-xfs

Now that failaddr and errno are set within the validating functions, the
if/else is unnecessary and we can do a compound test of crc || validated,
i.e.

	if (!xfs_buf_verify_cksum(vc, bp, XFS_AGFL_CRC_OFF) ||
	    !xfs_agfl_verify(vc, bp))
		xfs_verifier_error(bp, vc);

This condenses the code a bit and makes it a little nicer.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 fs/xfs/libxfs/xfs_alloc.c          | 18 ++++++------------
 fs/xfs/libxfs/xfs_alloc_btree.c    |  7 ++-----
 fs/xfs/libxfs/xfs_attr_leaf.c      |  9 +++------
 fs/xfs/libxfs/xfs_dir2_block.c     |  9 +++------
 fs/xfs/libxfs/xfs_dir2_data.c      |  9 +++------
 fs/xfs/libxfs/xfs_dir2_leaf.c      |  9 +++------
 fs/xfs/libxfs/xfs_dir2_node.c      |  9 +++------
 fs/xfs/libxfs/xfs_ialloc.c         | 11 ++++-------
 fs/xfs/libxfs/xfs_symlink_remote.c |  7 ++-----
 9 files changed, 29 insertions(+), 59 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index 213a3078113c..5499438e6ee1 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -609,12 +609,9 @@ xfs_agfl_read_verify(
 	if (!xfs_sb_version_hascrc(&mp->m_sb))
 		return;
 
-	if (!xfs_buf_verify_cksum(vc, bp, XFS_AGFL_CRC_OFF))
+	if (!xfs_buf_verify_cksum(vc, bp, XFS_AGFL_CRC_OFF) ||
+	    !xfs_agfl_verify(vc, bp))
 		xfs_verifier_error(bp, vc);
-	else {
-		if (!xfs_agfl_verify(vc, bp))
-			xfs_verifier_error(bp, vc);
-	}
 }
 
 static void
@@ -2635,14 +2632,11 @@ xfs_agf_read_verify(
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
 
-	if (xfs_sb_version_hascrc(&mp->m_sb) &&
-	    !xfs_buf_verify_cksum(vc, bp, XFS_AGF_CRC_OFF))
+	if ((xfs_sb_version_hascrc(&mp->m_sb) &&
+			!xfs_buf_verify_cksum(vc, bp, XFS_AGF_CRC_OFF)) ||
+	    XFS_TEST_ERROR(!xfs_agf_verify(vc, bp),
+			mp, XFS_ERRTAG_ALLOC_READ_AGF))
 		xfs_verifier_error(bp, vc);
-	else {
-		if (XFS_TEST_ERROR(!xfs_agf_verify(vc, bp),
-				   mp, XFS_ERRTAG_ALLOC_READ_AGF))
-			xfs_verifier_error(bp, vc);
-	}
 }
 
 static void
diff --git a/fs/xfs/libxfs/xfs_alloc_btree.c b/fs/xfs/libxfs/xfs_alloc_btree.c
index 9f56821b49af..84f3f9542279 100644
--- a/fs/xfs/libxfs/xfs_alloc_btree.c
+++ b/fs/xfs/libxfs/xfs_alloc_btree.c
@@ -346,12 +346,9 @@ xfs_allocbt_read_verify(
 	struct xfs_vc	*vc,
 	struct xfs_buf	*bp)
 {
-	if (!xfs_btree_sblock_verify_crc(vc, bp))
+	if (!xfs_btree_sblock_verify_crc(vc, bp) ||
+	    !xfs_allocbt_verify(vc, bp))
 		xfs_verifier_error(bp, vc);
-	else {
-		if (!xfs_allocbt_verify(vc, bp))
-			xfs_verifier_error(bp, vc);
-	}
 
 	if (bp->b_error)
 		trace_xfs_btree_corrupt(bp, _RET_IP_);
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index 34958aa7fe5f..3f116f57c57d 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -357,13 +357,10 @@ xfs_attr3_leaf_read_verify(
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 
-	if (xfs_sb_version_hascrc(&mp->m_sb) &&
-	     !xfs_buf_verify_cksum(vc, bp, XFS_ATTR3_LEAF_CRC_OFF))
+	if ((xfs_sb_version_hascrc(&mp->m_sb) &&
+			!xfs_buf_verify_cksum(vc, bp, XFS_ATTR3_LEAF_CRC_OFF)) ||
+	    !xfs_attr3_leaf_verify(vc, bp))
 		xfs_verifier_error(bp, vc);
-	else {
-		if (!xfs_attr3_leaf_verify(vc, bp))
-			xfs_verifier_error(bp, vc);
-	}
 }
 
 const struct xfs_buf_ops xfs_attr3_leaf_buf_ops = {
diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
index 46db4a7269d8..b59d2331ee24 100644
--- a/fs/xfs/libxfs/xfs_dir2_block.c
+++ b/fs/xfs/libxfs/xfs_dir2_block.c
@@ -77,13 +77,10 @@ xfs_dir3_block_read_verify(
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 
-	if (xfs_sb_version_hascrc(&mp->m_sb) &&
-	     !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_DATA_CRC_OFF))
+	if ((xfs_sb_version_hascrc(&mp->m_sb) &&
+			!xfs_buf_verify_cksum(vc, bp, XFS_DIR3_DATA_CRC_OFF)) ||
+	    !xfs_dir3_block_verify(vc, bp))
 		xfs_verifier_error(bp, vc);
-	else {
-		if (!xfs_dir3_block_verify(vc, bp))
-			xfs_verifier_error(bp, vc);
-	}
 }
 
 static void
diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
index 9904571a76d0..554d2b0f06b4 100644
--- a/fs/xfs/libxfs/xfs_dir2_data.c
+++ b/fs/xfs/libxfs/xfs_dir2_data.c
@@ -304,13 +304,10 @@ xfs_dir3_data_read_verify(
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 
-	if (xfs_sb_version_hascrc(&mp->m_sb) &&
-	    !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_DATA_CRC_OFF))
+	if ((xfs_sb_version_hascrc(&mp->m_sb) &&
+			!xfs_buf_verify_cksum(vc, bp, XFS_DIR3_DATA_CRC_OFF)) ||
+	    !xfs_dir3_data_verify(vc, bp))
 		xfs_verifier_error(bp, vc);
-	else {
-		if (!xfs_dir3_data_verify(vc, bp))
-			xfs_verifier_error(bp, vc);
-	}
 }
 
 static void
diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
index aa423cd57bd7..b316f3d63e89 100644
--- a/fs/xfs/libxfs/xfs_dir2_leaf.c
+++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
@@ -183,13 +183,10 @@ __read_verify(
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 
-	if (xfs_sb_version_hascrc(&mp->m_sb) &&
-	     !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_LEAF_CRC_OFF))
+	if ((xfs_sb_version_hascrc(&mp->m_sb) &&
+			!xfs_buf_verify_cksum(vc, bp, XFS_DIR3_LEAF_CRC_OFF)) ||
+	    !xfs_dir3_leaf_verify(vc, bp, magic))
 		xfs_verifier_error(bp, vc);
-	else {
-		if (!xfs_dir3_leaf_verify(vc, bp, magic))
-			xfs_verifier_error(bp, vc);
-	}
 }
 
 static void
diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
index 8a78233bff9d..b88452362247 100644
--- a/fs/xfs/libxfs/xfs_dir2_node.c
+++ b/fs/xfs/libxfs/xfs_dir2_node.c
@@ -116,13 +116,10 @@ xfs_dir3_free_read_verify(
 {
 	struct xfs_mount	*mp = bp->b_target->bt_mount;
 
-	if (xfs_sb_version_hascrc(&mp->m_sb) &&
-	    !xfs_buf_verify_cksum(vc, bp, XFS_DIR3_FREE_CRC_OFF))
+	if ((xfs_sb_version_hascrc(&mp->m_sb) &&
+			!xfs_buf_verify_cksum(vc, bp, XFS_DIR3_FREE_CRC_OFF)) ||
+	    !xfs_dir3_free_verify(vc, bp))
 		xfs_verifier_error(bp, vc);
-	else {
-		if (!xfs_dir3_free_verify(vc, bp))
-			xfs_verifier_error(bp, vc);
-	}
 }
 
 static void
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 99df9cb8161e..ec6b32da1217 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -2555,14 +2555,11 @@ xfs_agi_read_verify(
 {
 	struct xfs_mount *mp = bp->b_target->bt_mount;
 
-	if (xfs_sb_version_hascrc(&mp->m_sb) &&
-	    !xfs_buf_verify_cksum(vc, bp, XFS_AGI_CRC_OFF))
+	if ((xfs_sb_version_hascrc(&mp->m_sb) &&
+			!xfs_buf_verify_cksum(vc, bp, XFS_AGI_CRC_OFF)) ||
+	    XFS_TEST_ERROR(!xfs_agi_verify(vc, bp),
+			   mp, XFS_ERRTAG_IALLOC_READ_AGI))
 		xfs_verifier_error(bp, vc);
-	else {
-		if (XFS_TEST_ERROR(!xfs_agi_verify(vc, bp),
-				   mp, XFS_ERRTAG_IALLOC_READ_AGI))
-			xfs_verifier_error(bp, vc);
-	}
 }
 
 static void
diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c
index 0c708fb92e89..9f251b5205a9 100644
--- a/fs/xfs/libxfs/xfs_symlink_remote.c
+++ b/fs/xfs/libxfs/xfs_symlink_remote.c
@@ -124,12 +124,9 @@ xfs_symlink_read_verify(
 	if (!xfs_sb_version_hascrc(&mp->m_sb))
 		return;
 
-	if (!xfs_buf_verify_cksum(vc, bp, XFS_SYMLINK_CRC_OFF))
+	if (!xfs_buf_verify_cksum(vc, bp, XFS_SYMLINK_CRC_OFF) ||
+	    !xfs_symlink_verify(vc, bp))
 		xfs_verifier_error(bp, vc);
-	else {
-		if (!xfs_symlink_verify(vc, bp))
-			xfs_verifier_error(bp, vc);
-	}
 }
 
 static void
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH 01/10] xfs: change xfs_attr3_rmt_hdr_ok to return bool
  2018-12-05 21:02 ` [PATCH 01/10] xfs: change xfs_attr3_rmt_hdr_ok to return bool Eric Sandeen
@ 2018-12-07 13:36   ` Brian Foster
  2018-12-17 18:23   ` Darrick J. Wong
  1 sibling, 0 replies; 20+ messages in thread
From: Brian Foster @ 2018-12-07 13:36 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: linux-xfs

On Wed, Dec 05, 2018 at 03:02:15PM -0600, Eric Sandeen wrote:
> xfs_attr3_rmt_hdr_ok is only checked for true/false and the caller
> does nothing with the returned failaddr, so make it a bool.
> 
> (its usage and naming lend itself to a bool too, i.e. test (!ok))
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/libxfs/xfs_attr_remote.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
> index d89363c6b523..f86680e08613 100644
> --- a/fs/xfs/libxfs/xfs_attr_remote.c
> +++ b/fs/xfs/libxfs/xfs_attr_remote.c
> @@ -53,7 +53,7 @@ xfs_attr3_rmt_blocks(
>   * does CRC, location and bounds checking, the unpacking function checks the
>   * attribute parameters and owner.
>   */
> -static xfs_failaddr_t
> +static bool
>  xfs_attr3_rmt_hdr_ok(
>  	void			*ptr,
>  	xfs_ino_t		ino,
> @@ -64,16 +64,16 @@ xfs_attr3_rmt_hdr_ok(
>  	struct xfs_attr3_rmt_hdr *rmt = ptr;
>  
>  	if (bno != be64_to_cpu(rmt->rm_blkno))
> -		return __this_address;
> +		return false;
>  	if (offset != be32_to_cpu(rmt->rm_offset))
> -		return __this_address;
> +		return false;
>  	if (size != be32_to_cpu(rmt->rm_bytes))
> -		return __this_address;
> +		return false;
>  	if (ino != be64_to_cpu(rmt->rm_owner))
> -		return __this_address;
> +		return false;
>  
>  	/* ok */
> -	return NULL;
> +	return true;
>  }
>  
>  static xfs_failaddr_t
> @@ -287,7 +287,7 @@ xfs_attr_rmtval_copyout(
>  		byte_cnt = min(*valuelen, byte_cnt);
>  
>  		if (xfs_sb_version_hascrc(&mp->m_sb)) {
> -			if (xfs_attr3_rmt_hdr_ok(src, ino, *offset,
> +			if (!xfs_attr3_rmt_hdr_ok(src, ino, *offset,
>  						  byte_cnt, bno)) {
>  				xfs_alert(mp,
>  "remote attribute header mismatch bno/off/len/owner (0x%llx/0x%x/Ox%x/0x%llx)",
> -- 
> 2.17.0
> 
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 02/10] xfs: make checksum verifiers consistently return bools
  2018-12-05 21:03 ` [PATCH 02/10] xfs: make checksum verifiers consistently return bools Eric Sandeen
@ 2018-12-07 13:36   ` Brian Foster
  2018-12-17 18:24   ` Darrick J. Wong
  1 sibling, 0 replies; 20+ messages in thread
From: Brian Foster @ 2018-12-07 13:36 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: linux-xfs

On Wed, Dec 05, 2018 at 03:03:05PM -0600, Eric Sandeen wrote:
> xfs_verify_cksum returns the result of a comparison, so make it
> a bool. xfs_buf_verify_cksum calls it, so make it a bool as well.
> Other callers up the callchain from here are already bools.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/libxfs/xfs_cksum.h | 2 +-
>  fs/xfs/xfs_buf.h          | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_cksum.h b/fs/xfs/libxfs/xfs_cksum.h
> index 999a290cfd72..1e3802a99867 100644
> --- a/fs/xfs/libxfs/xfs_cksum.h
> +++ b/fs/xfs/libxfs/xfs_cksum.h
> @@ -71,7 +71,7 @@ xfs_update_cksum(char *buffer, size_t length, unsigned long cksum_offset)
>  /*
>   * Helper to verify the checksum for a buffer.
>   */
> -static inline int
> +static inline bool
>  xfs_verify_cksum(char *buffer, size_t length, unsigned long cksum_offset)
>  {
>  	uint32_t crc = xfs_start_cksum_safe(buffer, length, cksum_offset);
> diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
> index b9f5511ea998..5015255b5ede 100644
> --- a/fs/xfs/xfs_buf.h
> +++ b/fs/xfs/xfs_buf.h
> @@ -359,7 +359,7 @@ static inline void xfs_buf_relse(xfs_buf_t *bp)
>  	xfs_buf_rele(bp);
>  }
>  
> -static inline int
> +static inline bool
>  xfs_buf_verify_cksum(struct xfs_buf *bp, unsigned long cksum_offset)
>  {
>  	return xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length),
> -- 
> 2.17.0
> 
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 08/10] xfs: set failaddr into vc for checksum failures
  2018-12-05 21:09 ` [PATCH 08/10] xfs: set failaddr into vc for checksum failures Eric Sandeen
@ 2018-12-07 13:37   ` Brian Foster
  2018-12-10 16:00     ` Eric Sandeen
  0 siblings, 1 reply; 20+ messages in thread
From: Brian Foster @ 2018-12-07 13:37 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: linux-xfs

On Wed, Dec 05, 2018 at 03:09:48PM -0600, Eric Sandeen wrote:
> Modify CRC checking functions to set __this_address into the
> verifier context failaddr vc->fa using new macro XFS_BADCRC_RETURN,
> and pass that to failure handlers as well.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>  fs/xfs/libxfs/xfs_alloc.c          |  4 ++--
>  fs/xfs/libxfs/xfs_alloc_btree.c    |  2 +-
>  fs/xfs/libxfs/xfs_attr_leaf.c      |  2 +-
>  fs/xfs/libxfs/xfs_bmap_btree.c     |  2 +-
>  fs/xfs/libxfs/xfs_cksum.h          |  5 ++++-
>  fs/xfs/libxfs/xfs_da_btree.c       |  3 +--
>  fs/xfs/libxfs/xfs_dir2_block.c     |  2 +-
>  fs/xfs/libxfs/xfs_dir2_data.c      |  2 +-
>  fs/xfs/libxfs/xfs_dir2_leaf.c      |  2 +-
>  fs/xfs/libxfs/xfs_dir2_node.c      |  2 +-
>  fs/xfs/libxfs/xfs_ialloc.c         |  2 +-
>  fs/xfs/libxfs/xfs_ialloc_btree.c   |  2 +-
>  fs/xfs/libxfs/xfs_refcount_btree.c |  2 +-
>  fs/xfs/libxfs/xfs_rmap_btree.c     |  2 +-
>  fs/xfs/libxfs/xfs_symlink_remote.c |  2 +-
>  fs/xfs/libxfs/xfs_types.h          | 12 ++++++++++--
>  fs/xfs/xfs_linux.h                 |  7 -------
>  17 files changed, 29 insertions(+), 26 deletions(-)
> 
...
> diff --git a/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h
> index 29b0d354d9b7..ab045e8dfcb9 100644
> --- a/fs/xfs/libxfs/xfs_types.h
> +++ b/fs/xfs/libxfs/xfs_types.h
> @@ -45,8 +45,16 @@ struct xfs_vc {
>  	xfs_failaddr_t	fa;
>  };
>  
> -#define XFS_CORRUPTED_RETURN(vc) ({(vc)->fa = __this_address; false;})
> -#define XFS_VERIFIED_RETURN(vc) ({(vc)->fa = NULL; true;})
> +/*
> + * Return the address of a label.  Use barrier() so that the optimizer
> + * won't reorder code to refactor the error jumpouts into a single
> + * return, which throws off the reported address.
> + */
> +#define __this_address ({ __label__ __here; __here: barrier(); &&__here; })
> + 

FYI, minor whitespace damage on the line above.

> +#define XFS_CORRUPTED_RETURN(vc)	({(vc)->fa = __this_address; false;})
> +#define XFS_BADCRC_RETURN(vc)		({(vc)->fa = __this_address; false;})
> +#define XFS_VERIFIED_RETURN(vc)		({(vc)->fa = NULL; true;})
>  

A couple high level comments..

I don't particularly care that much whether we bury function returns in
the macro or open-code it, but the macro naming suggests the former
(based on precedent of other such macros in XFS) while we implement the
latter. If there's objection to a return within a macro, perhaps a
reasonable compromise between this and the common pattern of having to
return on a separate line is to tweak the macros to never clobber an
existing error and update the verifiers to check/return failure state at
opportune points. For example:

	...
	if (!uuid_equal(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid))
		XFS_VC_CORRUPT(vc);
	if (be32_to_cpu(agfl->agfl_magicnum) != XFS_AGFL_MAGIC)
		XFS_VC_CORRUPT(vc);
	if (bp->b_pag && be32_to_cpu(agfl->agfl_seqno) != bp->b_pag->pag_agno)
		XFS_VC_CORRUPT(vc);
	...

	return vc->fa ? false : true;

Of course, that assumes it's safe to keep checking the structure(s) as
such in the event of corruption, which perhaps is not ideal. Anyways, we
could also just return on a separate line or rename the macros. Just
thinking out loud a bit.

I'm also a little curious why we have the need for the success macro at
all. I've only made a cursory pass at this point, but is there a
particular need to set anything in the xfs_vc at the point of a
successful return as opposed to just leaving the structure in the
initialized state?

Brian

>  /*
>   * Null values for the types.
> diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
> index edbd5a210df2..4141e70bb3fa 100644
> --- a/fs/xfs/xfs_linux.h
> +++ b/fs/xfs/xfs_linux.h
> @@ -131,13 +131,6 @@ typedef __u32			xfs_nlink_t;
>  #define SYNCHRONIZE()	barrier()
>  #define __return_address __builtin_return_address(0)
>  
> -/*
> - * Return the address of a label.  Use barrier() so that the optimizer
> - * won't reorder code to refactor the error jumpouts into a single
> - * return, which throws off the reported address.
> - */
> -#define __this_address	({ __label__ __here; __here: barrier(); &&__here; })
> -
>  #define XFS_PROJID_DEFAULT	0
>  
>  #define howmany(x, y)	(((x)+((y)-1))/(y))
> -- 
> 2.17.0
> 
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 09/10] xfs: add errno to verifier context and populate it
  2018-12-05 21:11 ` [PATCH 09/10] xfs: add errno to verifier context and populate it Eric Sandeen
@ 2018-12-07 13:41   ` Brian Foster
  0 siblings, 0 replies; 20+ messages in thread
From: Brian Foster @ 2018-12-07 13:41 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: linux-xfs

On Wed, Dec 05, 2018 at 03:11:00PM -0600, Eric Sandeen wrote:
> Add errno to verifier context and set it on verifier failures;
> now rather than passing errno and vc->fa to xfs_verifier_error,
> we pass vc directly and let xfs_verifier_error suss out the
> errno and failaddr.
> 
> Also make 3 new macros, XFS_CORRUPTED, XFS_BADCRC, and
> XFS_VERIFIED which set errno and failaddr into the verifier context
> without returning.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>  fs/xfs/libxfs/xfs_alloc.c          | 12 ++++----
>  fs/xfs/libxfs/xfs_alloc_btree.c    |  6 ++--
>  fs/xfs/libxfs/xfs_attr_leaf.c      |  6 ++--
>  fs/xfs/libxfs/xfs_attr_remote.c    | 49 ++++++++++++------------------
>  fs/xfs/libxfs/xfs_bmap_btree.c     |  6 ++--
>  fs/xfs/libxfs/xfs_da_btree.c       |  9 +++---
>  fs/xfs/libxfs/xfs_dir2_block.c     |  6 ++--
>  fs/xfs/libxfs/xfs_dir2_data.c      |  9 +++---
>  fs/xfs/libxfs/xfs_dir2_leaf.c      |  6 ++--
>  fs/xfs/libxfs/xfs_dir2_node.c      |  8 ++---
>  fs/xfs/libxfs/xfs_ialloc.c         |  6 ++--
>  fs/xfs/libxfs/xfs_ialloc_btree.c   |  6 ++--
>  fs/xfs/libxfs/xfs_refcount_btree.c |  6 ++--
>  fs/xfs/libxfs/xfs_rmap_btree.c     |  6 ++--
>  fs/xfs/libxfs/xfs_sb.c             | 14 ++++++---
>  fs/xfs/libxfs/xfs_symlink_remote.c |  6 ++--
>  fs/xfs/libxfs/xfs_types.h          | 16 ++++++++--
>  fs/xfs/xfs_error.c                 |  7 ++---
>  fs/xfs/xfs_error.h                 |  3 +-
>  19 files changed, 96 insertions(+), 91 deletions(-)
> 
...
> diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
> index 07e866103dc2..50726c54c2ca 100644
> --- a/fs/xfs/libxfs/xfs_sb.c
> +++ b/fs/xfs/libxfs/xfs_sb.c
> @@ -719,9 +719,13 @@ xfs_sb_read_verify(
>  	error = xfs_validate_sb_read(mp, &sb);
>  
>  out_error:
> -	if (error == -EFSCORRUPTED || error == -EFSBADCRC)
> -		xfs_verifier_error(bp, error, __this_address);
> -	else if (error)
> +	if (error == -EFSCORRUPTED) {
> +		XFS_CORRUPTED(vc);

Can't this clobber a previous corruption state in the vc, depending on
how we get here?

> +		xfs_verifier_error(bp, vc);
> +	} else if (error == -EFSBADCRC) {
> +		XFS_BADCRC(vc);
> +		xfs_verifier_error(bp, vc);
> +	} else if (error)
>  		xfs_buf_ioerror(bp, error);
>  }
>  
> @@ -779,7 +783,9 @@ xfs_sb_write_verify(
>  	return;
>  
>  out_error:
> -	xfs_verifier_error(bp, error, __this_address);
> +	vc->fa = __this_address;
> +	vc->errno = error;
> +	xfs_verifier_error(bp, vc);
>  }
>  
>  const struct xfs_buf_ops xfs_sb_buf_ops = {
...
> diff --git a/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h
> index ab045e8dfcb9..4f0b8c73b599 100644
> --- a/fs/xfs/libxfs/xfs_types.h
> +++ b/fs/xfs/libxfs/xfs_types.h
...
> @@ -51,10 +57,14 @@ struct xfs_vc {
>   * return, which throws off the reported address.
>   */
>  #define __this_address ({ __label__ __here; __here: barrier(); &&__here; })
> +
> +#define XFS_CORRUPTED(vc)	({(vc)->fa = __this_address; (vc)->errno = -EFSCORRUPTED;})
> +#define XFS_BADCRC(vc)		({(vc)->fa = __this_address; (vc)->errno = -EFSBADCRC;})
> +#define XFS_VERIFIED(vc)	({(vc)->fa = NULL; (vc)->errno = 0;})
>   
> -#define XFS_CORRUPTED_RETURN(vc)	({(vc)->fa = __this_address; false;})
> -#define XFS_BADCRC_RETURN(vc)		({(vc)->fa = __this_address; false;})
> -#define XFS_VERIFIED_RETURN(vc)		({(vc)->fa = NULL; true;})
> +#define XFS_CORRUPTED_RETURN(vc)	({(vc)->fa = __this_address; (vc)->errno = -EFSCORRUPTED; false;})
> +#define XFS_BADCRC_RETURN(vc)		({(vc)->fa = __this_address; (vc)->errno = -EFSBADCRC; false;})
> +#define XFS_VERIFIED_RETURN(vc)		({(vc)->fa = NULL; (vc)->errno = 0;  true;})
>  

Case in point wrt the naming thoughts on the previous patch: what's the
need for separate XFS_CORRUPTED() macros if the _RETURN() ones don't
actually change execution flow? They just evaluate to a logical
true/false, which should be perfectly fine outside of a return
statement.

Hmm, maybe it would be better to stick with that "return value" model
after all, but just drop the _RETURN() bit of the name and use the same
macro in both contexts.

Brian

>  /*
>   * Null values for the types.
> diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
> index 9866f542e77b..4d305287823c 100644
> --- a/fs/xfs/xfs_error.c
> +++ b/fs/xfs/xfs_error.c
> @@ -381,11 +381,10 @@ xfs_buf_verifier_error(
>  void
>  xfs_verifier_error(
>  	struct xfs_buf		*bp,
> -	int			error,
> -	xfs_failaddr_t		failaddr)
> +	struct xfs_vc		*vc)
>  {
> -	return xfs_buf_verifier_error(bp, error, "", xfs_buf_offset(bp, 0),
> -			XFS_CORRUPTION_DUMP_LEN, failaddr);
> +	return xfs_buf_verifier_error(bp, vc->errno, "", xfs_buf_offset(bp, 0),
> +			XFS_CORRUPTION_DUMP_LEN, vc->fa);
>  }
>  
>  /*
> diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h
> index 246d3e989c6c..9b0ac387007d 100644
> --- a/fs/xfs/xfs_error.h
> +++ b/fs/xfs/xfs_error.h
> @@ -18,8 +18,7 @@ extern void xfs_corruption_error(const char *tag, int level,
>  extern void xfs_buf_verifier_error(struct xfs_buf *bp, int error,
>  			const char *name, void *buf, size_t bufsz,
>  			xfs_failaddr_t failaddr);
> -extern void xfs_verifier_error(struct xfs_buf *bp, int error,
> -			xfs_failaddr_t failaddr);
> +extern void xfs_verifier_error(struct xfs_buf *bp, struct xfs_vc *vc);
>  extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
>  			const char *name, void *buf, size_t bufsz,
>  			xfs_failaddr_t failaddr);
> -- 
> 2.17.0
> 
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 08/10] xfs: set failaddr into vc for checksum failures
  2018-12-07 13:37   ` Brian Foster
@ 2018-12-10 16:00     ` Eric Sandeen
  2018-12-17 18:39       ` Darrick J. Wong
  0 siblings, 1 reply; 20+ messages in thread
From: Eric Sandeen @ 2018-12-10 16:00 UTC (permalink / raw)
  To: Brian Foster; +Cc: linux-xfs

On 12/7/18 7:37 AM, Brian Foster wrote:
> On Wed, Dec 05, 2018 at 03:09:48PM -0600, Eric Sandeen wrote:
>> Modify CRC checking functions to set __this_address into the
>> verifier context failaddr vc->fa using new macro XFS_BADCRC_RETURN,
>> and pass that to failure handlers as well.
>>
>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>> ---
>>  fs/xfs/libxfs/xfs_alloc.c          |  4 ++--
>>  fs/xfs/libxfs/xfs_alloc_btree.c    |  2 +-
>>  fs/xfs/libxfs/xfs_attr_leaf.c      |  2 +-
>>  fs/xfs/libxfs/xfs_bmap_btree.c     |  2 +-
>>  fs/xfs/libxfs/xfs_cksum.h          |  5 ++++-
>>  fs/xfs/libxfs/xfs_da_btree.c       |  3 +--
>>  fs/xfs/libxfs/xfs_dir2_block.c     |  2 +-
>>  fs/xfs/libxfs/xfs_dir2_data.c      |  2 +-
>>  fs/xfs/libxfs/xfs_dir2_leaf.c      |  2 +-
>>  fs/xfs/libxfs/xfs_dir2_node.c      |  2 +-
>>  fs/xfs/libxfs/xfs_ialloc.c         |  2 +-
>>  fs/xfs/libxfs/xfs_ialloc_btree.c   |  2 +-
>>  fs/xfs/libxfs/xfs_refcount_btree.c |  2 +-
>>  fs/xfs/libxfs/xfs_rmap_btree.c     |  2 +-
>>  fs/xfs/libxfs/xfs_symlink_remote.c |  2 +-
>>  fs/xfs/libxfs/xfs_types.h          | 12 ++++++++++--
>>  fs/xfs/xfs_linux.h                 |  7 -------
>>  17 files changed, 29 insertions(+), 26 deletions(-)
>>
> ...
>> diff --git a/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h
>> index 29b0d354d9b7..ab045e8dfcb9 100644
>> --- a/fs/xfs/libxfs/xfs_types.h
>> +++ b/fs/xfs/libxfs/xfs_types.h
>> @@ -45,8 +45,16 @@ struct xfs_vc {
>>  	xfs_failaddr_t	fa;
>>  };
>>  
>> -#define XFS_CORRUPTED_RETURN(vc) ({(vc)->fa = __this_address; false;})
>> -#define XFS_VERIFIED_RETURN(vc) ({(vc)->fa = NULL; true;})
>> +/*
>> + * Return the address of a label.  Use barrier() so that the optimizer
>> + * won't reorder code to refactor the error jumpouts into a single
>> + * return, which throws off the reported address.
>> + */
>> +#define __this_address ({ __label__ __here; __here: barrier(); &&__here; })
>> + 
> 
> FYI, minor whitespace damage on the line above.
> 
>> +#define XFS_CORRUPTED_RETURN(vc)	({(vc)->fa = __this_address; false;})
>> +#define XFS_BADCRC_RETURN(vc)		({(vc)->fa = __this_address; false;})
>> +#define XFS_VERIFIED_RETURN(vc)		({(vc)->fa = NULL; true;})
>>  
> 
> A couple high level comments..
> 
> I don't particularly care that much whether we bury function returns in
> the macro or open-code it, but the macro naming suggests the former
> (based on precedent of other such macros in XFS) while we implement the
> latter. If there's objection to a return within a macro, perhaps a
> reasonable compromise between this and the common pattern of having to
> return on a separate line is to tweak the macros to never clobber an
> existing error and update the verifiers to check/return failure state at
> opportune points. For example:
> 
> 	...
> 	if (!uuid_equal(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid))
> 		XFS_VC_CORRUPT(vc);
> 	if (be32_to_cpu(agfl->agfl_magicnum) != XFS_AGFL_MAGIC)
> 		XFS_VC_CORRUPT(vc);
> 	if (bp->b_pag && be32_to_cpu(agfl->agfl_seqno) != bp->b_pag->pag_agno)
> 		XFS_VC_CORRUPT(vc);
> 	...
> 
> 	return vc->fa ? false : true;
> 
> Of course, that assumes it's safe to keep checking the structure(s) as
> such in the event of corruption, which perhaps is not ideal. Anyways, we
> could also just return on a separate line or rename the macros. Just
> thinking out loud a bit.
> 
> I'm also a little curious why we have the need for the success macro at
> all. I've only made a cursory pass at this point, but is there a
> particular need to set anything in the xfs_vc at the point of a
> successful return as opposed to just leaving the structure in the
> initialized state?

yeah, it's probably not necessary; it seemed consistent tho.  There is some
risk to this whole framework that failing to initialize a vc would cause
problems that might be difficult to debug, and always marking success
upon success seemed "safe."  But you're right, not not necessary if it's
properly initialized to success at the top of the call chain.

-Eric

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 01/10] xfs: change xfs_attr3_rmt_hdr_ok to return bool
  2018-12-05 21:02 ` [PATCH 01/10] xfs: change xfs_attr3_rmt_hdr_ok to return bool Eric Sandeen
  2018-12-07 13:36   ` Brian Foster
@ 2018-12-17 18:23   ` Darrick J. Wong
  1 sibling, 0 replies; 20+ messages in thread
From: Darrick J. Wong @ 2018-12-17 18:23 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: linux-xfs

On Wed, Dec 05, 2018 at 03:02:15PM -0600, Eric Sandeen wrote:
> xfs_attr3_rmt_hdr_ok is only checked for true/false and the caller
> does nothing with the returned failaddr, so make it a bool.
> (its usage and naming lend itself to a bool too, i.e. test (!ok))
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>  fs/xfs/libxfs/xfs_attr_remote.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
> index d89363c6b523..f86680e08613 100644
> --- a/fs/xfs/libxfs/xfs_attr_remote.c
> +++ b/fs/xfs/libxfs/xfs_attr_remote.c
> @@ -53,7 +53,7 @@ xfs_attr3_rmt_blocks(
>   * does CRC, location and bounds checking, the unpacking function checks the
>   * attribute parameters and owner.
>   */
> -static xfs_failaddr_t
> +static bool
>  xfs_attr3_rmt_hdr_ok(
>  	void			*ptr,
>  	xfs_ino_t		ino,
> @@ -64,16 +64,16 @@ xfs_attr3_rmt_hdr_ok(
>  	struct xfs_attr3_rmt_hdr *rmt = ptr;
>  
>  	if (bno != be64_to_cpu(rmt->rm_blkno))
> -		return __this_address;
> +		return false;
>  	if (offset != be32_to_cpu(rmt->rm_offset))
> -		return __this_address;
> +		return false;
>  	if (size != be32_to_cpu(rmt->rm_bytes))
> -		return __this_address;
> +		return false;
>  	if (ino != be64_to_cpu(rmt->rm_owner))
> -		return __this_address;
> +		return false;
>  
>  	/* ok */
> -	return NULL;
> +	return true;
>  }
>  
>  static xfs_failaddr_t
> @@ -287,7 +287,7 @@ xfs_attr_rmtval_copyout(
>  		byte_cnt = min(*valuelen, byte_cnt);
>  
>  		if (xfs_sb_version_hascrc(&mp->m_sb)) {
> -			if (xfs_attr3_rmt_hdr_ok(src, ino, *offset,
> +			if (!xfs_attr3_rmt_hdr_ok(src, ino, *offset,

Why not pass a verifier context to attr3_rmt_hdr_ok and enable
rmtval_copyout to report the approximate instruction address of the
failed check?

(Or maybe I missed you doing this later...?)

--D

>  						  byte_cnt, bno)) {
>  				xfs_alert(mp,
>  "remote attribute header mismatch bno/off/len/owner (0x%llx/0x%x/Ox%x/0x%llx)",
> -- 
> 2.17.0
> 
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 02/10] xfs: make checksum verifiers consistently return bools
  2018-12-05 21:03 ` [PATCH 02/10] xfs: make checksum verifiers consistently return bools Eric Sandeen
  2018-12-07 13:36   ` Brian Foster
@ 2018-12-17 18:24   ` Darrick J. Wong
  1 sibling, 0 replies; 20+ messages in thread
From: Darrick J. Wong @ 2018-12-17 18:24 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: linux-xfs

On Wed, Dec 05, 2018 at 03:03:05PM -0600, Eric Sandeen wrote:
> xfs_verify_cksum returns the result of a comparison, so make it
> a bool. xfs_buf_verify_cksum calls it, so make it a bool as well.
> Other callers up the callchain from here are already bools.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/libxfs/xfs_cksum.h | 2 +-
>  fs/xfs/xfs_buf.h          | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_cksum.h b/fs/xfs/libxfs/xfs_cksum.h
> index 999a290cfd72..1e3802a99867 100644
> --- a/fs/xfs/libxfs/xfs_cksum.h
> +++ b/fs/xfs/libxfs/xfs_cksum.h
> @@ -71,7 +71,7 @@ xfs_update_cksum(char *buffer, size_t length, unsigned long cksum_offset)
>  /*
>   * Helper to verify the checksum for a buffer.
>   */
> -static inline int
> +static inline bool
>  xfs_verify_cksum(char *buffer, size_t length, unsigned long cksum_offset)
>  {
>  	uint32_t crc = xfs_start_cksum_safe(buffer, length, cksum_offset);
> diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
> index b9f5511ea998..5015255b5ede 100644
> --- a/fs/xfs/xfs_buf.h
> +++ b/fs/xfs/xfs_buf.h
> @@ -359,7 +359,7 @@ static inline void xfs_buf_relse(xfs_buf_t *bp)
>  	xfs_buf_rele(bp);
>  }
>  
> -static inline int
> +static inline bool
>  xfs_buf_verify_cksum(struct xfs_buf *bp, unsigned long cksum_offset)
>  {
>  	return xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length),
> -- 
> 2.17.0
> 
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 03/10] xfs: pass a verifier context down verifier callchains
  2018-12-05 21:03 ` [PATCH 03/10] xfs: pass a verifier context down verifier callchains Eric Sandeen
@ 2018-12-17 18:29   ` Darrick J. Wong
  0 siblings, 0 replies; 20+ messages in thread
From: Darrick J. Wong @ 2018-12-17 18:29 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: linux-xfs

On Wed, Dec 05, 2018 at 03:03:56PM -0600, Eric Sandeen wrote:
> In order to get more context about a verifier failure, create a new
> xfs verifier context (xfs_vc) type and pass it all the way down verifier
> callchains to where we might return a failaddr_t.  This will eventually
> let us return more information, for example line number or buffer offset,
> etc.
> 
> At this point it contains only a failaddr member which is not yet used.
> 
> struct xfs_vc {
>        xfs_failaddr_t  fa;
> };
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>  fs/xfs/libxfs/xfs_alloc.c          | 14 +++++++---
>  fs/xfs/libxfs/xfs_alloc_btree.c    | 15 ++++++-----
>  fs/xfs/libxfs/xfs_attr_leaf.c      |  8 ++++--
>  fs/xfs/libxfs/xfs_attr_leaf.h      |  2 +-
>  fs/xfs/libxfs/xfs_attr_remote.c    | 13 ++++++---
>  fs/xfs/libxfs/xfs_bmap.c           |  4 ++-
>  fs/xfs/libxfs/xfs_bmap.h           |  2 +-
>  fs/xfs/libxfs/xfs_bmap_btree.c     | 11 +++++---
>  fs/xfs/libxfs/xfs_btree.c          | 13 +++++++--
>  fs/xfs/libxfs/xfs_btree.h          | 14 +++++-----
>  fs/xfs/libxfs/xfs_da_btree.c       | 20 ++++++++------
>  fs/xfs/libxfs/xfs_dir2_block.c     |  9 ++++---
>  fs/xfs/libxfs/xfs_dir2_data.c      | 31 +++++++++++++++-------
>  fs/xfs/libxfs/xfs_dir2_leaf.c      | 42 +++++++++++++++++++-----------
>  fs/xfs/libxfs/xfs_dir2_node.c      | 17 ++++++++----
>  fs/xfs/libxfs/xfs_dir2_priv.h      |  6 ++---
>  fs/xfs/libxfs/xfs_dir2_sf.c        |  1 +
>  fs/xfs/libxfs/xfs_dquot_buf.c      | 19 +++++++++-----
>  fs/xfs/libxfs/xfs_ialloc.c         |  7 +++--
>  fs/xfs/libxfs/xfs_ialloc_btree.c   | 13 +++++----
>  fs/xfs/libxfs/xfs_inode_buf.c      | 28 +++++++++++++-------
>  fs/xfs/libxfs/xfs_inode_buf.h      |  6 ++---
>  fs/xfs/libxfs/xfs_inode_fork.c     | 13 +++++----
>  fs/xfs/libxfs/xfs_inode_fork.h     |  6 ++---
>  fs/xfs/libxfs/xfs_quota_defs.h     |  4 +--
>  fs/xfs/libxfs/xfs_refcount_btree.c | 13 +++++----
>  fs/xfs/libxfs/xfs_rmap_btree.c     | 13 +++++----
>  fs/xfs/libxfs/xfs_rtbitmap.c       |  2 ++
>  fs/xfs/libxfs/xfs_sb.c             |  5 +++-
>  fs/xfs/libxfs/xfs_shared.h         |  2 +-
>  fs/xfs/libxfs/xfs_symlink_remote.c |  8 ++++--
>  fs/xfs/libxfs/xfs_types.h          |  4 +++
>  fs/xfs/scrub/btree.c               |  5 ++--
>  fs/xfs/scrub/common.c              |  3 ++-
>  fs/xfs/scrub/dabtree.c             | 15 ++++++-----
>  fs/xfs/scrub/inode.c               |  6 +++--
>  fs/xfs/scrub/repair.c              |  4 ++-
>  fs/xfs/xfs_buf.c                   | 12 ++++++---
>  fs/xfs/xfs_buf.h                   |  6 ++---
>  fs/xfs/xfs_dquot.c                 |  3 ++-
>  fs/xfs/xfs_inode.c                 |  5 ++--
>  fs/xfs/xfs_log_recover.c           |  6 +++--
>  fs/xfs/xfs_qm.c                    |  3 ++-
>  43 files changed, 284 insertions(+), 149 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
> index e1c0c0d2f1b0..59b8ab08dabd 100644
> --- a/fs/xfs/libxfs/xfs_alloc.c
> +++ b/fs/xfs/libxfs/xfs_alloc.c
> @@ -553,6 +553,7 @@ xfs_alloc_fixup_trees(
>  
>  static xfs_failaddr_t
>  xfs_agfl_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount *mp = bp->b_target->bt_mount;
> @@ -594,6 +595,7 @@ xfs_agfl_verify(
>  
>  static void
>  xfs_agfl_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount *mp = bp->b_target->bt_mount;
> @@ -611,7 +613,7 @@ xfs_agfl_read_verify(
>  	if (!xfs_buf_verify_cksum(bp, XFS_AGFL_CRC_OFF))
>  		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
>  	else {
> -		fa = xfs_agfl_verify(bp);
> +		fa = xfs_agfl_verify(vc, bp);
>  		if (fa)
>  			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  	}
> @@ -619,6 +621,7 @@ xfs_agfl_read_verify(
>  
>  static void
>  xfs_agfl_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -629,7 +632,7 @@ xfs_agfl_write_verify(
>  	if (!xfs_sb_version_hascrc(&mp->m_sb))
>  		return;
>  
> -	fa = xfs_agfl_verify(bp);
> +	fa = xfs_agfl_verify(vc, bp);
>  	if (fa) {
>  		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  		return;
> @@ -2575,6 +2578,7 @@ xfs_alloc_put_freelist(
>  
>  static xfs_failaddr_t
>  xfs_agf_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -2631,6 +2635,7 @@ xfs_agf_verify(
>  
>  static void
>  xfs_agf_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount *mp = bp->b_target->bt_mount;
> @@ -2640,7 +2645,7 @@ xfs_agf_read_verify(
>  	    !xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF))
>  		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
>  	else {
> -		fa = xfs_agf_verify(bp);
> +		fa = xfs_agf_verify(vc, bp);
>  		if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_ALLOC_READ_AGF))
>  			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  	}
> @@ -2648,13 +2653,14 @@ xfs_agf_read_verify(
>  
>  static void
>  xfs_agf_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
>  	struct xfs_buf_log_item	*bip = bp->b_log_item;
>  	xfs_failaddr_t		fa;
>  
> -	fa = xfs_agf_verify(bp);
> +	fa = xfs_agf_verify(vc, bp);
>  	if (fa) {
>  		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  		return;
> diff --git a/fs/xfs/libxfs/xfs_alloc_btree.c b/fs/xfs/libxfs/xfs_alloc_btree.c
> index 4e59cc8a2802..2e9353a76a58 100644
> --- a/fs/xfs/libxfs/xfs_alloc_btree.c
> +++ b/fs/xfs/libxfs/xfs_alloc_btree.c
> @@ -290,6 +290,7 @@ xfs_cntbt_diff_two_keys(
>  
>  static xfs_failaddr_t
>  xfs_allocbt_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -313,7 +314,7 @@ xfs_allocbt_verify(
>  	level = be16_to_cpu(block->bb_level);
>  	switch (block->bb_magic) {
>  	case cpu_to_be32(XFS_ABTB_CRC_MAGIC):
> -		fa = xfs_btree_sblock_v5hdr_verify(bp);
> +		fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
>  		if (fa)
>  			return fa;
>  		/* fall through */
> @@ -325,7 +326,7 @@ xfs_allocbt_verify(
>  			return __this_address;
>  		break;
>  	case cpu_to_be32(XFS_ABTC_CRC_MAGIC):
> -		fa = xfs_btree_sblock_v5hdr_verify(bp);
> +		fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
>  		if (fa)
>  			return fa;
>  		/* fall through */
> @@ -340,19 +341,20 @@ xfs_allocbt_verify(
>  		return __this_address;
>  	}
>  
> -	return xfs_btree_sblock_verify(bp, mp->m_alloc_mxr[level != 0]);
> +	return xfs_btree_sblock_verify(vc, bp, mp->m_alloc_mxr[level != 0]);
>  }
>  
>  static void
>  xfs_allocbt_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	xfs_failaddr_t	fa;
>  
> -	if (!xfs_btree_sblock_verify_crc(bp))
> +	if (!xfs_btree_sblock_verify_crc(vc, bp))
>  		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
>  	else {
> -		fa = xfs_allocbt_verify(bp);
> +		fa = xfs_allocbt_verify(vc, bp);
>  		if (fa)
>  			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  	}
> @@ -363,11 +365,12 @@ xfs_allocbt_read_verify(
>  
>  static void
>  xfs_allocbt_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	xfs_failaddr_t	fa;
>  
> -	fa = xfs_allocbt_verify(bp);
> +	fa = xfs_allocbt_verify(vc, bp);
>  	if (fa) {
>  		trace_xfs_btree_corrupt(bp, _RET_IP_);
>  		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
> index 2652d00842d6..5b146c909389 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.c
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.c
> @@ -237,6 +237,7 @@ xfs_attr3_leaf_hdr_to_disk(
>  
>  static xfs_failaddr_t
>  xfs_attr3_leaf_verify(
> +	struct xfs_vc			*vc,
>  	struct xfs_buf			*bp)
>  {
>  	struct xfs_attr3_icleaf_hdr	ichdr;
> @@ -322,6 +323,7 @@ xfs_attr3_leaf_verify(
>  
>  static void
>  xfs_attr3_leaf_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -329,7 +331,7 @@ xfs_attr3_leaf_write_verify(
>  	struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr;
>  	xfs_failaddr_t		fa;
>  
> -	fa = xfs_attr3_leaf_verify(bp);
> +	fa = xfs_attr3_leaf_verify(vc, bp);
>  	if (fa) {
>  		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  		return;
> @@ -352,6 +354,7 @@ xfs_attr3_leaf_write_verify(
>   */
>  static void
>  xfs_attr3_leaf_read_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -361,7 +364,7 @@ xfs_attr3_leaf_read_verify(
>  	     !xfs_buf_verify_cksum(bp, XFS_ATTR3_LEAF_CRC_OFF))
>  		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
>  	else {
> -		fa = xfs_attr3_leaf_verify(bp);
> +		fa = xfs_attr3_leaf_verify(vc, bp);
>  		if (fa)
>  			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  	}
> @@ -905,6 +908,7 @@ xfs_attr_shortform_allfit(
>  /* Verify the consistency of an inline attribute fork. */
>  xfs_failaddr_t
>  xfs_attr_shortform_verify(
> +	struct xfs_vc			*vc,
>  	struct xfs_inode		*ip)
>  {
>  	struct xfs_attr_shortform	*sfp;
> diff --git a/fs/xfs/libxfs/xfs_attr_leaf.h b/fs/xfs/libxfs/xfs_attr_leaf.h
> index 7b74e18becff..afe09eec66aa 100644
> --- a/fs/xfs/libxfs/xfs_attr_leaf.h
> +++ b/fs/xfs/libxfs/xfs_attr_leaf.h
> @@ -41,7 +41,7 @@ int	xfs_attr_shortform_to_leaf(struct xfs_da_args *args,
>  int	xfs_attr_shortform_remove(struct xfs_da_args *args);
>  int	xfs_attr_shortform_allfit(struct xfs_buf *bp, struct xfs_inode *dp);
>  int	xfs_attr_shortform_bytesfit(struct xfs_inode *dp, int bytes);
> -xfs_failaddr_t xfs_attr_shortform_verify(struct xfs_inode *ip);
> +xfs_failaddr_t xfs_attr_shortform_verify(struct xfs_vc *vc, struct xfs_inode *ip);
>  void	xfs_attr_fork_remove(struct xfs_inode *ip, struct xfs_trans *tp);
>  
>  /*
> diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
> index f86680e08613..e8d629de2cf5 100644
> --- a/fs/xfs/libxfs/xfs_attr_remote.c
> +++ b/fs/xfs/libxfs/xfs_attr_remote.c
> @@ -78,6 +78,7 @@ xfs_attr3_rmt_hdr_ok(
>  
>  static xfs_failaddr_t
>  xfs_attr3_rmt_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_mount	*mp,
>  	void			*ptr,
>  	int			fsbsize,
> @@ -106,6 +107,7 @@ xfs_attr3_rmt_verify(
>  
>  static int
>  __xfs_attr3_rmt_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp,
>  	bool		check_crc,
>  	xfs_failaddr_t	*failaddr)
> @@ -131,7 +133,7 @@ __xfs_attr3_rmt_read_verify(
>  			*failaddr = __this_address;
>  			return -EFSBADCRC;
>  		}
> -		*failaddr = xfs_attr3_rmt_verify(mp, ptr, blksize, bno);
> +		*failaddr = xfs_attr3_rmt_verify(vc, mp, ptr, blksize, bno);
>  		if (*failaddr)
>  			return -EFSCORRUPTED;
>  		len -= blksize;
> @@ -149,29 +151,32 @@ __xfs_attr3_rmt_read_verify(
>  
>  static void
>  xfs_attr3_rmt_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	xfs_failaddr_t	fa;
>  	int		error;
>  
> -	error = __xfs_attr3_rmt_read_verify(bp, true, &fa);
> +	error = __xfs_attr3_rmt_read_verify(vc, bp, true, &fa);
>  	if (error)
>  		xfs_verifier_error(bp, error, fa);
>  }
>  
>  static xfs_failaddr_t
>  xfs_attr3_rmt_verify_struct(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	xfs_failaddr_t	fa;
>  	int		error;
>  
> -	error = __xfs_attr3_rmt_read_verify(bp, false, &fa);
> +	error = __xfs_attr3_rmt_read_verify(vc, bp, false, &fa);
>  	return error ? fa : NULL;
>  }
>  
>  static void
>  xfs_attr3_rmt_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount *mp = bp->b_target->bt_mount;
> @@ -193,7 +198,7 @@ xfs_attr3_rmt_write_verify(
>  	while (len > 0) {
>  		struct xfs_attr3_rmt_hdr *rmt = (struct xfs_attr3_rmt_hdr *)ptr;
>  
> -		fa = xfs_attr3_rmt_verify(mp, ptr, blksize, bno);
> +		fa = xfs_attr3_rmt_verify(vc, mp, ptr, blksize, bno);
>  		if (fa) {
>  			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  			return;
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 19e921d1586f..fe0e0a1df5b1 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -1249,10 +1249,11 @@ xfs_iread_extents(
>  		 */
>  		frp = XFS_BMBT_REC_ADDR(mp, block, 1);
>  		for (j = 0; j < num_recs; j++, frp++, i++) {
> +			struct xfs_vc	vc = { 0 };

The sole field in xfs_vc is a pointer; is this going to trigger gcc
warnings about typecasting zero to a pointer?

(Which is silly and annoying, but I'm tired of getting patches to
swizzle back and forth between NULL and 0...)

>  			xfs_failaddr_t	fa;
>  
>  			xfs_bmbt_disk_get_all(frp, &new);
> -			fa = xfs_bmap_validate_extent(ip, whichfork, &new);
> +			fa = xfs_bmap_validate_extent(&vc, ip, whichfork, &new);
>  			if (fa) {
>  				error = -EFSCORRUPTED;
>  				xfs_inode_verifier_error(ip, error,
> @@ -6101,6 +6102,7 @@ xfs_bmap_finish_one(
>  /* Check that an inode's extent does not have invalid flags or bad ranges. */
>  xfs_failaddr_t
>  xfs_bmap_validate_extent(
> +	struct xfs_vc		*vc,
>  	struct xfs_inode	*ip,
>  	int			whichfork,
>  	struct xfs_bmbt_irec	*irec)
> diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
> index 488dc8860fd7..a586568cdfb9 100644
> --- a/fs/xfs/libxfs/xfs_bmap.h
> +++ b/fs/xfs/libxfs/xfs_bmap.h
> @@ -273,7 +273,7 @@ static inline int xfs_bmap_fork_to_state(int whichfork)
>  	}
>  }
>  
> -xfs_failaddr_t xfs_bmap_validate_extent(struct xfs_inode *ip, int whichfork,
> +xfs_failaddr_t xfs_bmap_validate_extent(struct xfs_vc *vc, struct xfs_inode *ip, int whichfork,
>  		struct xfs_bmbt_irec *irec);
>  
>  int	xfs_bmapi_remap(struct xfs_trans *tp, struct xfs_inode *ip,
> diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c
> index cdb74d2e2a43..4c8e97709704 100644
> --- a/fs/xfs/libxfs/xfs_bmap_btree.c
> +++ b/fs/xfs/libxfs/xfs_bmap_btree.c
> @@ -409,6 +409,7 @@ xfs_bmbt_diff_two_keys(
>  
>  static xfs_failaddr_t
>  xfs_bmbt_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -422,7 +423,7 @@ xfs_bmbt_verify(
>  		 * XXX: need a better way of verifying the owner here. Right now
>  		 * just make sure there has been one set.
>  		 */
> -		fa = xfs_btree_lblock_v5hdr_verify(bp, XFS_RMAP_OWN_UNKNOWN);
> +		fa = xfs_btree_lblock_v5hdr_verify(vc, bp, XFS_RMAP_OWN_UNKNOWN);
>  		if (fa)
>  			return fa;
>  		/* fall through */
> @@ -443,11 +444,12 @@ xfs_bmbt_verify(
>  	if (level > max(mp->m_bm_maxlevels[0], mp->m_bm_maxlevels[1]))
>  		return __this_address;
>  
> -	return xfs_btree_lblock_verify(bp, mp->m_bmap_dmxr[level != 0]);
> +	return xfs_btree_lblock_verify(vc, bp, mp->m_bmap_dmxr[level != 0]);
>  }
>  
>  static void
>  xfs_bmbt_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	xfs_failaddr_t	fa;
> @@ -455,7 +457,7 @@ xfs_bmbt_read_verify(
>  	if (!xfs_btree_lblock_verify_crc(bp))
>  		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
>  	else {
> -		fa = xfs_bmbt_verify(bp);
> +		fa = xfs_bmbt_verify(vc, bp);
>  		if (fa)
>  			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  	}
> @@ -466,11 +468,12 @@ xfs_bmbt_read_verify(
>  
>  static void
>  xfs_bmbt_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	xfs_failaddr_t	fa;
>  
> -	fa = xfs_bmbt_verify(bp);
> +	fa = xfs_bmbt_verify(vc, bp);
>  	if (fa) {
>  		trace_xfs_btree_corrupt(bp, _RET_IP_);
>  		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
> diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
> index bbdae2b4559f..755ac16e90c5 100644
> --- a/fs/xfs/libxfs/xfs_btree.c
> +++ b/fs/xfs/libxfs/xfs_btree.c
> @@ -58,6 +58,7 @@ xfs_btree_magic(
>   */
>  xfs_failaddr_t
>  __xfs_btree_check_lblock(
> +	struct xfs_vc		*vc,
>  	struct xfs_btree_cur	*cur,
>  	struct xfs_btree_block	*block,
>  	int			level,
> @@ -105,9 +106,10 @@ xfs_btree_check_lblock(
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = cur->bc_mp;
> +	struct xfs_vc		vc = { 0 };
>  	xfs_failaddr_t		fa;
>  
> -	fa = __xfs_btree_check_lblock(cur, block, level, bp);
> +	fa = __xfs_btree_check_lblock(&vc, cur, block, level, bp);
>  	if (unlikely(XFS_TEST_ERROR(fa != NULL, mp,
>  			XFS_ERRTAG_BTREE_CHECK_LBLOCK))) {
>  		if (bp)
> @@ -124,6 +126,7 @@ xfs_btree_check_lblock(
>   */
>  xfs_failaddr_t
>  __xfs_btree_check_sblock(
> +	struct xfs_vc		*vc,
>  	struct xfs_btree_cur	*cur,
>  	struct xfs_btree_block	*block,
>  	int			level,
> @@ -169,9 +172,10 @@ xfs_btree_check_sblock(
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = cur->bc_mp;
> +	struct xfs_vc		vc = { 0 };
>  	xfs_failaddr_t		fa;
>  
> -	fa = __xfs_btree_check_sblock(cur, block, level, bp);
> +	fa = __xfs_btree_check_sblock(&vc, cur, block, level, bp);
>  	if (unlikely(XFS_TEST_ERROR(fa != NULL, mp,
>  			XFS_ERRTAG_BTREE_CHECK_SBLOCK))) {
>  		if (bp)
> @@ -323,6 +327,7 @@ xfs_btree_sblock_calc_crc(
>  
>  bool
>  xfs_btree_sblock_verify_crc(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_btree_block  *block = XFS_BUF_TO_BLOCK(bp);
> @@ -4430,6 +4435,7 @@ xfs_btree_change_owner(
>  /* Verify the v5 fields of a long-format btree block. */
>  xfs_failaddr_t
>  xfs_btree_lblock_v5hdr_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp,
>  	uint64_t		owner)
>  {
> @@ -4451,6 +4457,7 @@ xfs_btree_lblock_v5hdr_verify(
>  /* Verify a long-format btree block. */
>  xfs_failaddr_t
>  xfs_btree_lblock_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp,
>  	unsigned int		max_recs)
>  {
> @@ -4482,6 +4489,7 @@ xfs_btree_lblock_verify(
>   */
>  xfs_failaddr_t
>  xfs_btree_sblock_v5hdr_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -4507,6 +4515,7 @@ xfs_btree_sblock_v5hdr_verify(
>   */
>  xfs_failaddr_t
>  xfs_btree_sblock_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp,
>  	unsigned int		max_recs)
>  {
> diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
> index e3b3e9dce5da..86cc17f1bf3f 100644
> --- a/fs/xfs/libxfs/xfs_btree.h
> +++ b/fs/xfs/libxfs/xfs_btree.h
> @@ -243,9 +243,9 @@ typedef struct xfs_btree_cur
>   * Internal long and short btree block checks.  They return NULL if the
>   * block is ok or the address of the failed check otherwise.
>   */
> -xfs_failaddr_t __xfs_btree_check_lblock(struct xfs_btree_cur *cur,
> +xfs_failaddr_t __xfs_btree_check_lblock(struct xfs_vc *vc, struct xfs_btree_cur *cur,
>  		struct xfs_btree_block *block, int level, struct xfs_buf *bp);
> -xfs_failaddr_t __xfs_btree_check_sblock(struct xfs_btree_cur *cur,
> +xfs_failaddr_t __xfs_btree_check_sblock(struct xfs_vc *vc, struct xfs_btree_cur *cur,
>  		struct xfs_btree_block *block, int level, struct xfs_buf *bp);
>  
>  /*
> @@ -417,7 +417,7 @@ int xfs_btree_change_owner(struct xfs_btree_cur *cur, uint64_t new_owner,
>  void xfs_btree_lblock_calc_crc(struct xfs_buf *);
>  bool xfs_btree_lblock_verify_crc(struct xfs_buf *);
>  void xfs_btree_sblock_calc_crc(struct xfs_buf *);
> -bool xfs_btree_sblock_verify_crc(struct xfs_buf *);
> +bool xfs_btree_sblock_verify_crc(struct xfs_vc *vc, struct xfs_buf *);
>  
>  /*
>   * Internal btree helpers also used by xfs_bmap.c.
> @@ -457,12 +457,12 @@ static inline int xfs_btree_get_level(struct xfs_btree_block *block)
>  #define	XFS_FILBLKS_MIN(a,b)	min_t(xfs_filblks_t, (a), (b))
>  #define	XFS_FILBLKS_MAX(a,b)	max_t(xfs_filblks_t, (a), (b))
>  
> -xfs_failaddr_t xfs_btree_sblock_v5hdr_verify(struct xfs_buf *bp);
> -xfs_failaddr_t xfs_btree_sblock_verify(struct xfs_buf *bp,
> +xfs_failaddr_t xfs_btree_sblock_v5hdr_verify(struct xfs_vc *vc, struct xfs_buf *bp);
> +xfs_failaddr_t xfs_btree_sblock_verify(struct xfs_vc *vc, struct xfs_buf *bp,
>  		unsigned int max_recs);
> -xfs_failaddr_t xfs_btree_lblock_v5hdr_verify(struct xfs_buf *bp,
> +xfs_failaddr_t xfs_btree_lblock_v5hdr_verify(struct xfs_vc *vc, struct xfs_buf *bp,
>  		uint64_t owner);
> -xfs_failaddr_t xfs_btree_lblock_verify(struct xfs_buf *bp,
> +xfs_failaddr_t xfs_btree_lblock_verify(struct xfs_vc *vc, struct xfs_buf *bp,
>  		unsigned int max_recs);
>  
>  uint xfs_btree_compute_maxlevels(uint *limits, unsigned long len);
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index 376bee94b5dd..38862a0990d4 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -118,6 +118,7 @@ xfs_da_state_free(xfs_da_state_t *state)
>  
>  static xfs_failaddr_t
>  xfs_da3_node_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -167,14 +168,15 @@ xfs_da3_node_verify(
>  
>  static void
>  xfs_da3_node_write_verify(
> -	struct xfs_buf	*bp)
> +	struct xfs_vc		*vc,
> +	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
>  	struct xfs_buf_log_item	*bip = bp->b_log_item;
>  	struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
>  	xfs_failaddr_t		fa;
>  
> -	fa = xfs_da3_node_verify(bp);
> +	fa = xfs_da3_node_verify(vc, bp);
>  	if (fa) {
>  		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  		return;
> @@ -197,6 +199,7 @@ xfs_da3_node_write_verify(
>   */
>  static void
>  xfs_da3_node_read_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_da_blkinfo	*info = bp->b_addr;
> @@ -211,19 +214,19 @@ xfs_da3_node_read_verify(
>  			}
>  			/* fall through */
>  		case XFS_DA_NODE_MAGIC:
> -			fa = xfs_da3_node_verify(bp);
> +			fa = xfs_da3_node_verify(vc, bp);
>  			if (fa)
>  				xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  			return;
>  		case XFS_ATTR_LEAF_MAGIC:
>  		case XFS_ATTR3_LEAF_MAGIC:
>  			bp->b_ops = &xfs_attr3_leaf_buf_ops;
> -			bp->b_ops->verify_read(bp);
> +			bp->b_ops->verify_read(vc, bp);
>  			return;
>  		case XFS_DIR2_LEAFN_MAGIC:
>  		case XFS_DIR3_LEAFN_MAGIC:
>  			bp->b_ops = &xfs_dir3_leafn_buf_ops;
> -			bp->b_ops->verify_read(bp);
> +			bp->b_ops->verify_read(vc, bp);
>  			return;
>  		default:
>  			xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
> @@ -234,6 +237,7 @@ xfs_da3_node_read_verify(
>  /* Verify the structure of a da3 block. */
>  static xfs_failaddr_t
>  xfs_da3_node_verify_struct(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_da_blkinfo	*info = bp->b_addr;
> @@ -241,15 +245,15 @@ xfs_da3_node_verify_struct(
>  	switch (be16_to_cpu(info->magic)) {
>  	case XFS_DA3_NODE_MAGIC:
>  	case XFS_DA_NODE_MAGIC:
> -		return xfs_da3_node_verify(bp);
> +		return xfs_da3_node_verify(vc, bp);
>  	case XFS_ATTR_LEAF_MAGIC:
>  	case XFS_ATTR3_LEAF_MAGIC:
>  		bp->b_ops = &xfs_attr3_leaf_buf_ops;
> -		return bp->b_ops->verify_struct(bp);
> +		return bp->b_ops->verify_struct(vc, bp);
>  	case XFS_DIR2_LEAFN_MAGIC:
>  	case XFS_DIR3_LEAFN_MAGIC:
>  		bp->b_ops = &xfs_dir3_leafn_buf_ops;
> -		return bp->b_ops->verify_struct(bp);
> +		return bp->b_ops->verify_struct(vc, bp);
>  	default:
>  		return __this_address;
>  	}
> diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c
> index 30ed5919da72..65ba4eccce8b 100644
> --- a/fs/xfs/libxfs/xfs_dir2_block.c
> +++ b/fs/xfs/libxfs/xfs_dir2_block.c
> @@ -48,6 +48,7 @@ xfs_dir_startup(void)
>  
>  static xfs_failaddr_t
>  xfs_dir3_block_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -66,11 +67,12 @@ xfs_dir3_block_verify(
>  		if (hdr3->magic != cpu_to_be32(XFS_DIR2_BLOCK_MAGIC))
>  			return __this_address;
>  	}
> -	return __xfs_dir3_data_check(NULL, bp);
> +	return __xfs_dir3_data_check(vc, NULL, bp);
>  }
>  
>  static void
>  xfs_dir3_block_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -80,7 +82,7 @@ xfs_dir3_block_read_verify(
>  	     !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF))
>  		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
>  	else {
> -		fa = xfs_dir3_block_verify(bp);
> +		fa = xfs_dir3_block_verify(vc, bp);
>  		if (fa)
>  			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  	}
> @@ -88,6 +90,7 @@ xfs_dir3_block_read_verify(
>  
>  static void
>  xfs_dir3_block_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -95,7 +98,7 @@ xfs_dir3_block_write_verify(
>  	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;
>  	xfs_failaddr_t		fa;
>  
> -	fa = xfs_dir3_block_verify(bp);
> +	fa = xfs_dir3_block_verify(vc, bp);
>  	if (fa) {
>  		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  		return;
> diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
> index 01162c62ec8f..6530621d8144 100644
> --- a/fs/xfs/libxfs/xfs_dir2_data.c
> +++ b/fs/xfs/libxfs/xfs_dir2_data.c
> @@ -22,6 +22,7 @@
>  #include "xfs_log.h"
>  
>  static xfs_failaddr_t xfs_dir2_data_freefind_verify(
> +		struct xfs_vc *vc,
>  		struct xfs_dir2_data_hdr *hdr, struct xfs_dir2_data_free *bf,
>  		struct xfs_dir2_data_unused *dup,
>  		struct xfs_dir2_data_free **bf_ent);
> @@ -33,6 +34,7 @@ static xfs_failaddr_t xfs_dir2_data_freefind_verify(
>   */
>  xfs_failaddr_t
>  __xfs_dir3_data_check(
> +	struct xfs_vc		*vc,		/* verifier context */
>  	struct xfs_inode	*dp,		/* incore inode pointer */
>  	struct xfs_buf		*bp)		/* data block's buffer */
>  {
> @@ -149,7 +151,7 @@ __xfs_dir3_data_check(
>  			if (be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)) !=
>  			    (char *)dup - (char *)hdr)
>  				return __this_address;
> -			fa = xfs_dir2_data_freefind_verify(hdr, bf, dup, &dfp);
> +			fa = xfs_dir2_data_freefind_verify(vc, hdr, bf, dup, &dfp);
>  			if (fa)
>  				return fa;
>  			if (dfp) {
> @@ -233,9 +235,10 @@ xfs_dir3_data_check(
>  	struct xfs_inode	*dp,
>  	struct xfs_buf		*bp)
>  {
> +	struct xfs_vc		vc = { 0 };
>  	xfs_failaddr_t		fa;
>  
> -	fa = __xfs_dir3_data_check(dp, bp);
> +	fa = __xfs_dir3_data_check(&vc, dp, bp);
>  	if (!fa)
>  		return;
>  	xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, dp->i_mount,
> @@ -247,6 +250,7 @@ xfs_dir3_data_check(
>  
>  static xfs_failaddr_t
>  xfs_dir3_data_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -265,7 +269,7 @@ xfs_dir3_data_verify(
>  		if (hdr3->magic != cpu_to_be32(XFS_DIR2_DATA_MAGIC))
>  			return __this_address;
>  	}
> -	return __xfs_dir3_data_check(NULL, bp);
> +	return __xfs_dir3_data_check(vc, NULL, bp);
>  }
>  
>  /*
> @@ -275,6 +279,7 @@ xfs_dir3_data_verify(
>   */
>  static void
>  xfs_dir3_data_reada_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_dir2_data_hdr *hdr = bp->b_addr;
> @@ -283,12 +288,12 @@ xfs_dir3_data_reada_verify(
>  	case cpu_to_be32(XFS_DIR2_BLOCK_MAGIC):
>  	case cpu_to_be32(XFS_DIR3_BLOCK_MAGIC):
>  		bp->b_ops = &xfs_dir3_block_buf_ops;
> -		bp->b_ops->verify_read(bp);
> +		bp->b_ops->verify_read(vc, bp);
>  		return;
>  	case cpu_to_be32(XFS_DIR2_DATA_MAGIC):
>  	case cpu_to_be32(XFS_DIR3_DATA_MAGIC):
>  		bp->b_ops = &xfs_dir3_data_buf_ops;
> -		bp->b_ops->verify_read(bp);
> +		bp->b_ops->verify_read(vc, bp);
>  		return;
>  	default:
>  		xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
> @@ -298,6 +303,7 @@ xfs_dir3_data_reada_verify(
>  
>  static void
>  xfs_dir3_data_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -307,7 +313,7 @@ xfs_dir3_data_read_verify(
>  	    !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF))
>  		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
>  	else {
> -		fa = xfs_dir3_data_verify(bp);
> +		fa = xfs_dir3_data_verify(vc, bp);
>  		if (fa)
>  			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  	}
> @@ -315,6 +321,7 @@ xfs_dir3_data_read_verify(
>  
>  static void
>  xfs_dir3_data_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -322,7 +329,7 @@ xfs_dir3_data_write_verify(
>  	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;
>  	xfs_failaddr_t		fa;
>  
> -	fa = xfs_dir3_data_verify(bp);
> +	fa = xfs_dir3_data_verify(vc, bp);
>  	if (fa) {
>  		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  		return;
> @@ -384,6 +391,7 @@ xfs_dir3_data_readahead(
>   */
>  static xfs_failaddr_t
>  xfs_dir2_data_freefind_verify(
> +	struct xfs_vc			*vc,
>  	struct xfs_dir2_data_hdr	*hdr,
>  	struct xfs_dir2_data_free	*bf,
>  	struct xfs_dir2_data_unused	*dup,
> @@ -957,6 +965,7 @@ xfs_dir2_data_make_free(
>  /* Check our free data for obvious signs of corruption. */
>  static inline xfs_failaddr_t
>  xfs_dir2_data_check_free(
> +	struct xfs_vc			*vc,
>  	struct xfs_dir2_data_hdr	*hdr,
>  	struct xfs_dir2_data_unused	*dup,
>  	xfs_dir2_data_aoff_t		offset,
> @@ -982,6 +991,7 @@ xfs_dir2_data_check_free(
>  /* Sanity-check a new bestfree entry. */
>  static inline xfs_failaddr_t
>  xfs_dir2_data_check_new_free(
> +	struct xfs_vc			*vc,
>  	struct xfs_dir2_data_hdr	*hdr,
>  	struct xfs_dir2_data_free	*dfp,
>  	struct xfs_dir2_data_unused	*newdup)
> @@ -1013,6 +1023,7 @@ xfs_dir2_data_use_free(
>  	xfs_dir2_data_unused_t	*newdup;	/* new unused entry */
>  	xfs_dir2_data_unused_t	*newdup2;	/* another new unused entry */
>  	struct xfs_dir2_data_free *bf;
> +	struct xfs_vc		vc = { 0 };
>  	xfs_failaddr_t		fa;
>  	int			matchback;	/* matches end of freespace */
>  	int			matchfront;	/* matches start of freespace */
> @@ -1020,7 +1031,7 @@ xfs_dir2_data_use_free(
>  	int			oldlen;		/* old unused entry's length */
>  
>  	hdr = bp->b_addr;
> -	fa = xfs_dir2_data_check_free(hdr, dup, offset, len);
> +	fa = xfs_dir2_data_check_free(&vc, hdr, dup, offset, len);
>  	if (fa)
>  		goto corrupt;
>  	/*
> @@ -1067,7 +1078,7 @@ xfs_dir2_data_use_free(
>  			xfs_dir2_data_freeremove(hdr, bf, dfp, needlogp);
>  			dfp = xfs_dir2_data_freeinsert(hdr, bf, newdup,
>  						       needlogp);
> -			fa = xfs_dir2_data_check_new_free(hdr, dfp, newdup);
> +			fa = xfs_dir2_data_check_new_free(&vc, hdr, dfp, newdup);
>  			if (fa)
>  				goto corrupt;
>  			/*
> @@ -1095,7 +1106,7 @@ xfs_dir2_data_use_free(
>  			xfs_dir2_data_freeremove(hdr, bf, dfp, needlogp);
>  			dfp = xfs_dir2_data_freeinsert(hdr, bf, newdup,
>  						       needlogp);
> -			fa = xfs_dir2_data_check_new_free(hdr, dfp, newdup);
> +			fa = xfs_dir2_data_check_new_free(&vc, hdr, dfp, newdup);
>  			if (fa)
>  				goto corrupt;
>  			/*
> diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c
> index 1728a3e6f5cf..1122a639b603 100644
> --- a/fs/xfs/libxfs/xfs_dir2_leaf.c
> +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c
> @@ -40,6 +40,7 @@ static void xfs_dir3_leaf_log_tail(struct xfs_da_args *args,
>  #ifdef DEBUG
>  static xfs_failaddr_t
>  xfs_dir3_leaf1_check(
> +	struct xfs_vc		*vc,
>  	struct xfs_inode	*dp,
>  	struct xfs_buf		*bp)
>  {
> @@ -55,7 +56,7 @@ xfs_dir3_leaf1_check(
>  	} else if (leafhdr.magic != XFS_DIR2_LEAF1_MAGIC)
>  		return __this_address;
>  
> -	return xfs_dir3_leaf_check_int(dp->i_mount, dp, &leafhdr, leaf);
> +	return xfs_dir3_leaf_check_int(vc, dp->i_mount, dp, &leafhdr, leaf);
>  }
>  
>  static inline void
> @@ -63,9 +64,10 @@ xfs_dir3_leaf_check(
>  	struct xfs_inode	*dp,
>  	struct xfs_buf		*bp)
>  {
> +	struct xfs_vc		vc = { 0 };
>  	xfs_failaddr_t		fa;
>  
> -	fa = xfs_dir3_leaf1_check(dp, bp);
> +	fa = xfs_dir3_leaf1_check(&vc, dp, bp);
>  	if (!fa)
>  		return;
>  	xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, dp->i_mount,
> @@ -79,6 +81,7 @@ xfs_dir3_leaf_check(
>  
>  xfs_failaddr_t
>  xfs_dir3_leaf_check_int(
> +	struct xfs_vc		*vc,
>  	struct xfs_mount	*mp,
>  	struct xfs_inode	*dp,
>  	struct xfs_dir3_icleaf_hdr *hdr,
> @@ -142,6 +145,7 @@ xfs_dir3_leaf_check_int(
>   */
>  static xfs_failaddr_t
>  xfs_dir3_leaf_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp,
>  	uint16_t		magic)
>  {
> @@ -170,13 +174,14 @@ xfs_dir3_leaf_verify(
>  			return __this_address;
>  	}
>  
> -	return xfs_dir3_leaf_check_int(mp, NULL, NULL, leaf);
> +	return xfs_dir3_leaf_check_int(vc, mp, NULL, NULL, leaf);
>  }
>  
>  static void
>  __read_verify(
> -	struct xfs_buf  *bp,
> -	uint16_t	magic)
> +	struct xfs_vc		*vc,
> +	struct xfs_buf  	*bp,
> +	uint16_t		magic)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
>  	xfs_failaddr_t		fa;
> @@ -185,7 +190,7 @@ __read_verify(
>  	     !xfs_buf_verify_cksum(bp, XFS_DIR3_LEAF_CRC_OFF))
>  		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
>  	else {
> -		fa = xfs_dir3_leaf_verify(bp, magic);
> +		fa = xfs_dir3_leaf_verify(vc, bp, magic);
>  		if (fa)
>  			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  	}
> @@ -193,15 +198,16 @@ __read_verify(
>  
>  static void
>  __write_verify(
> -	struct xfs_buf  *bp,
> -	uint16_t	magic)
> +	struct xfs_vc		*vc,
> +	struct xfs_buf  	*bp,
> +	uint16_t		magic)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
>  	struct xfs_buf_log_item	*bip = bp->b_log_item;
>  	struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr;
>  	xfs_failaddr_t		fa;
>  
> -	fa = xfs_dir3_leaf_verify(bp, magic);
> +	fa = xfs_dir3_leaf_verify(vc, bp, magic);
>  	if (fa) {
>  		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  		return;
> @@ -218,44 +224,50 @@ __write_verify(
>  
>  static xfs_failaddr_t
>  xfs_dir3_leaf1_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
> -	return xfs_dir3_leaf_verify(bp, XFS_DIR2_LEAF1_MAGIC);
> +	return xfs_dir3_leaf_verify(vc, bp, XFS_DIR2_LEAF1_MAGIC);
>  }
>  
>  static void
>  xfs_dir3_leaf1_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
> -	__read_verify(bp, XFS_DIR2_LEAF1_MAGIC);
> +	__read_verify(vc, bp, XFS_DIR2_LEAF1_MAGIC);
>  }
>  
>  static void
>  xfs_dir3_leaf1_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
> -	__write_verify(bp, XFS_DIR2_LEAF1_MAGIC);
> +	__write_verify(vc, bp, XFS_DIR2_LEAF1_MAGIC);
>  }
>  
>  static xfs_failaddr_t
>  xfs_dir3_leafn_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
> -	return xfs_dir3_leaf_verify(bp, XFS_DIR2_LEAFN_MAGIC);
> +	return xfs_dir3_leaf_verify(vc, bp, XFS_DIR2_LEAFN_MAGIC);
>  }
>  
>  static void
>  xfs_dir3_leafn_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
> -	__read_verify(bp, XFS_DIR2_LEAFN_MAGIC);
> +	__read_verify(vc, bp, XFS_DIR2_LEAFN_MAGIC);
>  }
>  
>  static void
>  xfs_dir3_leafn_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
> -	__write_verify(bp, XFS_DIR2_LEAFN_MAGIC);
> +	__write_verify(vc, bp, XFS_DIR2_LEAFN_MAGIC);
>  }
>  
>  const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops = {
> diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c
> index f1bb3434f51c..70f54145d0b0 100644
> --- a/fs/xfs/libxfs/xfs_dir2_node.c
> +++ b/fs/xfs/libxfs/xfs_dir2_node.c
> @@ -43,6 +43,7 @@ static int xfs_dir2_node_addname_int(xfs_da_args_t *args,
>  #ifdef DEBUG
>  static xfs_failaddr_t
>  xfs_dir3_leafn_check(
> +	struct xfs_vc		*vc,
>  	struct xfs_inode	*dp,
>  	struct xfs_buf		*bp)
>  {
> @@ -58,7 +59,7 @@ xfs_dir3_leafn_check(
>  	} else if (leafhdr.magic != XFS_DIR2_LEAFN_MAGIC)
>  		return __this_address;
>  
> -	return xfs_dir3_leaf_check_int(dp->i_mount, dp, &leafhdr, leaf);
> +	return xfs_dir3_leaf_check_int(vc, dp->i_mount, dp, &leafhdr, leaf);
>  }
>  
>  static inline void
> @@ -66,9 +67,10 @@ xfs_dir3_leaf_check(
>  	struct xfs_inode	*dp,
>  	struct xfs_buf		*bp)
>  {
> +	struct xfs_vc		vc = { 0 };
>  	xfs_failaddr_t		fa;
>  
> -	fa = xfs_dir3_leafn_check(dp, bp);
> +	fa = xfs_dir3_leafn_check(&vc, dp, bp);
>  	if (!fa)
>  		return;
>  	xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, dp->i_mount,
> @@ -82,6 +84,7 @@ xfs_dir3_leaf_check(
>  
>  static xfs_failaddr_t
>  xfs_dir3_free_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -110,6 +113,7 @@ xfs_dir3_free_verify(
>  
>  static void
>  xfs_dir3_free_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -119,7 +123,7 @@ xfs_dir3_free_read_verify(
>  	    !xfs_buf_verify_cksum(bp, XFS_DIR3_FREE_CRC_OFF))
>  		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
>  	else {
> -		fa = xfs_dir3_free_verify(bp);
> +		fa = xfs_dir3_free_verify(vc, bp);
>  		if (fa)
>  			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  	}
> @@ -127,6 +131,7 @@ xfs_dir3_free_read_verify(
>  
>  static void
>  xfs_dir3_free_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -134,7 +139,7 @@ xfs_dir3_free_write_verify(
>  	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;
>  	xfs_failaddr_t		fa;
>  
> -	fa = xfs_dir3_free_verify(bp);
> +	fa = xfs_dir3_free_verify(vc, bp);
>  	if (fa) {
>  		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  		return;
> @@ -159,6 +164,7 @@ const struct xfs_buf_ops xfs_dir3_free_buf_ops = {
>  /* Everything ok in the free block header? */
>  static xfs_failaddr_t
>  xfs_dir3_free_header_check(
> +	struct xfs_vc		*vc,
>  	struct xfs_inode	*dp,
>  	xfs_dablk_t		fbno,
>  	struct xfs_buf		*bp)
> @@ -201,6 +207,7 @@ __xfs_dir3_free_read(
>  	xfs_daddr_t		mappedbno,
>  	struct xfs_buf		**bpp)
>  {
> +	struct xfs_vc		vc = { 0 };
>  	xfs_failaddr_t		fa;
>  	int			err;
>  
> @@ -210,7 +217,7 @@ __xfs_dir3_free_read(
>  		return err;
>  
>  	/* Check things that we can't do in the verifier. */
> -	fa = xfs_dir3_free_header_check(dp, fbno, *bpp);
> +	fa = xfs_dir3_free_header_check(&vc, dp, fbno, *bpp);
>  	if (fa) {
>  		xfs_verifier_error(*bpp, -EFSCORRUPTED, fa);
>  		xfs_trans_brelse(tp, *bpp);
> diff --git a/fs/xfs/libxfs/xfs_dir2_priv.h b/fs/xfs/libxfs/xfs_dir2_priv.h
> index 59f9fb2241a5..c8d5dc67e02b 100644
> --- a/fs/xfs/libxfs/xfs_dir2_priv.h
> +++ b/fs/xfs/libxfs/xfs_dir2_priv.h
> @@ -32,7 +32,7 @@ extern void xfs_dir3_data_check(struct xfs_inode *dp, struct xfs_buf *bp);
>  #define	xfs_dir3_data_check(dp,bp)
>  #endif
>  
> -extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_inode *dp,
> +extern xfs_failaddr_t __xfs_dir3_data_check(struct xfs_vc *vc, struct xfs_inode *dp,
>  		struct xfs_buf *bp);
>  extern int xfs_dir3_data_read(struct xfs_trans *tp, struct xfs_inode *dp,
>  		xfs_dablk_t bno, xfs_daddr_t mapped_bno, struct xfs_buf **bpp);
> @@ -78,7 +78,7 @@ xfs_dir3_leaf_find_entry(struct xfs_dir3_icleaf_hdr *leafhdr,
>  		int lowstale, int highstale, int *lfloglow, int *lfloghigh);
>  extern int xfs_dir2_node_to_leaf(struct xfs_da_state *state);
>  
> -extern xfs_failaddr_t xfs_dir3_leaf_check_int(struct xfs_mount *mp,
> +extern xfs_failaddr_t xfs_dir3_leaf_check_int(struct xfs_vc *vc, struct xfs_mount *mp,
>  		struct xfs_inode *dp, struct xfs_dir3_icleaf_hdr *hdr,
>  		struct xfs_dir2_leaf *leaf);
>  
> @@ -117,7 +117,7 @@ extern int xfs_dir2_sf_create(struct xfs_da_args *args, xfs_ino_t pino);
>  extern int xfs_dir2_sf_lookup(struct xfs_da_args *args);
>  extern int xfs_dir2_sf_removename(struct xfs_da_args *args);
>  extern int xfs_dir2_sf_replace(struct xfs_da_args *args);
> -extern xfs_failaddr_t xfs_dir2_sf_verify(struct xfs_inode *ip);
> +extern xfs_failaddr_t xfs_dir2_sf_verify(struct xfs_vc *vc, struct xfs_inode *ip);
>  
>  /* xfs_dir2_readdir.c */
>  extern int xfs_readdir(struct xfs_trans *tp, struct xfs_inode *dp,
> diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c
> index 585dfdb7b6b6..ea47b403c1c1 100644
> --- a/fs/xfs/libxfs/xfs_dir2_sf.c
> +++ b/fs/xfs/libxfs/xfs_dir2_sf.c
> @@ -618,6 +618,7 @@ xfs_dir2_sf_check(
>  /* Verify the consistency of an inline directory. */
>  xfs_failaddr_t
>  xfs_dir2_sf_verify(
> +	struct xfs_vc			*vc,
>  	struct xfs_inode		*ip)
>  {
>  	struct xfs_mount		*mp = ip->i_mount;
> diff --git a/fs/xfs/libxfs/xfs_dquot_buf.c b/fs/xfs/libxfs/xfs_dquot_buf.c
> index d293f371dd54..0dc0a8d7ffc4 100644
> --- a/fs/xfs/libxfs/xfs_dquot_buf.c
> +++ b/fs/xfs/libxfs/xfs_dquot_buf.c
> @@ -37,6 +37,7 @@ xfs_calc_dquots_per_chunk(
>  
>  xfs_failaddr_t
>  xfs_dquot_verify(
> +	struct xfs_vc	 *vc,
>  	struct xfs_mount *mp,
>  	xfs_disk_dquot_t *ddq,
>  	xfs_dqid_t	 id,
> @@ -95,6 +96,7 @@ xfs_dquot_verify(
>  
>  xfs_failaddr_t
>  xfs_dqblk_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_mount	*mp,
>  	struct xfs_dqblk	*dqb,
>  	xfs_dqid_t	 	id,
> @@ -104,7 +106,7 @@ xfs_dqblk_verify(
>  	    !uuid_equal(&dqb->dd_uuid, &mp->m_sb.sb_meta_uuid))
>  		return __this_address;
>  
> -	return xfs_dquot_verify(mp, &dqb->dd_diskdq, id, type);
> +	return xfs_dquot_verify(vc, mp, &dqb->dd_diskdq, id, type);
>  }
>  
>  /*
> @@ -174,6 +176,7 @@ xfs_dquot_buf_verify_crc(
>  
>  STATIC xfs_failaddr_t
>  xfs_dquot_buf_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_mount	*mp,
>  	struct xfs_buf		*bp,
>  	bool			readahead)
> @@ -209,7 +212,7 @@ xfs_dquot_buf_verify(
>  		if (i == 0)
>  			id = be32_to_cpu(ddq->d_id);
>  
> -		fa = xfs_dqblk_verify(mp, &dqb[i], id + i, 0);
> +		fa = xfs_dqblk_verify(vc, mp, &dqb[i], id + i, 0);
>  		if (fa) {
>  			if (!readahead)
>  				xfs_buf_verifier_error(bp, -EFSCORRUPTED,
> @@ -224,22 +227,24 @@ xfs_dquot_buf_verify(
>  
>  static xfs_failaddr_t
>  xfs_dquot_buf_verify_struct(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
>  
> -	return xfs_dquot_buf_verify(mp, bp, false);
> +	return xfs_dquot_buf_verify(vc, mp, bp, false);
>  }
>  
>  static void
>  xfs_dquot_buf_read_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
>  
>  	if (!xfs_dquot_buf_verify_crc(mp, bp, false))
>  		return;
> -	xfs_dquot_buf_verify(mp, bp, false);
> +	xfs_dquot_buf_verify(vc, mp, bp, false);
>  }
>  
>  /*
> @@ -250,12 +255,13 @@ xfs_dquot_buf_read_verify(
>   */
>  static void
>  xfs_dquot_buf_readahead_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
>  
>  	if (!xfs_dquot_buf_verify_crc(mp, bp, true) ||
> -	    xfs_dquot_buf_verify(mp, bp, true) != NULL) {
> +	    xfs_dquot_buf_verify(vc, mp, bp, true) != NULL) {
>  		xfs_buf_ioerror(bp, -EIO);
>  		bp->b_flags &= ~XBF_DONE;
>  	}
> @@ -268,11 +274,12 @@ xfs_dquot_buf_readahead_verify(
>   */
>  static void
>  xfs_dquot_buf_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
>  
> -	xfs_dquot_buf_verify(mp, bp, false);
> +	xfs_dquot_buf_verify(vc, mp, bp, false);
>  }
>  
>  const struct xfs_buf_ops xfs_dquot_buf_ops = {
> diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
> index a8f6db735d5d..1b2b3b63b207 100644
> --- a/fs/xfs/libxfs/xfs_ialloc.c
> +++ b/fs/xfs/libxfs/xfs_ialloc.c
> @@ -2497,6 +2497,7 @@ xfs_ialloc_log_agi(
>  
>  static xfs_failaddr_t
>  xfs_agi_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount *mp = bp->b_target->bt_mount;
> @@ -2549,6 +2550,7 @@ xfs_agi_verify(
>  
>  static void
>  xfs_agi_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount *mp = bp->b_target->bt_mount;
> @@ -2558,7 +2560,7 @@ xfs_agi_read_verify(
>  	    !xfs_buf_verify_cksum(bp, XFS_AGI_CRC_OFF))
>  		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
>  	else {
> -		fa = xfs_agi_verify(bp);
> +		fa = xfs_agi_verify(vc, bp);
>  		if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_IALLOC_READ_AGI))
>  			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  	}
> @@ -2566,13 +2568,14 @@ xfs_agi_read_verify(
>  
>  static void
>  xfs_agi_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
>  	struct xfs_buf_log_item	*bip = bp->b_log_item;
>  	xfs_failaddr_t		fa;
>  
> -	fa = xfs_agi_verify(bp);
> +	fa = xfs_agi_verify(vc, bp);
>  	if (fa) {
>  		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  		return;
> diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
> index 7fbf8af0b159..02d7dd5c265c 100644
> --- a/fs/xfs/libxfs/xfs_ialloc_btree.c
> +++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
> @@ -256,6 +256,7 @@ xfs_inobt_diff_two_keys(
>  
>  static xfs_failaddr_t
>  xfs_inobt_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -276,7 +277,7 @@ xfs_inobt_verify(
>  	switch (block->bb_magic) {
>  	case cpu_to_be32(XFS_IBT_CRC_MAGIC):
>  	case cpu_to_be32(XFS_FIBT_CRC_MAGIC):
> -		fa = xfs_btree_sblock_v5hdr_verify(bp);
> +		fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
>  		if (fa)
>  			return fa;
>  		/* fall through */
> @@ -292,19 +293,20 @@ xfs_inobt_verify(
>  	if (level >= mp->m_in_maxlevels)
>  		return __this_address;
>  
> -	return xfs_btree_sblock_verify(bp, mp->m_inobt_mxr[level != 0]);
> +	return xfs_btree_sblock_verify(vc, bp, mp->m_inobt_mxr[level != 0]);
>  }
>  
>  static void
>  xfs_inobt_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	xfs_failaddr_t	fa;
>  
> -	if (!xfs_btree_sblock_verify_crc(bp))
> +	if (!xfs_btree_sblock_verify_crc(vc, bp))
>  		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
>  	else {
> -		fa = xfs_inobt_verify(bp);
> +		fa = xfs_inobt_verify(vc, bp);
>  		if (fa)
>  			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  	}
> @@ -315,11 +317,12 @@ xfs_inobt_read_verify(
>  
>  static void
>  xfs_inobt_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	xfs_failaddr_t	fa;
>  
> -	fa = xfs_inobt_verify(bp);
> +	fa = xfs_inobt_verify(vc, bp);
>  	if (fa) {
>  		trace_xfs_btree_corrupt(bp, _RET_IP_);
>  		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> index 09d9c8cfa4a0..7d9b4ea6eba9 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.c
> +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> @@ -77,6 +77,7 @@ xfs_dinode_good_version(
>   */
>  static void
>  xfs_inode_buf_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp,
>  	bool		readahead)
>  {
> @@ -126,23 +127,26 @@ xfs_inode_buf_verify(
>  
>  static void
>  xfs_inode_buf_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
> -	xfs_inode_buf_verify(bp, false);
> +	xfs_inode_buf_verify(vc, bp, false);
>  }
>  
>  static void
>  xfs_inode_buf_readahead_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
> -	xfs_inode_buf_verify(bp, true);
> +	xfs_inode_buf_verify(vc, bp, true);
>  }
>  
>  static void
>  xfs_inode_buf_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
> -	xfs_inode_buf_verify(bp, false);
> +	xfs_inode_buf_verify(vc, bp, false);
>  }
>  
>  const struct xfs_buf_ops xfs_inode_buf_ops = {
> @@ -376,6 +380,7 @@ xfs_log_dinode_to_disk(
>  
>  static xfs_failaddr_t
>  xfs_dinode_verify_fork(
> +	struct xfs_vc		*vc,
>  	struct xfs_dinode	*dip,
>  	struct xfs_mount	*mp,
>  	int			whichfork)
> @@ -417,6 +422,7 @@ xfs_dinode_verify_fork(
>  
>  static xfs_failaddr_t
>  xfs_dinode_verify_forkoff(
> +	struct xfs_vc		*vc,
>  	struct xfs_dinode	*dip,
>  	struct xfs_mount	*mp)
>  {
> @@ -442,6 +448,7 @@ xfs_dinode_verify_forkoff(
>  
>  xfs_failaddr_t
>  xfs_dinode_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_mount	*mp,
>  	xfs_ino_t		ino,
>  	struct xfs_dinode	*dip)
> @@ -496,7 +503,7 @@ xfs_dinode_verify(
>  		return __this_address;
>  
>  	/* check for illegal values of forkoff */
> -	fa = xfs_dinode_verify_forkoff(dip, mp);
> +	fa = xfs_dinode_verify_forkoff(vc, dip, mp);
>  	if (fa)
>  		return fa;
>  
> @@ -512,7 +519,7 @@ xfs_dinode_verify(
>  	case S_IFREG:
>  	case S_IFLNK:
>  	case S_IFDIR:
> -		fa = xfs_dinode_verify_fork(dip, mp, XFS_DATA_FORK);
> +		fa = xfs_dinode_verify_fork(vc, dip, mp, XFS_DATA_FORK);
>  		if (fa)
>  			return fa;
>  		break;
> @@ -524,7 +531,7 @@ xfs_dinode_verify(
>  	}
>  
>  	if (XFS_DFORK_Q(dip)) {
> -		fa = xfs_dinode_verify_fork(dip, mp, XFS_ATTR_FORK);
> +		fa = xfs_dinode_verify_fork(vc, dip, mp, XFS_ATTR_FORK);
>  		if (fa)
>  			return fa;
>  	} else {
> @@ -546,7 +553,7 @@ xfs_dinode_verify(
>  	}
>  
>  	/* extent size hint validation */
> -	fa = xfs_inode_validate_extsize(mp, be32_to_cpu(dip->di_extsize),
> +	fa = xfs_inode_validate_extsize(vc, mp, be32_to_cpu(dip->di_extsize),
>  			mode, flags);
>  	if (fa)
>  		return fa;
> @@ -575,7 +582,7 @@ xfs_dinode_verify(
>  		return __this_address;
>  
>  	/* COW extent size hint validation */
> -	fa = xfs_inode_validate_cowextsize(mp, be32_to_cpu(dip->di_cowextsize),
> +	fa = xfs_inode_validate_cowextsize(vc, mp, be32_to_cpu(dip->di_cowextsize),
>  			mode, flags, flags2);
>  	if (fa)
>  		return fa;
> @@ -620,6 +627,7 @@ xfs_iread(
>  {
>  	xfs_buf_t	*bp;
>  	xfs_dinode_t	*dip;
> +	struct xfs_vc	vc = { 0 };
>  	xfs_failaddr_t	fa;
>  	int		error;
>  
> @@ -649,7 +657,7 @@ xfs_iread(
>  		return error;
>  
>  	/* even unallocated inodes are verified */
> -	fa = xfs_dinode_verify(mp, ip->i_ino, dip);
> +	fa = xfs_dinode_verify(&vc, mp, ip->i_ino, dip);
>  	if (fa) {
>  		xfs_inode_verifier_error(ip, -EFSCORRUPTED, "dinode", dip,
>  				sizeof(*dip), fa);
> @@ -728,6 +736,7 @@ xfs_iread(
>   */
>  xfs_failaddr_t
>  xfs_inode_validate_extsize(
> +	struct xfs_vc			*vc,
>  	struct xfs_mount		*mp,
>  	uint32_t			extsize,
>  	uint16_t			mode,
> @@ -785,6 +794,7 @@ xfs_inode_validate_extsize(
>   */
>  xfs_failaddr_t
>  xfs_inode_validate_cowextsize(
> +	struct xfs_vc			*vc,
>  	struct xfs_mount		*mp,
>  	uint32_t			cowextsize,
>  	uint16_t			mode,
> diff --git a/fs/xfs/libxfs/xfs_inode_buf.h b/fs/xfs/libxfs/xfs_inode_buf.h
> index ab0f84165317..fceea886275f 100644
> --- a/fs/xfs/libxfs/xfs_inode_buf.h
> +++ b/fs/xfs/libxfs/xfs_inode_buf.h
> @@ -70,11 +70,11 @@ void	xfs_inobp_check(struct xfs_mount *, struct xfs_buf *);
>  #define	xfs_inobp_check(mp, bp)
>  #endif /* DEBUG */
>  
> -xfs_failaddr_t xfs_dinode_verify(struct xfs_mount *mp, xfs_ino_t ino,
> +xfs_failaddr_t xfs_dinode_verify(struct xfs_vc *vc, struct xfs_mount *mp, xfs_ino_t ino,
>  			   struct xfs_dinode *dip);
> -xfs_failaddr_t xfs_inode_validate_extsize(struct xfs_mount *mp,
> +xfs_failaddr_t xfs_inode_validate_extsize(struct xfs_vc *vc, struct xfs_mount *mp,
>  		uint32_t extsize, uint16_t mode, uint16_t flags);
> -xfs_failaddr_t xfs_inode_validate_cowextsize(struct xfs_mount *mp,
> +xfs_failaddr_t xfs_inode_validate_cowextsize(struct xfs_vc *vc, struct xfs_mount *mp,
>  		uint32_t cowextsize, uint16_t mode, uint16_t flags,
>  		uint64_t flags2);
>  
> diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
> index f9acf1d436f6..49dd81b0728f 100644
> --- a/fs/xfs/libxfs/xfs_inode_fork.c
> +++ b/fs/xfs/libxfs/xfs_inode_fork.c
> @@ -233,10 +233,11 @@ xfs_iformat_extents(
>  
>  		xfs_iext_first(ifp, &icur);
>  		for (i = 0; i < nex; i++, dp++) {
> +			struct xfs_vc	vc = { 0 };
>  			xfs_failaddr_t	fa;
>  
>  			xfs_bmbt_disk_get_all(dp, &new);
> -			fa = xfs_bmap_validate_extent(ip, whichfork, &new);
> +			fa = xfs_bmap_validate_extent(&vc, ip, whichfork, &new);
>  			if (fa) {
>  				xfs_inode_verifier_error(ip, -EFSCORRUPTED,
>  						"xfs_iformat_extents(2)",
> @@ -562,7 +563,7 @@ xfs_iextents_copy(
>  	for_each_xfs_iext(ifp, &icur, &rec) {
>  		if (isnullstartblock(rec.br_startblock))
>  			continue;
> -		ASSERT(xfs_bmap_validate_extent(ip, whichfork, &rec) == NULL);
> +		ASSERT(xfs_bmap_validate_extent(NULL, ip, whichfork, &rec) == NULL);
>  		xfs_bmbt_disk_set_all(dp, &rec);
>  		trace_xfs_write_extent(ip, &icur, state, _RET_IP_);
>  		copied += sizeof(struct xfs_bmbt_rec);
> @@ -701,6 +702,7 @@ struct xfs_ifork_ops xfs_default_ifork_ops = {
>  /* Verify the inline contents of the data fork of an inode. */
>  xfs_failaddr_t
>  xfs_ifork_verify_data(
> +	struct xfs_vc		*vc,
>  	struct xfs_inode	*ip,
>  	struct xfs_ifork_ops	*ops)
>  {
> @@ -711,9 +713,9 @@ xfs_ifork_verify_data(
>  	/* Check the inline data fork if there is one. */
>  	switch (VFS_I(ip)->i_mode & S_IFMT) {
>  	case S_IFDIR:
> -		return ops->verify_dir(ip);
> +		return ops->verify_dir(vc, ip);
>  	case S_IFLNK:
> -		return ops->verify_symlink(ip);
> +		return ops->verify_symlink(vc, ip);
>  	default:
>  		return NULL;
>  	}
> @@ -722,6 +724,7 @@ xfs_ifork_verify_data(
>  /* Verify the inline contents of the attr fork of an inode. */
>  xfs_failaddr_t
>  xfs_ifork_verify_attr(
> +	struct xfs_vc		*vc,
>  	struct xfs_inode	*ip,
>  	struct xfs_ifork_ops	*ops)
>  {
> @@ -730,5 +733,5 @@ xfs_ifork_verify_attr(
>  		return NULL;
>  	if (!XFS_IFORK_PTR(ip, XFS_ATTR_FORK))
>  		return __this_address;
> -	return ops->verify_attr(ip);
> +	return ops->verify_attr(vc, ip);
>  }
> diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h
> index 60361d2d74a1..b2f67389304c 100644
> --- a/fs/xfs/libxfs/xfs_inode_fork.h
> +++ b/fs/xfs/libxfs/xfs_inode_fork.h
> @@ -174,7 +174,7 @@ extern struct kmem_zone	*xfs_ifork_zone;
>  
>  extern void xfs_ifork_init_cow(struct xfs_inode *ip);
>  
> -typedef xfs_failaddr_t (*xfs_ifork_verifier_t)(struct xfs_inode *);
> +typedef xfs_failaddr_t (*xfs_ifork_verifier_t)(struct xfs_vc *vc, struct xfs_inode *);
>  
>  struct xfs_ifork_ops {
>  	xfs_ifork_verifier_t	verify_symlink;
> @@ -183,9 +183,9 @@ struct xfs_ifork_ops {
>  };
>  extern struct xfs_ifork_ops	xfs_default_ifork_ops;
>  
> -xfs_failaddr_t xfs_ifork_verify_data(struct xfs_inode *ip,
> +xfs_failaddr_t xfs_ifork_verify_data(struct xfs_vc *vc, struct xfs_inode *ip,
>  		struct xfs_ifork_ops *ops);
> -xfs_failaddr_t xfs_ifork_verify_attr(struct xfs_inode *ip,
> +xfs_failaddr_t xfs_ifork_verify_attr(struct xfs_vc *vc, struct xfs_inode *ip,
>  		struct xfs_ifork_ops *ops);
>  
>  #endif	/* __XFS_INODE_FORK_H__ */
> diff --git a/fs/xfs/libxfs/xfs_quota_defs.h b/fs/xfs/libxfs/xfs_quota_defs.h
> index 4bfdd5f4c6af..d6af05e0a6f1 100644
> --- a/fs/xfs/libxfs/xfs_quota_defs.h
> +++ b/fs/xfs/libxfs/xfs_quota_defs.h
> @@ -137,9 +137,9 @@ typedef uint16_t	xfs_qwarncnt_t;
>  		(XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA)
>  #define XFS_QMOPT_RESBLK_MASK	(XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS)
>  
> -extern xfs_failaddr_t xfs_dquot_verify(struct xfs_mount *mp,
> +extern xfs_failaddr_t xfs_dquot_verify(struct xfs_vc *vc, struct xfs_mount *mp,
>  		struct xfs_disk_dquot *ddq, xfs_dqid_t id, uint type);
> -extern xfs_failaddr_t xfs_dqblk_verify(struct xfs_mount *mp,
> +extern xfs_failaddr_t xfs_dqblk_verify(struct xfs_vc *vc, struct xfs_mount *mp,
>  		struct xfs_dqblk *dqb, xfs_dqid_t id, uint type);
>  extern int xfs_calc_dquots_per_chunk(unsigned int nbblks);
>  extern int xfs_dqblk_repair(struct xfs_mount *mp, struct xfs_dqblk *dqb,
> diff --git a/fs/xfs/libxfs/xfs_refcount_btree.c b/fs/xfs/libxfs/xfs_refcount_btree.c
> index 1aaa01c97517..125b536538ec 100644
> --- a/fs/xfs/libxfs/xfs_refcount_btree.c
> +++ b/fs/xfs/libxfs/xfs_refcount_btree.c
> @@ -203,6 +203,7 @@ xfs_refcountbt_diff_two_keys(
>  
>  STATIC xfs_failaddr_t
>  xfs_refcountbt_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -216,7 +217,7 @@ xfs_refcountbt_verify(
>  
>  	if (!xfs_sb_version_hasreflink(&mp->m_sb))
>  		return __this_address;
> -	fa = xfs_btree_sblock_v5hdr_verify(bp);
> +	fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
>  	if (fa)
>  		return fa;
>  
> @@ -227,19 +228,20 @@ xfs_refcountbt_verify(
>  	} else if (level >= mp->m_refc_maxlevels)
>  		return __this_address;
>  
> -	return xfs_btree_sblock_verify(bp, mp->m_refc_mxr[level != 0]);
> +	return xfs_btree_sblock_verify(vc, bp, mp->m_refc_mxr[level != 0]);
>  }
>  
>  STATIC void
>  xfs_refcountbt_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	xfs_failaddr_t	fa;
>  
> -	if (!xfs_btree_sblock_verify_crc(bp))
> +	if (!xfs_btree_sblock_verify_crc(vc, bp))
>  		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
>  	else {
> -		fa = xfs_refcountbt_verify(bp);
> +		fa = xfs_refcountbt_verify(vc, bp);
>  		if (fa)
>  			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  	}
> @@ -250,11 +252,12 @@ xfs_refcountbt_read_verify(
>  
>  STATIC void
>  xfs_refcountbt_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	xfs_failaddr_t	fa;
>  
> -	fa = xfs_refcountbt_verify(bp);
> +	fa = xfs_refcountbt_verify(vc, bp);
>  	if (fa) {
>  		trace_xfs_btree_corrupt(bp, _RET_IP_);
>  		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
> diff --git a/fs/xfs/libxfs/xfs_rmap_btree.c b/fs/xfs/libxfs/xfs_rmap_btree.c
> index f79cf040d745..f8828854ca2f 100644
> --- a/fs/xfs/libxfs/xfs_rmap_btree.c
> +++ b/fs/xfs/libxfs/xfs_rmap_btree.c
> @@ -290,6 +290,7 @@ xfs_rmapbt_diff_two_keys(
>  
>  static xfs_failaddr_t
>  xfs_rmapbt_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -315,7 +316,7 @@ xfs_rmapbt_verify(
>  
>  	if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
>  		return __this_address;
> -	fa = xfs_btree_sblock_v5hdr_verify(bp);
> +	fa = xfs_btree_sblock_v5hdr_verify(vc, bp);
>  	if (fa)
>  		return fa;
>  
> @@ -326,19 +327,20 @@ xfs_rmapbt_verify(
>  	} else if (level >= mp->m_rmap_maxlevels)
>  		return __this_address;
>  
> -	return xfs_btree_sblock_verify(bp, mp->m_rmap_mxr[level != 0]);
> +	return xfs_btree_sblock_verify(vc, bp, mp->m_rmap_mxr[level != 0]);
>  }
>  
>  static void
>  xfs_rmapbt_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	xfs_failaddr_t	fa;
>  
> -	if (!xfs_btree_sblock_verify_crc(bp))
> +	if (!xfs_btree_sblock_verify_crc(vc, bp))
>  		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
>  	else {
> -		fa = xfs_rmapbt_verify(bp);
> +		fa = xfs_rmapbt_verify(vc, bp);
>  		if (fa)
>  			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  	}
> @@ -349,11 +351,12 @@ xfs_rmapbt_read_verify(
>  
>  static void
>  xfs_rmapbt_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	xfs_failaddr_t	fa;
>  
> -	fa = xfs_rmapbt_verify(bp);
> +	fa = xfs_rmapbt_verify(vc, bp);
>  	if (fa) {
>  		trace_xfs_btree_corrupt(bp, _RET_IP_);
>  		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
> diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
> index b228c821bae6..6a0a953553b9 100644
> --- a/fs/xfs/libxfs/xfs_rtbitmap.c
> +++ b/fs/xfs/libxfs/xfs_rtbitmap.c
> @@ -36,6 +36,7 @@
>   */
>  static void
>  xfs_rtbuf_verify_read(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	return;
> @@ -43,6 +44,7 @@ xfs_rtbuf_verify_read(
>  
>  static void
>  xfs_rtbuf_verify_write(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	return;
> diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
> index b5a82acd7dfe..0f8197c368a9 100644
> --- a/fs/xfs/libxfs/xfs_sb.c
> +++ b/fs/xfs/libxfs/xfs_sb.c
> @@ -681,6 +681,7 @@ xfs_sb_to_disk(
>   */
>  static void
>  xfs_sb_read_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_sb		sb;
> @@ -732,13 +733,14 @@ xfs_sb_read_verify(
>   */
>  static void
>  xfs_sb_quiet_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_dsb	*dsb = XFS_BUF_TO_SBP(bp);
>  
>  	if (dsb->sb_magicnum == cpu_to_be32(XFS_SB_MAGIC)) {
>  		/* XFS filesystem, verify noisily! */
> -		xfs_sb_read_verify(bp);
> +		xfs_sb_read_verify(vc, bp);
>  		return;
>  	}
>  	/* quietly fail */
> @@ -747,6 +749,7 @@ xfs_sb_quiet_read_verify(
>  
>  static void
>  xfs_sb_write_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_sb		sb;
> diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h
> index 1c5debe748f0..c10d02addaa1 100644
> --- a/fs/xfs/libxfs/xfs_shared.h
> +++ b/fs/xfs/libxfs/xfs_shared.h
> @@ -132,6 +132,6 @@ bool xfs_symlink_hdr_ok(xfs_ino_t ino, uint32_t offset,
>  			uint32_t size, struct xfs_buf *bp);
>  void xfs_symlink_local_to_remote(struct xfs_trans *tp, struct xfs_buf *bp,
>  				 struct xfs_inode *ip, struct xfs_ifork *ifp);
> -xfs_failaddr_t xfs_symlink_shortform_verify(struct xfs_inode *ip);
> +xfs_failaddr_t xfs_symlink_shortform_verify(struct xfs_vc *vc, struct xfs_inode *ip);
>  
>  #endif /* __XFS_SHARED_H__ */
> diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c
> index 95374ab2dee7..e0ff80797942 100644
> --- a/fs/xfs/libxfs/xfs_symlink_remote.c
> +++ b/fs/xfs/libxfs/xfs_symlink_remote.c
> @@ -88,6 +88,7 @@ xfs_symlink_hdr_ok(
>  
>  static xfs_failaddr_t
>  xfs_symlink_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_mount	*mp = bp->b_target->bt_mount;
> @@ -114,6 +115,7 @@ xfs_symlink_verify(
>  
>  static void
>  xfs_symlink_read_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount *mp = bp->b_target->bt_mount;
> @@ -126,7 +128,7 @@ xfs_symlink_read_verify(
>  	if (!xfs_buf_verify_cksum(bp, XFS_SYMLINK_CRC_OFF))
>  		xfs_verifier_error(bp, -EFSBADCRC, __this_address);
>  	else {
> -		fa = xfs_symlink_verify(bp);
> +		fa = xfs_symlink_verify(vc, bp);
>  		if (fa)
>  			xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  	}
> @@ -134,6 +136,7 @@ xfs_symlink_read_verify(
>  
>  static void
>  xfs_symlink_write_verify(
> +	struct xfs_vc	*vc,
>  	struct xfs_buf	*bp)
>  {
>  	struct xfs_mount *mp = bp->b_target->bt_mount;
> @@ -144,7 +147,7 @@ xfs_symlink_write_verify(
>  	if (!xfs_sb_version_hascrc(&mp->m_sb))
>  		return;
>  
> -	fa = xfs_symlink_verify(bp);
> +	fa = xfs_symlink_verify(vc, bp);
>  	if (fa) {
>  		xfs_verifier_error(bp, -EFSCORRUPTED, fa);
>  		return;
> @@ -202,6 +205,7 @@ xfs_symlink_local_to_remote(
>  /* Verify the consistency of an inline symlink. */
>  xfs_failaddr_t
>  xfs_symlink_shortform_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_inode	*ip)
>  {
>  	char			*sfp;
> diff --git a/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h
> index b9e6c89284c3..6c27103522a9 100644
> --- a/fs/xfs/libxfs/xfs_types.h
> +++ b/fs/xfs/libxfs/xfs_types.h
> @@ -41,6 +41,10 @@ typedef int64_t		xfs_sfiloff_t;	/* signed block number in a file */
>   */
>  typedef void *		xfs_failaddr_t;
>  
> +struct xfs_vc {
> +	xfs_failaddr_t	fa;
> +};
> +
>  /*
>   * Null values for the types.
>   */
> diff --git a/fs/xfs/scrub/btree.c b/fs/xfs/scrub/btree.c
> index 4ae959f7ad2c..8780dcb479de 100644
> --- a/fs/xfs/scrub/btree.c
> +++ b/fs/xfs/scrub/btree.c
> @@ -490,6 +490,7 @@ xchk_btree_get_block(
>  	struct xfs_btree_block	**pblock,
>  	struct xfs_buf		**pbp)
>  {
> +	struct xfs_vc		vc = { 0 };
>  	xfs_failaddr_t		failed_at;
>  	int			error;
>  
> @@ -503,10 +504,10 @@ xchk_btree_get_block(
>  
>  	xfs_btree_get_block(bs->cur, level, pbp);
>  	if (bs->cur->bc_flags & XFS_BTREE_LONG_PTRS)
> -		failed_at = __xfs_btree_check_lblock(bs->cur, *pblock,
> +		failed_at = __xfs_btree_check_lblock(&vc, bs->cur, *pblock,
>  				level, *pbp);
>  	else
> -		failed_at = __xfs_btree_check_sblock(bs->cur, *pblock,
> +		failed_at = __xfs_btree_check_sblock(&vc, bs->cur, *pblock,
>  				 level, *pbp);
>  	if (failed_at) {
>  		xchk_btree_set_corrupt(bs->sc, bs->cur, level);
> diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c
> index 346b02abccf7..1571e66e657a 100644
> --- a/fs/xfs/scrub/common.c
> +++ b/fs/xfs/scrub/common.c
> @@ -791,6 +791,7 @@ xchk_buffer_recheck(
>  	struct xfs_scrub	*sc,
>  	struct xfs_buf		*bp)
>  {
> +	struct xfs_vc		vc = { 0 };
>  	xfs_failaddr_t		fa;
>  
>  	if (bp->b_ops == NULL) {
> @@ -801,7 +802,7 @@ xchk_buffer_recheck(
>  		xchk_set_incomplete(sc);
>  		return;
>  	}
> -	fa = bp->b_ops->verify_struct(bp);
> +	fa = bp->b_ops->verify_struct(&vc, bp);
>  	if (!fa)
>  		return;
>  	sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
> diff --git a/fs/xfs/scrub/dabtree.c b/fs/xfs/scrub/dabtree.c
> index f1260b4bfdee..4626a208d132 100644
> --- a/fs/xfs/scrub/dabtree.c
> +++ b/fs/xfs/scrub/dabtree.c
> @@ -177,6 +177,7 @@ xchk_da_btree_ptr_ok(
>   */
>  static void
>  xchk_da_btree_read_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_da_blkinfo	*info = bp->b_addr;
> @@ -185,7 +186,7 @@ xchk_da_btree_read_verify(
>  	case XFS_DIR2_LEAF1_MAGIC:
>  	case XFS_DIR3_LEAF1_MAGIC:
>  		bp->b_ops = &xfs_dir3_leaf1_buf_ops;
> -		bp->b_ops->verify_read(bp);
> +		bp->b_ops->verify_read(vc, bp);
>  		return;
>  	default:
>  		/*
> @@ -193,12 +194,13 @@ xchk_da_btree_read_verify(
>  		 * DA*_NODE, ATTR*_LEAF, and DIR*_LEAFN blocks.
>  		 */
>  		bp->b_ops = &xfs_da3_node_buf_ops;
> -		bp->b_ops->verify_read(bp);
> +		bp->b_ops->verify_read(vc, bp);
>  		return;
>  	}
>  }
>  static void
>  xchk_da_btree_write_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_da_blkinfo	*info = bp->b_addr;
> @@ -207,7 +209,7 @@ xchk_da_btree_write_verify(
>  	case XFS_DIR2_LEAF1_MAGIC:
>  	case XFS_DIR3_LEAF1_MAGIC:
>  		bp->b_ops = &xfs_dir3_leaf1_buf_ops;
> -		bp->b_ops->verify_write(bp);
> +		bp->b_ops->verify_write(vc, bp);
>  		return;
>  	default:
>  		/*
> @@ -215,12 +217,13 @@ xchk_da_btree_write_verify(
>  		 * DA*_NODE, ATTR*_LEAF, and DIR*_LEAFN blocks.
>  		 */
>  		bp->b_ops = &xfs_da3_node_buf_ops;
> -		bp->b_ops->verify_write(bp);
> +		bp->b_ops->verify_write(vc, bp);
>  		return;
>  	}
>  }
>  static void *
>  xchk_da_btree_verify(
> +	struct xfs_vc		*vc,
>  	struct xfs_buf		*bp)
>  {
>  	struct xfs_da_blkinfo	*info = bp->b_addr;
> @@ -229,10 +232,10 @@ xchk_da_btree_verify(
>  	case XFS_DIR2_LEAF1_MAGIC:
>  	case XFS_DIR3_LEAF1_MAGIC:
>  		bp->b_ops = &xfs_dir3_leaf1_buf_ops;
> -		return bp->b_ops->verify_struct(bp);
> +		return bp->b_ops->verify_struct(vc, bp);
>  	default:
>  		bp->b_ops = &xfs_da3_node_buf_ops;
> -		return bp->b_ops->verify_struct(bp);
> +		return bp->b_ops->verify_struct(vc, bp);
>  	}
>  }
>  
> diff --git a/fs/xfs/scrub/inode.c b/fs/xfs/scrub/inode.c
> index e386c9b0b4ab..f8c6869b8fc6 100644
> --- a/fs/xfs/scrub/inode.c
> +++ b/fs/xfs/scrub/inode.c
> @@ -83,9 +83,10 @@ xchk_inode_extsize(
>  	uint16_t		mode,
>  	uint16_t		flags)
>  {
> +	struct xfs_vc		vc = { 0 };
>  	xfs_failaddr_t		fa;
>  
> -	fa = xfs_inode_validate_extsize(sc->mp, be32_to_cpu(dip->di_extsize),
> +	fa = xfs_inode_validate_extsize(&vc, sc->mp, be32_to_cpu(dip->di_extsize),
>  			mode, flags);
>  	if (fa)
>  		xchk_ino_set_corrupt(sc, ino);
> @@ -106,9 +107,10 @@ xchk_inode_cowextsize(
>  	uint16_t		flags,
>  	uint64_t		flags2)
>  {
> +	struct xfs_vc		vc = { 0 };
>  	xfs_failaddr_t		fa;
>  
> -	fa = xfs_inode_validate_cowextsize(sc->mp,
> +	fa = xfs_inode_validate_cowextsize(&vc, sc->mp,
>  			be32_to_cpu(dip->di_cowextsize), mode, flags,
>  			flags2);
>  	if (fa)
> diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c
> index 4fc0a5ea7673..dc9b5762d1ac 100644
> --- a/fs/xfs/scrub/repair.c
> +++ b/fs/xfs/scrub/repair.c
> @@ -766,11 +766,13 @@ xrep_findroot_block(
>  		if (bp->b_ops != fab->buf_ops)
>  			goto out;
>  	} else {
> +		struct xfs_vc	vc = { 0 };
> +
>  		ASSERT(!xfs_trans_buf_is_dirty(bp));
>  		if (!uuid_equal(&btblock->bb_u.s.bb_uuid,
>  				&mp->m_sb.sb_meta_uuid))
>  			goto out;
> -		fab->buf_ops->verify_read(bp);
> +		fab->buf_ops->verify_read(&vc, bp);
>  		if (bp->b_error) {
>  			bp->b_error = 0;
>  			goto out;
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index b21ea2ba768d..b46e22c7a8c8 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -786,6 +786,8 @@ xfs_buf_ensure_ops(
>  	struct xfs_buf		*bp,
>  	const struct xfs_buf_ops *ops)
>  {
> +	struct xfs_vc	vc = { 0 };

Indentation?

--D

> +
>  	ASSERT(bp->b_flags & XBF_DONE);
>  	ASSERT(bp->b_error == 0);
>  
> @@ -793,7 +795,7 @@ xfs_buf_ensure_ops(
>  		return 0;
>  
>  	bp->b_ops = ops;
> -	bp->b_ops->verify_read(bp);
> +	bp->b_ops->verify_read(&vc, bp);
>  	if (bp->b_error)
>  		bp->b_flags &= ~XBF_DONE;
>  	return bp->b_error;
> @@ -1228,8 +1230,10 @@ xfs_buf_ioend(
>  
>  	/* Only validate buffers that were read without errors */
>  	if (read && !bp->b_error && bp->b_ops) {
> +		struct xfs_vc	vc = { 0 };
> +
>  		ASSERT(!bp->b_iodone);
> -		bp->b_ops->verify_read(bp);
> +		bp->b_ops->verify_read(&vc, bp);
>  	}
>  
>  	if (!bp->b_error)
> @@ -1447,7 +1451,9 @@ _xfs_buf_ioapply(
>  		 * the IO should not be dispatched.
>  		 */
>  		if (bp->b_ops) {
> -			bp->b_ops->verify_write(bp);
> +			struct xfs_vc	vc = { 0 };
> +
> +			bp->b_ops->verify_write(&vc, bp);
>  			if (bp->b_error) {
>  				xfs_force_shutdown(bp->b_target->bt_mount,
>  						   SHUTDOWN_CORRUPT_INCORE);
> diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
> index 5015255b5ede..d1c6c92b7104 100644
> --- a/fs/xfs/xfs_buf.h
> +++ b/fs/xfs/xfs_buf.h
> @@ -125,9 +125,9 @@ struct xfs_buf_map {
>  
>  struct xfs_buf_ops {
>  	char *name;
> -	void (*verify_read)(struct xfs_buf *);
> -	void (*verify_write)(struct xfs_buf *);
> -	xfs_failaddr_t (*verify_struct)(struct xfs_buf *bp);
> +	void (*verify_read)(struct xfs_vc *vc, struct xfs_buf *);
> +	void (*verify_write)(struct xfs_vc *vc, struct xfs_buf *);
> +	xfs_failaddr_t (*verify_struct)(struct xfs_vc *vc, struct xfs_buf *bp);
>  };
>  
>  typedef struct xfs_buf {
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index 87e6dd5326d5..14b386c584b6 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -1074,6 +1074,7 @@ xfs_qm_dqflush(
>  	struct xfs_buf		*bp;
>  	struct xfs_dqblk	*dqb;
>  	struct xfs_disk_dquot	*ddqp;
> +	struct xfs_vc		vc = { 0 };
>  	xfs_failaddr_t		fa;
>  	int			error;
>  
> @@ -1122,7 +1123,7 @@ xfs_qm_dqflush(
>  	/*
>  	 * A simple sanity check in case we got a corrupted dquot.
>  	 */
> -	fa = xfs_dqblk_verify(mp, dqb, be32_to_cpu(ddqp->d_id), 0);
> +	fa = xfs_dqblk_verify(&vc, mp, dqb, be32_to_cpu(ddqp->d_id), 0);
>  	if (fa) {
>  		xfs_alert(mp, "corrupt dquot ID 0x%x in memory at %pS",
>  				be32_to_cpu(ddqp->d_id), fa);
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 05db9540e459..d2fd4d4b7864 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -3416,9 +3416,10 @@ xfs_inode_verify_forks(
>  	struct xfs_inode	*ip)
>  {
>  	struct xfs_ifork	*ifp;
> +	struct xfs_vc		vc = { 0 };
>  	xfs_failaddr_t		fa;
>  
> -	fa = xfs_ifork_verify_data(ip, &xfs_default_ifork_ops);
> +	fa = xfs_ifork_verify_data(&vc, ip, &xfs_default_ifork_ops);
>  	if (fa) {
>  		ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
>  		xfs_inode_verifier_error(ip, -EFSCORRUPTED, "data fork",
> @@ -3426,7 +3427,7 @@ xfs_inode_verify_forks(
>  		return false;
>  	}
>  
> -	fa = xfs_ifork_verify_attr(ip, &xfs_default_ifork_ops);
> +	fa = xfs_ifork_verify_attr(&vc, ip, &xfs_default_ifork_ops);
>  	if (fa) {
>  		ifp = XFS_IFORK_PTR(ip, XFS_ATTR_FORK);
>  		xfs_inode_verifier_error(ip, -EFSCORRUPTED, "attr fork",
> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> index 1fc9e9042e0e..bcafd3961d20 100644
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -2650,6 +2650,7 @@ xlog_recover_do_reg_buffer(
>  	int			i;
>  	int			bit;
>  	int			nbits;
> +	struct xfs_vc		vc = { 0 };
>  	xfs_failaddr_t		fa;
>  
>  	trace_xfs_log_recover_buf_reg_buf(mp->m_log, buf_f);
> @@ -2699,7 +2700,7 @@ xlog_recover_do_reg_buffer(
>  					item->ri_buf[i].i_len, __func__);
>  				goto next;
>  			}
> -			fa = xfs_dquot_verify(mp, item->ri_buf[i].i_addr,
> +			fa = xfs_dquot_verify(&vc, mp, item->ri_buf[i].i_addr,
>  					       -1, 0);
>  			if (fa) {
>  				xfs_alert(mp,
> @@ -3308,6 +3309,7 @@ xlog_recover_dquot_pass2(
>  	xfs_mount_t		*mp = log->l_mp;
>  	xfs_buf_t		*bp;
>  	struct xfs_disk_dquot	*ddq, *recddq;
> +	struct xfs_vc		vc = { 0 };
>  	xfs_failaddr_t		fa;
>  	int			error;
>  	xfs_dq_logformat_t	*dq_f;
> @@ -3351,7 +3353,7 @@ xlog_recover_dquot_pass2(
>  	 */
>  	dq_f = item->ri_buf[0].i_addr;
>  	ASSERT(dq_f);
> -	fa = xfs_dquot_verify(mp, recddq, dq_f->qlf_id, 0);
> +	fa = xfs_dquot_verify(&vc, mp, recddq, dq_f->qlf_id, 0);
>  	if (fa) {
>  		xfs_alert(mp, "corrupt dquot ID 0x%x in log at %pS",
>  				dq_f->qlf_id, fa);
> diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
> index 52ed7904df10..09cd6e971074 100644
> --- a/fs/xfs/xfs_qm.c
> +++ b/fs/xfs/xfs_qm.c
> @@ -833,6 +833,7 @@ xfs_qm_reset_dqcounts(
>  {
>  	struct xfs_dqblk	*dqb;
>  	int			j;
> +	struct xfs_vc		vc = { 0 };
>  	xfs_failaddr_t		fa;
>  
>  	trace_xfs_reset_dqcounts(bp, _RET_IP_);
> @@ -858,7 +859,7 @@ xfs_qm_reset_dqcounts(
>  		 * find uninitialised dquot blks. See comment in
>  		 * xfs_dquot_verify.
>  		 */
> -		fa = xfs_dqblk_verify(mp, &dqb[j], id + j, type);
> +		fa = xfs_dqblk_verify(&vc, mp, &dqb[j], id + j, type);
>  		if (fa)
>  			xfs_dqblk_repair(mp, &dqb[j], id + j, type);
>  
> -- 
> 2.17.0
> 
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 08/10] xfs: set failaddr into vc for checksum failures
  2018-12-10 16:00     ` Eric Sandeen
@ 2018-12-17 18:39       ` Darrick J. Wong
  0 siblings, 0 replies; 20+ messages in thread
From: Darrick J. Wong @ 2018-12-17 18:39 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Brian Foster, linux-xfs

On Mon, Dec 10, 2018 at 10:00:08AM -0600, Eric Sandeen wrote:
> On 12/7/18 7:37 AM, Brian Foster wrote:
> > On Wed, Dec 05, 2018 at 03:09:48PM -0600, Eric Sandeen wrote:
> >> Modify CRC checking functions to set __this_address into the
> >> verifier context failaddr vc->fa using new macro XFS_BADCRC_RETURN,
> >> and pass that to failure handlers as well.
> >>
> >> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> >> ---
> >>  fs/xfs/libxfs/xfs_alloc.c          |  4 ++--
> >>  fs/xfs/libxfs/xfs_alloc_btree.c    |  2 +-
> >>  fs/xfs/libxfs/xfs_attr_leaf.c      |  2 +-
> >>  fs/xfs/libxfs/xfs_bmap_btree.c     |  2 +-
> >>  fs/xfs/libxfs/xfs_cksum.h          |  5 ++++-
> >>  fs/xfs/libxfs/xfs_da_btree.c       |  3 +--
> >>  fs/xfs/libxfs/xfs_dir2_block.c     |  2 +-
> >>  fs/xfs/libxfs/xfs_dir2_data.c      |  2 +-
> >>  fs/xfs/libxfs/xfs_dir2_leaf.c      |  2 +-
> >>  fs/xfs/libxfs/xfs_dir2_node.c      |  2 +-
> >>  fs/xfs/libxfs/xfs_ialloc.c         |  2 +-
> >>  fs/xfs/libxfs/xfs_ialloc_btree.c   |  2 +-
> >>  fs/xfs/libxfs/xfs_refcount_btree.c |  2 +-
> >>  fs/xfs/libxfs/xfs_rmap_btree.c     |  2 +-
> >>  fs/xfs/libxfs/xfs_symlink_remote.c |  2 +-
> >>  fs/xfs/libxfs/xfs_types.h          | 12 ++++++++++--
> >>  fs/xfs/xfs_linux.h                 |  7 -------
> >>  17 files changed, 29 insertions(+), 26 deletions(-)
> >>
> > ...
> >> diff --git a/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h
> >> index 29b0d354d9b7..ab045e8dfcb9 100644
> >> --- a/fs/xfs/libxfs/xfs_types.h
> >> +++ b/fs/xfs/libxfs/xfs_types.h
> >> @@ -45,8 +45,16 @@ struct xfs_vc {
> >>  	xfs_failaddr_t	fa;
> >>  };
> >>  
> >> -#define XFS_CORRUPTED_RETURN(vc) ({(vc)->fa = __this_address; false;})
> >> -#define XFS_VERIFIED_RETURN(vc) ({(vc)->fa = NULL; true;})
> >> +/*
> >> + * Return the address of a label.  Use barrier() so that the optimizer
> >> + * won't reorder code to refactor the error jumpouts into a single
> >> + * return, which throws off the reported address.
> >> + */
> >> +#define __this_address ({ __label__ __here; __here: barrier(); &&__here; })
> >> + 
> > 
> > FYI, minor whitespace damage on the line above.
> > 
> >> +#define XFS_CORRUPTED_RETURN(vc)	({(vc)->fa = __this_address; false;})
> >> +#define XFS_BADCRC_RETURN(vc)		({(vc)->fa = __this_address; false;})
> >> +#define XFS_VERIFIED_RETURN(vc)		({(vc)->fa = NULL; true;})
> >>  
> > 
> > A couple high level comments..
> > 
> > I don't particularly care that much whether we bury function returns in
> > the macro or open-code it, but the macro naming suggests the former
> > (based on precedent of other such macros in XFS) while we implement the
> > latter. If there's objection to a return within a macro, perhaps a
> > reasonable compromise between this and the common pattern of having to
> > return on a separate line is to tweak the macros to never clobber an
> > existing error and update the verifiers to check/return failure state at
> > opportune points. For example:
> > 
> > 	...
> > 	if (!uuid_equal(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid))
> > 		XFS_VC_CORRUPT(vc);
> > 	if (be32_to_cpu(agfl->agfl_magicnum) != XFS_AGFL_MAGIC)
> > 		XFS_VC_CORRUPT(vc);
> > 	if (bp->b_pag && be32_to_cpu(agfl->agfl_seqno) != bp->b_pag->pag_agno)
> > 		XFS_VC_CORRUPT(vc);
> > 	...
> > 
> > 	return vc->fa ? false : true;
> > 
> > Of course, that assumes it's safe to keep checking the structure(s) as
> > such in the event of corruption, which perhaps is not ideal. Anyways, we
> > could also just return on a separate line or rename the macros. Just
> > thinking out loud a bit.

I would be fine with changing the name but leaving the return, e.g.:

#define XFS_VC_CORRUPT(vc) ({vc->fa = __this_address; false;})

if (!uuid_equal(&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid))
	return XFS_VC_CORRUPT(vc);

Since I don't see much point in continuing once we've decided the
metadata is garbage.  Scrub used to try to continue to find all the
errors in a metadata, but Dave had good reasons for shooting down that
strategy (unnecessary work, slows down the checker, potential for
straying into places we shouldn't).

> > I'm also a little curious why we have the need for the success macro at
> > all. I've only made a cursory pass at this point, but is there a
> > particular need to set anything in the xfs_vc at the point of a
> > successful return as opposed to just leaving the structure in the
> > initialized state?
> 
> yeah, it's probably not necessary; it seemed consistent tho.  There is some
> risk to this whole framework that failing to initialize a vc would cause
> problems that might be difficult to debug, and always marking success
> upon success seemed "safe."  But you're right, not not necessary if it's
> properly initialized to success at the top of the call chain.

Yeah, how about a good static initializer so we don't have to open code
struct xfs_vc	vc = { NULL }; everywhere?

--D

> -Eric

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2018-12-17 18:39 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-05 21:01 [PATCH RFC 0/10] xfs: add verifier context structure Eric Sandeen
2018-12-05 21:02 ` [PATCH 01/10] xfs: change xfs_attr3_rmt_hdr_ok to return bool Eric Sandeen
2018-12-07 13:36   ` Brian Foster
2018-12-17 18:23   ` Darrick J. Wong
2018-12-05 21:03 ` [PATCH 02/10] xfs: make checksum verifiers consistently return bools Eric Sandeen
2018-12-07 13:36   ` Brian Foster
2018-12-17 18:24   ` Darrick J. Wong
2018-12-05 21:03 ` [PATCH 03/10] xfs: pass a verifier context down verifier callchains Eric Sandeen
2018-12-17 18:29   ` Darrick J. Wong
2018-12-05 21:04 ` [PATCH 04/10] xfs: pass a verifier context to crc validation functions Eric Sandeen
2018-12-05 21:05 ` [PATCH 05/10] xfs: define new macros to set verifier context on return Eric Sandeen
2018-12-05 21:06 ` [PATCH 06/10] xfs: teach xfs_btree_[sl]block_verify_crc to populate verifier context Eric Sandeen
2018-12-05 21:08 ` [PATCH 07/10] xfs: change all verifiers to return booleans Eric Sandeen
2018-12-05 21:09 ` [PATCH 08/10] xfs: set failaddr into vc for checksum failures Eric Sandeen
2018-12-07 13:37   ` Brian Foster
2018-12-10 16:00     ` Eric Sandeen
2018-12-17 18:39       ` Darrick J. Wong
2018-12-05 21:11 ` [PATCH 09/10] xfs: add errno to verifier context and populate it Eric Sandeen
2018-12-07 13:41   ` Brian Foster
2018-12-05 21:11 ` [PATCH 10/10] xfs: condense crc and verifier checks where possible Eric Sandeen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).