diff options
Diffstat (limited to 'fs/bcachefs/journal_io.c')
-rw-r--r-- | fs/bcachefs/journal_io.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 093e4acad085..06d06e88569d 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -3,6 +3,7 @@ #include "alloc_background.h" #include "alloc_foreground.h" #include "btree_io.h" +#include "btree_journal_iter.h" #include "btree_update_interior.h" #include "btree_write_buffer.h" #include "buckets.h" @@ -106,11 +107,6 @@ static bool jset_csum_good(struct bch_fs *c, struct jset *j, struct bch_csum *cs return !bch2_crc_cmp(j->csum, *csum); } -static inline u32 journal_entry_radix_idx(struct bch_fs *c, u64 seq) -{ - return (seq - c->journal_entries_base_seq) & (~0U >> 1); -} - static void __journal_replay_free(struct bch_fs *c, struct journal_replay *i) { @@ -242,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); |