diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/btree_iter.c | 3 | ||||
-rw-r--r-- | fs/bcachefs/btree_types.h | 3 | ||||
-rw-r--r-- | fs/bcachefs/btree_update_leaf.c | 12 | ||||
-rw-r--r-- | fs/bcachefs/journal.h | 11 |
4 files changed, 25 insertions, 4 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 7b12bd163df7..ca775e63b4c6 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2153,6 +2153,9 @@ void bch2_trans_reset(struct btree_trans *trans, unsigned flags) trans->nr_updates2 = 0; trans->mem_top = 0; + trans->extra_journal_entries = NULL; + trans->extra_journal_entry_u64s = 0; + if (trans->fs_usage_deltas) { trans->fs_usage_deltas->used = 0; memset((void *) trans->fs_usage_deltas + diff --git a/fs/bcachefs/btree_types.h b/fs/bcachefs/btree_types.h index 57796340fb36..769c05c8d938 100644 --- a/fs/bcachefs/btree_types.h +++ b/fs/bcachefs/btree_types.h @@ -308,6 +308,9 @@ struct btree_trans { struct btree_insert_entry *updates2; /* update path: */ + struct jset_entry *extra_journal_entries; + unsigned extra_journal_entry_u64s; + struct journal_res journal_res; struct journal_preres journal_preres; u64 *journal_seq; diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index a93bc1890263..98b60d230dce 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -413,6 +413,16 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, goto err; } + if (unlikely(trans->extra_journal_entry_u64s)) { + memcpy_u64s_small(bch2_journal_reservation_entry(&c->journal, + &trans->journal_res), + trans->extra_journal_entries, + trans->extra_journal_entry_u64s); + + trans->journal_res.offset += trans->extra_journal_entry_u64s; + trans->journal_res.u64s -= trans->extra_journal_entry_u64s; + } + /* * Not allowed to fail after we've gotten our journal reservation - we * have to use it: @@ -800,7 +810,7 @@ int __bch2_trans_commit(struct btree_trans *trans) memset(&trans->journal_preres, 0, sizeof(trans->journal_preres)); - trans->journal_u64s = 0; + trans->journal_u64s = trans->extra_journal_entry_u64s; trans->journal_preres_u64s = 0; if (!(trans->flags & BTREE_INSERT_NOCHECK_RW) && diff --git a/fs/bcachefs/journal.h b/fs/bcachefs/journal.h index 81e26ba43fa1..6630db6ecc14 100644 --- a/fs/bcachefs/journal.h +++ b/fs/bcachefs/journal.h @@ -199,13 +199,18 @@ bch2_journal_add_entry_noreservation(struct journal_buf *buf, size_t u64s) return entry; } +static inline struct jset_entry * +bch2_journal_reservation_entry(struct journal *j, struct journal_res *res) +{ + return vstruct_idx(j->buf[res->idx].data, res->offset); +} + static inline void bch2_journal_add_entry(struct journal *j, struct journal_res *res, unsigned type, enum btree_id id, unsigned level, const void *data, unsigned u64s) { - struct journal_buf *buf = &j->buf[res->idx]; - struct jset_entry *entry = vstruct_idx(buf->data, res->offset); + struct jset_entry *entry = bch2_journal_reservation_entry(j, res); unsigned actual = jset_u64s(u64s); EBUG_ON(!res->ref); @@ -221,7 +226,7 @@ static inline void bch2_journal_add_entry(struct journal *j, struct journal_res entry->pad[0] = 0; entry->pad[1] = 0; entry->pad[2] = 0; - memcpy_u64s(entry->_data, data, u64s); + memcpy_u64s_small(entry->_data, data, u64s); } static inline void bch2_journal_add_keys(struct journal *j, struct journal_res *res, |