summaryrefslogtreecommitdiff
path: root/fs/bcachefs/ec.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bcachefs/ec.c')
-rw-r--r--fs/bcachefs/ec.c36
1 files changed, 7 insertions, 29 deletions
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index 00e16801417a..c2840cb674b2 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -35,8 +35,6 @@
#include <linux/raid/pq.h>
#include <linux/raid/xor.h>
-static bool bch2_stripe_is_open(struct bch_fs *, u64);
-
static void raid5_recov(unsigned disks, unsigned failed_idx,
size_t size, void **data)
{
@@ -388,20 +386,11 @@ int bch2_trigger_stripe(struct btree_trans *trans,
new_s->nr_redundant != old_s->nr_redundant));
if (flags & BTREE_TRIGGER_transactional) {
- u64 old_lru_pos = stripe_lru_pos(old_s);
- u64 new_lru_pos = stripe_lru_pos(new_s);
-
- if (new_lru_pos == STRIPE_LRU_POS_EMPTY &&
- !bch2_stripe_is_open(c, idx)) {
- _new.k->type = KEY_TYPE_deleted;
- set_bkey_val_u64s(_new.k, 0);
- new_s = NULL;
- new_lru_pos = 0;
- }
-
int ret = bch2_lru_change(trans,
- BCH_LRU_STRIPE_FRAGMENTATION, idx,
- old_lru_pos, new_lru_pos);
+ BCH_LRU_STRIPE_FRAGMENTATION,
+ idx,
+ stripe_lru_pos(old_s),
+ stripe_lru_pos(new_s));
if (ret)
return ret;
}
@@ -965,7 +954,7 @@ static int ec_stripe_delete(struct btree_trans *trans, u64 idx)
*/
if (k.k->type == KEY_TYPE_stripe &&
!bch2_stripe_is_open(trans->c, idx) &&
- stripe_lru_pos(bkey_s_c_to_stripe(k).v) == STRIPE_LRU_POS_EMPTY)
+ stripe_lru_pos(bkey_s_c_to_stripe(k).v) == 1)
return bch2_btree_delete_at(trans, &iter, 0);
return 0;
@@ -1789,19 +1778,8 @@ static int __get_existing_stripe(struct btree_trans *trans,
return 0;
struct bkey_s_c_stripe s = bkey_s_c_to_stripe(k);
-
- if (stripe_lru_pos(s.v) == STRIPE_LRU_POS_EMPTY) {
- /*
- * We can't guarantee that the trigger will always delete
- * stripes - the stripe might still be open when the last data
- * in it was deleted
- */
- return !bch2_stripe_is_open(c, idx)
- ? bch2_btree_delete_at(trans, &iter, 0) ?:
- bch2_trans_commit(trans, NULL, NULL, BCH_TRANS_COMMIT_no_enospc) ?:
- bch_err_throw(c, transaction_restart_commit)
- : 0;
- }
+ if (stripe_lru_pos(s.v) <= 1)
+ return 0;
if (s.v->disk_label == head->disk_label &&
s.v->algorithm == head->algo &&