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

Commit b2a21e7a authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner
Browse files

xfs: remove redundant geometry information from xfs_da_state



It's carried in state->args->geo, so there's no need to duplicate it
and use more stack space than necessary.

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent c2c4c477
Loading
Loading
Loading
Loading
+0 −8
Original line number Original line Diff line number Diff line
@@ -896,8 +896,6 @@ restart:
	state = xfs_da_state_alloc();
	state = xfs_da_state_alloc();
	state->args = args;
	state->args = args;
	state->mp = mp;
	state->mp = mp;
	state->blocksize = args->geo->blksize;
	state->node_ents = args->geo->node_ents;


	/*
	/*
	 * Search to see if name already exists, and get back a pointer
	 * Search to see if name already exists, and get back a pointer
@@ -1075,8 +1073,6 @@ restart:
		state = xfs_da_state_alloc();
		state = xfs_da_state_alloc();
		state->args = args;
		state->args = args;
		state->mp = mp;
		state->mp = mp;
		state->blocksize = args->geo->blksize;
		state->node_ents = args->geo->node_ents;
		state->inleaf = 0;
		state->inleaf = 0;
		error = xfs_da3_node_lookup_int(state, &retval);
		error = xfs_da3_node_lookup_int(state, &retval);
		if (error)
		if (error)
@@ -1167,8 +1163,6 @@ xfs_attr_node_removename(xfs_da_args_t *args)
	state = xfs_da_state_alloc();
	state = xfs_da_state_alloc();
	state->args = args;
	state->args = args;
	state->mp = dp->i_mount;
	state->mp = dp->i_mount;
	state->blocksize = args->geo->blksize;
	state->node_ents = args->geo->node_ents;


	/*
	/*
	 * Search to see if name exists, and get back a pointer to it.
	 * Search to see if name exists, and get back a pointer to it.
@@ -1430,8 +1424,6 @@ xfs_attr_node_get(xfs_da_args_t *args)
	state = xfs_da_state_alloc();
	state = xfs_da_state_alloc();
	state->args = args;
	state->args = args;
	state->mp = args->dp->i_mount;
	state->mp = args->dp->i_mount;
	state->blocksize = args->geo->blksize;
	state->node_ents = args->geo->node_ents;


	/*
	/*
	 * Search to see if name exists, and get back a pointer to it.
	 * Search to see if name exists, and get back a pointer to it.
+10 −9
Original line number Original line Diff line number Diff line
@@ -1494,8 +1494,8 @@ xfs_attr3_leaf_rebalance(


	xfs_attr3_leaf_hdr_to_disk(leaf1, &ichdr1);
	xfs_attr3_leaf_hdr_to_disk(leaf1, &ichdr1);
	xfs_attr3_leaf_hdr_to_disk(leaf2, &ichdr2);
	xfs_attr3_leaf_hdr_to_disk(leaf2, &ichdr2);
	xfs_trans_log_buf(args->trans, blk1->bp, 0, state->blocksize-1);
	xfs_trans_log_buf(args->trans, blk1->bp, 0, args->geo->blksize - 1);
	xfs_trans_log_buf(args->trans, blk2->bp, 0, state->blocksize-1);
	xfs_trans_log_buf(args->trans, blk2->bp, 0, args->geo->blksize - 1);


	/*
	/*
	 * Copy out last hashval in each block for B-tree code.
	 * Copy out last hashval in each block for B-tree code.
@@ -1592,7 +1592,7 @@ xfs_attr3_leaf_figure_balance(
	half += ichdr1->usedbytes + ichdr2->usedbytes +
	half += ichdr1->usedbytes + ichdr2->usedbytes +
			xfs_attr_leaf_newentsize(state->args, NULL);
			xfs_attr_leaf_newentsize(state->args, NULL);
	half /= 2;
	half /= 2;
	lastdelta = state->blocksize;
	lastdelta = state->args->geo->blksize;
	entry = xfs_attr3_leaf_entryp(leaf1);
	entry = xfs_attr3_leaf_entryp(leaf1);
	for (count = index = 0; count < max; entry++, index++, count++) {
	for (count = index = 0; count < max; entry++, index++, count++) {


@@ -1690,7 +1690,7 @@ xfs_attr3_leaf_toosmall(
	bytes = xfs_attr3_leaf_hdr_size(leaf) +
	bytes = xfs_attr3_leaf_hdr_size(leaf) +
		ichdr.count * sizeof(xfs_attr_leaf_entry_t) +
		ichdr.count * sizeof(xfs_attr_leaf_entry_t) +
		ichdr.usedbytes;
		ichdr.usedbytes;
	if (bytes > (state->blocksize >> 1)) {
	if (bytes > (state->args->geo->blksize >> 1)) {
		*action = 0;	/* blk over 50%, don't try to join */
		*action = 0;	/* blk over 50%, don't try to join */
		return(0);
		return(0);
	}
	}
