Lines Matching refs:state

39 STATIC int xfs_da3_root_split(xfs_da_state_t *state,
42 STATIC int xfs_da3_node_split(xfs_da_state_t *state,
48 STATIC void xfs_da3_node_rebalance(xfs_da_state_t *state,
51 STATIC void xfs_da3_node_add(xfs_da_state_t *state,
58 STATIC int xfs_da3_root_join(xfs_da_state_t *state,
60 STATIC int xfs_da3_node_toosmall(xfs_da_state_t *state, int *retval);
61 STATIC void xfs_da3_node_remove(xfs_da_state_t *state,
63 STATIC void xfs_da3_node_unbalance(xfs_da_state_t *state,
70 STATIC int xfs_da3_blk_unlink(xfs_da_state_t *state,
75 kmem_zone_t *xfs_da_state_zone; /* anchor for state struct zone */
78 * Allocate a dir-state structure.
85 struct xfs_da_state *state;
87 state = kmem_cache_zalloc(xfs_da_state_zone, GFP_NOFS | __GFP_NOFAIL);
88 state->args = args;
89 state->mp = args->dp->i_mount;
90 return state;
94 * Kill the altpath contents of a da-state structure.
97 xfs_da_state_kill_altpath(xfs_da_state_t *state)
101 for (i = 0; i < state->altpath.active; i++)
102 state->altpath.blk[i].bp = NULL;
103 state->altpath.active = 0;
107 * Free a da-state structure.
110 xfs_da_state_free(xfs_da_state_t *state)
112 xfs_da_state_kill_altpath(state);
114 memset((char *)state, 0, sizeof(*state));
116 kmem_cache_free(xfs_da_state_zone, state);
472 struct xfs_da_state *state)
483 trace_xfs_da_split(state->args);
491 max = state->path.active - 1;
493 ASSERT(state->path.blk[max].magic == XFS_ATTR_LEAF_MAGIC ||
494 state->path.blk[max].magic == XFS_DIR2_LEAFN_MAGIC);
496 addblk = &state->path.blk[max]; /* initial dummy value */
497 for (i = max; (i >= 0) && addblk; state->path.active--, i--) {
498 oldblk = &state->path.blk[i];
499 newblk = &state->altpath.blk[i];
509 error = xfs_attr3_leaf_split(state, oldblk, newblk);
522 state->extravalid = 1;
523 if (state->inleaf) {
524 state->extraafter = 0; /* before newblk */
525 trace_xfs_attr_leaf_split_before(state->args);
526 error = xfs_attr3_leaf_split(state, oldblk,
527 &state->extrablk);
529 state->extraafter = 1; /* after newblk */
530 trace_xfs_attr_leaf_split_after(state->args);
531 error = xfs_attr3_leaf_split(state, newblk,
532 &state->extrablk);
539 error = xfs_dir2_leafn_split(state, oldblk, newblk);
545 error = xfs_da3_node_split(state, oldblk, newblk, addblk,
563 xfs_da3_fixhashpath(state, &state->path);
573 ASSERT(state->extravalid == 0 ||
574 state->path.blk[max].magic == XFS_DIR2_LEAFN_MAGIC);
579 ASSERT(state->path.active == 0);
580 oldblk = &state->path.blk[0];
581 error = xfs_da3_root_split(state, oldblk, addblk);
605 xfs_trans_log_buf(state->args->trans, addblk->bp,
618 xfs_trans_log_buf(state->args->trans, addblk->bp,
634 struct xfs_da_state *state,
652 trace_xfs_da_root_split(state->args);
658 args = state->args;
764 struct xfs_da_state *state,
777 struct xfs_inode *dp = state->args->dp;
779 trace_xfs_da_node_split(state->args);
787 useextra = state->extravalid && state->args->whichfork == XFS_ATTR_FORK;
792 if (nodehdr.count + newcount > state->args->geo->node_ents) {
797 error = xfs_da_grow_inode(state->args, &blkno);
801 error = xfs_da3_node_create(state->args, blkno, treelevel,
802 &newblk->bp, state->args->whichfork);
807 xfs_da3_node_rebalance(state, oldblk, newblk);
808 error = xfs_da3_blk_link(state, oldblk, newblk);
832 xfs_da3_node_add(state, oldblk, addblk);
834 if (state->extraafter)
836 xfs_da3_node_add(state, oldblk, &state->extrablk);
837 state->extravalid = 0;
841 xfs_da3_node_add(state, newblk, addblk);
843 if (state->extraafter)
845 xfs_da3_node_add(state, newblk, &state->extrablk);
846 state->extravalid = 0;
861 struct xfs_da_state *state,
878 struct xfs_inode *dp = state->args->dp;
880 trace_xfs_da_node_rebalance(state->args);
910 tp = state->args->trans;
968 state->args->geo->node_hdr_size));
973 state->args->geo->node_hdr_size +
1005 struct xfs_da_state *state,
1013 struct xfs_inode *dp = state->args->dp;
1015 trace_xfs_da_node_add(state->args);
1023 if (state->args->whichfork == XFS_DATA_FORK)
1024 ASSERT(newblk->blkno >= state->args->geo->leafblk &&
1025 newblk->blkno < state->args->geo->freeblk);
1037 xfs_trans_log_buf(state->args->trans, oldblk->bp,
1043 xfs_trans_log_buf(state->args->trans, oldblk->bp,
1045 state->args->geo->node_hdr_size));
1063 struct xfs_da_state *state)
1070 trace_xfs_da_join(state->args);
1072 drop_blk = &state->path.blk[ state->path.active-1 ];
1073 save_blk = &state->altpath.blk[ state->path.active-1 ];
1074 ASSERT(state->path.blk[0].magic == XFS_DA_NODE_MAGIC);
1082 for ( ; state->path.active >= 2; drop_blk--, save_blk--,
1083 state->path.active--) {
1092 error = xfs_attr3_leaf_toosmall(state, &action);
1097 xfs_attr3_leaf_unbalance(state, drop_blk, save_blk);
1100 error = xfs_dir2_leafn_toosmall(state, &action);
1105 xfs_dir2_leafn_unbalance(state, drop_blk, save_blk);
1112 xfs_da3_node_remove(state, drop_blk);
1113 xfs_da3_fixhashpath(state, &state->path);
1114 error = xfs_da3_node_toosmall(state, &action);
1119 xfs_da3_node_unbalance(state, drop_blk, save_blk);
1122 xfs_da3_fixhashpath(state, &state->altpath);
1123 error = xfs_da3_blk_unlink(state, drop_blk, save_blk);
1124 xfs_da_state_kill_altpath(state);
1127 error = xfs_da_shrink_inode(state->args, drop_blk->blkno,
1138 xfs_da3_node_remove(state, drop_blk);
1139 xfs_da3_fixhashpath(state, &state->path);
1140 error = xfs_da3_root_join(state, &state->path.blk[0]);
1172 struct xfs_da_state *state,
1181 struct xfs_inode *dp = state->args->dp;
1183 trace_xfs_da_root_join(state->args);
1187 args = state->args;
1235 * If the block is empty, fill in the state structure and return 2.
1236 * If it can be collapsed, fill in the state structure and return 1.
1241 struct xfs_da_state *state,
1255 struct xfs_inode *dp = state->args->dp;
1257 trace_xfs_da_node_toosmall(state->args);
1264 blk = &state->path.blk[ state->path.active-1 ];
1268 if (nodehdr.count > (state->args->geo->node_ents >> 1)) {
1285 memcpy(&state->altpath, &state->path, sizeof(state->path));
1286 error = xfs_da3_path_shift(state, &state->altpath, forward,
1305 count = state->args->geo->node_ents;
1306 count -= state->args->geo->node_ents >> 2;
1319 error = xfs_da3_node_read(state->args->trans, dp, blkno, &bp,
1320 state->args->whichfork);
1326 xfs_trans_brelse(state->args->trans, bp);
1340 memcpy(&state->altpath, &state->path, sizeof(state->path));
1342 error = xfs_da3_path_shift(state, &state->altpath, forward,
1345 error = xfs_da3_path_shift(state, &state->path, forward,
1383 struct xfs_da_state *state,
1392 struct xfs_inode *dp = state->args->dp;
1394 trace_xfs_da_fixhashpath(state->args);
1425 xfs_trans_log_buf(state->args->trans, blk->bp,
1438 struct xfs_da_state *state,
1446 struct xfs_inode *dp = state->args->dp;
1448 trace_xfs_da_node_remove(state->args);
1464 xfs_trans_log_buf(state->args->trans, drop_blk->bp,
1469 xfs_trans_log_buf(state->args->trans, drop_blk->bp,
1473 xfs_trans_log_buf(state->args->trans, drop_blk->bp,
1474 XFS_DA_LOGRANGE(node, &node->hdr, state->args->geo->node_hdr_size));
1488 struct xfs_da_state *state,
1501 struct xfs_inode *dp = state->args->dp;
1503 trace_xfs_da_node_unbalance(state->args);
1511 tp = state->args->trans;
1547 state->args->geo->node_hdr_size));
1561 * in the state structure as we go.
1563 * We will set the state structure to point to each of the elements
1572 struct xfs_da_state *state,
1591 struct xfs_inode *dp = state->args->dp;
1593 args = state->args;
1600 for (blk = &state->path.blk[0], state->path.active = 1;
1601 state->path.active <= XFS_DA_NODE_MAXDEPTH;
1602 blk++, state->path.active++) {
1611 state->path.active--;
1724 &blk->index, state);
1735 error = xfs_da3_path_shift(state, &state->path, 1, 1,
1793 struct xfs_da_state *state,
1804 struct xfs_inode *dp = state->args->dp;
1809 args = state->args;
1886 struct xfs_da_state *state,
1900 args = state->args;
1966 struct xfs_da_state *state,
1981 struct xfs_inode *dp = state->args->dp;
1983 trace_xfs_da_path_shift(state->args);
1990 args = state->args;