Lines Matching refs:znode
29 * tree. If a znode is not in memory, we read it from flash while still having
112 * insert_old_idx_znode - record a znode obsoleted since last commit start.
114 * @znode: znode of obsoleted index node
118 int insert_old_idx_znode(struct ubifs_info *c, struct ubifs_znode *znode)
120 if (znode->parent) {
123 zbr = &znode->parent->zbranch[znode->iip];
134 * ins_clr_old_idx_znode - record a znode obsoleted since last commit start.
136 * @znode: znode of obsoleted index node
141 struct ubifs_znode *znode)
145 if (znode->parent) {
148 zbr = &znode->parent->zbranch[znode->iip];
206 * copy_znode - copy a dirty znode.
208 * @znode: znode to copy
210 * A dirty znode being committed may not be changed, so it is copied.
213 struct ubifs_znode *znode)
221 memcpy(zn, znode, c->max_znode_sz);
226 ubifs_assert(!test_bit(OBSOLETE_ZNODE, &znode->flags));
227 __set_bit(OBSOLETE_ZNODE, &znode->flags);
229 if (znode->level != 0) {
237 if (zbr->znode)
238 zbr->znode->parent = zn;
247 * add_idx_dirt - add dirt due to a dirty znode.
261 * dirty_cow_znode - ensure a znode is not being committed.
263 * @zbr: branch of znode to check
265 * Returns dirtied znode on success or negative error code on failure.
270 struct ubifs_znode *znode = zbr->znode;
274 if (!test_bit(COW_ZNODE, &znode->flags)) {
275 /* znode is not being committed */
276 if (!test_and_set_bit(DIRTY_ZNODE, &znode->flags)) {
284 return znode;
287 zn = copy_znode(c, znode);
299 zbr->znode = zn;
578 * get_znode - get a TNC znode that may not be loaded yet.
580 * @znode: parent znode
581 * @n: znode branch slot number
583 * This function returns the znode or a negative error code.
586 struct ubifs_znode *znode, int n)
590 zbr = &znode->zbranch[n];
591 if (zbr->znode)
592 znode = zbr->znode;
594 znode = ubifs_load_znode(c, zbr, znode, n);
595 return znode;
601 * @zn: znode is passed and returned here
602 * @n: znode branch slot number is passed and returned here
609 struct ubifs_znode *znode = *zn;
613 if (nn < znode->child_cnt) {
620 zp = znode->parent;
623 nn = znode->iip + 1;
624 znode = zp;
625 if (nn < znode->child_cnt) {
626 znode = get_znode(c, znode, nn);
627 if (IS_ERR(znode))
628 return PTR_ERR(znode);
629 while (znode->level != 0) {
630 znode = get_znode(c, znode, 0);
631 if (IS_ERR(znode))
632 return PTR_ERR(znode);
638 *zn = znode;
646 * @zn: znode is returned here
647 * @n: znode branch slot number is passed and returned here
654 struct ubifs_znode *znode = *zn;
664 zp = znode->parent;
667 nn = znode->iip - 1;
668 znode = zp;
670 znode = get_znode(c, znode, nn);
671 if (IS_ERR(znode))
672 return PTR_ERR(znode);
673 while (znode->level != 0) {
674 nn = znode->child_cnt - 1;
675 znode = get_znode(c, znode, nn);
676 if (IS_ERR(znode))
677 return PTR_ERR(znode);
679 nn = znode->child_cnt - 1;
683 *zn = znode;
692 * @zn: znode is returned here
730 * like to insert, but inserting in this znode
735 * znode zp
740 * znode za | | znode zb
745 * The lookup finds Key2 in znode zb. Lets say
749 * znode za at slot n = 1. But that is invalid
751 * be inserted into znode zb.
782 struct ubifs_znode *znode = *zn;
786 err = tnc_next(c, &znode, &nn);
791 if (keys_cmp(c, &znode->zbranch[nn].key, key))
793 err = matches_name(c, &znode->zbranch[nn], nm);
798 *zn = znode;
874 * @zn: znode is returned here
897 struct ubifs_znode *o_znode = NULL, *znode = *zn;
900 cmp = fallible_matches_name(c, &znode->zbranch[nn], nm);
906 o_znode = znode;
965 *zn = znode;
968 err = tnc_next(c, &znode, &nn);
973 if (keys_cmp(c, &znode->zbranch[nn].key, key))
975 err = fallible_matches_name(c, &znode->zbranch[nn], nm);
980 *zn = znode;
985 o_znode = znode;
1023 * @zn: znode is passed and returned here
1041 struct ubifs_znode *znode;
1044 znode = *zn;
1046 if (matches_position(&znode->zbranch[nn], lnum, offs))
1051 err = tnc_prev(c, &znode, &nn);
1056 if (keys_cmp(c, &znode->zbranch[nn].key, key))
1058 if (matches_position(&znode->zbranch[nn], lnum, offs)) {
1059 *zn = znode;
1066 znode = *zn;
1069 err = tnc_next(c, &znode, &nn);
1074 if (keys_cmp(c, &znode->zbranch[nn].key, key))
1076 *zn = znode;
1078 if (matches_position(&znode->zbranch[nn], lnum, offs))
1084 * dirty_cow_bottom_up - dirty a znode and its ancestors.
1086 * @znode: znode to dirty
1088 * If we do not have a unique key that resides in a znode, then we cannot
1089 * dirty that znode from the top down (i.e. by using lookup_level0_dirty)
1094 struct ubifs_znode *znode)
1099 ubifs_assert(c->zroot.znode);
1100 ubifs_assert(znode);
1101 if (c->zroot.znode->level > BOTTOM_UP_HEIGHT) {
1103 c->bottom_up_buf = kmalloc(c->zroot.znode->level * sizeof(int),
1109 if (c->zroot.znode->level) {
1114 zp = znode->parent;
1117 n = znode->iip;
1118 ubifs_assert(p < c->zroot.znode->level);
1120 if (!zp->cnext && ubifs_zn_dirty(znode))
1122 znode = zp;
1130 zp = znode->parent;
1135 znode = dirty_cow_znode(c, zbr);
1137 ubifs_assert(znode == c->zroot.znode);
1138 znode = dirty_cow_znode(c, &c->zroot);
1140 if (IS_ERR(znode) || !p)
1143 ubifs_assert(path[p - 1] < znode->child_cnt);
1144 znode = znode->zbranch[path[p - 1]].znode;
1147 return znode;
1151 * ubifs_lookup_level0 - search for zero-level znode.
1154 * @zn: znode is returned here
1155 * @n: znode branch slot number is returned here
1157 * This function looks up the TNC tree and search for zero-level znode which
1158 * refers key @key. The found zero-level znode is returned in @zn. There are 3
1160 * o exact match, i.e. the found zero-level znode contains key @key, then %1
1162 * o not exact match, which means that zero-level znode does not contain
1176 struct ubifs_znode *znode;
1181 znode = c->zroot.znode;
1182 if (unlikely(!znode)) {
1183 znode = ubifs_load_znode(c, &c->zroot, NULL, 0);
1184 if (IS_ERR(znode))
1185 return PTR_ERR(znode);
1188 znode->time = time;
1193 exact = ubifs_search_zbranch(c, znode, key, n);
1195 if (znode->level == 0)
1200 zbr = &znode->zbranch[*n];
1202 if (zbr->znode) {
1203 znode->time = time;
1204 znode = zbr->znode;
1208 /* znode is not in TNC cache, load it from the media */
1209 znode = ubifs_load_znode(c, zbr, znode, *n);
1210 if (IS_ERR(znode))
1211 return PTR_ERR(znode);
1214 *zn = znode;
1216 dbg_tnc("found %d, lvl %d, n %d", exact, znode->level, *n);
1244 * children of current znode. For example, this happens if we split a
1245 * znode like this: | 3 | 5 | 5 | 6 | 7 |, which results in something
1256 * if we changed the leftmost key of the parent znode, the garbage
1263 err = tnc_prev(c, &znode, n);
1265 dbg_tnc("found 0, lvl %d, n -1", znode->level);
1271 if (keys_cmp(c, key, &znode->zbranch[*n].key)) {
1272 dbg_tnc("found 0, lvl %d, n -1", znode->level);
1277 dbg_tnc("found 1, lvl %d, n %d", znode->level, *n);
1278 *zn = znode;
1283 * lookup_level0_dirty - search for zero-level znode dirtying.
1286 * @zn: znode is returned here
1287 * @n: znode branch slot number is returned here
1289 * This function looks up the TNC tree and search for zero-level znode which
1290 * refers key @key. The found zero-level znode is returned in @zn. There are 3
1292 * o exact match, i.e. the found zero-level znode contains key @key, then %1
1294 * o not exact match, which means that zero-level znode does not contain @key
1301 * znode are marked as dirty.
1311 struct ubifs_znode *znode;
1316 znode = c->zroot.znode;
1317 if (unlikely(!znode)) {
1318 znode = ubifs_load_znode(c, &c->zroot, NULL, 0);
1319 if (IS_ERR(znode))
1320 return PTR_ERR(znode);
1323 znode = dirty_cow_znode(c, &c->zroot);
1324 if (IS_ERR(znode))
1325 return PTR_ERR(znode);
1327 znode->time = time;
1332 exact = ubifs_search_zbranch(c, znode, key, n);
1334 if (znode->level == 0)
1339 zbr = &znode->zbranch[*n];
1341 if (zbr->znode) {
1342 znode->time = time;
1343 znode = dirty_cow_znode(c, zbr);
1344 if (IS_ERR(znode))
1345 return PTR_ERR(znode);
1349 /* znode is not in TNC cache, load it from the media */
1350 znode = ubifs_load_znode(c, zbr, znode, *n);
1351 if (IS_ERR(znode))
1352 return PTR_ERR(znode);
1353 znode = dirty_cow_znode(c, zbr);
1354 if (IS_ERR(znode))
1355 return PTR_ERR(znode);
1358 *zn = znode;
1360 dbg_tnc("found %d, lvl %d, n %d", exact, znode->level, *n);
1368 err = tnc_prev(c, &znode, n);
1371 dbg_tnc("found 0, lvl %d, n -1", znode->level);
1376 if (keys_cmp(c, key, &znode->zbranch[*n].key)) {
1378 dbg_tnc("found 0, lvl %d, n -1", znode->level);
1382 if (znode->cnext || !ubifs_zn_dirty(znode)) {
1383 znode = dirty_cow_bottom_up(c, znode);
1384 if (IS_ERR(znode))
1385 return PTR_ERR(znode);
1388 dbg_tnc("found 1, lvl %d, n %d", znode->level, *n);
1389 *zn = znode;
1446 struct ubifs_znode *znode;
1451 found = ubifs_lookup_level0(c, key, &znode, &n);
1459 zt = &znode->zbranch[n];
1477 zbr = znode->zbranch[n];
1521 struct ubifs_znode *znode;
1529 err = ubifs_lookup_level0(c, &bu->key, &znode, &n);
1534 len = znode->zbranch[n].len;
1541 bu->zbranch[bu->cnt++] = znode->zbranch[n];
1543 lnum = znode->zbranch[n].lnum;
1544 offs = ALIGN(znode->zbranch[n].offs + len, 8);
1552 err = tnc_next(c, &znode, &n);
1555 zbr = &znode->zbranch[n];
1808 struct ubifs_znode *znode;
1812 found = ubifs_lookup_level0(c, key, &znode, &n);
1823 err = resolve_collision(c, key, &znode, &n, nm);
1824 dbg_tnc("rc returned %d, znode %p, n %d", err, znode, n);
1832 err = tnc_read_node_nm(c, &znode->zbranch[n], node);
1880 * @znode: znode to correct parent znodes for
1887 struct ubifs_znode *znode)
1891 ubifs_assert(znode->parent);
1892 ubifs_assert(znode->iip == 0);
1894 key = &znode->zbranch[0].key;
1895 key1 = &znode->parent->zbranch[0].key;
1899 znode = znode->parent;
1900 znode->alt = 1;
1901 if (!znode->parent || znode->iip)
1903 key1 = &znode->parent->zbranch[0].key;
1908 * insert_zbranch - insert a zbranch into a znode.
1909 * @znode: znode into which to insert
1914 * znode's array of zbranches and keeps zbranches consolidated, so when a new
1915 * zbranch has to be inserted to the @znode->zbranches[]' array at the @n-th
1918 static void insert_zbranch(struct ubifs_znode *znode,
1923 ubifs_assert(ubifs_zn_dirty(znode));
1925 if (znode->level) {
1926 for (i = znode->child_cnt; i > n; i--) {
1927 znode->zbranch[i] = znode->zbranch[i - 1];
1928 if (znode->zbranch[i].znode)
1929 znode->zbranch[i].znode->iip = i;
1931 if (zbr->znode)
1932 zbr->znode->iip = n;
1934 for (i = znode->child_cnt; i > n; i--)
1935 znode->zbranch[i] = znode->zbranch[i - 1];
1937 znode->zbranch[n] = *zbr;
1938 znode->child_cnt += 1;
1942 * this znode may have changed. If this znode is subsequently split
1945 * happens, then it will no longer be possible to find this znode in the
1955 znode->alt = 1;
1961 * @znode: znode to insert into
1965 * This function inserts a new node described by @zbr into znode @znode. If
1966 * znode does not have a free slot for new zbranch, it is split. Parent znodes
1970 static int tnc_insert(struct ubifs_info *c, struct ubifs_znode *znode,
1981 zp = znode->parent;
1982 if (znode->child_cnt < c->fanout) {
1984 dbg_tnc("inserted at %d level %d, key %s", n, znode->level,
1987 insert_zbranch(znode, zbr, n);
1990 if (n == 0 && zp && znode->iip == 0)
1991 correct_parent_keys(c, znode);
1997 * Unfortunately, @znode does not have more empty slots and we have to
2000 dbg_tnc("splitting level %d, key %s", znode->level, DBGKEY(key));
2002 if (znode->alt)
2004 * We can no longer be sure of finding this znode by key, so we
2007 ins_clr_old_idx_znode(c, znode);
2013 zn->level = znode->level;
2016 if (znode->level == 0 && key_type(c, key) == UBIFS_DATA_KEY) {
2019 key1 = &znode->zbranch[n - 1].key;
2030 key1 = &znode->zbranch[0].key;
2033 key1 = &znode->zbranch[n].key;
2038 zi = znode;
2059 /* Insert into existing znode */
2060 zi = znode;
2064 /* Insert into new znode */
2069 zbr->znode->parent = zn;
2078 znode->child_cnt = keep;
2084 zn->zbranch[i] = znode->zbranch[keep + i];
2087 if (zn->zbranch[i].znode) {
2088 zn->zbranch[i].znode->parent = zn;
2089 zn->zbranch[i].znode->iip = i;
2098 /* Insert new znode (produced by spitting) into the parent */
2100 if (n == 0 && zi == znode && znode->iip == 0)
2101 correct_parent_keys(c, znode);
2104 n = znode->iip + 1;
2108 zbr->znode = zn;
2112 znode = zp;
2117 /* We have to split root znode */
2118 dbg_tnc("creating new zroot at level %d", znode->level + 1);
2125 zi->level = znode->level + 1;
2130 zi->zbranch[0].key = znode->zbranch[0].key;
2131 zi->zbranch[0].znode = znode;
2136 zi->zbranch[1].znode = zn;
2141 c->zroot.znode = zi;
2145 znode->parent = zi;
2146 znode->iip = 0;
2167 struct ubifs_znode *znode;
2171 found = lookup_level0_dirty(c, key, &znode, &n);
2175 zbr.znode = NULL;
2180 err = tnc_insert(c, znode, &zbr, n + 1);
2182 struct ubifs_zbranch *zbr = &znode->zbranch[n];
2216 struct ubifs_znode *znode;
2221 found = lookup_level0_dirty(c, key, &znode, &n);
2228 struct ubifs_zbranch *zbr = &znode->zbranch[n];
2241 found = resolve_collision_directly(c, key, &znode, &n,
2243 dbg_tnc("rc returned %d, znode %p, n %d, LEB %d:%d",
2244 found, znode, n, old_lnum, old_offs);
2251 /* Ensure the znode is dirtied */
2252 if (znode->cnext || !ubifs_zn_dirty(znode)) {
2253 znode = dirty_cow_bottom_up(c, znode);
2254 if (IS_ERR(znode)) {
2255 err = PTR_ERR(znode);
2259 zbr = &znode->zbranch[n];
2299 struct ubifs_znode *znode;
2304 found = lookup_level0_dirty(c, key, &znode, &n);
2312 found = fallible_resolve_collision(c, key, &znode, &n,
2315 found = resolve_collision(c, key, &znode, &n, nm);
2316 dbg_tnc("rc returned %d, znode %p, n %d", found, znode, n);
2322 /* Ensure the znode is dirtied */
2323 if (znode->cnext || !ubifs_zn_dirty(znode)) {
2324 znode = dirty_cow_bottom_up(c, znode);
2325 if (IS_ERR(znode)) {
2326 err = PTR_ERR(znode);
2332 struct ubifs_zbranch *zbr = &znode->zbranch[n];
2346 zbr.znode = NULL;
2351 err = tnc_insert(c, znode, &zbr, n + 1);
2379 * tnc_delete - delete a znode form TNC.
2381 * @znode: znode to delete from
2384 * This function deletes a leaf node from @n-th slot of @znode. Returns zero in
2387 static int tnc_delete(struct ubifs_info *c, struct ubifs_znode *znode, int n)
2394 ubifs_assert(znode->level == 0);
2396 dbg_tnc("deleting %s", DBGKEY(&znode->zbranch[n].key));
2398 zbr = &znode->zbranch[n];
2403 dbg_dump_znode(c, znode);
2408 for (i = n; i < znode->child_cnt - 1; i++)
2409 znode->zbranch[i] = znode->zbranch[i + 1];
2410 znode->child_cnt -= 1;
2412 if (znode->child_cnt > 0)
2416 * This was the last zbranch, we have to delete this znode from the
2421 ubifs_assert(!test_bit(OBSOLETE_ZNODE, &znode->flags));
2422 ubifs_assert(ubifs_zn_dirty(znode));
2424 zp = znode->parent;
2425 n = znode->iip;
2429 err = insert_old_idx_znode(c, znode);
2433 if (znode->cnext) {
2434 __set_bit(OBSOLETE_ZNODE, &znode->flags);
2438 kfree(znode);
2439 znode = zp;
2440 } while (znode->child_cnt == 1); /* while removing last child */
2442 /* Remove from znode, entry n - 1 */
2443 znode->child_cnt -= 1;
2444 ubifs_assert(znode->level != 0);
2445 for (i = n; i < znode->child_cnt; i++) {
2446 znode->zbranch[i] = znode->zbranch[i + 1];
2447 if (znode->zbranch[i].znode)
2448 znode->zbranch[i].znode->iip = i;
2455 if (!znode->parent) {
2456 while (znode->child_cnt == 1 && znode->level != 0) {
2457 zp = znode;
2458 zbr = &znode->zbranch[0];
2459 znode = get_znode(c, znode, 0);
2460 if (IS_ERR(znode))
2461 return PTR_ERR(znode);
2462 znode = dirty_cow_znode(c, zbr);
2463 if (IS_ERR(znode))
2464 return PTR_ERR(znode);
2465 znode->parent = NULL;
2466 znode->iip = 0;
2476 c->zroot.znode = znode;
2504 struct ubifs_znode *znode;
2508 found = lookup_level0_dirty(c, key, &znode, &n);
2514 err = tnc_delete(c, znode, n);
2535 struct ubifs_znode *znode;
2539 err = lookup_level0_dirty(c, key, &znode, &n);
2545 err = fallible_resolve_collision(c, key, &znode, &n,
2548 err = resolve_collision(c, key, &znode, &n, nm);
2549 dbg_tnc("rc returned %d, znode %p, n %d", err, znode, n);
2553 /* Ensure the znode is dirtied */
2554 if (znode->cnext || !ubifs_zn_dirty(znode)) {
2555 znode = dirty_cow_bottom_up(c, znode);
2556 if (IS_ERR(znode)) {
2557 err = PTR_ERR(znode);
2561 err = tnc_delete(c, znode, n);
2605 struct ubifs_znode *znode;
2610 /* Find first level 0 znode that contains keys to remove */
2611 err = ubifs_lookup_level0(c, from_key, &znode, &n);
2618 err = tnc_next(c, &znode, &n);
2625 key = &znode->zbranch[n].key;
2632 /* Ensure the znode is dirtied */
2633 if (znode->cnext || !ubifs_zn_dirty(znode)) {
2634 znode = dirty_cow_bottom_up(c, znode);
2635 if (IS_ERR(znode)) {
2636 err = PTR_ERR(znode);
2642 for (i = n + 1, k = 0; i < znode->child_cnt; i++, k++) {
2643 key = &znode->zbranch[i].key;
2646 lnc_free(&znode->zbranch[i]);
2647 err = ubifs_add_dirt(c, znode->zbranch[i].lnum,
2648 znode->zbranch[i].len);
2650 dbg_dump_znode(c, znode);
2656 for (i = n + 1 + k; i < znode->child_cnt; i++)
2657 znode->zbranch[i - k] = znode->zbranch[i];
2658 znode->child_cnt -= k;
2662 err = tnc_delete(c, znode, n);
2768 struct ubifs_znode *znode;
2777 err = ubifs_lookup_level0(c, key, &znode, &n);
2784 err = resolve_collision(c, key, &znode, &n, nm);
2785 dbg_tnc("rc returned %d, znode %p, n %d",
2786 err, znode, n);
2792 err = tnc_next(c, &znode, &n);
2804 * tree and @znode/@n variables contain the closest
2807 err = tnc_next(c, &znode, &n);
2813 zbr = &znode->zbranch[n];
2860 struct ubifs_znode *znode = cnext;
2863 if (test_bit(OBSOLETE_ZNODE, &znode->flags))
2864 kfree(znode);
2877 if (c->zroot.znode) {
2878 clean_freed = ubifs_destroy_tnc_subtree(c->zroot.znode);
2887 * left_znode - get the znode to the left.
2889 * @znode: znode
2891 * This function returns a pointer to the znode to the left of @znode or NULL if
2895 struct ubifs_znode *znode)
2897 int level = znode->level;
2900 int n = znode->iip - 1;
2903 znode = znode->parent;
2904 if (!znode)
2908 znode = get_znode(c, znode, n);
2909 if (IS_ERR(znode))
2910 return znode;
2911 while (znode->level != level) {
2912 n = znode->child_cnt - 1;
2913 znode = get_znode(c, znode, n);
2914 if (IS_ERR(znode))
2915 return znode;
2920 return znode;
2924 * right_znode - get the znode to the right.
2926 * @znode: znode
2928 * This function returns a pointer to the znode to the right of @znode or NULL
2932 struct ubifs_znode *znode)
2934 int level = znode->level;
2937 int n = znode->iip + 1;
2940 znode = znode->parent;
2941 if (!znode)
2943 if (n < znode->child_cnt) {
2945 znode = get_znode(c, znode, n);
2946 if (IS_ERR(znode))
2947 return znode;
2948 while (znode->level != level) {
2949 znode = get_znode(c, znode, 0);
2950 if (IS_ERR(znode))
2951 return znode;
2956 return znode;
2974 * dirty znode which still refers the same @lnum:@offs. This function is clever
2977 * Note, if a znode was deleted or changed too much, then this function will
2981 * This function returns a pointer to the znode found or %NULL if it is not
2988 struct ubifs_znode *znode, *zn;
2998 /* Get the root znode */
2999 znode = c->zroot.znode;
3000 if (!znode) {
3001 znode = ubifs_load_znode(c, &c->zroot, NULL, 0);
3002 if (IS_ERR(znode))
3003 return znode;
3007 return znode;
3009 if (level >= znode->level)
3012 ubifs_search_zbranch(c, znode, key, &n);
3015 * We reached a znode where the leftmost key is greater
3022 znode = left_znode(c, znode);
3023 if (!znode)
3025 if (IS_ERR(znode))
3026 return znode;
3027 ubifs_search_zbranch(c, znode, key, &n);
3030 if (znode->level == level + 1)
3032 znode = get_znode(c, znode, n);
3033 if (IS_ERR(znode))
3034 return znode;
3037 if (znode->zbranch[n].lnum == lnum && znode->zbranch[n].offs == offs)
3038 return get_znode(c, znode, n);
3046 zn = znode;
3054 znode = left_znode(c, znode);
3055 if (!znode)
3057 if (IS_ERR(znode))
3058 return znode;
3059 n = znode->child_cnt - 1;
3062 if (znode->zbranch[n].lnum == lnum &&
3063 znode->zbranch[n].offs == offs)
3064 return get_znode(c, znode, n);
3066 if (keys_cmp(c, &znode->zbranch[n].key, key) < 0)
3070 znode = zn;
3075 if (++n >= znode->child_cnt) {
3076 znode = right_znode(c, znode);
3077 if (!znode)
3079 if (IS_ERR(znode))
3080 return znode;
3084 if (znode->zbranch[n].lnum == lnum &&
3085 znode->zbranch[n].offs == offs)
3086 return get_znode(c, znode, n);
3088 if (keys_cmp(c, &znode->zbranch[n].key, key) > 0)
3103 * if the index node is referred to in the TNC and the corresponding znode is
3105 * znode is clean, and a negative error code in case of failure.
3114 struct ubifs_znode *znode;
3116 znode = lookup_znode(c, key, level, lnum, offs);
3117 if (!znode)
3119 if (IS_ERR(znode))
3120 return PTR_ERR(znode);
3122 return ubifs_zn_dirty(znode) ? 1 : 2;
3142 struct ubifs_znode *znode, *zn;
3146 found = ubifs_lookup_level0(c, key, &znode, &n);
3151 zbr = &znode->zbranch[n];
3160 zn = znode;
3164 err = tnc_prev(c, &znode, &n);
3169 if (keys_cmp(c, key, &znode->zbranch[n].key))
3171 zbr = &znode->zbranch[n];
3176 znode = zn;
3179 err = tnc_next(c, &znode, &n);
3185 if (keys_cmp(c, key, &znode->zbranch[n].key))
3187 zbr = &znode->zbranch[n];
3206 * the corresponding znode is clean or has not been loaded.
3251 struct ubifs_znode *znode;
3255 znode = lookup_znode(c, key, level, lnum, offs);
3256 if (!znode)
3258 if (IS_ERR(znode)) {
3259 err = PTR_ERR(znode);
3262 znode = dirty_cow_bottom_up(c, znode);
3263 if (IS_ERR(znode)) {
3264 err = PTR_ERR(znode);
3291 struct ubifs_znode *znode;
3304 err = ubifs_lookup_level0(c, &from_key, &znode, &n);
3314 err = tnc_next(c, &znode, &n);
3323 key = &znode->zbranch[n].key;