@@ -1744,7 +1744,8 @@ xfs_attr3_leaf_toosmall(


		xfs_attr3_leaf_hdr_from_disk(&ichdr2, bp->b_addr);
		xfs_attr3_leaf_hdr_from_disk(&ichdr2, bp->b_addr);


		bytes = state->blocksize - (state->blocksize >> 2) -
		bytes = state->args->geo->blksize -
			(state->args->geo->blksize >> 2) -
			ichdr.usedbytes - ichdr2.usedbytes -
			ichdr.usedbytes - ichdr2.usedbytes -
			((ichdr.count + ichdr2.count) *
			((ichdr.count + ichdr2.count) *
					sizeof(xfs_attr_leaf_entry_t)) -
					sizeof(xfs_attr_leaf_entry_t)) -
@@ -1997,7 +1998,7 @@ xfs_attr3_leaf_unbalance(
		struct xfs_attr_leafblock *tmp_leaf;
		struct xfs_attr_leafblock *tmp_leaf;
		struct xfs_attr3_icleaf_hdr tmphdr;
		struct xfs_attr3_icleaf_hdr tmphdr;


		tmp_leaf = kmem_zalloc(state->blocksize, KM_SLEEP);
		tmp_leaf = kmem_zalloc(state->args->geo->blksize, KM_SLEEP);


		/*
		/*
		 * Copy the header into the temp leaf so that all the stuff
		 * Copy the header into the temp leaf so that all the stuff
@@ -2010,7 +2011,7 @@ xfs_attr3_leaf_unbalance(
		tmphdr.magic = savehdr.magic;
		tmphdr.magic = savehdr.magic;
		tmphdr.forw = savehdr.forw;
		tmphdr.forw = savehdr.forw;
		tmphdr.back = savehdr.back;
		tmphdr.back = savehdr.back;
		tmphdr.firstused = state->blocksize;
		tmphdr.firstused = state->args->geo->blksize;


		/* write the header to the temp buffer to initialise it */
		/* write the header to the temp buffer to initialise it */
		xfs_attr3_leaf_hdr_to_disk(tmp_leaf, &tmphdr);
		xfs_attr3_leaf_hdr_to_disk(tmp_leaf, &tmphdr);
@@ -2035,14 +2036,14 @@ xfs_attr3_leaf_unbalance(
						tmp_leaf, &tmphdr, tmphdr.count,
						tmp_leaf, &tmphdr, tmphdr.count,
						drophdr.count);
						drophdr.count);
		}
		}
		memcpy(save_leaf, tmp_leaf, state->blocksize);
		memcpy(save_leaf, tmp_leaf, state->args->geo->blksize);
		savehdr = tmphdr; /* struct copy */
		savehdr = tmphdr; /* struct copy */
		kmem_free(tmp_leaf);
		kmem_free(tmp_leaf);
	}
	}


	xfs_attr3_leaf_hdr_to_disk(save_leaf, &savehdr);
	xfs_attr3_leaf_hdr_to_disk(save_leaf, &savehdr);
	xfs_trans_log_buf(state->args->trans, save_blk->bp, 0,
	xfs_trans_log_buf(state->args->trans, save_blk->bp, 0,
					   state->blocksize - 1);
					   state->args->geo->blksize - 1);


	/*
	/*
	 * Copy out last hashval in each block for B-tree code.
	 * Copy out last hashval in each block for B-tree code.
+7 −6
Original line number Original line Diff line number Diff line
@@ -663,7 +663,7 @@ xfs_da3_node_split(
	/*
	/*
	 * Do we have to split the node?
	 * Do we have to split the node?
	 */
	 */
	if (nodehdr.count + newcount > state->node_ents) {
	if (nodehdr.count + newcount > state->args->geo->node_ents) {
		/*
		/*
		 * Allocate a new node, add to the doubly linked chain of
		 * Allocate a new node, add to the doubly linked chain of
		 * nodes, then move some of our excess entries into it.
		 * nodes, then move some of our excess entries into it.
@@ -1089,14 +1089,15 @@ xfs_da3_root_join(
	 * that could occur. For dir3 blocks we also need to update the block
	 * that could occur. For dir3 blocks we also need to update the block
	 * number in the buffer header.
	 * number in the buffer header.
	 */
	 */
	memcpy(root_blk->bp->b_addr, bp->b_addr, state->blocksize);
	memcpy(root_blk->bp->b_addr, bp->b_addr, args->geo->blksize);
	root_blk->bp->b_ops = bp->b_ops;
	root_blk->bp->b_ops = bp->b_ops;
	xfs_trans_buf_copy_type(root_blk->bp, bp);
	xfs_trans_buf_copy_type(root_blk->bp, bp);
	if (oldroothdr.magic == XFS_DA3_NODE_MAGIC) {
	if (oldroothdr.magic == XFS_DA3_NODE_MAGIC) {
		struct xfs_da3_blkinfo *da3 = root_blk->bp->b_addr;
		struct xfs_da3_blkinfo *da3 = root_blk->bp->b_addr;
		da3->blkno = cpu_to_be64(root_blk->bp->b_bn);
		da3->blkno = cpu_to_be64(root_blk->bp->b_bn);
	}
	}
	xfs_trans_log_buf(args->trans, root_blk->bp, 0, state->blocksize - 1);
	xfs_trans_log_buf(args->trans, root_blk->bp, 0,
			  args->geo->blksize - 1);
	error = xfs_da_shrink_inode(args, child, bp);
	error = xfs_da_shrink_inode(args, child, bp);
	return(error);
	return(error);
}
}
@@ -1139,7 +1140,7 @@ xfs_da3_node_toosmall(
	info = blk->bp->b_addr;
	info = blk->bp->b_addr;
	node = (xfs_da_intnode_t *)info;
	node = (xfs_da_intnode_t *)info;
	dp->d_ops->node_hdr_from_disk(&nodehdr, node);
	dp->d_ops->node_hdr_from_disk(&nodehdr, node);
	if (nodehdr.count > (state->node_ents >> 1)) {
	if (nodehdr.count > (state->args->geo->node_ents >> 1)) {
		*action = 0;	/* blk over 50%, don't try to join */
		*action = 0;	/* blk over 50%, don't try to join */
		return(0);	/* blk over 50%, don't try to join */
		return(0);	/* blk over 50%, don't try to join */
	}
	}
@@ -1176,8 +1177,8 @@ xfs_da3_node_toosmall(
	 * We prefer coalescing with the lower numbered sibling so as
	 * We prefer coalescing with the lower numbered sibling so as
	 * to shrink a directory over time.
	 * to shrink a directory over time.
	 */
	 */
	count  = state->node_ents;
	count  = state->args->geo->node_ents;
	count -= state->node_ents >> 2;
	count -= state->args->geo->node_ents >> 2;
	count -= nodehdr.count;
	count -= nodehdr.count;


	/* start with smaller blk num */
	/* start with smaller blk num */
+0 −2
Original line number Original line Diff line number Diff line
@@ -128,8 +128,6 @@ typedef struct xfs_da_state_path {
typedef struct xfs_da_state {
typedef struct xfs_da_state {
	xfs_da_args_t		*args;		/* filename arguments */
	xfs_da_args_t		*args;		/* filename arguments */
	struct xfs_mount	*mp;		/* filesystem mount point */
	struct xfs_mount	*mp;		/* filesystem mount point */
	unsigned int		blocksize;	/* logical block size */
	unsigned int		node_ents;	/* how many entries in danode */
	xfs_da_state_path_t	path;		/* search/split paths */
	xfs_da_state_path_t	path;		/* search/split paths */
	xfs_da_state_path_t	altpath;	/* alternate path for join */
	xfs_da_state_path_t	altpath;	/* alternate path for join */
	unsigned char		inleaf;		/* insert into 1->lf, 0->splf */
	unsigned char		inleaf;		/* insert into 1->lf, 0->splf */
+3 −10
Original line number Original line Diff line number Diff line
@@ -1414,7 +1414,7 @@ xfs_dir2_leafn_toosmall(


	count = leafhdr.count - leafhdr.stale;
	count = leafhdr.count - leafhdr.stale;
	bytes = dp->d_ops->leaf_hdr_size + count * sizeof(ents[0]);
	bytes = dp->d_ops->leaf_hdr_size + count * sizeof(ents[0]);
	if (bytes > (state->blocksize >> 1)) {
	if (bytes > (state->args->geo->blksize >> 1)) {
		/*
		/*
		 * Blk over 50%, don't try to join.
		 * Blk over 50%, don't try to join.
		 */
		 */
@@ -1467,7 +1467,8 @@ xfs_dir2_leafn_toosmall(
		 * Count bytes in the two blocks combined.
		 * Count bytes in the two blocks combined.
		 */
		 */
		count = leafhdr.count - leafhdr.stale;
		count = leafhdr.count - leafhdr.stale;
		bytes = state->blocksize - (state->blocksize >> 2);
		bytes = state->args->geo->blksize -
			(state->args->geo->blksize >> 2);


		leaf = bp->b_addr;
		leaf = bp->b_addr;
		dp->d_ops->leaf_hdr_from_disk(&hdr2, leaf);
		dp->d_ops->leaf_hdr_from_disk(&hdr2, leaf);
@@ -1591,8 +1592,6 @@ xfs_dir2_node_addname(
	state = xfs_da_state_alloc();
	state = xfs_da_state_alloc();
	state->args = args;
	state->args = args;
	state->mp = args->dp->i_mount;
	state->mp = args->dp->i_mount;
	state->blocksize = args->geo->blksize;
	state->node_ents = args->geo->node_ents;
	/*
	/*
	 * Look up the name.  We're not supposed to find it, but
	 * Look up the name.  We're not supposed to find it, but
	 * this gives us the insertion point.
	 * this gives us the insertion point.
@@ -2037,8 +2036,6 @@ xfs_dir2_node_lookup(
	state = xfs_da_state_alloc();
	state = xfs_da_state_alloc();
	state->args = args;
	state->args = args;
	state->mp = args->dp->i_mount;
	state->mp = args->dp->i_mount;
	state->blocksize = args->geo->blksize;
	state->node_ents = args->geo->node_ents;
	/*
	/*
	 * Fill in the path to the entry in the cursor.
	 * Fill in the path to the entry in the cursor.
	 */
	 */
@@ -2092,8 +2089,6 @@ xfs_dir2_node_removename(
	state = xfs_da_state_alloc();
	state = xfs_da_state_alloc();
	state->args = args;
	state->args = args;
	state->mp = args->dp->i_mount;
	state->mp = args->dp->i_mount;
	state->blocksize = args->geo->blksize;
	state->node_ents = args->geo->node_ents;


	/* Look up the entry we're deleting, set up the cursor. */
	/* Look up the entry we're deleting, set up the cursor. */
	error = xfs_da3_node_lookup_int(state, &rval);
	error = xfs_da3_node_lookup_int(state, &rval);
@@ -2162,8 +2157,6 @@ xfs_dir2_node_replace(
	state = xfs_da_state_alloc();
	state = xfs_da_state_alloc();
	state->args = args;
	state->args = args;
	state->mp = args->dp->i_mount;
	state->mp = args->dp->i_mount;
	state->blocksize = args->geo->blksize;
	state->node_ents = args->geo->node_ents;
	inum = args->inumber;
	inum = args->inumber;
	/*
	/*
	 * Lookup the entry to change in the btree.
	 * Lookup the entry to change in the btree.