Lines Matching refs:znode
24 * @znode: previous znode
27 * Returns the next element or %NULL if @znode is already the last one.
31 struct ubifs_znode *znode)
38 if (unlikely(!znode))
41 if (unlikely(znode == zr)) {
42 if (znode->level == 0)
47 level = znode->level;
49 iip = znode->iip;
51 ubifs_assert(c, znode->level <= zr->level);
54 * First walk up until there is a znode with next branch to
57 while (znode->parent != zr && iip >= znode->parent->child_cnt) {
58 znode = znode->parent;
59 iip = znode->iip;
62 if (unlikely(znode->parent == zr &&
63 iip >= znode->parent->child_cnt)) {
68 * We were already looking for znode at lower
77 znode = ubifs_tnc_find_child(zr, 0);
78 ubifs_assert(c, znode);
82 zn = ubifs_tnc_find_child(znode->parent, iip + 1);
85 iip = znode->parent->child_cnt;
91 znode = zn;
98 iip = znode->iip;
111 * ubifs_search_zbranch - search znode branch.
113 * @znode: znode to search in
115 * @n: znode branch slot number is returned here
117 * This is a helper function which search branch with key @key in @znode using
122 * closest branch is returned in @n; the slot if all keys in this znode are
126 const struct ubifs_znode *znode,
129 int beg = 0, end = znode->child_cnt, mid;
131 const struct ubifs_zbranch *zbr = &znode->zbranch[0];
151 ubifs_assert(c, *n >= -1 && *n < znode->child_cnt);
156 if (*n + 1 < znode->child_cnt)
163 * ubifs_tnc_postorder_first - find first znode to do postorder tree traversal.
164 * @znode: znode to start at (root of the sub-tree to traverse)
166 * Find the lowest leftmost znode in a subtree of the TNC tree. The LNC is
169 struct ubifs_znode *ubifs_tnc_postorder_first(struct ubifs_znode *znode)
171 if (unlikely(!znode))
174 while (znode->level > 0) {
177 child = ubifs_tnc_find_child(znode, 0);
179 return znode;
180 znode = child;
183 return znode;
189 * @znode: previous znode
192 * Returns the next element or %NULL if @znode is already the last one.
195 struct ubifs_znode *znode)
199 ubifs_assert(c, znode);
200 if (unlikely(!znode->parent))
204 zn = ubifs_tnc_find_child(znode->parent, znode->iip + 1);
207 return znode->parent;
209 /* Go to the first znode in this new subtree */
216 * @znode: znode defining subtree to destroy
222 struct ubifs_znode *znode)
224 struct ubifs_znode *zn = ubifs_tnc_postorder_first(znode);
231 if (!zn->zbranch[n].znode)
235 !ubifs_zn_dirty(zn->zbranch[n].znode))
239 kfree(zn->zbranch[n].znode);
242 if (zn == znode) {
257 * This function destroys the whole TNC tree and updates clean global znode
264 if (!c->zroot.znode)
268 freed = ubifs_destroy_tnc_subtree(c, c->zroot.znode);
272 c->zroot.znode = NULL;
276 * read_znode - read an indexing node from flash and fill znode.
279 * @znode: znode to read to
281 * This function reads an indexing node from the flash media and fills znode
288 struct ubifs_znode *znode)
313 znode->child_cnt = le16_to_cpu(idx->child_cnt);
314 znode->level = le16_to_cpu(idx->level);
317 lnum, offs, znode->level, znode->child_cnt);
319 if (znode->child_cnt > c->fanout || znode->level > UBIFS_MAX_LEVELS) {
321 c->fanout, znode->child_cnt);
322 ubifs_err(c, "max levels %d, znode level %d",
323 UBIFS_MAX_LEVELS, znode->level);
328 for (i = 0; i < znode->child_cnt; i++) {
330 struct ubifs_zbranch *zbr = &znode->zbranch[i];
337 zbr->znode = NULL;
362 if (znode->level)
390 for (i = 0; i < znode->child_cnt - 1; i++) {
393 key1 = &znode->zbranch[i].key;
394 key2 = &znode->zbranch[i + 1].key;
421 * ubifs_load_znode - load znode to TNC cache.
423 * @zbr: znode branch
424 * @parent: znode's parent
427 * This function loads znode pointed to by @zbr into the TNC cache and
436 struct ubifs_znode *znode;
438 ubifs_assert(c, !zbr->znode);
440 * A slab cache is not presently used for znodes because the znode size
443 znode = kzalloc(c->max_znode_sz, GFP_NOFS);
444 if (!znode)
447 err = read_znode(c, zbr, znode);
454 * Increment the global clean znode counter as well. It is OK that
455 * global and per-FS clean znode counters may be inconsistent for some
461 zbr->znode = znode;
462 znode->parent = parent;
463 znode->time = ktime_get_seconds();
464 znode->iip = iip;
466 return znode;
469 kfree(znode);