mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-01 10:45:49 +00:00
bcachefs: Use darray for extra_journal_entries
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
d864842581
commit
2a6870ada4
@ -3055,8 +3055,7 @@ void bch2_trans_begin(struct btree_trans *trans)
|
||||
trans->mem_top = 0;
|
||||
|
||||
trans->hooks = NULL;
|
||||
trans->extra_journal_entries = NULL;
|
||||
trans->extra_journal_entry_u64s = 0;
|
||||
trans->extra_journal_entries.nr = 0;
|
||||
|
||||
if (trans->fs_usage_deltas) {
|
||||
trans->fs_usage_deltas->used = 0;
|
||||
@ -3196,6 +3195,8 @@ void bch2_trans_exit(struct btree_trans *trans)
|
||||
|
||||
bch2_journal_preres_put(&c->journal, &trans->journal_preres);
|
||||
|
||||
kfree(trans->extra_journal_entries.data);
|
||||
|
||||
if (trans->fs_usage_deltas) {
|
||||
if (trans->fs_usage_deltas->size + sizeof(trans->fs_usage_deltas) ==
|
||||
REPLICAS_DELTA_LIST_MAX)
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "bkey_methods.h"
|
||||
#include "buckets_types.h"
|
||||
#include "darray.h"
|
||||
#include "journal_types.h"
|
||||
#include "six.h"
|
||||
|
||||
@ -416,8 +417,7 @@ struct btree_trans {
|
||||
|
||||
/* update path: */
|
||||
struct btree_trans_commit_hook *hooks;
|
||||
struct jset_entry *extra_journal_entries;
|
||||
unsigned extra_journal_entry_u64s;
|
||||
DARRAY(u64) extra_journal_entries;
|
||||
struct journal_entry_pin *journal_pin;
|
||||
|
||||
struct journal_res journal_res;
|
||||
|
@ -518,8 +518,15 @@ static int btree_update_nodes_written_trans(struct btree_trans *trans,
|
||||
struct bkey_i *k;
|
||||
int ret;
|
||||
|
||||
trans->extra_journal_entries = (void *) &as->journal_entries[0];
|
||||
trans->extra_journal_entry_u64s = as->journal_u64s;
|
||||
ret = darray_make_room(&trans->extra_journal_entries, as->journal_u64s);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
memcpy(&darray_top(trans->extra_journal_entries),
|
||||
as->journal_entries,
|
||||
as->journal_u64s * sizeof(u64));
|
||||
trans->extra_journal_entries.nr += as->journal_u64s;
|
||||
|
||||
trans->journal_pin = &as->journal;
|
||||
|
||||
for_each_keylist_key(&as->new_keys, k) {
|
||||
@ -1905,7 +1912,6 @@ static int __bch2_btree_node_update_key(struct btree_trans *trans,
|
||||
struct bch_fs *c = trans->c;
|
||||
struct btree_iter iter2 = { NULL };
|
||||
struct btree *parent;
|
||||
u64 journal_entries[BKEY_BTREE_PTR_U64s_MAX];
|
||||
int ret;
|
||||
|
||||
if (!skip_triggers) {
|
||||
@ -1949,12 +1955,16 @@ static int __bch2_btree_node_update_key(struct btree_trans *trans,
|
||||
} else {
|
||||
BUG_ON(btree_node_root(c, b) != b);
|
||||
|
||||
trans->extra_journal_entries = (void *) &journal_entries[0];
|
||||
trans->extra_journal_entry_u64s =
|
||||
journal_entry_set((void *) &journal_entries[0],
|
||||
BCH_JSET_ENTRY_btree_root,
|
||||
b->c.btree_id, b->c.level,
|
||||
new_key, new_key->k.u64s);
|
||||
ret = darray_make_room(&trans->extra_journal_entries,
|
||||
jset_u64s(new_key->k.u64s));
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
journal_entry_set((void *) &darray_top(trans->extra_journal_entries),
|
||||
BCH_JSET_ENTRY_btree_root,
|
||||
b->c.btree_id, b->c.level,
|
||||
new_key, new_key->k.u64s);
|
||||
trans->extra_journal_entries.nr += jset_u64s(new_key->k.u64s);
|
||||
}
|
||||
|
||||
ret = bch2_trans_commit(trans, NULL, NULL,
|
||||
|
@ -707,13 +707,13 @@ bch2_trans_commit_write_locked(struct btree_trans *trans,
|
||||
trans->journal_res.seq = c->journal.replay_journal_seq;
|
||||
}
|
||||
|
||||
if (unlikely(trans->extra_journal_entry_u64s)) {
|
||||
if (unlikely(trans->extra_journal_entries.nr)) {
|
||||
memcpy_u64s_small(journal_res_entry(&c->journal, &trans->journal_res),
|
||||
trans->extra_journal_entries,
|
||||
trans->extra_journal_entry_u64s);
|
||||
trans->extra_journal_entries.data,
|
||||
trans->extra_journal_entries.nr);
|
||||
|
||||
trans->journal_res.offset += trans->extra_journal_entry_u64s;
|
||||
trans->journal_res.u64s -= trans->extra_journal_entry_u64s;
|
||||
trans->journal_res.offset += trans->extra_journal_entries.nr;
|
||||
trans->journal_res.u64s -= trans->extra_journal_entries.nr;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1096,7 +1096,7 @@ int __bch2_trans_commit(struct btree_trans *trans)
|
||||
int ret = 0;
|
||||
|
||||
if (!trans->nr_updates &&
|
||||
!trans->extra_journal_entry_u64s)
|
||||
!trans->extra_journal_entries.nr)
|
||||
goto out_reset;
|
||||
|
||||
if (trans->flags & BTREE_INSERT_GC_LOCK_HELD)
|
||||
@ -1120,7 +1120,7 @@ int __bch2_trans_commit(struct btree_trans *trans)
|
||||
|
||||
memset(&trans->journal_preres, 0, sizeof(trans->journal_preres));
|
||||
|
||||
trans->journal_u64s = trans->extra_journal_entry_u64s;
|
||||
trans->journal_u64s = trans->extra_journal_entries.nr;
|
||||
trans->journal_preres_u64s = 0;
|
||||
|
||||
trans->journal_transaction_names = READ_ONCE(c->opts.journal_transaction_names);
|
||||
@ -1180,8 +1180,7 @@ int __bch2_trans_commit(struct btree_trans *trans)
|
||||
trans->extra_journal_res = 0;
|
||||
trans->nr_updates = 0;
|
||||
trans->hooks = NULL;
|
||||
trans->extra_journal_entries = NULL;
|
||||
trans->extra_journal_entry_u64s = 0;
|
||||
trans->extra_journal_entries.nr = 0;
|
||||
|
||||
if (trans->fs_usage_deltas) {
|
||||
trans->fs_usage_deltas->used = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user