1

bcachefs: trans->updates will also be resizable

the reflink triggers are also bumping up against the maximum number of
paths in a transaction - and generating proportional numbers of updates.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2023-12-12 20:30:44 -05:00
parent 31403dca5b
commit 5cc6daf749
3 changed files with 5 additions and 4 deletions

View File

@ -2888,7 +2888,7 @@ struct btree_trans *__bch2_trans_get(struct bch_fs *c, unsigned fn_idx)
if (IS_ENABLED(__KERNEL__)) { if (IS_ENABLED(__KERNEL__)) {
trans = this_cpu_xchg(c->btree_trans_bufs->trans, NULL); trans = this_cpu_xchg(c->btree_trans_bufs->trans, NULL);
if (trans) { if (trans) {
memset(trans, 0, offsetof(struct btree_trans, updates)); memset(trans, 0, offsetof(struct btree_trans, list));
goto got_trans; goto got_trans;
} }
} }
@ -2936,6 +2936,7 @@ got_trans:
trans->paths_allocated = trans->_paths_allocated; trans->paths_allocated = trans->_paths_allocated;
trans->sorted = trans->_sorted; trans->sorted = trans->_sorted;
trans->paths = trans->_paths; trans->paths = trans->_paths;
trans->updates = trans->_updates;
*trans_paths_nr(trans->paths) = BTREE_ITER_MAX; *trans_paths_nr(trans->paths) = BTREE_ITER_MAX;

View File

@ -383,6 +383,7 @@ struct btree_trans {
unsigned long *paths_allocated; unsigned long *paths_allocated;
struct btree_path *paths; struct btree_path *paths;
u8 *sorted; u8 *sorted;
struct btree_insert_entry *updates;
void *mem; void *mem;
unsigned mem_top; unsigned mem_top;
@ -433,8 +434,6 @@ struct btree_trans {
/* Entries before this are zeroed out on every bch2_trans_get() call */ /* Entries before this are zeroed out on every bch2_trans_get() call */
struct btree_insert_entry updates[BTREE_ITER_MAX];
struct list_head list; struct list_head list;
struct closure ref; struct closure ref;
@ -442,6 +441,7 @@ struct btree_trans {
struct btree_trans_paths trans_paths; struct btree_trans_paths trans_paths;
struct btree_path _paths[BTREE_ITER_MAX]; struct btree_path _paths[BTREE_ITER_MAX];
u8 _sorted[BTREE_ITER_MAX + 8]; u8 _sorted[BTREE_ITER_MAX + 8];
struct btree_insert_entry _updates[BTREE_ITER_MAX];
}; };
static inline struct btree_path *btree_iter_path(struct btree_trans *trans, struct btree_iter *iter) static inline struct btree_path *btree_iter_path(struct btree_trans *trans, struct btree_iter *iter)

View File

@ -386,7 +386,7 @@ bch2_trans_update_by_path(struct btree_trans *trans, btree_path_idx_t path_idx,
struct btree_path *path = trans->paths + path_idx; struct btree_path *path = trans->paths + path_idx;
EBUG_ON(!path->should_be_locked); EBUG_ON(!path->should_be_locked);
EBUG_ON(trans->nr_updates >= ARRAY_SIZE(trans->updates)); EBUG_ON(trans->nr_updates >= BTREE_ITER_MAX);
EBUG_ON(!bpos_eq(k->k.p, path->pos)); EBUG_ON(!bpos_eq(k->k.p, path->pos));
n = (struct btree_insert_entry) { n = (struct btree_insert_entry) {