summaryrefslogtreecommitdiff
path: root/fs/bcachefs/super.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-01-21 15:32:13 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:14 -0400
commit7ef2a73a5881323d53453cc3be7261fe1a49af1d (patch)
tree85e8d67b00a6c28dd8691e79d1674c111e8a1328 /fs/bcachefs/super.c
parentdbaee468461bfa82e6453ca0e009e9661cc570da (diff)
downloadlwn-7ef2a73a5881323d53453cc3be7261fe1a49af1d.tar.gz
lwn-7ef2a73a5881323d53453cc3be7261fe1a49af1d.zip
bcachefs: Fix check for if extent update is allocating
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/super.c')
-rw-r--r--fs/bcachefs/super.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index 55069f40d04b..9a862b19ce22 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -375,6 +375,7 @@ static void bch2_fs_free(struct bch_fs *c)
bch2_io_clock_exit(&c->io_clock[READ]);
bch2_fs_compress_exit(c);
percpu_free_rwsem(&c->mark_lock);
+ free_percpu(c->usage_scratch);
free_percpu(c->usage[0]);
free_percpu(c->pcpu);
mempool_exit(&c->btree_iters_pool);
@@ -506,7 +507,7 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
{
struct bch_sb_field_members *mi;
struct bch_fs *c;
- unsigned i, iter_size;
+ unsigned i, iter_size, fs_usage_size;
const char *err;
pr_verbose_init(opts, "");
@@ -600,6 +601,9 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
(btree_blocks(c) + 1) * 2 *
sizeof(struct btree_node_iter_set);
+ fs_usage_size = sizeof(struct bch_fs_usage) +
+ sizeof(u64) * c->replicas.nr;
+
if (!(c->wq = alloc_workqueue("bcachefs",
WQ_FREEZABLE|WQ_MEM_RECLAIM|WQ_HIGHPRI, 1)) ||
!(c->copygc_wq = alloc_workqueue("bcache_copygc",
@@ -616,7 +620,8 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
max(offsetof(struct btree_read_bio, bio),
offsetof(struct btree_write_bio, wbio.bio)),
BIOSET_NEED_BVECS) ||
- !(c->usage[0] = alloc_percpu(struct bch_fs_usage)) ||
+ !(c->usage[0] = __alloc_percpu(fs_usage_size, sizeof(u64))) ||
+ !(c->usage_scratch = __alloc_percpu(fs_usage_size, sizeof(u64))) ||
!(c->pcpu = alloc_percpu(struct bch_fs_pcpu)) ||
mempool_init_kvpmalloc_pool(&c->btree_bounce_pool, 1,
btree_bytes(c)) ||