mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
bcachefs: Set preallocated transaction mem to avoid restarts
this will reduce transaction restarts, from observation of tracepoints. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
3dc5fcfcf5
commit
0b5c9f5940
@ -2370,8 +2370,12 @@ void bch2_trans_init(struct btree_trans *trans, struct bch_fs *c,
|
||||
*/
|
||||
bch2_trans_alloc_iters(trans, c);
|
||||
|
||||
if (expected_mem_bytes)
|
||||
bch2_trans_preload_mem(trans, expected_mem_bytes);
|
||||
if (expected_mem_bytes) {
|
||||
expected_mem_bytes = roundup_pow_of_two(expected_mem_bytes);
|
||||
trans->mem = kmalloc(expected_mem_bytes, GFP_KERNEL);
|
||||
if (trans->mem)
|
||||
trans->mem_bytes = expected_mem_bytes;
|
||||
}
|
||||
|
||||
trans->srcu_idx = srcu_read_lock(&c->btree_trans_barrier);
|
||||
|
||||
|
@ -523,6 +523,7 @@ static void btree_update_nodes_written(struct btree_update *as)
|
||||
{
|
||||
struct bch_fs *c = as->c;
|
||||
struct btree *b = as->b;
|
||||
struct btree_trans trans;
|
||||
u64 journal_seq = 0;
|
||||
unsigned i;
|
||||
int ret;
|
||||
@ -540,14 +541,16 @@ static void btree_update_nodes_written(struct btree_update *as)
|
||||
* journal reclaim does btree updates when flushing bkey_cached entries,
|
||||
* which may require allocations as well.
|
||||
*/
|
||||
ret = bch2_trans_do(c, &as->disk_res, &journal_seq,
|
||||
BTREE_INSERT_NOFAIL|
|
||||
BTREE_INSERT_USE_RESERVE|
|
||||
BTREE_INSERT_USE_ALLOC_RESERVE|
|
||||
BTREE_INSERT_NOCHECK_RW|
|
||||
BTREE_INSERT_JOURNAL_RECLAIM|
|
||||
BTREE_INSERT_JOURNAL_RESERVED,
|
||||
btree_update_nodes_written_trans(&trans, as));
|
||||
bch2_trans_init(&trans, c, 0, 512);
|
||||
ret = __bch2_trans_do(&trans, &as->disk_res, &journal_seq,
|
||||
BTREE_INSERT_NOFAIL|
|
||||
BTREE_INSERT_USE_RESERVE|
|
||||
BTREE_INSERT_USE_ALLOC_RESERVE|
|
||||
BTREE_INSERT_NOCHECK_RW|
|
||||
BTREE_INSERT_JOURNAL_RECLAIM|
|
||||
BTREE_INSERT_JOURNAL_RESERVED,
|
||||
btree_update_nodes_written_trans(&trans, as));
|
||||
bch2_trans_exit(&trans);
|
||||
BUG_ON(ret && !bch2_journal_error(&c->journal));
|
||||
|
||||
if (b) {
|
||||
|
@ -278,7 +278,8 @@ __bch2_create(struct mnt_idmap *idmap,
|
||||
if (!tmpfile)
|
||||
mutex_lock(&dir->ei_update_lock);
|
||||
|
||||
bch2_trans_init(&trans, c, 8, 1024);
|
||||
bch2_trans_init(&trans, c, 8,
|
||||
2048 + (!tmpfile ? dentry->d_name.len : 0));
|
||||
retry:
|
||||
bch2_trans_begin(&trans);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user