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

Commit 1d9025e5 authored by Dave Chinner's avatar Dave Chinner Committed by Ben Myers
Browse files

xfs: remove struct xfs_dabuf and infrastructure



The struct xfs_dabuf now only tracks a single xfs_buf and all the
information it holds can be gained directly from the xfs_buf. Hence
we can remove the struct dabuf and pass the xfs_buf around
everywhere.

Kill the struct dabuf and the associated infrastructure.

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent 3605431f
Loading
Loading
Loading
Loading
+36 −42
Original line number Original line Diff line number Diff line
@@ -893,7 +893,7 @@ STATIC int
xfs_attr_leaf_addname(xfs_da_args_t *args)
xfs_attr_leaf_addname(xfs_da_args_t *args)
{
{
	xfs_inode_t *dp;
	xfs_inode_t *dp;
	xfs_dabuf_t *bp;
	struct xfs_buf *bp;
	int retval, error, committed, forkoff;
	int retval, error, committed, forkoff;


	trace_xfs_attr_leaf_addname(args);
	trace_xfs_attr_leaf_addname(args);
@@ -915,11 +915,11 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
	 */
	 */
	retval = xfs_attr_leaf_lookup_int(bp, args);
	retval = xfs_attr_leaf_lookup_int(bp, args);
	if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) {
	if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) {
		xfs_da_brelse(args->trans, bp);
		xfs_trans_brelse(args->trans, bp);
		return(retval);
		return(retval);
	} else if (retval == EEXIST) {
	} else if (retval == EEXIST) {
		if (args->flags & ATTR_CREATE) {	/* pure create op */
		if (args->flags & ATTR_CREATE) {	/* pure create op */
			xfs_da_brelse(args->trans, bp);
			xfs_trans_brelse(args->trans, bp);
			return(retval);
			return(retval);
		}
		}


@@ -937,7 +937,6 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
	 * if required.
	 * if required.
	 */
	 */
	retval = xfs_attr_leaf_add(bp, args);
	retval = xfs_attr_leaf_add(bp, args);
	xfs_da_buf_done(bp);
	if (retval == ENOSPC) {
	if (retval == ENOSPC) {
		/*
		/*
		 * Promote the attribute list to the Btree format, then
		 * Promote the attribute list to the Btree format, then
@@ -1065,8 +1064,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
			 */
			 */
			if (committed)
			if (committed)
				xfs_trans_ijoin(args->trans, dp, 0);
				xfs_trans_ijoin(args->trans, dp, 0);
		} else
		}
			xfs_da_buf_done(bp);


		/*
		/*
		 * Commit the remove and start the next trans in series.
		 * Commit the remove and start the next trans in series.
@@ -1092,7 +1090,7 @@ STATIC int
xfs_attr_leaf_removename(xfs_da_args_t *args)
xfs_attr_leaf_removename(xfs_da_args_t *args)
{
{
	xfs_inode_t *dp;
	xfs_inode_t *dp;
	xfs_dabuf_t *bp;
	struct xfs_buf *bp;
	int error, committed, forkoff;
	int error, committed, forkoff;


	trace_xfs_attr_leaf_removename(args);
	trace_xfs_attr_leaf_removename(args);
@@ -1111,7 +1109,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
	ASSERT(bp != NULL);
	ASSERT(bp != NULL);
	error = xfs_attr_leaf_lookup_int(bp, args);
	error = xfs_attr_leaf_lookup_int(bp, args);
	if (error == ENOATTR) {
	if (error == ENOATTR) {
		xfs_da_brelse(args->trans, bp);
		xfs_trans_brelse(args->trans, bp);
		return(error);
		return(error);
	}
	}


@@ -1141,8 +1139,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
		 */
		 */
		if (committed)
		if (committed)
			xfs_trans_ijoin(args->trans, dp, 0);
			xfs_trans_ijoin(args->trans, dp, 0);
	} else
	}
		xfs_da_buf_done(bp);
	return(0);
	return(0);
}
}


