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-14 23:20:28 -0400 |
commit | e3b52d286790debf4e4382a1a8f4b0c2045ca194 (patch) | |
tree | bb958efef9ab8dd05834fb90db876e03c46b42e0 | |
parent | 4ea658014dde8f1a7047878da88794594396261a (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 | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 6e8a89a0f244..06d06e88569d 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -238,6 +238,23 @@ static int journal_entry_add(struct bch_fs *c, struct bch_dev *ca, return ret; } replace: + /* Drop overwrites, log entries if we don't need them: */ + if (!c->opts.retain_recovery_info && + !c->opts.journal_rewind) { + 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); + } + i = kvmalloc(offsetof(struct journal_replay, j) + bytes, GFP_KERNEL); if (!i) return bch_err_throw(c, ENOMEM_journal_entry_add); |