bcachefs: mempoolify btree_trans
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
cc1add4a80
commit
581edb6341
@ -580,6 +580,8 @@ struct bch_fs {
|
||||
struct mutex btree_interior_update_lock;
|
||||
struct closure_waitlist btree_interior_update_wait;
|
||||
|
||||
mempool_t btree_iters_pool;
|
||||
|
||||
struct workqueue_struct *wq;
|
||||
/* copygc needs its own workqueue for index updates.. */
|
||||
struct workqueue_struct *copygc_wq;
|
||||
|
@ -1648,10 +1648,7 @@ static int btree_trans_realloc_iters(struct btree_trans *trans)
|
||||
|
||||
bch2_trans_unlock(trans);
|
||||
|
||||
new_iters = kmalloc(sizeof(struct btree_iter) * BTREE_ITER_MAX,
|
||||
GFP_NOFS);
|
||||
if (!new_iters)
|
||||
return -ENOMEM;
|
||||
new_iters = mempool_alloc(&trans->c->btree_iters_pool, GFP_NOFS);
|
||||
|
||||
memcpy(new_iters, trans->iters,
|
||||
sizeof(struct btree_iter) * trans->nr_iters);
|
||||
@ -1679,12 +1676,10 @@ static int btree_trans_realloc_iters(struct btree_trans *trans)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bch2_trans_preload_iters(struct btree_trans *trans)
|
||||
void bch2_trans_preload_iters(struct btree_trans *trans)
|
||||
{
|
||||
if (trans->iters != trans->iters_onstack)
|
||||
return 0;
|
||||
|
||||
return btree_trans_realloc_iters(trans);
|
||||
if (trans->iters == trans->iters_onstack)
|
||||
btree_trans_realloc_iters(trans);
|
||||
}
|
||||
|
||||
static struct btree_iter *__btree_trans_get_iter(struct btree_trans *trans,
|
||||
@ -1868,7 +1863,7 @@ int bch2_trans_exit(struct btree_trans *trans)
|
||||
|
||||
kfree(trans->mem);
|
||||
if (trans->iters != trans->iters_onstack)
|
||||
kfree(trans->iters);
|
||||
mempool_free(trans->iters, &trans->c->btree_iters_pool);
|
||||
trans->mem = (void *) 0x1;
|
||||
trans->iters = (void *) 0x1;
|
||||
return ret;
|
||||
|
@ -270,7 +270,7 @@ static inline int btree_iter_err(struct bkey_s_c k)
|
||||
|
||||
/* new multiple iterator interface: */
|
||||
|
||||
int bch2_trans_preload_iters(struct btree_trans *);
|
||||
void bch2_trans_preload_iters(struct btree_trans *);
|
||||
void bch2_trans_iter_free(struct btree_trans *,
|
||||
struct btree_iter *);
|
||||
|
||||
|
@ -398,7 +398,7 @@ static int check_dirents(struct bch_fs *c)
|
||||
|
||||
bch2_trans_init(&trans, c);
|
||||
|
||||
BUG_ON(bch2_trans_preload_iters(&trans));
|
||||
bch2_trans_preload_iters(&trans);
|
||||
|
||||
iter = bch2_trans_get_iter(&trans, BTREE_ID_DIRENTS,
|
||||
POS(BCACHEFS_ROOT_INO, 0), 0);
|
||||
@ -539,7 +539,7 @@ static int check_xattrs(struct bch_fs *c)
|
||||
|
||||
bch2_trans_init(&trans, c);
|
||||
|
||||
BUG_ON(bch2_trans_preload_iters(&trans));
|
||||
bch2_trans_preload_iters(&trans);
|
||||
|
||||
iter = bch2_trans_get_iter(&trans, BTREE_ID_XATTRS,
|
||||
POS(BCACHEFS_ROOT_INO, 0), 0);
|
||||
|
@ -372,6 +372,7 @@ static void bch2_fs_free(struct bch_fs *c)
|
||||
bch2_fs_compress_exit(c);
|
||||
percpu_free_rwsem(&c->usage_lock);
|
||||
free_percpu(c->usage_percpu);
|
||||
mempool_exit(&c->btree_iters_pool);
|
||||
mempool_exit(&c->btree_bounce_pool);
|
||||
bioset_exit(&c->btree_bio);
|
||||
mempool_exit(&c->btree_interior_update_pool);
|
||||
@ -600,6 +601,8 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
|
||||
percpu_init_rwsem(&c->usage_lock) ||
|
||||
mempool_init_kvpmalloc_pool(&c->btree_bounce_pool, 1,
|
||||
btree_bytes(c)) ||
|
||||
mempool_init_kmalloc_pool(&c->btree_iters_pool, 1,
|
||||
sizeof(struct btree_iter) * BTREE_ITER_MAX) ||
|
||||
bch2_io_clock_init(&c->io_clock[READ]) ||
|
||||
bch2_io_clock_init(&c->io_clock[WRITE]) ||
|
||||
bch2_fs_journal_init(&c->journal) ||
|
||||
|
Loading…
x
Reference in New Issue
Block a user