diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2025-08-14 10:38:15 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-08-18 21:06:43 -0400 |
commit | f46735b8af6a4cd23687dddcbadc03cc7e3650ea (patch) | |
tree | 355e9859db4f7e787ea08ec80f582c56b6b4c38b | |
parent | fb64284c73ff0c30fd9824348bac3305f930ee88 (diff) |
bcachefs: Drop overwrites, log entries in replay if we don't need them
Allow journal replay to succeed with less memory.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/journal_io.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 6e8a89a0f244..1ad1f180940f 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -191,6 +191,27 @@ static int journal_entry_add(struct bch_fs *c, struct bch_dev *ca, } } + /* Drop overwrites, log entries if we don't need them: */ + if (!c->opts.retain_recovery_info && + !c->opts.journal_rewind) { + vstruct_for_each_safe(j, src) + if (vstruct_end(src) > vstruct_end(j)) + goto nocompact; + + struct jset_entry *dst = j->start; + vstruct_for_each_safe(j, src) { + if (src->type == BCH_JSET_ENTRY_log || + src->type == BCH_JSET_ENTRY_overwrite) + continue; + + memcpy(dst, src, vstruct_bytes(src)); + dst = vstruct_next(dst); + } + + j->u64s = cpu_to_le32((u64 *) dst - j->_data); + bytes = vstruct_bytes(j); + } +nocompact: jlist->last_seq = max(jlist->last_seq, last_seq); _i = genradix_ptr_alloc(&c->journal_entries, |