summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/btree_key_cache.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-04-17 17:50:47 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:32 -0400
commita729e489ab0805fb93047508fb9439cd1464cf70 (patch)
tree87d9ebef33d476b8fcb1c5ac35a9176b0995da70 /fs/bcachefs/btree_key_cache.c
parentb0babf2a34233c651060e54b68fa3cd0b9e7a6e7 (diff)
downloadlinux-a729e489ab0805fb93047508fb9439cd1464cf70.tar.gz
linux-a729e489ab0805fb93047508fb9439cd1464cf70.tar.bz2
linux-a729e489ab0805fb93047508fb9439cd1464cf70.zip
bcachefs: Allocate some extra room in btree_key_cache_fill()
If we allocate a buffer that's a bit bigger than necessary the transaction commit path will be much less likely to have to reallocate - which requires a transaction restart. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/btree_key_cache.c')
-rw-r--r--fs/bcachefs/btree_key_cache.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c
index f86d57d1ace0..d316e9b9ae02 100644
--- a/fs/bcachefs/btree_key_cache.c
+++ b/fs/bcachefs/btree_key_cache.c
@@ -236,6 +236,13 @@ static int btree_key_cache_fill(struct btree_trans *trans,
*/
new_u64s = k.k->u64s + 1;
+ /*
+ * Allocate some extra space so that the transaction commit path is less
+ * likely to have to reallocate, since that requires a transaction
+ * restart:
+ */
+ new_u64s = min(256U, (new_u64s * 3) / 2);
+
if (new_u64s > ck->u64s) {
new_u64s = roundup_pow_of_two(new_u64s);
new_k = kmalloc(new_u64s * sizeof(u64), GFP_NOFS);