Lines Matching defs:znode
35 * @znode: previous znode
38 * Returns the next element or %NULL if @znode is already the last one.
41 struct ubifs_znode *znode)
48 if (unlikely(!znode))
51 if (unlikely(znode == zr)) {
52 if (znode->level == 0)
57 level = znode->level;
59 iip = znode->iip;
61 ubifs_assert(znode->level <= zr->level);
64 * First walk up until there is a znode with next branch to
67 while (znode->parent != zr && iip >= znode->parent->child_cnt) {
68 znode = znode->parent;
69 iip = znode->iip;
72 if (unlikely(znode->parent == zr &&
73 iip >= znode->parent->child_cnt)) {
78 * We were already looking for znode at lower
87 znode = ubifs_tnc_find_child(zr, 0);
88 ubifs_assert(znode);
92 zn = ubifs_tnc_find_child(znode->parent, iip + 1);
95 iip = znode->parent->child_cnt;
101 znode = zn;
108 iip = znode->iip;
121 * ubifs_search_zbranch - search znode branch.
123 * @znode: znode to search in
125 * @n: znode branch slot number is returned here
127 * This is a helper function which search branch with key @key in @znode using
132 * closest branch is returned in @n; the slot if all keys in this znode are
136 const struct ubifs_znode *znode,
139 int beg = 0, end = znode->child_cnt, uninitialized_var(mid);
141 const struct ubifs_zbranch *zbr = &znode->zbranch[0];
161 ubifs_assert(*n >= -1 && *n < znode->child_cnt);
166 if (*n + 1 < znode->child_cnt)
173 * ubifs_tnc_postorder_first - find first znode to do postorder tree traversal.
174 * @znode: znode to start at (root of the sub-tree to traverse)
176 * Find the lowest leftmost znode in a subtree of the TNC tree. The LNC is
179 struct ubifs_znode *ubifs_tnc_postorder_first(struct ubifs_znode *znode)
181 if (unlikely(!znode))
184 while (znode->level > 0) {
187 child = ubifs_tnc_find_child(znode, 0);
189 return znode;
190 znode = child;
193 return znode;
198 * @znode: previous znode
201 * Returns the next element or %NULL if @znode is already the last one.
203 struct ubifs_znode *ubifs_tnc_postorder_next(struct ubifs_znode *znode)
207 ubifs_assert(znode);
208 if (unlikely(!znode->parent))
212 zn = ubifs_tnc_find_child(znode->parent, znode->iip + 1);
215 return znode->parent;
217 /* Go to the first znode in this new subtree */
223 * @znode: znode defining subtree to destroy
228 long ubifs_destroy_tnc_subtree(struct ubifs_znode *znode)
230 struct ubifs_znode *zn = ubifs_tnc_postorder_first(znode);
237 if (!zn->zbranch[n].znode)
241 !ubifs_zn_dirty(zn->zbranch[n].znode))
245 kfree(zn->zbranch[n].znode);
248 if (zn == znode) {
260 * read_znode - read an indexing node from flash and fill znode.
265 * @znode: znode to read to
267 * This function reads an indexing node from the flash media and fills znode
274 struct ubifs_znode *znode)
289 znode->child_cnt = le16_to_cpu(idx->child_cnt);
290 znode->level = le16_to_cpu(idx->level);
293 lnum, offs, znode->level, znode->child_cnt);
295 if (znode->child_cnt > c->fanout || znode->level > UBIFS_MAX_LEVELS) {
297 c->fanout, znode->child_cnt);
298 ubifs_err("max levels %d, znode level %d",
299 UBIFS_MAX_LEVELS, znode->level);
304 for (i = 0; i < znode->child_cnt; i++) {
306 struct ubifs_zbranch *zbr = &znode->zbranch[i];
312 zbr->znode = NULL;
337 if (znode->level)
365 for (i = 0; i < znode->child_cnt - 1; i++) {
368 key1 = &znode->zbranch[i].key;
369 key2 = &znode->zbranch[i + 1].key;
396 * ubifs_load_znode - load znode to TNC cache.
398 * @zbr: znode branch
399 * @parent: znode's parent
402 * This function loads znode pointed to by @zbr into the TNC cache and
411 struct ubifs_znode *znode;
413 ubifs_assert(!zbr->znode);
415 * A slab cache is not presently used for znodes because the znode size
418 znode = kzalloc(c->max_znode_sz, GFP_NOFS);
419 if (!znode)
422 err = read_znode(c, zbr->lnum, zbr->offs, zbr->len, znode);
429 * Increment the global clean znode counter as well. It is OK that
430 * global and per-FS clean znode counters may be inconsistent for some
436 zbr->znode = znode;
437 znode->parent = parent;
438 znode->time = get_seconds();
439 znode->iip = iip;
441 return znode;
444 kfree(znode);