summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-12-26 22:27:10 -0500
committerKent Overstreet <kent.overstreet@gmail.com>2021-12-26 23:35:14 -0500
commitb034dfb24fece43a7677b9a29781495aeb62767f (patch)
tree2ba6a5a8a80ae0791bc8a8fea480f00cd6471fd7
parentd7f15ba1c657c81e0188148fba2632ef27eae2b5 (diff)
bcachefs: Kill bch2_ec_mem_alloc()
bch2_ec_mem_alloc() was only used by GC, and there's no real need to preallocate the stripes radix tree since we can cope fine with memory allocation failure when we use the radix tree. This deletes a fair bit of code, and it's also needed for the upcoming patch because bch2_btree_iter_peek_prev() won't be working before journal replay completes (and using it was incorrect previously, as well). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--fs/bcachefs/btree_gc.c7
-rw-r--r--fs/bcachefs/buckets.c6
-rw-r--r--fs/bcachefs/ec.c40
-rw-r--r--fs/bcachefs/ec.h2
4 files changed, 5 insertions, 50 deletions
diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c
index 174022d1ab8f..d1883701afc3 100644
--- a/fs/bcachefs/btree_gc.c
+++ b/fs/bcachefs/btree_gc.c
@@ -1270,7 +1270,6 @@ static int bch2_gc_start(struct bch_fs *c,
{
struct bch_dev *ca = NULL;
unsigned i;
- int ret;
BUG_ON(c->usage_gc);
@@ -1302,12 +1301,6 @@ static int bch2_gc_start(struct bch_fs *c,
}
}
- ret = bch2_ec_mem_alloc(c, true);
- if (ret) {
- bch_err(c, "error allocating ec gc mem");
- return ret;
- }
-
percpu_down_write(&c->mark_lock);
/*
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c
index db8438fea1a1..f7d4a0678e39 100644
--- a/fs/bcachefs/buckets.c
+++ b/fs/bcachefs/buckets.c
@@ -1097,7 +1097,11 @@ static int bch2_mark_stripe(struct btree_trans *trans,
spin_unlock(&c->ec_stripes_heap_lock);
}
} else {
- struct gc_stripe *m = genradix_ptr(&c->gc_stripes, idx);
+ struct gc_stripe *m =
+ genradix_ptr_alloc(&c->gc_stripes, idx, GFP_KERNEL);
+
+ if (!m)
+ return -ENOMEM;
/*
* This will be wrong when we bring back runtime gc: we should
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index 20e44e572288..3cccd1faade5 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -1608,46 +1608,6 @@ int bch2_stripes_read(struct bch_fs *c)
return ret;
}
-int bch2_ec_mem_alloc(struct bch_fs *c, bool gc)
-{
- struct btree_trans trans;
- struct btree_iter iter;
- struct bkey_s_c k;
- size_t i, idx = 0;
- int ret = 0;
-
- bch2_trans_init(&trans, c, 0, 0);
- bch2_trans_iter_init(&trans, &iter, BTREE_ID_stripes, POS(0, U64_MAX), 0);
-
- k = bch2_btree_iter_prev(&iter);
- ret = bkey_err(k);
- if (!ret && k.k)
- idx = k.k->p.offset + 1;
-
- bch2_trans_iter_exit(&trans, &iter);
- bch2_trans_exit(&trans);
- if (ret)
- return ret;
-
- if (!idx)
- return 0;
-
- if (!gc &&
- !init_heap(&c->ec_stripes_heap, roundup_pow_of_two(idx),
- GFP_KERNEL))
- return -ENOMEM;
-#if 0
- ret = genradix_prealloc(&c->stripes[gc], idx, GFP_KERNEL);
-#else
- for (i = 0; i < idx; i++)
- if (!gc
- ? !genradix_ptr_alloc(&c->stripes, i, GFP_KERNEL)
- : !genradix_ptr_alloc(&c->gc_stripes, i, GFP_KERNEL))
- return -ENOMEM;
-#endif
- return 0;
-}
-
void bch2_stripes_heap_to_text(struct printbuf *out, struct bch_fs *c)
{
ec_stripes_heap *h = &c->ec_stripes_heap;
diff --git a/fs/bcachefs/ec.h b/fs/bcachefs/ec.h
index 468141072bb4..78d468c7680a 100644
--- a/fs/bcachefs/ec.h
+++ b/fs/bcachefs/ec.h
@@ -217,8 +217,6 @@ void bch2_stripes_heap_start(struct bch_fs *);
int bch2_stripes_read(struct bch_fs *);
-int bch2_ec_mem_alloc(struct bch_fs *, bool);
-
void bch2_stripes_heap_to_text(struct printbuf *, struct bch_fs *);
void bch2_new_stripes_to_text(struct printbuf *, struct bch_fs *);