diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-10-07 20:59:00 +0200 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 23:09:13 +0200 |
commit | 56767d66e888e0e998eabbbcffa5c6da49ef5402 (patch) | |
tree | 27c92e636727cffb16db688a2b714097212e1d12 /fs/bcachefs/migrate.c | |
parent | bcachefs: More btree iterator fixes (diff) | |
download | linux-56767d66e888e0e998eabbbcffa5c6da49ef5402.tar.xz linux-56767d66e888e0e998eabbbcffa5c6da49ef5402.zip |
bcachefs: Fixes for usrdata/metadata drop paths
These paths weren't updated for btree_path and snapshots - a couple of
minor fixes.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/migrate.c')
-rw-r--r-- | fs/bcachefs/migrate.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/fs/bcachefs/migrate.c b/fs/bcachefs/migrate.c index 7c764ee4ea09..9f9eb799337e 100644 --- a/fs/bcachefs/migrate.c +++ b/fs/bcachefs/migrate.c @@ -51,7 +51,8 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags BTREE_ITER_PREFETCH| BTREE_ITER_ALL_SNAPSHOTS); - while ((k = bch2_btree_iter_peek(&iter)).k && + while ((bch2_trans_begin(&trans), + (k = bch2_btree_iter_peek(&iter)).k) && !(ret = bkey_err(k))) { if (!bch2_bkey_has_device(k, dev_idx)) { bch2_btree_iter_advance(&iter); @@ -72,8 +73,6 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags */ bch2_extent_normalize(c, bkey_i_to_s(sk.k)); - bch2_btree_iter_set_pos(&iter, bkey_start_pos(&sk.k->k)); - ret = bch2_btree_iter_traverse(&iter) ?: bch2_trans_update(&trans, &iter, sk.k, BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE) ?: @@ -125,12 +124,14 @@ static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags) closure_init_stack(&cl); for (id = 0; id < BTREE_ID_NR; id++) { - for_each_btree_node(&trans, iter, id, POS_MIN, - BTREE_ITER_PREFETCH, b) { -retry: + bch2_trans_node_iter_init(&trans, &iter, id, POS_MIN, 0, 0, + BTREE_ITER_PREFETCH); + + while (bch2_trans_begin(&trans), + (b = bch2_btree_iter_peek_node(&iter))) { if (!bch2_bkey_has_device(bkey_i_to_s_c(&b->key), dev_idx)) - continue; + goto next; bch2_bkey_buf_copy(&k, c, &b->key); @@ -143,14 +144,16 @@ retry: ret = bch2_btree_node_update_key(&trans, &iter, b, k.k, false); if (ret == -EINTR) { - b = bch2_btree_iter_peek_node(&iter); ret = 0; - goto retry; + continue; } + if (ret) { bch_err(c, "Error updating btree node key: %i", ret); break; } +next: + bch2_btree_iter_next_node(&iter); } bch2_trans_iter_exit(&trans, &iter); |