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

Commit 1813dd64 authored by Dave Chinner's avatar Dave Chinner Committed by Ben Myers
Browse files

xfs: convert buffer verifiers to an ops structure.



To separate the verifiers from iodone functions and associate read
and write verifiers at the same time, introduce a buffer verifier
operations structure to the xfs_buf.

This avoids the need for assigning the write verifier, clearing the
iodone function and re-running ioend processing in the read
verifier, and gets rid of the nasty "b_pre_io" name for the write
verifier function pointer. If we ever need to, it will also be
easier to add further content specific callbacks to a buffer with an
ops structure in place.

We also avoid needing to export verifier functions, instead we
can simply export the ops structures for those that are needed
outside the function they are defined in.

This patch also fixes a directory block readahead verifier issue
it exposed.

This patch also adds ops callbacks to the inode/alloc btree blocks
initialised by growfs. These will need more work before they will
work with CRCs.

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarPhil White <pwhite@sgi.com>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent b0f539de
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -108,6 +108,8 @@ typedef struct xfs_agf {
extern int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp,
			xfs_agnumber_t agno, int flags, struct xfs_buf **bpp);

extern const struct xfs_buf_ops xfs_agf_buf_ops;

/*
 * Size of the unlinked inode hash table in the agi.
 */
@@ -161,6 +163,8 @@ typedef struct xfs_agi {
extern int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp,
				xfs_agnumber_t agno, struct xfs_buf **bpp);

extern const struct xfs_buf_ops xfs_agi_buf_ops;

/*
 * The third a.g. block contains the a.g. freelist, an array
 * of block pointers to blocks owned by the allocation btree code.
+16 −12
Original line number Diff line number Diff line
@@ -465,7 +465,7 @@ xfs_agfl_verify(
#endif
}

void
static void
xfs_agfl_write_verify(
	struct xfs_buf	*bp)
{
@@ -477,11 +477,13 @@ 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);
}

const struct xfs_buf_ops xfs_agfl_buf_ops = {
	.verify_read = xfs_agfl_read_verify,
	.verify_write = xfs_agfl_write_verify,
};

/*
 * Read in the allocation group free block array.
 */
@@ -499,7 +501,7 @@ xfs_alloc_read_agfl(
	error = xfs_trans_read_buf(
			mp, tp, mp->m_ddev_targp,
			XFS_AG_DADDR(mp, agno, XFS_AGFL_DADDR(mp)),
			XFS_FSS_TO_BB(mp, 1), 0, &bp, xfs_agfl_read_verify);
			XFS_FSS_TO_BB(mp, 1), 0, &bp, &xfs_agfl_buf_ops);
	if (error)
		return error;
	ASSERT(!xfs_buf_geterror(bp));
@@ -2181,23 +2183,25 @@ xfs_agf_verify(
	}
}

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

static void
xfs_agf_read_verify(
xfs_agf_write_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);
}

const struct xfs_buf_ops xfs_agf_buf_ops = {
	.verify_read = xfs_agf_read_verify,
	.verify_write = xfs_agf_write_verify,
};

/*
 * Read in the allocation group header (free/alloc section).
 */
@@ -2215,7 +2219,7 @@ xfs_read_agf(
	error = xfs_trans_read_buf(
			mp, tp, mp->m_ddev_targp,
			XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
			XFS_FSS_TO_BB(mp, 1), flags, bpp, xfs_agf_read_verify);
			XFS_FSS_TO_BB(mp, 1), flags, bpp, &xfs_agf_buf_ops);
	if (error)
		return error;
	if (!*bpp)
+2 −2
Original line number Diff line number Diff line
@@ -231,7 +231,7 @@ xfs_alloc_get_rec(
	xfs_extlen_t		*len,	/* output: length of extent */
	int			*stat);	/* output: success/failure */

void xfs_agf_write_verify(struct xfs_buf *bp);
void xfs_agfl_write_verify(struct xfs_buf *bp);
extern const struct xfs_buf_ops xfs_agf_buf_ops;
extern const struct xfs_buf_ops xfs_agfl_buf_ops;

#endif	/* __XFS_ALLOC_H__ */
+10 −8
Original line number Diff line number Diff line
@@ -329,22 +329,25 @@ xfs_allocbt_verify(
}

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

void
xfs_allocbt_read_verify(
static void
xfs_allocbt_write_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);
}

const struct xfs_buf_ops xfs_allocbt_buf_ops = {
	.verify_read = xfs_allocbt_read_verify,
	.verify_write = xfs_allocbt_write_verify,
};


#ifdef DEBUG
STATIC int
xfs_allocbt_keys_inorder(
@@ -400,8 +403,7 @@ static const struct xfs_btree_ops xfs_allocbt_ops = {
	.init_rec_from_cur	= xfs_allocbt_init_rec_from_cur,
	.init_ptr_from_cur	= xfs_allocbt_init_ptr_from_cur,
	.key_diff		= xfs_allocbt_key_diff,
	.read_verify		= xfs_allocbt_read_verify,
	.write_verify		= xfs_allocbt_write_verify,
	.buf_ops		= &xfs_allocbt_buf_ops,
#ifdef DEBUG
	.keys_inorder		= xfs_allocbt_keys_inorder,
	.recs_inorder		= xfs_allocbt_recs_inorder,
+2 −0
Original line number Diff line number Diff line
@@ -93,4 +93,6 @@ extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *,
		xfs_agnumber_t, xfs_btnum_t);
extern int xfs_allocbt_maxrecs(struct xfs_mount *, int, int);

extern const struct xfs_buf_ops xfs_allocbt_buf_ops;

#endif	/* __XFS_ALLOC_BTREE_H__ */
Loading