Lines Matching refs:state
40 STATIC int xfs_da3_root_split(xfs_da_state_t *state,
43 STATIC int xfs_da3_node_split(xfs_da_state_t *state,
49 STATIC void xfs_da3_node_rebalance(xfs_da_state_t *state,
52 STATIC void xfs_da3_node_add(xfs_da_state_t *state,
59 STATIC int xfs_da3_root_join(xfs_da_state_t *state,
61 STATIC int xfs_da3_node_toosmall(xfs_da_state_t *state, int *retval);
62 STATIC void xfs_da3_node_remove(xfs_da_state_t *state,
64 STATIC void xfs_da3_node_unbalance(xfs_da_state_t *state,
71 STATIC int xfs_da3_blk_unlink(xfs_da_state_t *state,
76 struct kmem_cache *xfs_da_state_cache; /* anchor for dir/attr state */
79 * Allocate a dir-state structure.
86 struct xfs_da_state *state;
88 state = kmem_cache_zalloc(xfs_da_state_cache, GFP_NOFS | __GFP_NOFAIL);
89 state->args = args;
90 state->mp = args->dp->i_mount;
91 return state;
95 * Kill the altpath contents of a da-state structure.
98 xfs_da_state_kill_altpath(xfs_da_state_t *state)
102 for (i = 0; i < state->altpath.active; i++)
103 state->altpath.blk[i].bp = NULL;
104 state->altpath.active = 0;
108 * Free a da-state structure.
111 xfs_da_state_free(xfs_da_state_t *state)
113 xfs_da_state_kill_altpath(state);
115 memset((char *)state, 0, sizeof(*state));
117 kmem_cache_free(xfs_da_state_cache, state);
122 struct xfs_da_state *state,
125 xfs_da_state_kill_altpath(state);
126 memset(state, 0, sizeof(struct xfs_da_state));
127 state->args = args;
128 state->mp = state->args->dp->i_mount;
484 struct xfs_da_state *state)
495 trace_xfs_da_split(state->args);
497 if (XFS_TEST_ERROR(false, state->mp, XFS_ERRTAG_DA_LEAF_SPLIT))
506 max = state->path.active - 1;
508 ASSERT(state->path.blk[max].magic == XFS_ATTR_LEAF_MAGIC ||
509 state->path.blk[max].magic == XFS_DIR2_LEAFN_MAGIC);
511 addblk = &state->path.blk[max]; /* initial dummy value */
512 for (i = max; (i >= 0) && addblk; state->path.active--, i--) {
513 oldblk = &state->path.blk[i];
514 newblk = &state->altpath.blk[i];
524 error = xfs_attr3_leaf_split(state, oldblk, newblk);
537 state->extravalid = 1;
538 if (state->inleaf) {
539 state->extraafter = 0; /* before newblk */
540 trace_xfs_attr_leaf_split_before(state->args);
541 error = xfs_attr3_leaf_split(state, oldblk,
542 &state->extrablk);
544 state->extraafter = 1; /* after newblk */
545 trace_xfs_attr_leaf_split_after(state->args);
546 error = xfs_attr3_leaf_split(state, newblk,
547 &state->extrablk);
554 error = xfs_dir2_leafn_split(state, oldblk, newblk);
560 error = xfs_da3_node_split(state, oldblk, newblk, addblk,
578 xfs_da3_fixhashpath(state, &state->path);
588 ASSERT(state->extravalid == 0 ||
589 state->path.blk[max].magic == XFS_DIR2_LEAFN_MAGIC);
594 ASSERT(state->path.active == 0);
595 oldblk = &state->path.blk[0];
596 error = xfs_da3_root_split(state, oldblk, addblk);
620 xfs_trans_log_buf(state->args->trans, addblk->bp,
633 xfs_trans_log_buf(state->args->trans, addblk->bp,
649 struct xfs_da_state *state,
667 trace_xfs_da_root_split(state->args);
673 args = state->args;
779 struct xfs_da_state *state,
792 struct xfs_inode *dp = state->args->dp;
794 trace_xfs_da_node_split(state->args);
802 useextra = state->extravalid && state->args->whichfork == XFS_ATTR_FORK;
807 if (nodehdr.count + newcount > state->args->geo->node_ents) {
812 error = xfs_da_grow_inode(state->args, &blkno);
816 error = xfs_da3_node_create(state->args, blkno, treelevel,
817 &newblk->bp, state->args->whichfork);
822 xfs_da3_node_rebalance(state, oldblk, newblk);
823 error = xfs_da3_blk_link(state, oldblk, newblk);
847 xfs_da3_node_add(state, oldblk, addblk);
849 if (state->extraafter)
851 xfs_da3_node_add(state, oldblk, &state->extrablk);
852 state->extravalid = 0;
856 xfs_da3_node_add(state, newblk, addblk);
858 if (state->extraafter)
860 xfs_da3_node_add(state, newblk, &state->extrablk);
861 state->extravalid = 0;
876 struct xfs_da_state *state,
892 struct xfs_inode *dp = state->args->dp;
894 trace_xfs_da_node_rebalance(state->args);
922 tp = state->args->trans;
980 state->args->geo->node_hdr_size));
985 state->args->geo->node_hdr_size +
1017 struct xfs_da_state *state,
1025 struct xfs_inode *dp = state->args->dp;
1027 trace_xfs_da_node_add(state->args);
1035 if (state->args->whichfork == XFS_DATA_FORK)
1036 ASSERT(newblk->blkno >= state->args->geo->leafblk &&
1037 newblk->blkno < state->args->geo->freeblk);
1049 xfs_trans_log_buf(state->args->trans, oldblk->bp,
1055 xfs_trans_log_buf(state->args->trans, oldblk->bp,
1057 state->args->geo->node_hdr_size));
1075 struct xfs_da_state *state)
1082 trace_xfs_da_join(state->args);
1084 drop_blk = &state->path.blk[ state->path.active-1 ];
1085 save_blk = &state->altpath.blk[ state->path.active-1 ];
1086 ASSERT(state->path.blk[0].magic == XFS_DA_NODE_MAGIC);
1094 for ( ; state->path.active >= 2; drop_blk--, save_blk--,
1095 state->path.active--) {
1104 error = xfs_attr3_leaf_toosmall(state, &action);
1109 xfs_attr3_leaf_unbalance(state, drop_blk, save_blk);
1112 error = xfs_dir2_leafn_toosmall(state, &action);
1117 xfs_dir2_leafn_unbalance(state, drop_blk, save_blk);
1124 xfs_da3_node_remove(state, drop_blk);
1125 xfs_da3_fixhashpath(state, &state->path);
1126 error = xfs_da3_node_toosmall(state, &action);
1131 xfs_da3_node_unbalance(state, drop_blk, save_blk);
1134 xfs_da3_fixhashpath(state, &state->altpath);
1135 error = xfs_da3_blk_unlink(state, drop_blk, save_blk);
1136 xfs_da_state_kill_altpath(state);
1139 error = xfs_da_shrink_inode(state->args, drop_blk->blkno,
1150 xfs_da3_node_remove(state, drop_blk);
1151 xfs_da3_fixhashpath(state, &state->path);
1152 error = xfs_da3_root_join(state, &state->path.blk[0]);
1184 struct xfs_da_state *state,
1193 struct xfs_inode *dp = state->args->dp;
1195 trace_xfs_da_root_join(state->args);
1199 args = state->args;
1247 * If the block is empty, fill in the state structure and return 2.
1248 * If it can be collapsed, fill in the state structure and return 1.
1253 struct xfs_da_state *state,
1267 struct xfs_inode *dp = state->args->dp;
1269 trace_xfs_da_node_toosmall(state->args);
1276 blk = &state->path.blk[ state->path.active-1 ];
1280 if (nodehdr.count > (state->args->geo->node_ents >> 1)) {
1297 memcpy(&state->altpath, &state->path, sizeof(state->path));
1298 error = xfs_da3_path_shift(state, &state->altpath, forward,
1317 count = state->args->geo->node_ents;
1318 count -= state->args->geo->node_ents >> 2;
1331 error = xfs_da3_node_read(state->args->trans, dp, blkno, &bp,
1332 state->args->whichfork);
1338 xfs_trans_brelse(state->args->trans, bp);
1352 memcpy(&state->altpath, &state->path, sizeof(state->path));
1354 error = xfs_da3_path_shift(state, &state->altpath, forward,
1357 error = xfs_da3_path_shift(state, &state->path, forward,
1395 struct xfs_da_state *state,
1404 struct xfs_inode *dp = state->args->dp;
1406 trace_xfs_da_fixhashpath(state->args);
1437 xfs_trans_log_buf(state->args->trans, blk->bp,
1450 struct xfs_da_state *state,
1458 struct xfs_inode *dp = state->args->dp;
1460 trace_xfs_da_node_remove(state->args);
1476 xfs_trans_log_buf(state->args->trans, drop_blk->bp,
1481 xfs_trans_log_buf(state->args->trans, drop_blk->bp,
1485 xfs_trans_log_buf(state->args->trans, drop_blk->bp,
1486 XFS_DA_LOGRANGE(node, &node->hdr, state->args->geo->node_hdr_size));
1500 struct xfs_da_state *state,
1513 struct xfs_inode *dp = state->args->dp;
1515 trace_xfs_da_node_unbalance(state->args);
1523 tp = state->args->trans;
1559 state->args->geo->node_hdr_size));
1573 * in the state structure as we go.
1575 * We will set the state structure to point to each of the elements
1584 struct xfs_da_state *state,
1603 struct xfs_inode *dp = state->args->dp;
1605 args = state->args;
1612 for (blk = &state->path.blk[0], state->path.active = 1;
1613 state->path.active <= XFS_DA_NODE_MAXDEPTH;
1614 blk++, state->path.active++) {
1623 state->path.active--;
1736 &blk->index, state);
1747 error = xfs_da3_path_shift(state, &state->path, 1, 1,
1805 struct xfs_da_state *state,
1816 struct xfs_inode *dp = state->args->dp;
1821 args = state->args;
1898 struct xfs_da_state *state,
1912 args = state->args;
1978 struct xfs_da_state *state,
1993 struct xfs_inode *dp = state->args->dp;
1995 trace_xfs_da_path_shift(state->args);
2002 args = state->args;