53 lines
1.9 KiB
Diff
53 lines
1.9 KiB
Diff
From e37f4286d41e5e8ddddd1b0716a08c0395deaf4a Mon Sep 17 00:00:00 2001
|
|
From: Kent Overstreet <kent.overstreet@linux.dev>
|
|
Date: Mon, 2 Dec 2024 23:36:38 -0500
|
|
Subject: [PATCH 158/233] bcachefs: Fix allocating too big journal entry
|
|
Content-Type: text/plain; charset="utf-8"
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
The "journal space available" calculations didn't take into account
|
|
mismatched bucket sizes; we need to take the minimum space available out
|
|
of our devices.
|
|
|
|
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
|
|
Signed-off-by: Alexander Miroshnichenko <alex@millerson.name>
|
|
---
|
|
fs/bcachefs/journal_reclaim.c | 7 ++++++-
|
|
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/fs/bcachefs/journal_reclaim.c b/fs/bcachefs/journal_reclaim.c
|
|
index 1aabbbe328d9..b7936ad3ae7f 100644
|
|
--- a/fs/bcachefs/journal_reclaim.c
|
|
+++ b/fs/bcachefs/journal_reclaim.c
|
|
@@ -140,6 +140,7 @@ static struct journal_space __journal_space_available(struct journal *j, unsigne
|
|
struct bch_fs *c = container_of(j, struct bch_fs, journal);
|
|
unsigned pos, nr_devs = 0;
|
|
struct journal_space space, dev_space[BCH_SB_MEMBERS_MAX];
|
|
+ unsigned min_bucket_size = U32_MAX;
|
|
|
|
BUG_ON(nr_devs_want > ARRAY_SIZE(dev_space));
|
|
|
|
@@ -148,6 +149,8 @@ static struct journal_space __journal_space_available(struct journal *j, unsigne
|
|
if (!ca->journal.nr)
|
|
continue;
|
|
|
|
+ min_bucket_size = min(min_bucket_size, ca->mi.bucket_size);
|
|
+
|
|
space = journal_dev_space_available(j, ca, from);
|
|
if (!space.next_entry)
|
|
continue;
|
|
@@ -167,7 +170,9 @@ static struct journal_space __journal_space_available(struct journal *j, unsigne
|
|
* We sorted largest to smallest, and we want the smallest out of the
|
|
* @nr_devs_want largest devices:
|
|
*/
|
|
- return dev_space[nr_devs_want - 1];
|
|
+ space = dev_space[nr_devs_want - 1];
|
|
+ space.next_entry = min(space.next_entry, min_bucket_size);
|
|
+ return space;
|
|
}
|
|
|
|
void bch2_journal_space_available(struct journal *j)
|
|
--
|
|
2.45.2
|
|
|