Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 612cfbfe authored by Dave Chinner's avatar Dave Chinner Committed by Ben Myers
Browse files

xfs: add pre-write metadata buffer verifier callbacks



These verifiers are essentially the same code as the read verifiers,
but do not require ioend processing. Hence factor the read verifier
functions and add a new write verifier wrapper that is used as the
callback.

This is done as one large patch for all verifiers rather than one
patch per verifier as the change is largely mechanical. This
includes hooking up the write verifier via the read verifier
function.

Hooking up the write verifier for buffers obtained via
xfs_trans_get_buf() will be done in a separate patch as that touches
code in many different places rather than just the verifier
functions.

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarMark Tinguely <tinguely@sgi.com>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent cfb02852
Loading
Loading
Loading
Loading
+32 −3
Original line number Diff line number Diff line
@@ -430,8 +430,8 @@ xfs_alloc_fixup_trees(
	return 0;
}

void
xfs_agfl_read_verify(
static void
xfs_agfl_verify(
	struct xfs_buf	*bp)
{
#ifdef WHEN_CRCS_COME_ALONG
@@ -463,6 +463,21 @@ xfs_agfl_read_verify(
		xfs_buf_ioerror(bp, EFSCORRUPTED);
	}
#endif
}

static void
xfs_agfl_write_verify(
	struct xfs_buf	*bp)
{
	xfs_agfl_verify(bp);
}

void
xfs_agfl_read_verify(
	struct xfs_buf	*bp)
{
	xfs_agfl_verify(bp);
	bp->b_pre_io = xfs_agfl_write_verify;
	bp->b_iodone = NULL;
	xfs_buf_ioend(bp, 0);
}
@@ -2129,7 +2144,7 @@ xfs_alloc_put_freelist(
}

static void
xfs_agf_read_verify(
xfs_agf_verify(
	struct xfs_buf	*bp)
 {
	struct xfs_mount *mp = bp->b_target->bt_mount;
@@ -2164,7 +2179,21 @@ xfs_agf_read_verify(
		XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, agf);
		xfs_buf_ioerror(bp, EFSCORRUPTED);
	}
}

static void
xfs_agf_write_verify(
	struct xfs_buf	*bp)
{
	xfs_agf_verify(bp);
}

void
xfs_agf_read_verify(
	struct xfs_buf	*bp)
{
	xfs_agf_verify(bp);
	bp->b_pre_io = xfs_agf_write_verify;
	bp->b_iodone = NULL;
	xfs_buf_ioend(bp, 0);
}
+17 −4
Original line number Diff line number Diff line
@@ -272,8 +272,8 @@ xfs_allocbt_key_diff(
	return (__int64_t)be32_to_cpu(kp->ar_startblock) - rec->ar_startblock;
}

void
xfs_allocbt_read_verify(
static void
xfs_allocbt_verify(
	struct xfs_buf		*bp)
{
	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -323,11 +323,24 @@ xfs_allocbt_read_verify(

	if (!sblock_ok) {
		trace_xfs_btree_corrupt(bp, _RET_IP_);
		XFS_CORRUPTION_ERROR("xfs_allocbt_read_verify",
					XFS_ERRLEVEL_LOW, mp, block);
		XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, block);
		xfs_buf_ioerror(bp, EFSCORRUPTED);
	}
}

static void
xfs_allocbt_write_verify(
	struct xfs_buf	*bp)
{
	xfs_allocbt_verify(bp);
}

void
xfs_allocbt_read_verify(
	struct xfs_buf	*bp)
{
	xfs_allocbt_verify(bp);
	bp->b_pre_io = xfs_allocbt_write_verify;
	bp->b_iodone = NULL;
	xfs_buf_ioend(bp, 0);
}
+17 −2
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ STATIC void xfs_attr_leaf_moveents(xfs_attr_leafblock_t *src_leaf,
					 xfs_mount_t *mp);
STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index);

void
static void
xfs_attr_leaf_verify(
	struct xfs_buf		*bp)
{
@@ -101,11 +101,26 @@ xfs_attr_leaf_verify(
		XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, hdr);
		xfs_buf_ioerror(bp, EFSCORRUPTED);
	}
}

static void
xfs_attr_leaf_write_verify(
	struct xfs_buf	*bp)
{
	xfs_attr_leaf_verify(bp);
}

void
xfs_attr_leaf_read_verify(
	struct xfs_buf	*bp)
{
	xfs_attr_leaf_verify(bp);
	bp->b_pre_io = xfs_attr_leaf_write_verify;
	bp->b_iodone = NULL;
	xfs_buf_ioend(bp, 0);
}


int
xfs_attr_leaf_read(
	struct xfs_trans	*tp,
@@ -115,7 +130,7 @@ xfs_attr_leaf_read(
	struct xfs_buf		**bpp)
{
	return xfs_da_read_buf(tp, dp, bno, mappedbno, bpp,
					XFS_ATTR_FORK, xfs_attr_leaf_verify);
				XFS_ATTR_FORK, xfs_attr_leaf_read_verify);
}

/*========================================================================
+1 −1
Original line number Diff line number Diff line
@@ -264,6 +264,6 @@ int xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize,
int	xfs_attr_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp,
			xfs_dablk_t bno, xfs_daddr_t mappedbno,
			struct xfs_buf **bpp);
void	xfs_attr_leaf_verify(struct xfs_buf *bp);
void	xfs_attr_leaf_read_verify(struct xfs_buf *bp);

#endif	/* __XFS_ATTR_LEAF_H__ */
+17 −4
Original line number Diff line number Diff line
@@ -708,8 +708,8 @@ xfs_bmbt_key_diff(
				      cur->bc_rec.b.br_startoff;
}

void
xfs_bmbt_read_verify(
static void
xfs_bmbt_verify(
	struct xfs_buf		*bp)
{
	struct xfs_mount	*mp = bp->b_target->bt_mount;
@@ -744,11 +744,24 @@ xfs_bmbt_read_verify(

	if (!lblock_ok) {
		trace_xfs_btree_corrupt(bp, _RET_IP_);
		XFS_CORRUPTION_ERROR("xfs_bmbt_read_verify",
					XFS_ERRLEVEL_LOW, mp, block);
		XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, block);
		xfs_buf_ioerror(bp, EFSCORRUPTED);
	}
}

static void
xfs_bmbt_write_verify(
	struct xfs_buf	*bp)
{
	xfs_bmbt_verify(bp);
}

void
xfs_bmbt_read_verify(
	struct xfs_buf	*bp)
{
	xfs_bmbt_verify(bp);
	bp->b_pre_io = xfs_bmbt_write_verify;
	bp->b_iodone = NULL;
	xfs_buf_ioend(bp, 0);
}
Loading