Skip to content

Commit ce4e789

Browse files
Long Licmaiolino
authored andcommitted
xfs: factor out xfs_attr3_node_entry_remove
Factor out wrapper xfs_attr3_node_entry_remove function, which exported for external use. Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Long Li <leo.lilong@huawei.com> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent e942498 commit ce4e789

2 files changed

Lines changed: 44 additions & 11 deletions

File tree

fs/xfs/libxfs/xfs_da_btree.c

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,21 +1506,20 @@ xfs_da3_fixhashpath(
15061506
}
15071507

15081508
/*
1509-
* Remove an entry from an intermediate node.
1509+
* Internal implementation to remove an entry from an intermediate node.
15101510
*/
15111511
STATIC void
1512-
xfs_da3_node_remove(
1513-
struct xfs_da_state *state,
1514-
struct xfs_da_state_blk *drop_blk)
1512+
__xfs_da3_node_remove(
1513+
struct xfs_trans *tp,
1514+
struct xfs_inode *dp,
1515+
struct xfs_da_geometry *geo,
1516+
struct xfs_da_state_blk *drop_blk)
15151517
{
15161518
struct xfs_da_intnode *node;
15171519
struct xfs_da3_icnode_hdr nodehdr;
15181520
struct xfs_da_node_entry *btree;
15191521
int index;
15201522
int tmp;
1521-
struct xfs_inode *dp = state->args->dp;
1522-
1523-
trace_xfs_da_node_remove(state->args);
15241523

15251524
node = drop_blk->bp->b_addr;
15261525
xfs_da3_node_hdr_from_disk(dp->i_mount, &nodehdr, node);
@@ -1536,24 +1535,56 @@ xfs_da3_node_remove(
15361535
tmp = nodehdr.count - index - 1;
15371536
tmp *= (uint)sizeof(xfs_da_node_entry_t);
15381537
memmove(&btree[index], &btree[index + 1], tmp);
1539-
xfs_trans_log_buf(state->args->trans, drop_blk->bp,
1538+
xfs_trans_log_buf(tp, drop_blk->bp,
15401539
XFS_DA_LOGRANGE(node, &btree[index], tmp));
15411540
index = nodehdr.count - 1;
15421541
}
15431542
memset(&btree[index], 0, sizeof(xfs_da_node_entry_t));
1544-
xfs_trans_log_buf(state->args->trans, drop_blk->bp,
1543+
xfs_trans_log_buf(tp, drop_blk->bp,
15451544
XFS_DA_LOGRANGE(node, &btree[index], sizeof(btree[index])));
15461545
nodehdr.count -= 1;
15471546
xfs_da3_node_hdr_to_disk(dp->i_mount, node, &nodehdr);
1548-
xfs_trans_log_buf(state->args->trans, drop_blk->bp,
1549-
XFS_DA_LOGRANGE(node, &node->hdr, state->args->geo->node_hdr_size));
1547+
xfs_trans_log_buf(tp, drop_blk->bp,
1548+
XFS_DA_LOGRANGE(node, &node->hdr, geo->node_hdr_size));
15501549

15511550
/*
15521551
* Copy the last hash value from the block to propagate upwards.
15531552
*/
15541553
drop_blk->hashval = be32_to_cpu(btree[index - 1].hashval);
15551554
}
15561555

1556+
/*
1557+
* Remove an entry from an intermediate node.
1558+
*/
1559+
STATIC void
1560+
xfs_da3_node_remove(
1561+
struct xfs_da_state *state,
1562+
struct xfs_da_state_blk *drop_blk)
1563+
{
1564+
trace_xfs_da_node_remove(state->args);
1565+
1566+
__xfs_da3_node_remove(state->args->trans, state->args->dp,
1567+
state->args->geo, drop_blk);
1568+
}
1569+
1570+
/*
1571+
* Remove an entry from an intermediate attr node at the specified index.
1572+
*/
1573+
void
1574+
xfs_attr3_node_entry_remove(
1575+
struct xfs_trans *tp,
1576+
struct xfs_inode *dp,
1577+
struct xfs_buf *bp,
1578+
int index)
1579+
{
1580+
struct xfs_da_state_blk blk = {
1581+
.index = index,
1582+
.bp = bp,
1583+
};
1584+
1585+
__xfs_da3_node_remove(tp, dp, dp->i_mount->m_attr_geo, &blk);
1586+
}
1587+
15571588
/*
15581589
* Unbalance the elements between two intermediate nodes,
15591590
* move all Btree elements from one node into another.

fs/xfs/libxfs/xfs_da_btree.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ int xfs_da3_split(xfs_da_state_t *state);
184184
int xfs_da3_join(xfs_da_state_t *state);
185185
void xfs_da3_fixhashpath(struct xfs_da_state *state,
186186
struct xfs_da_state_path *path_to_to_fix);
187+
void xfs_attr3_node_entry_remove(struct xfs_trans *tp, struct xfs_inode *dp,
188+
struct xfs_buf *bp, int index);
187189

188190
/*
189191
* Routines used for finding things in the Btree.

0 commit comments

Comments
 (0)