Commit 56767d66 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

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: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent d697b9ab
...@@ -51,7 +51,8 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags ...@@ -51,7 +51,8 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags
BTREE_ITER_PREFETCH| BTREE_ITER_PREFETCH|
BTREE_ITER_ALL_SNAPSHOTS); 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))) { !(ret = bkey_err(k))) {
if (!bch2_bkey_has_device(k, dev_idx)) { if (!bch2_bkey_has_device(k, dev_idx)) {
bch2_btree_iter_advance(&iter); bch2_btree_iter_advance(&iter);
...@@ -72,8 +73,6 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags ...@@ -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_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) ?: ret = bch2_btree_iter_traverse(&iter) ?:
bch2_trans_update(&trans, &iter, sk.k, bch2_trans_update(&trans, &iter, sk.k,
BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE) ?: BTREE_UPDATE_INTERNAL_SNAPSHOT_NODE) ?:
...@@ -125,12 +124,14 @@ static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags) ...@@ -125,12 +124,14 @@ static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags)
closure_init_stack(&cl); closure_init_stack(&cl);
for (id = 0; id < BTREE_ID_NR; id++) { for (id = 0; id < BTREE_ID_NR; id++) {
for_each_btree_node(&trans, iter, id, POS_MIN, bch2_trans_node_iter_init(&trans, &iter, id, POS_MIN, 0, 0,
BTREE_ITER_PREFETCH, b) { BTREE_ITER_PREFETCH);
retry:
while (bch2_trans_begin(&trans),
(b = bch2_btree_iter_peek_node(&iter))) {
if (!bch2_bkey_has_device(bkey_i_to_s_c(&b->key), if (!bch2_bkey_has_device(bkey_i_to_s_c(&b->key),
dev_idx)) dev_idx))
continue; goto next;
bch2_bkey_buf_copy(&k, c, &b->key); bch2_bkey_buf_copy(&k, c, &b->key);
...@@ -143,14 +144,16 @@ static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags) ...@@ -143,14 +144,16 @@ static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags)
ret = bch2_btree_node_update_key(&trans, &iter, b, k.k, false); ret = bch2_btree_node_update_key(&trans, &iter, b, k.k, false);
if (ret == -EINTR) { if (ret == -EINTR) {
b = bch2_btree_iter_peek_node(&iter);
ret = 0; ret = 0;
goto retry; continue;
} }
if (ret) { if (ret) {
bch_err(c, "Error updating btree node key: %i", ret); bch_err(c, "Error updating btree node key: %i", ret);
break; break;
} }
next:
bch2_btree_iter_next_node(&iter);
} }
bch2_trans_iter_exit(&trans, &iter); bch2_trans_iter_exit(&trans, &iter);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment