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 | ||||
-rw-r--r-- | fs/bcachefs/super.c | 6 |
4 files changed, 19 insertions, 47 deletions
diff --git a/fs/bcachefs/data_update.c b/fs/bcachefs/data_update.c index a314d70c6b8e..b7e0e31407bf 100644 --- a/fs/bcachefs/data_update.c +++ b/fs/bcachefs/data_update.c @@ -460,17 +460,11 @@ 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)) - ret = 0; - if (ret) + if (!bch2_err_matches(ret, BCH_ERR_transaction_restart)) 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) { @@ -479,11 +473,15 @@ 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); - goto next; +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; + } } 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 c5ed62a11f23..ed8329c6c00d 100644 --- a/fs/bcachefs/fs-io-buffered.c +++ b/fs/bcachefs/fs-io-buffered.c @@ -290,7 +290,8 @@ void bch2_readahead(struct readahead_control *ractl) * scheduling. */ blk_start_plug(&plug); - bch2_pagecache_add_get(inode); + if (!bch2_pagecache_add_tryget(inode)) + goto out; struct btree_trans *trans = bch2_trans_get(c); while ((folio = readpage_iter_peek(&readpages_iter))) { @@ -317,6 +318,7 @@ 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); } diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index 70d5aff38723..09e7f8ae9922 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -1557,7 +1557,6 @@ static void bch2_dev_free(struct bch_dev *ca) bch2_bucket_bitmap_free(&ca->bucket_backpointer_mismatch); bch2_bucket_bitmap_free(&ca->bucket_backpointer_empty); - genradix_free(&ca->buckets_gc); bch2_free_super(&ca->disk_sb); bch2_dev_allocator_background_exit(ca); @@ -2543,11 +2542,6 @@ struct bch_fs *bch2_fs_open(darray_const_str *devices, BUG_ON(darray_push(&sbs, sb)); } - if (opts->nochanges && !opts->read_only) { - ret = bch_err_throw(c, erofs_nochanges); - goto err_print; - } - darray_for_each(sbs, sb) if (!best || sb_cmp(sb->sb, best->sb) > 0) best = sb; |