hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/fs/ubifs/lpt_commit.c
....@@ -1,20 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * This file is part of UBIFS.
34 *
45 * 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
186 *
197 * Authors: Adrian Hunter
208 * Artem Bityutskiy (Битюцкий Артём)
....@@ -619,38 +607,6 @@
619607 }
620608
621609 /**
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
-/**
654610 * add_pnode_dirt - add dirty space to LPT LEB properties.
655611 * @c: UBIFS file-system description object
656612 * @pnode: pnode for which to add dirt
....@@ -702,7 +658,7 @@
702658 {
703659 struct ubifs_pnode *pnode;
704660
705
- pnode = pnode_lookup(c, 0);
661
+ pnode = ubifs_pnode_lookup(c, 0);
706662 if (IS_ERR(pnode))
707663 return PTR_ERR(pnode);
708664
....@@ -956,7 +912,7 @@
956912 struct ubifs_pnode *pnode;
957913 struct ubifs_nbranch *branch;
958914
959
- pnode = pnode_lookup(c, node_num);
915
+ pnode = ubifs_pnode_lookup(c, node_num);
960916 if (IS_ERR(pnode))
961917 return PTR_ERR(pnode);
962918 branch = &pnode->parent->nbranch[pnode->iip];
....@@ -1279,6 +1235,10 @@
12791235 if (err)
12801236 goto out;
12811237
1238
+ err = ubifs_lpt_calc_hash(c, c->mst_node->hash_lpt);
1239
+ if (err)
1240
+ goto out;
1241
+
12821242 /* Copy the LPT's own lprops for end commit to write */
12831243 memcpy(c->ltab_cmt, c->ltab,
12841244 sizeof(struct ubifs_lpt_lprops) * c->lpt_lebs);
....@@ -1558,7 +1518,7 @@
15581518 struct ubifs_nbranch *branch;
15591519
15601520 cond_resched();
1561
- pnode = pnode_lookup(c, i);
1521
+ pnode = ubifs_pnode_lookup(c, i);
15621522 if (IS_ERR(pnode))
15631523 return PTR_ERR(pnode);
15641524 branch = &pnode->parent->nbranch[pnode->iip];
....@@ -1636,7 +1596,7 @@
16361596 if (!dbg_is_chk_lprops(c))
16371597 return 0;
16381598
1639
- buf = p = __vmalloc(c->leb_size, GFP_NOFS, PAGE_KERNEL);
1599
+ buf = p = __vmalloc(c->leb_size, GFP_NOFS);
16401600 if (!buf) {
16411601 ubifs_err(c, "cannot allocate memory for ltab checking");
16421602 return 0;
....@@ -1710,7 +1670,7 @@
17101670 for (i = 0; i < cnt; i++) {
17111671 struct ubifs_pnode *pnode;
17121672
1713
- pnode = pnode_lookup(c, i);
1673
+ pnode = ubifs_pnode_lookup(c, i);
17141674 if (IS_ERR(pnode))
17151675 return PTR_ERR(pnode);
17161676 cond_resched();
....@@ -1885,7 +1845,7 @@
18851845 void *buf, *p;
18861846
18871847 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);
18891849 if (!buf) {
18901850 ubifs_err(c, "cannot allocate memory to dump LPT");
18911851 return;