hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/fs/ubifs/budget.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 (Битюцкий Артём)
....@@ -63,7 +51,7 @@
6351 static void shrink_liability(struct ubifs_info *c, int nr_to_write)
6452 {
6553 down_read(&c->vfs_sb->s_umount);
66
- writeback_inodes_sb(c->vfs_sb, WB_REASON_FS_FREE_SPACE);
54
+ writeback_inodes_sb_nr(c->vfs_sb, nr_to_write, WB_REASON_FS_FREE_SPACE);
6755 up_read(&c->vfs_sb->s_umount);
6856 }
6957
....@@ -224,11 +212,10 @@
224212 subtract_lebs += 1;
225213
226214 /*
227
- * The GC journal head LEB is not really accessible. And since
228
- * different write types go to different heads, we may count only on
229
- * one head's space.
215
+ * Since different write types go to different heads, we should
216
+ * reserve one leb for each head.
230217 */
231
- subtract_lebs += c->jhead_cnt - 1;
218
+ subtract_lebs += c->jhead_cnt;
232219
233220 /* We also reserve one LEB for deletions, which bypass budgeting */
234221 subtract_lebs += 1;
....@@ -415,7 +402,7 @@
415402 dd_growth = req->dirtied_page ? c->bi.page_budget : 0;
416403
417404 if (req->dirtied_ino)
418
- dd_growth += c->bi.inode_budget << (req->dirtied_ino - 1);
405
+ dd_growth += c->bi.inode_budget * req->dirtied_ino;
419406 if (req->mod_dent)
420407 dd_growth += c->bi.dent_budget;
421408 dd_growth += req->dirtied_ino_d;