@@ -1155,7 +1152,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
STATIC int
STATIC int
xfs_attr_leaf_get(xfs_da_args_t *args)
xfs_attr_leaf_get(xfs_da_args_t *args)
{
{
	xfs_dabuf_t *bp;
	struct xfs_buf *bp;
	int error;
	int error;


	args->blkno = 0;
	args->blkno = 0;
@@ -1167,11 +1164,11 @@ xfs_attr_leaf_get(xfs_da_args_t *args)


	error = xfs_attr_leaf_lookup_int(bp, args);
	error = xfs_attr_leaf_lookup_int(bp, args);
	if (error != EEXIST)  {
	if (error != EEXIST)  {
		xfs_da_brelse(args->trans, bp);
		xfs_trans_brelse(args->trans, bp);
		return(error);
		return(error);
	}
	}
	error = xfs_attr_leaf_getvalue(bp, args);
	error = xfs_attr_leaf_getvalue(bp, args);
	xfs_da_brelse(args->trans, bp);
	xfs_trans_brelse(args->trans, bp);
	if (!error && (args->rmtblkno > 0) && !(args->flags & ATTR_KERNOVAL)) {
	if (!error && (args->rmtblkno > 0) && !(args->flags & ATTR_KERNOVAL)) {
		error = xfs_attr_rmtval_get(args);
		error = xfs_attr_rmtval_get(args);
	}
	}
@@ -1186,23 +1183,23 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context)
{
{
	xfs_attr_leafblock_t *leaf;
	xfs_attr_leafblock_t *leaf;
	int error;
	int error;
	xfs_dabuf_t *bp;
	struct xfs_buf *bp;


	context->cursor->blkno = 0;
	context->cursor->blkno = 0;
	error = xfs_da_read_buf(NULL, context->dp, 0, -1, &bp, XFS_ATTR_FORK);
	error = xfs_da_read_buf(NULL, context->dp, 0, -1, &bp, XFS_ATTR_FORK);
	if (error)
	if (error)
		return XFS_ERROR(error);
		return XFS_ERROR(error);
	ASSERT(bp != NULL);
	ASSERT(bp != NULL);
	leaf = bp->data;
	leaf = bp->b_addr;
	if (unlikely(leaf->hdr.info.magic != cpu_to_be16(XFS_ATTR_LEAF_MAGIC))) {
	if (unlikely(leaf->hdr.info.magic != cpu_to_be16(XFS_ATTR_LEAF_MAGIC))) {
		XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW,
		XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW,
				     context->dp->i_mount, leaf);
				     context->dp->i_mount, leaf);
		xfs_da_brelse(NULL, bp);
		xfs_trans_brelse(NULL, bp);
		return XFS_ERROR(EFSCORRUPTED);
		return XFS_ERROR(EFSCORRUPTED);
	}
	}


	error = xfs_attr_leaf_list_int(bp, context);
	error = xfs_attr_leaf_list_int(bp, context);
	xfs_da_brelse(NULL, bp);
	xfs_trans_brelse(NULL, bp);
	return XFS_ERROR(error);
	return XFS_ERROR(error);
}
}


@@ -1489,7 +1486,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
	xfs_da_state_t *state;
	xfs_da_state_t *state;
	xfs_da_state_blk_t *blk;
	xfs_da_state_blk_t *blk;
	xfs_inode_t *dp;
	xfs_inode_t *dp;
	xfs_dabuf_t *bp;
	struct xfs_buf *bp;
	int retval, error, committed, forkoff;
	int retval, error, committed, forkoff;


	trace_xfs_attr_node_removename(args);
	trace_xfs_attr_node_removename(args);
@@ -1601,14 +1598,13 @@ xfs_attr_node_removename(xfs_da_args_t *args)
		 */
		 */
		ASSERT(state->path.active == 1);
		ASSERT(state->path.active == 1);
		ASSERT(state->path.blk[0].bp);
		ASSERT(state->path.blk[0].bp);
		xfs_da_buf_done(state->path.blk[0].bp);
		state->path.blk[0].bp = NULL;
		state->path.blk[0].bp = NULL;


		error = xfs_da_read_buf(args->trans, args->dp, 0, -1, &bp,
		error = xfs_da_read_buf(args->trans, args->dp, 0, -1, &bp,
						     XFS_ATTR_FORK);
						     XFS_ATTR_FORK);
		if (error)
		if (error)
			goto out;
			goto out;
		ASSERT((((xfs_attr_leafblock_t *)bp->data)->hdr.info.magic) ==
		ASSERT((((xfs_attr_leafblock_t *)bp->b_addr)->hdr.info.magic) ==
		       cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
		       cpu_to_be16(XFS_ATTR_LEAF_MAGIC));


		if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
		if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
@@ -1635,7 +1631,7 @@ xfs_attr_node_removename(xfs_da_args_t *args)
			if (committed)
			if (committed)
				xfs_trans_ijoin(args->trans, dp, 0);
				xfs_trans_ijoin(args->trans, dp, 0);
		} else
		} else
			xfs_da_brelse(args->trans, bp);
			xfs_trans_brelse(args->trans, bp);
	}
	}
	error = 0;
	error = 0;


