summaryrefslogtreecommitdiff
path: root/fs/bcachefs/ec.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-03-10 23:37:19 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:57 -0400
commite28ef07e0ef47c03f773571d85bc82fcce831376 (patch)
treef607da59b7bbfee2c85074013a9259f12f06f7ab /fs/bcachefs/ec.c
parent46e14854fca4a262a823079c1958a204f983fa4e (diff)
bcachefs: Simplify stripe_idx_to_delete
This is not technically correct - it's subject to a race if we ever end up with a stripe with all empty blocks (that needs to be deleted) being held open. But the "correct" version was much too inefficient, and soon we'll be adding a stripes LRU. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/ec.c')
-rw-r--r--fs/bcachefs/ec.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index 0a2e7db6906f..c747ae2d4046 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -659,14 +659,13 @@ static void bch2_stripe_close(struct bch_fs *c, struct ec_stripe_new *s)
static u64 stripe_idx_to_delete(struct bch_fs *c)
{
ec_stripes_heap *h = &c->ec_stripes_heap;
- size_t heap_idx;
lockdep_assert_held(&c->ec_stripes_heap_lock);
- for (heap_idx = 0; heap_idx < h->used; heap_idx++)
- if (h->data[heap_idx].blocks_nonempty == 0 &&
- !bch2_stripe_is_open(c, h->data[heap_idx].idx))
- return h->data[heap_idx].idx;
+ if (h->used &&
+ h->data[0].blocks_nonempty == 0 &&
+ !bch2_stripe_is_open(c, h->data[0].idx))
+ return h->data[0].idx;
return 0;
}