Commit 09d70d0b authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Nocow locking fixup

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 12795a19
...@@ -308,9 +308,11 @@ void bch2_data_update_exit(struct data_update *update) ...@@ -308,9 +308,11 @@ void bch2_data_update_exit(struct data_update *update)
bch2_bkey_ptrs_c(bkey_i_to_s_c(update->k.k)); bch2_bkey_ptrs_c(bkey_i_to_s_c(update->k.k));
const struct bch_extent_ptr *ptr; const struct bch_extent_ptr *ptr;
bkey_for_each_ptr(ptrs, ptr) bkey_for_each_ptr(ptrs, ptr) {
bch2_bucket_nocow_unlock(&c->nocow_locks, bch2_bucket_nocow_unlock(&c->nocow_locks,
PTR_BUCKET_POS(c, ptr), 0); PTR_BUCKET_POS(c, ptr), 0);
percpu_ref_put(&bch_dev_bkey_exists(c, ptr->dev)->ref);
}
bch2_bkey_buf_exit(&update->k, c); bch2_bkey_buf_exit(&update->k, c);
bch2_disk_reservation_put(c, &update->op.res); bch2_disk_reservation_put(c, &update->op.res);
...@@ -410,6 +412,7 @@ int bch2_data_update_init(struct btree_trans *trans, ...@@ -410,6 +412,7 @@ int bch2_data_update_init(struct btree_trans *trans,
struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k); struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k);
const union bch_extent_entry *entry; const union bch_extent_entry *entry;
struct extent_ptr_decoded p; struct extent_ptr_decoded p;
const struct bch_extent_ptr *ptr;
unsigned i, reserve_sectors = k.k->size * data_opts.extra_replicas; unsigned i, reserve_sectors = k.k->size * data_opts.extra_replicas;
unsigned int ptrs_locked = 0; unsigned int ptrs_locked = 0;
int ret; int ret;
...@@ -435,6 +438,9 @@ int bch2_data_update_init(struct btree_trans *trans, ...@@ -435,6 +438,9 @@ int bch2_data_update_init(struct btree_trans *trans,
if (m->data_opts.btree_insert_flags & BTREE_INSERT_USE_RESERVE) if (m->data_opts.btree_insert_flags & BTREE_INSERT_USE_RESERVE)
m->op.alloc_reserve = RESERVE_movinggc; m->op.alloc_reserve = RESERVE_movinggc;
bkey_for_each_ptr(ptrs, ptr)
percpu_ref_get(&bch_dev_bkey_exists(c, ptr->dev)->ref);
i = 0; i = 0;
bkey_for_each_ptr_decode(k.k, ptrs, p, entry) { bkey_for_each_ptr_decode(k.k, ptrs, p, entry) {
bool locked; bool locked;
...@@ -508,6 +514,7 @@ int bch2_data_update_init(struct btree_trans *trans, ...@@ -508,6 +514,7 @@ int bch2_data_update_init(struct btree_trans *trans,
if ((1U << i) & ptrs_locked) if ((1U << i) & ptrs_locked)
bch2_bucket_nocow_unlock(&c->nocow_locks, bch2_bucket_nocow_unlock(&c->nocow_locks,
PTR_BUCKET_POS(c, &p.ptr), 0); PTR_BUCKET_POS(c, &p.ptr), 0);
percpu_ref_put(&bch_dev_bkey_exists(c, p.ptr.dev)->ref);
i++; i++;
} }
......
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