Lines Matching refs:nnode

368  * ubifs_pack_nnode - pack all the bit fields of a nnode.
371 * @nnode: nnode to pack
374 struct ubifs_nnode *nnode)
382 pack_bits(c, &addr, &pos, nnode->num, c->pcnt_bits);
384 int lnum = nnode->nbranch[i].lnum;
389 pack_bits(c, &addr, &pos, nnode->nbranch[i].offs,
482 * @nnode: nnode for which to add dirt
484 void ubifs_add_nnode_dirt(struct ubifs_info *c, struct ubifs_nnode *nnode)
486 struct ubifs_nnode *np = nnode->parent;
489 ubifs_add_lpt_dirt(c, np->nbranch[nnode->iip].lnum,
512 * calc_nnode_num - calculate nnode number.
516 * The nnode number is a number that uniquely identifies a nnode and can be used
517 * easily to traverse the tree from the root to that nnode.
519 * This function calculates and returns the nnode number for the nnode at @row
537 * calc_nnode_num_from_parent - calculate nnode number.
539 * @parent: parent nnode
542 * The nnode number is a number that uniquely identifies a nnode and can be used
543 * easily to traverse the tree from the root to that nnode.
545 * This function calculates and returns the nnode number based on the parent's
546 * nnode number and the index in parent.
564 * @parent: parent nnode
571 * nnode number and the index in parent.
605 struct ubifs_nnode *nnode = NULL;
629 nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_KERNEL);
633 if (!pnode || !nnode || !buf || !ltab || !lsave) {
745 /* Only 1 nnode at this level, so it is the root */
757 nnode->nbranch[j].lnum = blnum;
758 nnode->nbranch[j].offs = boffs;
762 nnode->nbranch[j].lnum = 0;
763 nnode->nbranch[j].offs = 0;
766 nnode->num = calc_nnode_num(row, i);
767 ubifs_pack_nnode(c, p, nnode);
771 /* Only 1 nnode at this level, so it is the root */
866 kfree(nnode);
1004 * ubifs_unpack_nnode - unpack a nnode.
1006 * @buf: buffer containing packed nnode to unpack
1007 * @nnode: nnode structure to fill
1012 struct ubifs_nnode *nnode)
1021 nnode->num = ubifs_unpack_bits(c, &addr, &pos, c->pcnt_bits);
1029 nnode->nbranch[i].lnum = lnum;
1030 nnode->nbranch[i].offs = ubifs_unpack_bits(c, &addr, &pos,
1096 * validate_nnode - validate a nnode.
1098 * @nnode: nnode to validate
1099 * @parent: parent nnode (or NULL for the root nnode)
1104 static int validate_nnode(const struct ubifs_info *c, struct ubifs_nnode *nnode,
1112 if (nnode->num != num)
1123 int lnum = nnode->nbranch[i].lnum;
1124 int offs = nnode->nbranch[i].offs;
1143 * @parent: parent nnode
1196 * ubifs_read_nnode - read a nnode from flash and link it to the tree in memory.
1198 * @parent: parent nnode (or NULL for the root)
1206 struct ubifs_nnode *nnode = NULL;
1218 nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_NOFS);
1219 if (!nnode) {
1225 * This nnode was not written which just means that the LEB
1227 * make the nnode as though we had read it, which in fact means
1231 nnode->num = calc_nnode_num_from_parent(c, parent, iip);
1236 err = ubifs_unpack_nnode(c, buf, nnode);
1240 err = validate_nnode(c, nnode, parent, iip);
1244 nnode->num = calc_nnode_num_from_parent(c, parent, iip);
1246 branch->nnode = nnode;
1247 nnode->level = parent->level - 1;
1249 c->nroot = nnode;
1250 nnode->level = c->lpt_hght;
1252 nnode->parent = parent;
1253 nnode->iip = iip;
1257 ubifs_err(c, "error %d reading nnode at %d:%d", err, lnum, offs);
1259 kfree(nnode);
1266 * @parent: parent nnode
1396 * ubifs_get_nnode - get a nnode.
1398 * @parent: parent nnode (or NULL for the root)
1401 * This function returns a pointer to the nnode on success or a negative error
1408 struct ubifs_nnode *nnode;
1412 nnode = branch->nnode;
1413 if (nnode)
1414 return nnode;
1418 return branch->nnode;
1424 * @parent: parent nnode
1459 struct ubifs_nnode *nnode;
1467 nnode = c->nroot;
1472 nnode = ubifs_get_nnode(c, nnode, iip);
1473 if (IS_ERR(nnode))
1474 return ERR_CAST(nnode);
1477 return ubifs_get_pnode(c, nnode, iip);
1505 * dirty_cow_nnode - ensure a nnode is not being committed.
1507 * @nnode: nnode to check
1509 * Returns dirtied nnode on success or negative error code on failure.
1512 struct ubifs_nnode *nnode)
1517 if (!test_bit(COW_CNODE, &nnode->flags)) {
1518 /* nnode is not being committed */
1519 if (!test_and_set_bit(DIRTY_CNODE, &nnode->flags)) {
1521 ubifs_add_nnode_dirt(c, nnode);
1523 return nnode;
1526 /* nnode is being committed, so copy it */
1527 n = kmemdup(nnode, sizeof(struct ubifs_nnode), GFP_NOFS);
1543 ubifs_assert(c, !test_bit(OBSOLETE_CNODE, &nnode->flags));
1544 __set_bit(OBSOLETE_CNODE, &nnode->flags);
1547 ubifs_add_nnode_dirt(c, nnode);
1548 if (nnode->parent)
1549 nnode->parent->nbranch[n->iip].nnode = n;
1606 struct ubifs_nnode *nnode;
1614 nnode = c->nroot;
1615 nnode = dirty_cow_nnode(c, nnode);
1616 if (IS_ERR(nnode))
1617 return ERR_CAST(nnode);
1623 nnode = ubifs_get_nnode(c, nnode, iip);
1624 if (IS_ERR(nnode))
1625 return ERR_CAST(nnode);
1626 nnode = dirty_cow_nnode(c, nnode);
1627 if (IS_ERR(nnode))
1628 return ERR_CAST(nnode);
1631 pnode = ubifs_get_pnode(c, nnode, iip);
1655 struct ubifs_nnode *nnode, *nn;
1685 nnode = cnode->parent;
1695 nnode = ubifs_get_nnode(c, nn, iip);
1696 if (IS_ERR(nnode)) {
1697 err = PTR_ERR(nnode);
1703 cnode = (struct ubifs_cnode *)nnode;
1729 cnode = (struct ubifs_cnode *)nnode;
1917 * @nnode: where to keep a nnode
1921 * @ptr.nnode: pointer to the nnode (if it is an nnode) which may be here or in
1928 struct ubifs_nnode nnode;
1934 struct ubifs_nnode *nnode;
1941 * scan_get_nnode - for the scan, get a nnode from either the tree or flash.
1943 * @path: where to put the nnode
1944 * @parent: parent of the nnode
1945 * @iip: index in parent of the nnode
1947 * This function returns a pointer to the nnode on success or a negative error
1955 struct ubifs_nnode *nnode;
1960 nnode = branch->nnode;
1961 if (nnode) {
1963 path->ptr.nnode = nnode;
1964 return nnode;
1966 nnode = &path->nnode;
1968 path->ptr.nnode = nnode;
1969 memset(nnode, 0, sizeof(struct ubifs_nnode));
1972 * This nnode was not written which just means that the LEB
1974 * make the nnode as though we had read it, which in fact means
1978 nnode->num = calc_nnode_num_from_parent(c, parent, iip);
1984 err = ubifs_unpack_nnode(c, buf, nnode);
1988 err = validate_nnode(c, nnode, parent, iip);
1992 nnode->num = calc_nnode_num_from_parent(c, parent, iip);
1993 nnode->level = parent->level - 1;
1994 nnode->parent = parent;
1995 nnode->iip = iip;
1996 return nnode;
2082 struct ubifs_nnode *nnode;
2106 path[0].ptr.nnode = c->nroot;
2110 nnode = c->nroot;
2116 nnode = scan_get_nnode(c, path + h, nnode, iip);
2117 if (IS_ERR(nnode)) {
2118 err = PTR_ERR(nnode);
2123 pnode = scan_get_pnode(c, path + h, nnode, iip);
2148 nnode = kmemdup(&path[h].nnode, sz, GFP_NOFS);
2149 if (!nnode) {
2153 parent = nnode->parent;
2154 parent->nbranch[nnode->iip].nnode = nnode;
2155 path[h].ptr.nnode = nnode;
2157 path[h + 1].cnode.parent = nnode;
2213 nnode = path[h].ptr.nnode;
2216 iip = nnode->iip;
2223 nnode = scan_get_nnode(c, path + h, nnode, iip);
2224 if (IS_ERR(nnode)) {
2225 err = PTR_ERR(nnode);
2230 pnode = scan_get_pnode(c, path + h, nnode, iip);
2374 * @cnode: next cnode (nnode or pnode) to check
2383 struct ubifs_nnode *nnode, *nn;
2392 nnode = cnode->parent;
2394 /* cnode is a nnode */
2397 ubifs_err(c, "nnode num %d expected %d parent num %d iip %d",
2399 (nnode ? nnode->num : 0), cnode->iip);
2432 cnode = (struct ubifs_cnode *)nnode;