.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * This file is part of UBIFS. |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2006-2008 Nokia Corporation. |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify it |
---|
7 | | - * under the terms of the GNU General Public License version 2 as published by |
---|
8 | | - * the Free Software Foundation. |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope that it will be useful, but WITHOUT |
---|
11 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
12 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
13 | | - * more details. |
---|
14 | | - * |
---|
15 | | - * You should have received a copy of the GNU General Public License along with |
---|
16 | | - * this program; if not, write to the Free Software Foundation, Inc., 51 |
---|
17 | | - * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
18 | 6 | * |
---|
19 | 7 | * Authors: Adrian Hunter |
---|
20 | 8 | * Artem Bityutskiy (Битюцкий Артём) |
---|
.. | .. |
---|
619 | 607 | } |
---|
620 | 608 | |
---|
621 | 609 | /** |
---|
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 | 610 | * add_pnode_dirt - add dirty space to LPT LEB properties. |
---|
655 | 611 | * @c: UBIFS file-system description object |
---|
656 | 612 | * @pnode: pnode for which to add dirt |
---|
.. | .. |
---|
702 | 658 | { |
---|
703 | 659 | struct ubifs_pnode *pnode; |
---|
704 | 660 | |
---|
705 | | - pnode = pnode_lookup(c, 0); |
---|
| 661 | + pnode = ubifs_pnode_lookup(c, 0); |
---|
706 | 662 | if (IS_ERR(pnode)) |
---|
707 | 663 | return PTR_ERR(pnode); |
---|
708 | 664 | |
---|
.. | .. |
---|
956 | 912 | struct ubifs_pnode *pnode; |
---|
957 | 913 | struct ubifs_nbranch *branch; |
---|
958 | 914 | |
---|
959 | | - pnode = pnode_lookup(c, node_num); |
---|
| 915 | + pnode = ubifs_pnode_lookup(c, node_num); |
---|
960 | 916 | if (IS_ERR(pnode)) |
---|
961 | 917 | return PTR_ERR(pnode); |
---|
962 | 918 | branch = &pnode->parent->nbranch[pnode->iip]; |
---|
.. | .. |
---|
1279 | 1235 | if (err) |
---|
1280 | 1236 | goto out; |
---|
1281 | 1237 | |
---|
| 1238 | + err = ubifs_lpt_calc_hash(c, c->mst_node->hash_lpt); |
---|
| 1239 | + if (err) |
---|
| 1240 | + goto out; |
---|
| 1241 | + |
---|
1282 | 1242 | /* Copy the LPT's own lprops for end commit to write */ |
---|
1283 | 1243 | memcpy(c->ltab_cmt, c->ltab, |
---|
1284 | 1244 | sizeof(struct ubifs_lpt_lprops) * c->lpt_lebs); |
---|
.. | .. |
---|
1558 | 1518 | struct ubifs_nbranch *branch; |
---|
1559 | 1519 | |
---|
1560 | 1520 | cond_resched(); |
---|
1561 | | - pnode = pnode_lookup(c, i); |
---|
| 1521 | + pnode = ubifs_pnode_lookup(c, i); |
---|
1562 | 1522 | if (IS_ERR(pnode)) |
---|
1563 | 1523 | return PTR_ERR(pnode); |
---|
1564 | 1524 | branch = &pnode->parent->nbranch[pnode->iip]; |
---|
.. | .. |
---|
1636 | 1596 | if (!dbg_is_chk_lprops(c)) |
---|
1637 | 1597 | return 0; |
---|
1638 | 1598 | |
---|
1639 | | - buf = p = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL); |
---|
| 1599 | + buf = p = __vmalloc(c->leb_size, GFP_NOFS); |
---|
1640 | 1600 | if (!buf) { |
---|
1641 | 1601 | ubifs_err(c, "cannot allocate memory for ltab checking"); |
---|
1642 | 1602 | return 0; |
---|
.. | .. |
---|
1710 | 1670 | for (i = 0; i < cnt; i++) { |
---|
1711 | 1671 | struct ubifs_pnode *pnode; |
---|
1712 | 1672 | |
---|
1713 | | - pnode = pnode_lookup(c, i); |
---|
| 1673 | + pnode = ubifs_pnode_lookup(c, i); |
---|
1714 | 1674 | if (IS_ERR(pnode)) |
---|
1715 | 1675 | return PTR_ERR(pnode); |
---|
1716 | 1676 | cond_resched(); |
---|
.. | .. |
---|
1885 | 1845 | void *buf, *p; |
---|
1886 | 1846 | |
---|
1887 | 1847 | pr_err("(pid %d) start dumping LEB %d\n", current->pid, lnum); |
---|
1888 | | - buf = p = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL); |
---|
| 1848 | + buf = p = __vmalloc(c->leb_size, GFP_NOFS); |
---|
1889 | 1849 | if (!buf) { |
---|
1890 | 1850 | ubifs_err(c, "cannot allocate memory to dump LPT"); |
---|
1891 | 1851 | return; |
---|