Lines Matching full:node

19 /* Get the length and offset of the given record in the given node */
20 u16 hfs_brec_lenoff(struct hfs_bnode *node, u16 rec, u16 *off) in hfs_brec_lenoff() argument
25 dataoff = node->tree->node_size - (rec + 2) * 2; in hfs_brec_lenoff()
26 hfs_bnode_read(node, retval, dataoff, 4); in hfs_brec_lenoff()
32 u16 hfs_brec_keylen(struct hfs_bnode *node, u16 rec) in hfs_brec_keylen() argument
36 if (node->type != HFS_NODE_INDEX && node->type != HFS_NODE_LEAF) in hfs_brec_keylen()
39 if ((node->type == HFS_NODE_INDEX) && in hfs_brec_keylen()
40 !(node->tree->attributes & HFS_TREE_VARIDXKEYS) && in hfs_brec_keylen()
41 (node->tree->cnid != HFSPLUS_ATTR_CNID)) { in hfs_brec_keylen()
42 retval = node->tree->max_key_len + 2; in hfs_brec_keylen()
44 recoff = hfs_bnode_read_u16(node, in hfs_brec_keylen()
45 node->tree->node_size - (rec + 1) * 2); in hfs_brec_keylen()
48 if (recoff > node->tree->node_size - 2) { in hfs_brec_keylen()
53 retval = hfs_bnode_read_u16(node, recoff) + 2; in hfs_brec_keylen()
54 if (retval > node->tree->max_key_len + 2) { in hfs_brec_keylen()
66 struct hfs_bnode *node, *new_node; in hfs_brec_insert() local
76 node = hfs_bnode_find(tree, tree->leaf_head); in hfs_brec_insert()
77 if (IS_ERR(node)) in hfs_brec_insert()
78 return PTR_ERR(node); in hfs_brec_insert()
79 fd->bnode = node; in hfs_brec_insert()
89 node = fd->bnode; in hfs_brec_insert()
90 hfs_bnode_dump(node); in hfs_brec_insert()
92 end_rec_off = tree->node_size - (node->num_recs + 1) * 2; in hfs_brec_insert()
93 end_off = hfs_bnode_read_u16(node, end_rec_off); in hfs_brec_insert()
105 if (node->type == HFS_NODE_LEAF) { in hfs_brec_insert()
109 node->num_recs++; in hfs_brec_insert()
111 hfs_bnode_write_u16(node, in hfs_brec_insert()
113 node->num_recs); in hfs_brec_insert()
114 hfs_bnode_write_u16(node, end_rec_off, end_off + size); in hfs_brec_insert()
122 data_off = hfs_bnode_read_u16(node, data_rec_off + 2); in hfs_brec_insert()
123 hfs_bnode_write_u16(node, data_rec_off, data_off + size); in hfs_brec_insert()
128 hfs_bnode_move(node, data_off + size, data_off, in hfs_brec_insert()
132 hfs_bnode_write(node, fd->search_key, data_off, key_len); in hfs_brec_insert()
133 hfs_bnode_write(node, entry, data_off + key_len, entry_len); in hfs_brec_insert()
134 hfs_bnode_dump(node); in hfs_brec_insert()
138 * at the start of the node and it is not the new node in hfs_brec_insert()
140 if (!rec && new_node != node) { in hfs_brec_insert()
141 hfs_bnode_read_key(node, fd->search_key, data_off + size); in hfs_brec_insert()
182 struct hfs_bnode *node, *parent; in hfs_brec_remove() local
186 node = fd->bnode; in hfs_brec_remove()
189 end_off = tree->node_size - (node->num_recs + 1) * 2; in hfs_brec_remove()
191 if (node->type == HFS_NODE_LEAF) { in hfs_brec_remove()
195 hfs_bnode_dump(node); in hfs_brec_remove()
198 if (!--node->num_recs) { in hfs_brec_remove()
199 hfs_bnode_unlink(node); in hfs_brec_remove()
200 if (!node->parent) in hfs_brec_remove()
202 parent = hfs_bnode_find(tree, node->parent); in hfs_brec_remove()
205 hfs_bnode_put(node); in hfs_brec_remove()
206 node = fd->bnode = parent; in hfs_brec_remove()
208 __hfs_brec_find(node, fd, hfs_find_rec_by_key); in hfs_brec_remove()
211 hfs_bnode_write_u16(node, in hfs_brec_remove()
213 node->num_recs); in hfs_brec_remove()
220 data_off = hfs_bnode_read_u16(node, rec_off); in hfs_brec_remove()
221 hfs_bnode_write_u16(node, rec_off + 2, data_off - size); in hfs_brec_remove()
226 hfs_bnode_move(node, fd->keyoffset, fd->keyoffset + size, in hfs_brec_remove()
229 hfs_bnode_dump(node); in hfs_brec_remove()
238 struct hfs_bnode *node, *new_node, *next_node; in hfs_bnode_split() local
244 node = fd->bnode; in hfs_bnode_split()
248 hfs_bnode_get(node); in hfs_bnode_split()
250 node->this, new_node->this, node->next); in hfs_bnode_split()
251 new_node->next = node->next; in hfs_bnode_split()
252 new_node->prev = node->this; in hfs_bnode_split()
253 new_node->parent = node->parent; in hfs_bnode_split()
254 new_node->type = node->type; in hfs_bnode_split()
255 new_node->height = node->height; in hfs_bnode_split()
257 if (node->next) in hfs_bnode_split()
258 next_node = hfs_bnode_find(tree, node->next); in hfs_bnode_split()
263 hfs_bnode_put(node); in hfs_bnode_split()
268 size = tree->node_size / 2 - node->num_recs * 2 - 14; in hfs_bnode_split()
272 data_start = hfs_bnode_read_u16(node, old_rec_off); in hfs_bnode_split()
276 if (++num_recs < node->num_recs) in hfs_bnode_split()
279 hfs_bnode_put(node); in hfs_bnode_split()
292 data_start = hfs_bnode_read_u16(node, old_rec_off); in hfs_bnode_split()
294 hfs_bnode_put(node); in hfs_bnode_split()
301 new_node->num_recs = node->num_recs - num_recs; in hfs_bnode_split()
302 node->num_recs = num_recs; in hfs_bnode_split()
313 data_end = hfs_bnode_read_u16(node, old_rec_off); in hfs_bnode_split()
318 hfs_bnode_copy(new_node, 14, node, data_start, data_end - data_start); in hfs_bnode_split()
330 node->next = new_node->this; in hfs_bnode_split()
331 hfs_bnode_read(node, &node_desc, 0, sizeof(node_desc)); in hfs_bnode_split()
332 node_desc.next = cpu_to_be32(node->next); in hfs_bnode_split()
333 node_desc.num_recs = cpu_to_be16(node->num_recs); in hfs_bnode_split()
334 hfs_bnode_write(node, &node_desc, 0, sizeof(node_desc)); in hfs_bnode_split()
343 } else if (node->this == tree->leaf_tail) { in hfs_bnode_split()
344 /* if there is no next node, this might be the new tail */ in hfs_bnode_split()
349 hfs_bnode_dump(node); in hfs_bnode_split()
351 hfs_bnode_put(node); in hfs_bnode_split()
359 struct hfs_bnode *node, *new_node, *parent; in hfs_brec_update_parent() local
365 node = fd->bnode; in hfs_brec_update_parent()
367 if (!node->parent) in hfs_brec_update_parent()
371 parent = hfs_bnode_find(tree, node->parent); in hfs_brec_update_parent()
383 newkeylen = hfs_bnode_read_u16(node, 14) + 2; in hfs_brec_update_parent()
398 hfs_dbg(BNODE_MOD, "splitting index node\n"); in hfs_brec_update_parent()
423 hfs_bnode_copy(parent, fd->keyoffset, node, 14, newkeylen); in hfs_brec_update_parent()
426 hfs_bnode_put(node); in hfs_brec_update_parent()
427 node = parent; in hfs_brec_update_parent()
447 if (new_node == node) in hfs_brec_update_parent()
450 hfs_bnode_read_key(node, fd->search_key, 14); in hfs_brec_update_parent()
455 if (!rec && node->parent) in hfs_brec_update_parent()
458 fd->bnode = node; in hfs_brec_update_parent()
464 struct hfs_bnode *node, *new_node; in hfs_btree_inc_height() local
469 node = NULL; in hfs_btree_inc_height()
471 node = hfs_bnode_find(tree, tree->root); in hfs_btree_inc_height()
472 if (IS_ERR(node)) in hfs_btree_inc_height()
473 return PTR_ERR(node); in hfs_btree_inc_height()
477 hfs_bnode_put(node); in hfs_btree_inc_height()
506 if (node) { in hfs_btree_inc_height()
508 node->parent = tree->root; in hfs_btree_inc_height()
509 if (node->type == HFS_NODE_LEAF || in hfs_btree_inc_height()
512 key_size = hfs_bnode_read_u16(node, 14) + 2; in hfs_btree_inc_height()
515 hfs_bnode_copy(new_node, 14, node, 14, key_size); in hfs_btree_inc_height()
522 cnid = cpu_to_be32(node->this); in hfs_btree_inc_height()
528 hfs_bnode_put(node); in hfs_btree_inc_height()