Lines Matching refs:znode
112 int insert_old_idx_znode(struct ubifs_info *c, struct ubifs_znode *znode) in insert_old_idx_znode() argument
114 if (znode->parent) { in insert_old_idx_znode()
117 zbr = &znode->parent->zbranch[znode->iip]; in insert_old_idx_znode()
135 struct ubifs_znode *znode) in ins_clr_old_idx_znode() argument
139 if (znode->parent) { in ins_clr_old_idx_znode()
142 zbr = &znode->parent->zbranch[znode->iip]; in ins_clr_old_idx_znode()
191 struct ubifs_znode *znode) in copy_znode() argument
199 memcpy(zn, znode, c->max_znode_sz); in copy_znode()
204 ubifs_assert(!ubifs_zn_obsolete(znode)); in copy_znode()
205 __set_bit(OBSOLETE_ZNODE, &znode->flags); in copy_znode()
207 if (znode->level != 0) { in copy_znode()
215 if (zbr->znode) in copy_znode()
216 zbr->znode->parent = zn; in copy_znode()
248 struct ubifs_znode *znode = zbr->znode; in dirty_cow_znode() local
252 if (!ubifs_zn_cow(znode)) { in dirty_cow_znode()
254 if (!test_and_set_bit(DIRTY_ZNODE, &znode->flags)) { in dirty_cow_znode()
262 return znode; in dirty_cow_znode()
265 zn = copy_znode(c, znode); in dirty_cow_znode()
277 zbr->znode = zn; in dirty_cow_znode()
567 struct ubifs_znode *znode, int n) in get_znode() argument
571 zbr = &znode->zbranch[n]; in get_znode()
572 if (zbr->znode) in get_znode()
573 znode = zbr->znode; in get_znode()
575 znode = ubifs_load_znode(c, zbr, znode, n); in get_znode()
576 return znode; in get_znode()
590 struct ubifs_znode *znode = *zn; in tnc_next() local
594 if (nn < znode->child_cnt) { in tnc_next()
601 zp = znode->parent; in tnc_next()
604 nn = znode->iip + 1; in tnc_next()
605 znode = zp; in tnc_next()
606 if (nn < znode->child_cnt) { in tnc_next()
607 znode = get_znode(c, znode, nn); in tnc_next()
608 if (IS_ERR(znode)) in tnc_next()
609 return PTR_ERR(znode); in tnc_next()
610 while (znode->level != 0) { in tnc_next()
611 znode = get_znode(c, znode, 0); in tnc_next()
612 if (IS_ERR(znode)) in tnc_next()
613 return PTR_ERR(znode); in tnc_next()
619 *zn = znode; in tnc_next()
635 struct ubifs_znode *znode = *zn; in tnc_prev() local
645 zp = znode->parent; in tnc_prev()
648 nn = znode->iip - 1; in tnc_prev()
649 znode = zp; in tnc_prev()
651 znode = get_znode(c, znode, nn); in tnc_prev()
652 if (IS_ERR(znode)) in tnc_prev()
653 return PTR_ERR(znode); in tnc_prev()
654 while (znode->level != 0) { in tnc_prev()
655 nn = znode->child_cnt - 1; in tnc_prev()
656 znode = get_znode(c, znode, nn); in tnc_prev()
657 if (IS_ERR(znode)) in tnc_prev()
658 return PTR_ERR(znode); in tnc_prev()
660 nn = znode->child_cnt - 1; in tnc_prev()
664 *zn = znode; in tnc_prev()
763 struct ubifs_znode *znode = *zn; in resolve_collision() local
767 err = tnc_next(c, &znode, &nn); in resolve_collision()
772 if (keys_cmp(c, &znode->zbranch[nn].key, key)) in resolve_collision()
774 err = matches_name(c, &znode->zbranch[nn], nm); in resolve_collision()
779 *zn = znode; in resolve_collision()
878 struct ubifs_znode *o_znode = NULL, *znode = *zn; in fallible_resolve_collision() local
881 cmp = fallible_matches_name(c, &znode->zbranch[nn], nm); in fallible_resolve_collision()
887 o_znode = znode; in fallible_resolve_collision()
946 *zn = znode; in fallible_resolve_collision()
949 err = tnc_next(c, &znode, &nn); in fallible_resolve_collision()
954 if (keys_cmp(c, &znode->zbranch[nn].key, key)) in fallible_resolve_collision()
956 err = fallible_matches_name(c, &znode->zbranch[nn], nm); in fallible_resolve_collision()
961 *zn = znode; in fallible_resolve_collision()
966 o_znode = znode; in fallible_resolve_collision()
1022 struct ubifs_znode *znode; in resolve_collision_directly() local
1025 znode = *zn; in resolve_collision_directly()
1027 if (matches_position(&znode->zbranch[nn], lnum, offs)) in resolve_collision_directly()
1032 err = tnc_prev(c, &znode, &nn); in resolve_collision_directly()
1037 if (keys_cmp(c, &znode->zbranch[nn].key, key)) in resolve_collision_directly()
1039 if (matches_position(&znode->zbranch[nn], lnum, offs)) { in resolve_collision_directly()
1040 *zn = znode; in resolve_collision_directly()
1047 znode = *zn; in resolve_collision_directly()
1050 err = tnc_next(c, &znode, &nn); in resolve_collision_directly()
1055 if (keys_cmp(c, &znode->zbranch[nn].key, key)) in resolve_collision_directly()
1057 *zn = znode; in resolve_collision_directly()
1059 if (matches_position(&znode->zbranch[nn], lnum, offs)) in resolve_collision_directly()
1075 struct ubifs_znode *znode) in dirty_cow_bottom_up() argument
1080 ubifs_assert(c->zroot.znode); in dirty_cow_bottom_up()
1081 ubifs_assert(znode); in dirty_cow_bottom_up()
1082 if (c->zroot.znode->level > BOTTOM_UP_HEIGHT) { in dirty_cow_bottom_up()
1084 c->bottom_up_buf = kmalloc(c->zroot.znode->level * sizeof(int), in dirty_cow_bottom_up()
1090 if (c->zroot.znode->level) { in dirty_cow_bottom_up()
1095 zp = znode->parent; in dirty_cow_bottom_up()
1098 n = znode->iip; in dirty_cow_bottom_up()
1099 ubifs_assert(p < c->zroot.znode->level); in dirty_cow_bottom_up()
1101 if (!zp->cnext && ubifs_zn_dirty(znode)) in dirty_cow_bottom_up()
1103 znode = zp; in dirty_cow_bottom_up()
1111 zp = znode->parent; in dirty_cow_bottom_up()
1116 znode = dirty_cow_znode(c, zbr); in dirty_cow_bottom_up()
1118 ubifs_assert(znode == c->zroot.znode); in dirty_cow_bottom_up()
1119 znode = dirty_cow_znode(c, &c->zroot); in dirty_cow_bottom_up()
1121 if (IS_ERR(znode) || !p) in dirty_cow_bottom_up()
1124 ubifs_assert(path[p - 1] < znode->child_cnt); in dirty_cow_bottom_up()
1125 znode = znode->zbranch[path[p - 1]].znode; in dirty_cow_bottom_up()
1128 return znode; in dirty_cow_bottom_up()
1157 struct ubifs_znode *znode; in ubifs_lookup_level0() local
1163 znode = c->zroot.znode; in ubifs_lookup_level0()
1164 if (unlikely(!znode)) { in ubifs_lookup_level0()
1165 znode = ubifs_load_znode(c, &c->zroot, NULL, 0); in ubifs_lookup_level0()
1166 if (IS_ERR(znode)) in ubifs_lookup_level0()
1167 return PTR_ERR(znode); in ubifs_lookup_level0()
1170 znode->time = time; in ubifs_lookup_level0()
1175 exact = ubifs_search_zbranch(c, znode, key, n); in ubifs_lookup_level0()
1177 if (znode->level == 0) in ubifs_lookup_level0()
1182 zbr = &znode->zbranch[*n]; in ubifs_lookup_level0()
1184 if (zbr->znode) { in ubifs_lookup_level0()
1185 znode->time = time; in ubifs_lookup_level0()
1186 znode = zbr->znode; in ubifs_lookup_level0()
1191 znode = ubifs_load_znode(c, zbr, znode, *n); in ubifs_lookup_level0()
1192 if (IS_ERR(znode)) in ubifs_lookup_level0()
1193 return PTR_ERR(znode); in ubifs_lookup_level0()
1196 *zn = znode; in ubifs_lookup_level0()
1198 dbg_tnc("found %d, lvl %d, n %d", exact, znode->level, *n); in ubifs_lookup_level0()
1245 err = tnc_prev(c, &znode, n); in ubifs_lookup_level0()
1247 dbg_tnc("found 0, lvl %d, n -1", znode->level); in ubifs_lookup_level0()
1253 if (keys_cmp(c, key, &znode->zbranch[*n].key)) { in ubifs_lookup_level0()
1254 dbg_tnc("found 0, lvl %d, n -1", znode->level); in ubifs_lookup_level0()
1259 dbg_tnc("found 1, lvl %d, n %d", znode->level, *n); in ubifs_lookup_level0()
1260 *zn = znode; in ubifs_lookup_level0()
1293 struct ubifs_znode *znode; in lookup_level0_dirty() local
1298 znode = c->zroot.znode; in lookup_level0_dirty()
1299 if (unlikely(!znode)) { in lookup_level0_dirty()
1300 znode = ubifs_load_znode(c, &c->zroot, NULL, 0); in lookup_level0_dirty()
1301 if (IS_ERR(znode)) in lookup_level0_dirty()
1302 return PTR_ERR(znode); in lookup_level0_dirty()
1305 znode = dirty_cow_znode(c, &c->zroot); in lookup_level0_dirty()
1306 if (IS_ERR(znode)) in lookup_level0_dirty()
1307 return PTR_ERR(znode); in lookup_level0_dirty()
1309 znode->time = time; in lookup_level0_dirty()
1314 exact = ubifs_search_zbranch(c, znode, key, n); in lookup_level0_dirty()
1316 if (znode->level == 0) in lookup_level0_dirty()
1321 zbr = &znode->zbranch[*n]; in lookup_level0_dirty()
1323 if (zbr->znode) { in lookup_level0_dirty()
1324 znode->time = time; in lookup_level0_dirty()
1325 znode = dirty_cow_znode(c, zbr); in lookup_level0_dirty()
1326 if (IS_ERR(znode)) in lookup_level0_dirty()
1327 return PTR_ERR(znode); in lookup_level0_dirty()
1332 znode = ubifs_load_znode(c, zbr, znode, *n); in lookup_level0_dirty()
1333 if (IS_ERR(znode)) in lookup_level0_dirty()
1334 return PTR_ERR(znode); in lookup_level0_dirty()
1335 znode = dirty_cow_znode(c, zbr); in lookup_level0_dirty()
1336 if (IS_ERR(znode)) in lookup_level0_dirty()
1337 return PTR_ERR(znode); in lookup_level0_dirty()
1340 *zn = znode; in lookup_level0_dirty()
1342 dbg_tnc("found %d, lvl %d, n %d", exact, znode->level, *n); in lookup_level0_dirty()
1350 err = tnc_prev(c, &znode, n); in lookup_level0_dirty()
1353 dbg_tnc("found 0, lvl %d, n -1", znode->level); in lookup_level0_dirty()
1358 if (keys_cmp(c, key, &znode->zbranch[*n].key)) { in lookup_level0_dirty()
1360 dbg_tnc("found 0, lvl %d, n -1", znode->level); in lookup_level0_dirty()
1364 if (znode->cnext || !ubifs_zn_dirty(znode)) { in lookup_level0_dirty()
1365 znode = dirty_cow_bottom_up(c, znode); in lookup_level0_dirty()
1366 if (IS_ERR(znode)) in lookup_level0_dirty()
1367 return PTR_ERR(znode); in lookup_level0_dirty()
1370 dbg_tnc("found 1, lvl %d, n %d", znode->level, *n); in lookup_level0_dirty()
1371 *zn = znode; in lookup_level0_dirty()
1432 struct ubifs_znode *znode; in ubifs_tnc_locate() local
1437 found = ubifs_lookup_level0(c, key, &znode, &n); in ubifs_tnc_locate()
1445 zt = &znode->zbranch[n]; in ubifs_tnc_locate()
1463 zbr = znode->zbranch[n]; in ubifs_tnc_locate()
1507 struct ubifs_znode *znode; in ubifs_tnc_get_bu_keys() local
1515 err = ubifs_lookup_level0(c, &bu->key, &znode, &n); in ubifs_tnc_get_bu_keys()
1520 len = znode->zbranch[n].len; in ubifs_tnc_get_bu_keys()
1527 bu->zbranch[bu->cnt++] = znode->zbranch[n]; in ubifs_tnc_get_bu_keys()
1529 lnum = znode->zbranch[n].lnum; in ubifs_tnc_get_bu_keys()
1530 offs = ALIGN(znode->zbranch[n].offs + len, 8); in ubifs_tnc_get_bu_keys()
1538 err = tnc_next(c, &znode, &n); in ubifs_tnc_get_bu_keys()
1541 zbr = &znode->zbranch[n]; in ubifs_tnc_get_bu_keys()
1794 struct ubifs_znode *znode; in do_lookup_nm() local
1798 found = ubifs_lookup_level0(c, key, &znode, &n); in do_lookup_nm()
1809 err = resolve_collision(c, key, &znode, &n, nm); in do_lookup_nm()
1810 dbg_tnc("rc returned %d, znode %p, n %d", err, znode, n); in do_lookup_nm()
1818 err = tnc_read_node_nm(c, &znode->zbranch[n], node); in do_lookup_nm()
1873 struct ubifs_znode *znode) in correct_parent_keys() argument
1877 ubifs_assert(znode->parent); in correct_parent_keys()
1878 ubifs_assert(znode->iip == 0); in correct_parent_keys()
1880 key = &znode->zbranch[0].key; in correct_parent_keys()
1881 key1 = &znode->parent->zbranch[0].key; in correct_parent_keys()
1885 znode = znode->parent; in correct_parent_keys()
1886 znode->alt = 1; in correct_parent_keys()
1887 if (!znode->parent || znode->iip) in correct_parent_keys()
1889 key1 = &znode->parent->zbranch[0].key; in correct_parent_keys()
1904 static void insert_zbranch(struct ubifs_znode *znode, in insert_zbranch() argument
1909 ubifs_assert(ubifs_zn_dirty(znode)); in insert_zbranch()
1911 if (znode->level) { in insert_zbranch()
1912 for (i = znode->child_cnt; i > n; i--) { in insert_zbranch()
1913 znode->zbranch[i] = znode->zbranch[i - 1]; in insert_zbranch()
1914 if (znode->zbranch[i].znode) in insert_zbranch()
1915 znode->zbranch[i].znode->iip = i; in insert_zbranch()
1917 if (zbr->znode) in insert_zbranch()
1918 zbr->znode->iip = n; in insert_zbranch()
1920 for (i = znode->child_cnt; i > n; i--) in insert_zbranch()
1921 znode->zbranch[i] = znode->zbranch[i - 1]; in insert_zbranch()
1923 znode->zbranch[n] = *zbr; in insert_zbranch()
1924 znode->child_cnt += 1; in insert_zbranch()
1941 znode->alt = 1; in insert_zbranch()
1956 static int tnc_insert(struct ubifs_info *c, struct ubifs_znode *znode, in tnc_insert() argument
1967 zp = znode->parent; in tnc_insert()
1968 if (znode->child_cnt < c->fanout) { in tnc_insert()
1970 dbg_tnck(key, "inserted at %d level %d, key ", n, znode->level); in tnc_insert()
1972 insert_zbranch(znode, zbr, n); in tnc_insert()
1975 if (n == 0 && zp && znode->iip == 0) in tnc_insert()
1976 correct_parent_keys(c, znode); in tnc_insert()
1985 dbg_tnck(key, "splitting level %d, key ", znode->level); in tnc_insert()
1987 if (znode->alt) in tnc_insert()
1992 ins_clr_old_idx_znode(c, znode); in tnc_insert()
1998 zn->level = znode->level; in tnc_insert()
2001 if (znode->level == 0 && key_type(c, key) == UBIFS_DATA_KEY) { in tnc_insert()
2004 key1 = &znode->zbranch[n - 1].key; in tnc_insert()
2015 key1 = &znode->zbranch[0].key; in tnc_insert()
2018 key1 = &znode->zbranch[n].key; in tnc_insert()
2023 zi = znode; in tnc_insert()
2045 zi = znode; in tnc_insert()
2054 zbr->znode->parent = zn; in tnc_insert()
2063 znode->child_cnt = keep; in tnc_insert()
2069 zn->zbranch[i] = znode->zbranch[keep + i]; in tnc_insert()
2072 if (zn->zbranch[i].znode) { in tnc_insert()
2073 zn->zbranch[i].znode->parent = zn; in tnc_insert()
2074 zn->zbranch[i].znode->iip = i; in tnc_insert()
2085 if (n == 0 && zi == znode && znode->iip == 0) in tnc_insert()
2086 correct_parent_keys(c, znode); in tnc_insert()
2089 n = znode->iip + 1; in tnc_insert()
2093 zbr->znode = zn; in tnc_insert()
2097 znode = zp; in tnc_insert()
2103 dbg_tnc("creating new zroot at level %d", znode->level + 1); in tnc_insert()
2110 zi->level = znode->level + 1; in tnc_insert()
2115 zi->zbranch[0].key = znode->zbranch[0].key; in tnc_insert()
2116 zi->zbranch[0].znode = znode; in tnc_insert()
2121 zi->zbranch[1].znode = zn; in tnc_insert()
2126 c->zroot.znode = zi; in tnc_insert()
2130 znode->parent = zi; in tnc_insert()
2131 znode->iip = 0; in tnc_insert()
2152 struct ubifs_znode *znode; in ubifs_tnc_add() local
2156 found = lookup_level0_dirty(c, key, &znode, &n); in ubifs_tnc_add()
2160 zbr.znode = NULL; in ubifs_tnc_add()
2165 err = tnc_insert(c, znode, &zbr, n + 1); in ubifs_tnc_add()
2167 struct ubifs_zbranch *zbr = &znode->zbranch[n]; in ubifs_tnc_add()
2201 struct ubifs_znode *znode; in ubifs_tnc_replace() local
2206 found = lookup_level0_dirty(c, key, &znode, &n); in ubifs_tnc_replace()
2213 struct ubifs_zbranch *zbr = &znode->zbranch[n]; in ubifs_tnc_replace()
2226 found = resolve_collision_directly(c, key, &znode, &n, in ubifs_tnc_replace()
2229 found, znode, n, old_lnum, old_offs); in ubifs_tnc_replace()
2237 if (znode->cnext || !ubifs_zn_dirty(znode)) { in ubifs_tnc_replace()
2238 znode = dirty_cow_bottom_up(c, znode); in ubifs_tnc_replace()
2239 if (IS_ERR(znode)) { in ubifs_tnc_replace()
2240 err = PTR_ERR(znode); in ubifs_tnc_replace()
2244 zbr = &znode->zbranch[n]; in ubifs_tnc_replace()
2284 struct ubifs_znode *znode; in ubifs_tnc_add_nm() local
2289 found = lookup_level0_dirty(c, key, &znode, &n); in ubifs_tnc_add_nm()
2297 found = fallible_resolve_collision(c, key, &znode, &n, in ubifs_tnc_add_nm()
2300 found = resolve_collision(c, key, &znode, &n, nm); in ubifs_tnc_add_nm()
2301 dbg_tnc("rc returned %d, znode %p, n %d", found, znode, n); in ubifs_tnc_add_nm()
2308 if (znode->cnext || !ubifs_zn_dirty(znode)) { in ubifs_tnc_add_nm()
2309 znode = dirty_cow_bottom_up(c, znode); in ubifs_tnc_add_nm()
2310 if (IS_ERR(znode)) { in ubifs_tnc_add_nm()
2311 err = PTR_ERR(znode); in ubifs_tnc_add_nm()
2317 struct ubifs_zbranch *zbr = &znode->zbranch[n]; in ubifs_tnc_add_nm()
2331 zbr.znode = NULL; in ubifs_tnc_add_nm()
2336 err = tnc_insert(c, znode, &zbr, n + 1); in ubifs_tnc_add_nm()
2372 static int tnc_delete(struct ubifs_info *c, struct ubifs_znode *znode, int n) in tnc_delete() argument
2379 ubifs_assert(znode->level == 0); in tnc_delete()
2381 dbg_tnck(&znode->zbranch[n].key, "deleting key "); in tnc_delete()
2383 zbr = &znode->zbranch[n]; in tnc_delete()
2388 ubifs_dump_znode(c, znode); in tnc_delete()
2393 for (i = n; i < znode->child_cnt - 1; i++) in tnc_delete()
2394 znode->zbranch[i] = znode->zbranch[i + 1]; in tnc_delete()
2395 znode->child_cnt -= 1; in tnc_delete()
2397 if (znode->child_cnt > 0) in tnc_delete()
2406 ubifs_assert(!ubifs_zn_obsolete(znode)); in tnc_delete()
2407 ubifs_assert(ubifs_zn_dirty(znode)); in tnc_delete()
2409 zp = znode->parent; in tnc_delete()
2410 n = znode->iip; in tnc_delete()
2414 err = insert_old_idx_znode(c, znode); in tnc_delete()
2418 if (znode->cnext) { in tnc_delete()
2419 __set_bit(OBSOLETE_ZNODE, &znode->flags); in tnc_delete()
2423 kfree(znode); in tnc_delete()
2424 znode = zp; in tnc_delete()
2425 } while (znode->child_cnt == 1); /* while removing last child */ in tnc_delete()
2428 znode->child_cnt -= 1; in tnc_delete()
2429 ubifs_assert(znode->level != 0); in tnc_delete()
2430 for (i = n; i < znode->child_cnt; i++) { in tnc_delete()
2431 znode->zbranch[i] = znode->zbranch[i + 1]; in tnc_delete()
2432 if (znode->zbranch[i].znode) in tnc_delete()
2433 znode->zbranch[i].znode->iip = i; in tnc_delete()
2440 if (!znode->parent) { in tnc_delete()
2441 while (znode->child_cnt == 1 && znode->level != 0) { in tnc_delete()
2442 zp = znode; in tnc_delete()
2443 zbr = &znode->zbranch[0]; in tnc_delete()
2444 znode = get_znode(c, znode, 0); in tnc_delete()
2445 if (IS_ERR(znode)) in tnc_delete()
2446 return PTR_ERR(znode); in tnc_delete()
2447 znode = dirty_cow_znode(c, zbr); in tnc_delete()
2448 if (IS_ERR(znode)) in tnc_delete()
2449 return PTR_ERR(znode); in tnc_delete()
2450 znode->parent = NULL; in tnc_delete()
2451 znode->iip = 0; in tnc_delete()
2461 c->zroot.znode = znode; in tnc_delete()
2488 struct ubifs_znode *znode; in ubifs_tnc_remove() local
2492 found = lookup_level0_dirty(c, key, &znode, &n); in ubifs_tnc_remove()
2498 err = tnc_delete(c, znode, n); in ubifs_tnc_remove()
2519 struct ubifs_znode *znode; in ubifs_tnc_remove_nm() local
2523 err = lookup_level0_dirty(c, key, &znode, &n); in ubifs_tnc_remove_nm()
2529 err = fallible_resolve_collision(c, key, &znode, &n, in ubifs_tnc_remove_nm()
2532 err = resolve_collision(c, key, &znode, &n, nm); in ubifs_tnc_remove_nm()
2533 dbg_tnc("rc returned %d, znode %p, n %d", err, znode, n); in ubifs_tnc_remove_nm()
2538 if (znode->cnext || !ubifs_zn_dirty(znode)) { in ubifs_tnc_remove_nm()
2539 znode = dirty_cow_bottom_up(c, znode); in ubifs_tnc_remove_nm()
2540 if (IS_ERR(znode)) { in ubifs_tnc_remove_nm()
2541 err = PTR_ERR(znode); in ubifs_tnc_remove_nm()
2545 err = tnc_delete(c, znode, n); in ubifs_tnc_remove_nm()
2589 struct ubifs_znode *znode; in ubifs_tnc_remove_range() local
2595 err = ubifs_lookup_level0(c, from_key, &znode, &n); in ubifs_tnc_remove_range()
2602 err = tnc_next(c, &znode, &n); in ubifs_tnc_remove_range()
2609 key = &znode->zbranch[n].key; in ubifs_tnc_remove_range()
2617 if (znode->cnext || !ubifs_zn_dirty(znode)) { in ubifs_tnc_remove_range()
2618 znode = dirty_cow_bottom_up(c, znode); in ubifs_tnc_remove_range()
2619 if (IS_ERR(znode)) { in ubifs_tnc_remove_range()
2620 err = PTR_ERR(znode); in ubifs_tnc_remove_range()
2626 for (i = n + 1, k = 0; i < znode->child_cnt; i++, k++) { in ubifs_tnc_remove_range()
2627 key = &znode->zbranch[i].key; in ubifs_tnc_remove_range()
2630 lnc_free(&znode->zbranch[i]); in ubifs_tnc_remove_range()
2631 err = ubifs_add_dirt(c, znode->zbranch[i].lnum, in ubifs_tnc_remove_range()
2632 znode->zbranch[i].len); in ubifs_tnc_remove_range()
2634 ubifs_dump_znode(c, znode); in ubifs_tnc_remove_range()
2640 for (i = n + 1 + k; i < znode->child_cnt; i++) in ubifs_tnc_remove_range()
2641 znode->zbranch[i - k] = znode->zbranch[i]; in ubifs_tnc_remove_range()
2642 znode->child_cnt -= k; in ubifs_tnc_remove_range()
2646 err = tnc_delete(c, znode, n); in ubifs_tnc_remove_range()
2752 struct ubifs_znode *znode; in ubifs_tnc_next_ent() local
2761 err = ubifs_lookup_level0(c, key, &znode, &n); in ubifs_tnc_next_ent()
2768 err = resolve_collision(c, key, &znode, &n, nm); in ubifs_tnc_next_ent()
2770 err, znode, n); in ubifs_tnc_next_ent()
2776 err = tnc_next(c, &znode, &n); in ubifs_tnc_next_ent()
2791 err = tnc_next(c, &znode, &n); in ubifs_tnc_next_ent()
2797 zbr = &znode->zbranch[n]; in ubifs_tnc_next_ent()
2844 struct ubifs_znode *znode = cnext; in tnc_destroy_cnext() local
2847 if (ubifs_zn_obsolete(znode)) in tnc_destroy_cnext()
2848 kfree(znode); in tnc_destroy_cnext()
2859 if (c->zroot.znode) { in ubifs_tnc_close()
2863 freed = ubifs_destroy_tnc_subtree(c->zroot.znode); in ubifs_tnc_close()
2881 struct ubifs_znode *znode) in left_znode() argument
2883 int level = znode->level; in left_znode()
2886 int n = znode->iip - 1; in left_znode()
2889 znode = znode->parent; in left_znode()
2890 if (!znode) in left_znode()
2894 znode = get_znode(c, znode, n); in left_znode()
2895 if (IS_ERR(znode)) in left_znode()
2896 return znode; in left_znode()
2897 while (znode->level != level) { in left_znode()
2898 n = znode->child_cnt - 1; in left_znode()
2899 znode = get_znode(c, znode, n); in left_znode()
2900 if (IS_ERR(znode)) in left_znode()
2901 return znode; in left_znode()
2906 return znode; in left_znode()
2918 struct ubifs_znode *znode) in right_znode() argument
2920 int level = znode->level; in right_znode()
2923 int n = znode->iip + 1; in right_znode()
2926 znode = znode->parent; in right_znode()
2927 if (!znode) in right_znode()
2929 if (n < znode->child_cnt) { in right_znode()
2931 znode = get_znode(c, znode, n); in right_znode()
2932 if (IS_ERR(znode)) in right_znode()
2933 return znode; in right_znode()
2934 while (znode->level != level) { in right_znode()
2935 znode = get_znode(c, znode, 0); in right_znode()
2936 if (IS_ERR(znode)) in right_znode()
2937 return znode; in right_znode()
2942 return znode; in right_znode()
2974 struct ubifs_znode *znode, *zn; in lookup_znode() local
2987 znode = c->zroot.znode; in lookup_znode()
2988 if (!znode) { in lookup_znode()
2989 znode = ubifs_load_znode(c, &c->zroot, NULL, 0); in lookup_znode()
2990 if (IS_ERR(znode)) in lookup_znode()
2991 return znode; in lookup_znode()
2995 return znode; in lookup_znode()
2997 if (level >= znode->level) in lookup_znode()
3000 ubifs_search_zbranch(c, znode, key, &n); in lookup_znode()
3010 znode = left_znode(c, znode); in lookup_znode()
3011 if (!znode) in lookup_znode()
3013 if (IS_ERR(znode)) in lookup_znode()
3014 return znode; in lookup_znode()
3015 ubifs_search_zbranch(c, znode, key, &n); in lookup_znode()
3018 if (znode->level == level + 1) in lookup_znode()
3020 znode = get_znode(c, znode, n); in lookup_znode()
3021 if (IS_ERR(znode)) in lookup_znode()
3022 return znode; in lookup_znode()
3025 if (znode->zbranch[n].lnum == lnum && znode->zbranch[n].offs == offs) in lookup_znode()
3026 return get_znode(c, znode, n); in lookup_znode()
3034 zn = znode; in lookup_znode()
3042 znode = left_znode(c, znode); in lookup_znode()
3043 if (!znode) in lookup_znode()
3045 if (IS_ERR(znode)) in lookup_znode()
3046 return znode; in lookup_znode()
3047 n = znode->child_cnt - 1; in lookup_znode()
3050 if (znode->zbranch[n].lnum == lnum && in lookup_znode()
3051 znode->zbranch[n].offs == offs) in lookup_znode()
3052 return get_znode(c, znode, n); in lookup_znode()
3054 if (keys_cmp(c, &znode->zbranch[n].key, key) < 0) in lookup_znode()
3058 znode = zn; in lookup_znode()
3063 if (++n >= znode->child_cnt) { in lookup_znode()
3064 znode = right_znode(c, znode); in lookup_znode()
3065 if (!znode) in lookup_znode()
3067 if (IS_ERR(znode)) in lookup_znode()
3068 return znode; in lookup_znode()
3072 if (znode->zbranch[n].lnum == lnum && in lookup_znode()
3073 znode->zbranch[n].offs == offs) in lookup_znode()
3074 return get_znode(c, znode, n); in lookup_znode()
3076 if (keys_cmp(c, &znode->zbranch[n].key, key) > 0) in lookup_znode()
3102 struct ubifs_znode *znode; in is_idx_node_in_tnc() local
3104 znode = lookup_znode(c, key, level, lnum, offs); in is_idx_node_in_tnc()
3105 if (!znode) in is_idx_node_in_tnc()
3107 if (IS_ERR(znode)) in is_idx_node_in_tnc()
3108 return PTR_ERR(znode); in is_idx_node_in_tnc()
3110 return ubifs_zn_dirty(znode) ? 1 : 2; in is_idx_node_in_tnc()
3130 struct ubifs_znode *znode, *zn; in is_leaf_node_in_tnc() local
3134 found = ubifs_lookup_level0(c, key, &znode, &n); in is_leaf_node_in_tnc()
3139 zbr = &znode->zbranch[n]; in is_leaf_node_in_tnc()
3148 zn = znode; in is_leaf_node_in_tnc()
3152 err = tnc_prev(c, &znode, &n); in is_leaf_node_in_tnc()
3157 if (keys_cmp(c, key, &znode->zbranch[n].key)) in is_leaf_node_in_tnc()
3159 zbr = &znode->zbranch[n]; in is_leaf_node_in_tnc()
3164 znode = zn; in is_leaf_node_in_tnc()
3167 err = tnc_next(c, &znode, &n); in is_leaf_node_in_tnc()
3173 if (keys_cmp(c, key, &znode->zbranch[n].key)) in is_leaf_node_in_tnc()
3175 zbr = &znode->zbranch[n]; in is_leaf_node_in_tnc()
3239 struct ubifs_znode *znode; in ubifs_dirty_idx_node() local
3243 znode = lookup_znode(c, key, level, lnum, offs); in ubifs_dirty_idx_node()
3244 if (!znode) in ubifs_dirty_idx_node()
3246 if (IS_ERR(znode)) { in ubifs_dirty_idx_node()
3247 err = PTR_ERR(znode); in ubifs_dirty_idx_node()
3250 znode = dirty_cow_bottom_up(c, znode); in ubifs_dirty_idx_node()
3251 if (IS_ERR(znode)) { in ubifs_dirty_idx_node()
3252 err = PTR_ERR(znode); in ubifs_dirty_idx_node()
3277 struct ubifs_znode *znode; in dbg_check_inode_size() local
3290 err = ubifs_lookup_level0(c, &from_key, &znode, &n); in dbg_check_inode_size()
3299 err = tnc_next(c, &znode, &n); in dbg_check_inode_size()
3308 key = &znode->zbranch[n].key; in dbg_check_inode_size()