diff options
-rw-r--r-- | fs/bcachefs/data_update.c | 20 | ||||
-rw-r--r-- | fs/bcachefs/ec.c | 36 | ||||
-rw-r--r-- | fs/bcachefs/fs-io-buffered.c | 4 |
3 files changed, 19 insertions, 41 deletions
diff --git a/fs/bcachefs/data_update.c b/fs/bcachefs/data_update.c index b7e0e31407bf..a314d70c6b8e 100644 --- a/fs/bcachefs/data_update.c +++ b/fs/bcachefs/data_update.c @@ -460,11 +460,17 @@ restart_drop_extra_replicas: this_cpu_add(c->counters[BCH_COUNTER_io_move_finish], new->k.size); if (trace_io_move_finish_enabled()) trace_io_move_finish2(m, &new->k_i, insert); - goto next; err: - if (!bch2_err_matches(ret, BCH_ERR_transaction_restart)) + if (bch2_err_matches(ret, BCH_ERR_transaction_restart)) + ret = 0; + if (ret) break; - +next: + while (bkey_ge(iter.pos, bch2_keylist_front(&op->insert_keys)->k.p)) { + bch2_keylist_pop_front(&op->insert_keys); + if (bch2_keylist_empty(&op->insert_keys)) + goto out; + } continue; nowork: if (m->stats) { @@ -473,15 +479,11 @@ nowork: atomic64_add(k.k->p.offset - iter.pos.offset, &m->stats->sectors_raced); } + count_event(c, io_move_fail); bch2_btree_iter_advance(&iter); -next: - while (bkey_ge(iter.pos, bch2_keylist_front(&op->insert_keys)->k.p)) { - bch2_keylist_pop_front(&op->insert_keys); - if (bch2_keylist_empty(&op->insert_keys)) - goto out; - } + goto next; } out: BUG_ON(bch2_err_matches(ret, BCH_ERR_transaction_restart)); 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 && diff --git a/fs/bcachefs/fs-io-buffered.c b/fs/bcachefs/fs-io-buffered.c index ed8329c6c00d..c5ed62a11f23 100644 --- a/fs/bcachefs/fs-io-buffered.c +++ b/fs/bcachefs/fs-io-buffered.c @@ -290,8 +290,7 @@ void bch2_readahead(struct readahead_control *ractl) * scheduling. */ blk_start_plug(&plug); - if (!bch2_pagecache_add_tryget(inode)) - goto out; + bch2_pagecache_add_get(inode); struct btree_trans *trans = bch2_trans_get(c); while ((folio = readpage_iter_peek(&readpages_iter))) { @@ -318,7 +317,6 @@ void bch2_readahead(struct readahead_control *ractl) bch2_trans_put(trans); bch2_pagecache_add_put(inode); -out: blk_finish_plug(&plug); darray_exit(&readpages_iter.folios); } |