Skip to content

Commit 0e26b6e

Browse files
saschahauerrichardweinberger
authored andcommitted
ubifs: Export pnode_lookup as ubifs_pnode_lookup
ubifs_lpt_lookup could be implemented using pnode_lookup. To make that possible move pnode_lookup from lpt.c to lpt_commit.c. Rename it to ubifs_pnode_lookup since it's now exported. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent 22ceaa8 commit 0e26b6e

File tree

3 files changed

+37
-36
lines changed

3 files changed

+37
-36
lines changed

fs/ubifs/lpt.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,38 @@ struct ubifs_pnode *ubifs_get_pnode(struct ubifs_info *c,
14381438
return branch->pnode;
14391439
}
14401440

1441+
/**
1442+
* ubifs_pnode_lookup - lookup a pnode in the LPT.
1443+
* @c: UBIFS file-system description object
1444+
* @i: pnode number (0 to (main_lebs - 1) / UBIFS_LPT_FANOUT)
1445+
*
1446+
* This function returns a pointer to the pnode on success or a negative
1447+
* error code on failure.
1448+
*/
1449+
struct ubifs_pnode *ubifs_pnode_lookup(struct ubifs_info *c, int i)
1450+
{
1451+
int err, h, iip, shft;
1452+
struct ubifs_nnode *nnode;
1453+
1454+
if (!c->nroot) {
1455+
err = ubifs_read_nnode(c, NULL, 0);
1456+
if (err)
1457+
return ERR_PTR(err);
1458+
}
1459+
i <<= UBIFS_LPT_FANOUT_SHIFT;
1460+
nnode = c->nroot;
1461+
shft = c->lpt_hght * UBIFS_LPT_FANOUT_SHIFT;
1462+
for (h = 1; h < c->lpt_hght; h++) {
1463+
iip = ((i >> shft) & (UBIFS_LPT_FANOUT - 1));
1464+
shft -= UBIFS_LPT_FANOUT_SHIFT;
1465+
nnode = ubifs_get_nnode(c, nnode, iip);
1466+
if (IS_ERR(nnode))
1467+
return ERR_CAST(nnode);
1468+
}
1469+
iip = ((i >> shft) & (UBIFS_LPT_FANOUT - 1));
1470+
return ubifs_get_pnode(c, nnode, iip);
1471+
}
1472+
14411473
/**
14421474
* ubifs_lpt_lookup - lookup LEB properties in the LPT.
14431475
* @c: UBIFS file-system description object

fs/ubifs/lpt_commit.c

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -618,38 +618,6 @@ static struct ubifs_pnode *next_pnode_to_dirty(struct ubifs_info *c,
618618
return ubifs_get_pnode(c, nnode, iip);
619619
}
620620

621-
/**
622-
* pnode_lookup - lookup a pnode in the LPT.
623-
* @c: UBIFS file-system description object
624-
* @i: pnode number (0 to (main_lebs - 1) / UBIFS_LPT_FANOUT))
625-
*
626-
* This function returns a pointer to the pnode on success or a negative
627-
* error code on failure.
628-
*/
629-
static struct ubifs_pnode *pnode_lookup(struct ubifs_info *c, int i)
630-
{
631-
int err, h, iip, shft;
632-
struct ubifs_nnode *nnode;
633-
634-
if (!c->nroot) {
635-
err = ubifs_read_nnode(c, NULL, 0);
636-
if (err)
637-
return ERR_PTR(err);
638-
}
639-
i <<= UBIFS_LPT_FANOUT_SHIFT;
640-
nnode = c->nroot;
641-
shft = c->lpt_hght * UBIFS_LPT_FANOUT_SHIFT;
642-
for (h = 1; h < c->lpt_hght; h++) {
643-
iip = ((i >> shft) & (UBIFS_LPT_FANOUT - 1));
644-
shft -= UBIFS_LPT_FANOUT_SHIFT;
645-
nnode = ubifs_get_nnode(c, nnode, iip);
646-
if (IS_ERR(nnode))
647-
return ERR_CAST(nnode);
648-
}
649-
iip = ((i >> shft) & (UBIFS_LPT_FANOUT - 1));
650-
return ubifs_get_pnode(c, nnode, iip);
651-
}
652-
653621
/**
654622
* add_pnode_dirt - add dirty space to LPT LEB properties.
655623
* @c: UBIFS file-system description object
@@ -702,7 +670,7 @@ static int make_tree_dirty(struct ubifs_info *c)
702670
{
703671
struct ubifs_pnode *pnode;
704672

705-
pnode = pnode_lookup(c, 0);
673+
pnode = ubifs_pnode_lookup(c, 0);
706674
if (IS_ERR(pnode))
707675
return PTR_ERR(pnode);
708676

@@ -956,7 +924,7 @@ static int make_pnode_dirty(struct ubifs_info *c, int node_num, int lnum,
956924
struct ubifs_pnode *pnode;
957925
struct ubifs_nbranch *branch;
958926

959-
pnode = pnode_lookup(c, node_num);
927+
pnode = ubifs_pnode_lookup(c, node_num);
960928
if (IS_ERR(pnode))
961929
return PTR_ERR(pnode);
962930
branch = &pnode->parent->nbranch[pnode->iip];
@@ -1558,7 +1526,7 @@ static int dbg_is_pnode_dirty(struct ubifs_info *c, int lnum, int offs)
15581526
struct ubifs_nbranch *branch;
15591527

15601528
cond_resched();
1561-
pnode = pnode_lookup(c, i);
1529+
pnode = ubifs_pnode_lookup(c, i);
15621530
if (IS_ERR(pnode))
15631531
return PTR_ERR(pnode);
15641532
branch = &pnode->parent->nbranch[pnode->iip];
@@ -1710,7 +1678,7 @@ int dbg_check_ltab(struct ubifs_info *c)
17101678
for (i = 0; i < cnt; i++) {
17111679
struct ubifs_pnode *pnode;
17121680

1713-
pnode = pnode_lookup(c, i);
1681+
pnode = ubifs_pnode_lookup(c, i);
17141682
if (IS_ERR(pnode))
17151683
return PTR_ERR(pnode);
17161684
cond_resched();

fs/ubifs/ubifs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,7 @@ struct ubifs_pnode *ubifs_get_pnode(struct ubifs_info *c,
17121712
struct ubifs_nnode *parent, int iip);
17131713
struct ubifs_nnode *ubifs_get_nnode(struct ubifs_info *c,
17141714
struct ubifs_nnode *parent, int iip);
1715+
struct ubifs_pnode *ubifs_pnode_lookup(struct ubifs_info *c, int i);
17151716
int ubifs_read_nnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip);
17161717
void ubifs_add_lpt_dirt(struct ubifs_info *c, int lnum, int dirty);
17171718
void ubifs_add_nnode_dirt(struct ubifs_info *c, struct ubifs_nnode *nnode);

0 commit comments

Comments
 (0)