summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_iter.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-11-16 18:20:50 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:47 -0400
commitdbd1e8259ad2b35aafe230fdabfa387b3b54ab64 (patch)
tree54ea66b7b384447244d04a161f362ae36ad4a983 /fs/bcachefs/btree_iter.c
parent0b5c9f59401e4f339c2b716d2f9210114b7885c1 (diff)
downloadlwn-dbd1e8259ad2b35aafe230fdabfa387b3b54ab64.tar.gz
lwn-dbd1e8259ad2b35aafe230fdabfa387b3b54ab64.zip
bcachefs: Dont' use percpu btree_iter buf in userspace
bcachefs-tools doesn't have a real percpu (per thread) implementation yet Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_iter.c')
-rw-r--r--fs/bcachefs/btree_iter.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c
index 6eebbadcef45..0e8c8f3400de 100644
--- a/fs/bcachefs/btree_iter.c
+++ b/fs/bcachefs/btree_iter.c
@@ -2343,12 +2343,15 @@ static void bch2_trans_alloc_iters(struct btree_trans *trans, struct bch_fs *c)
unsigned new_size = BTREE_ITER_MAX;
size_t iters_bytes = sizeof(struct btree_iter) * new_size;
size_t updates_bytes = sizeof(struct btree_insert_entry) * new_size;
- void *p;
+ void *p = NULL;
BUG_ON(trans->used_mempool);
- p = this_cpu_xchg(c->btree_iters_bufs->iter, NULL) ?:
- mempool_alloc(&trans->c->btree_iters_pool, GFP_NOFS);
+#ifdef __KERNEL__
+ p = this_cpu_xchg(c->btree_iters_bufs->iter, NULL);
+#endif
+ if (!p)
+ p = mempool_alloc(&trans->c->btree_iters_pool, GFP_NOFS);
trans->iters = p; p += iters_bytes;
trans->updates = p; p += updates_bytes;
@@ -2406,7 +2409,12 @@ int bch2_trans_exit(struct btree_trans *trans)
kfree(trans->fs_usage_deltas);
kfree(trans->mem);
+#ifdef __KERNEL__
+ /*
+ * Userspace doesn't have a real percpu implementation:
+ */
trans->iters = this_cpu_xchg(c->btree_iters_bufs->iter, trans->iters);
+#endif
if (trans->iters)
mempool_free(trans->iters, &trans->c->btree_iters_pool);