@@ -1665,8 +1661,7 @@ xfs_attr_fillstate(xfs_da_state_t *state)
	ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH));
	ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH));
	for (blk = path->blk, level = 0; level < path->active; blk++, level++) {
	for (blk = path->blk, level = 0; level < path->active; blk++, level++) {
		if (blk->bp) {
		if (blk->bp) {
			blk->disk_blkno = xfs_da_blkno(blk->bp);
			blk->disk_blkno = XFS_BUF_ADDR(blk->bp);
			xfs_da_buf_done(blk->bp);
			blk->bp = NULL;
			blk->bp = NULL;
		} else {
		} else {
			blk->disk_blkno = 0;
			blk->disk_blkno = 0;
@@ -1681,8 +1676,7 @@ xfs_attr_fillstate(xfs_da_state_t *state)
	ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH));
	ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH));
	for (blk = path->blk, level = 0; level < path->active; blk++, level++) {
	for (blk = path->blk, level = 0; level < path->active; blk++, level++) {
		if (blk->bp) {
		if (blk->bp) {
			blk->disk_blkno = xfs_da_blkno(blk->bp);
			blk->disk_blkno = XFS_BUF_ADDR(blk->bp);
			xfs_da_buf_done(blk->bp);
			blk->bp = NULL;
			blk->bp = NULL;
		} else {
		} else {
			blk->disk_blkno = 0;
			blk->disk_blkno = 0;
@@ -1792,7 +1786,7 @@ xfs_attr_node_get(xfs_da_args_t *args)
	 * If not in a transaction, we have to release all the buffers.
	 * If not in a transaction, we have to release all the buffers.
	 */
	 */
	for (i = 0; i < state->path.active; i++) {
	for (i = 0; i < state->path.active; i++) {
		xfs_da_brelse(args->trans, state->path.blk[i].bp);
		xfs_trans_brelse(args->trans, state->path.blk[i].bp);
		state->path.blk[i].bp = NULL;
		state->path.blk[i].bp = NULL;
	}
	}


@@ -1808,7 +1802,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
	xfs_da_intnode_t *node;
	xfs_da_intnode_t *node;
	xfs_da_node_entry_t *btree;
	xfs_da_node_entry_t *btree;
	int error, i;
	int error, i;
	xfs_dabuf_t *bp;
	struct xfs_buf *bp;


	cursor = context->cursor;
	cursor = context->cursor;
	cursor->initted = 1;
	cursor->initted = 1;
@@ -1825,30 +1819,30 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
		if ((error != 0) && (error != EFSCORRUPTED))
		if ((error != 0) && (error != EFSCORRUPTED))
			return(error);
			return(error);
		if (bp) {
		if (bp) {
			node = bp->data;
			node = bp->b_addr;
			switch (be16_to_cpu(node->hdr.info.magic)) {
			switch (be16_to_cpu(node->hdr.info.magic)) {
			case XFS_DA_NODE_MAGIC:
			case XFS_DA_NODE_MAGIC:
				trace_xfs_attr_list_wrong_blk(context);
				trace_xfs_attr_list_wrong_blk(context);
				xfs_da_brelse(NULL, bp);
				xfs_trans_brelse(NULL, bp);
				bp = NULL;
				bp = NULL;
				break;
				break;
			case XFS_ATTR_LEAF_MAGIC:
			case XFS_ATTR_LEAF_MAGIC:
				leaf = bp->data;
				leaf = bp->b_addr;
				if (cursor->hashval > be32_to_cpu(leaf->entries[
				if (cursor->hashval > be32_to_cpu(leaf->entries[
				    be16_to_cpu(leaf->hdr.count)-1].hashval)) {
				    be16_to_cpu(leaf->hdr.count)-1].hashval)) {
					trace_xfs_attr_list_wrong_blk(context);
					trace_xfs_attr_list_wrong_blk(context);
					xfs_da_brelse(NULL, bp);
					xfs_trans_brelse(NULL, bp);
					bp = NULL;
					bp = NULL;
				} else if (cursor->hashval <=
				} else if (cursor->hashval <=
					     be32_to_cpu(leaf->entries[0].hashval)) {
					     be32_to_cpu(leaf->entries[0].hashval)) {
					trace_xfs_attr_list_wrong_blk(context);
					trace_xfs_attr_list_wrong_blk(context);
					xfs_da_brelse(NULL, bp);
					xfs_trans_brelse(NULL, bp);
					bp = NULL;
					bp = NULL;
				}
				}
				break;
				break;
			default:
			default:
				trace_xfs_attr_list_wrong_blk(context);
				trace_xfs_attr_list_wrong_blk(context);
				xfs_da_brelse(NULL, bp);
				xfs_trans_brelse(NULL, bp);
				bp = NULL;
				bp = NULL;
			}
			}
		}
		}
@@ -1873,7 +1867,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
						 context->dp->i_mount);
						 context->dp->i_mount);
				return(XFS_ERROR(EFSCORRUPTED));
				return(XFS_ERROR(EFSCORRUPTED));
			}
			}
			node = bp->data;
			node = bp->b_addr;
			if (node->hdr.info.magic ==
			if (node->hdr.info.magic ==
			    cpu_to_be16(XFS_ATTR_LEAF_MAGIC))
			    cpu_to_be16(XFS_ATTR_LEAF_MAGIC))
				break;
				break;
