diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-11-16 04:52:55 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:08:47 +0300 |
commit | 0b5c9f59401e4f339c2b716d2f9210114b7885c1 (patch) | |
tree | 260e9464dda68dc2af1c343929b2b0300a7c7827 | |
parent | 3dc5fcfcf51efa7dfd6ef900b06ad1fef0820664 (diff) | |
download | linux-0b5c9f59401e4f339c2b716d2f9210114b7885c1.tar.xz |
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>
-rw-r--r-- | fs/bcachefs/btree_iter.c | 8 | ||||
-rw-r--r-- | fs/bcachefs/btree_update_interior.c | 19 | ||||
-rw-r--r-- | fs/bcachefs/fs.c | 3 |
3 files changed, 19 insertions, 11 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 007d69656660..6eebbadcef45 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -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); diff --git a/fs/bcachefs/btree_update_interior.c b/fs/bcachefs/btree_update_interior.c index c1f822b96c48..0a83d9fdecd1 100644 --- a/fs/bcachefs/btree_update_interior.c +++ b/fs/bcachefs/btree_update_interior.c @@ -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) { diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index 231a5433577f..480469784152 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -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); |