diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2018-09-07 08:36:26 -0400 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2018-10-23 07:48:17 -0400 |
commit | 0e26b6e2551e21df72c140e46819523e1b686009 (patch) | |
tree | 10704f3951b94efcd5cad1cba250afd8d0920564 | |
parent | 22ceaa8c688d0c8a6fc6eb7ebf32c01914220d0a (diff) |
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>
-rw-r--r-- | fs/ubifs/lpt.c | 32 | ||||
-rw-r--r-- | fs/ubifs/lpt_commit.c | 40 | ||||
-rw-r--r-- | fs/ubifs/ubifs.h | 1 |
3 files changed, 37 insertions, 36 deletions
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c index 31393370e334..ed0c67fe7500 100644 --- a/fs/ubifs/lpt.c +++ b/fs/ubifs/lpt.c | |||
@@ -1439,6 +1439,38 @@ struct ubifs_pnode *ubifs_get_pnode(struct ubifs_info *c, | |||
1439 | } | 1439 | } |
1440 | 1440 | ||
1441 | /** | 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 | |||
1473 | /** | ||
1442 | * ubifs_lpt_lookup - lookup LEB properties in the LPT. | 1474 | * ubifs_lpt_lookup - lookup LEB properties in the LPT. |
1443 | * @c: UBIFS file-system description object | 1475 | * @c: UBIFS file-system description object |
1444 | * @lnum: LEB number to lookup | 1476 | * @lnum: LEB number to lookup |
diff --git a/fs/ubifs/lpt_commit.c b/fs/ubifs/lpt_commit.c index 7ce30994bbba..62d6a87d4f5d 100644 --- a/fs/ubifs/lpt_commit.c +++ b/fs/ubifs/lpt_commit.c | |||
@@ -619,38 +619,6 @@ static struct ubifs_pnode *next_pnode_to_dirty(struct ubifs_info *c, | |||
619 | } | 619 | } |
620 | 620 | ||
621 | /** | 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 | |||
653 | /** | ||
654 | * add_pnode_dirt - add dirty space to LPT LEB properties. | 622 | * add_pnode_dirt - add dirty space to LPT LEB properties. |
655 | * @c: UBIFS file-system description object | 623 | * @c: UBIFS file-system description object |
656 | * @pnode: pnode for which to add dirt | 624 | * @pnode: pnode for which to add dirt |
@@ -702,7 +670,7 @@ static int make_tree_dirty(struct ubifs_info *c) | |||
702 | { | 670 | { |
703 | struct ubifs_pnode *pnode; | 671 | struct ubifs_pnode *pnode; |
704 | 672 | ||
705 | pnode = pnode_lookup(c, 0); | 673 | pnode = ubifs_pnode_lookup(c, 0); |
706 | if (IS_ERR(pnode)) | 674 | if (IS_ERR(pnode)) |
707 | return PTR_ERR(pnode); | 675 | return PTR_ERR(pnode); |
708 | 676 | ||
@@ -956,7 +924,7 @@ static int make_pnode_dirty(struct ubifs_info *c, int node_num, int lnum, | |||
956 | struct ubifs_pnode *pnode; | 924 | struct ubifs_pnode *pnode; |
957 | struct ubifs_nbranch *branch; | 925 | struct ubifs_nbranch *branch; |
958 | 926 | ||
959 | pnode = pnode_lookup(c, node_num); | 927 | pnode = ubifs_pnode_lookup(c, node_num); |
960 | if (IS_ERR(pnode)) | 928 | if (IS_ERR(pnode)) |
961 | return PTR_ERR(pnode); | 929 | return PTR_ERR(pnode); |
962 | branch = &pnode->parent->nbranch[pnode->iip]; | 930 | branch = &pnode->parent->nbranch[pnode->iip]; |
@@ -1558,7 +1526,7 @@ static int dbg_is_pnode_dirty(struct ubifs_info *c, int lnum, int offs) | |||
1558 | struct ubifs_nbranch *branch; | 1526 | struct ubifs_nbranch *branch; |
1559 | 1527 | ||
1560 | cond_resched(); | 1528 | cond_resched(); |
1561 | pnode = pnode_lookup(c, i); | 1529 | pnode = ubifs_pnode_lookup(c, i); |
1562 | if (IS_ERR(pnode)) | 1530 | if (IS_ERR(pnode)) |
1563 | return PTR_ERR(pnode); | 1531 | return PTR_ERR(pnode); |
1564 | branch = &pnode->parent->nbranch[pnode->iip]; | 1532 | branch = &pnode->parent->nbranch[pnode->iip]; |
@@ -1710,7 +1678,7 @@ int dbg_check_ltab(struct ubifs_info *c) | |||
1710 | for (i = 0; i < cnt; i++) { | 1678 | for (i = 0; i < cnt; i++) { |
1711 | struct ubifs_pnode *pnode; | 1679 | struct ubifs_pnode *pnode; |
1712 | 1680 | ||
1713 | pnode = pnode_lookup(c, i); | 1681 | pnode = ubifs_pnode_lookup(c, i); |
1714 | if (IS_ERR(pnode)) | 1682 | if (IS_ERR(pnode)) |
1715 | return PTR_ERR(pnode); | 1683 | return PTR_ERR(pnode); |
1716 | cond_resched(); | 1684 | cond_resched(); |
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 4368cde476b0..306cc7a4f725 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h | |||
@@ -1712,6 +1712,7 @@ struct ubifs_pnode *ubifs_get_pnode(struct ubifs_info *c, | |||
1712 | struct ubifs_nnode *parent, int iip); | 1712 | struct ubifs_nnode *parent, int iip); |
1713 | struct ubifs_nnode *ubifs_get_nnode(struct ubifs_info *c, | 1713 | struct ubifs_nnode *ubifs_get_nnode(struct ubifs_info *c, |
1714 | struct ubifs_nnode *parent, int iip); | 1714 | struct ubifs_nnode *parent, int iip); |
1715 | struct ubifs_pnode *ubifs_pnode_lookup(struct ubifs_info *c, int i); | ||
1715 | int ubifs_read_nnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip); | 1716 | int ubifs_read_nnode(struct ubifs_info *c, struct ubifs_nnode *parent, int iip); |
1716 | void ubifs_add_lpt_dirt(struct ubifs_info *c, int lnum, int dirty); | 1717 | void ubifs_add_lpt_dirt(struct ubifs_info *c, int lnum, int dirty); |
1717 | void ubifs_add_nnode_dirt(struct ubifs_info *c, struct ubifs_nnode *nnode); | 1718 | void ubifs_add_nnode_dirt(struct ubifs_info *c, struct ubifs_nnode *nnode); |