@@ -1883,7 +1877,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
						     XFS_ERRLEVEL_LOW,
						     XFS_ERRLEVEL_LOW,
						     context->dp->i_mount,
						     context->dp->i_mount,
						     node);
						     node);
				xfs_da_brelse(NULL, bp);
				xfs_trans_brelse(NULL, bp);
				return(XFS_ERROR(EFSCORRUPTED));
				return(XFS_ERROR(EFSCORRUPTED));
			}
			}
			btree = node->btree;
			btree = node->btree;
@@ -1898,10 +1892,10 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
				}
				}
			}
			}
			if (i == be16_to_cpu(node->hdr.count)) {
			if (i == be16_to_cpu(node->hdr.count)) {
				xfs_da_brelse(NULL, bp);
				xfs_trans_brelse(NULL, bp);
				return(0);
				return(0);
			}
			}
			xfs_da_brelse(NULL, bp);
			xfs_trans_brelse(NULL, bp);
		}
		}
	}
	}
	ASSERT(bp != NULL);
	ASSERT(bp != NULL);
@@ -1912,24 +1906,24 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
	 * adding the information.
	 * adding the information.
	 */
	 */
	for (;;) {
	for (;;) {
		leaf = bp->data;
		leaf = bp->b_addr;
		if (unlikely(leaf->hdr.info.magic !=
		if (unlikely(leaf->hdr.info.magic !=
			     cpu_to_be16(XFS_ATTR_LEAF_MAGIC))) {
			     cpu_to_be16(XFS_ATTR_LEAF_MAGIC))) {
			XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)",
			XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)",
					     XFS_ERRLEVEL_LOW,
					     XFS_ERRLEVEL_LOW,
					     context->dp->i_mount, leaf);
					     context->dp->i_mount, leaf);
			xfs_da_brelse(NULL, bp);
			xfs_trans_brelse(NULL, bp);
			return(XFS_ERROR(EFSCORRUPTED));
			return(XFS_ERROR(EFSCORRUPTED));
		}
		}
		error = xfs_attr_leaf_list_int(bp, context);
		error = xfs_attr_leaf_list_int(bp, context);
		if (error) {
		if (error) {
			xfs_da_brelse(NULL, bp);
			xfs_trans_brelse(NULL, bp);
			return error;
			return error;
		}
		}
		if (context->seen_enough || leaf->hdr.info.forw == 0)
		if (context->seen_enough || leaf->hdr.info.forw == 0)
			break;
			break;
		cursor->blkno = be32_to_cpu(leaf->hdr.info.forw);
		cursor->blkno = be32_to_cpu(leaf->hdr.info.forw);
		xfs_da_brelse(NULL, bp);
		xfs_trans_brelse(NULL, bp);
		error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1,
		error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1,
					      &bp, XFS_ATTR_FORK);
					      &bp, XFS_ATTR_FORK);
		if (error)
		if (error)
@@ -1941,7 +1935,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
			return(XFS_ERROR(EFSCORRUPTED));
			return(XFS_ERROR(EFSCORRUPTED));
		}
		}
	}
	}
	xfs_da_brelse(NULL, bp);
	xfs_trans_brelse(NULL, bp);
	return(0);
	return(0);
}
}


Loading