Commit d8585a79 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: bch2_dev_have_ref()

bch2_dev_bkey_exists() is going away; bch2_dev_have_ref() documents that
we're looking up a device without checking if it's present because we
have a reference to it already.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 222eacab
...@@ -360,7 +360,7 @@ void bch2_data_update_exit(struct data_update *update) ...@@ -360,7 +360,7 @@ 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));
bkey_for_each_ptr(ptrs, ptr) { bkey_for_each_ptr(ptrs, ptr) {
struct bch_dev *ca = bch2_dev_bkey_exists(c, ptr->dev); struct bch_dev *ca = bch2_dev_have_ref(c, ptr->dev);
if (c->opts.nocow_enabled) if (c->opts.nocow_enabled)
bch2_bucket_nocow_unlock(&c->nocow_locks, bch2_bucket_nocow_unlock(&c->nocow_locks,
PTR_BUCKET_POS(ca, ptr), 0); PTR_BUCKET_POS(ca, ptr), 0);
...@@ -559,7 +559,7 @@ int bch2_data_update_init(struct btree_trans *trans, ...@@ -559,7 +559,7 @@ int bch2_data_update_init(struct btree_trans *trans,
i = 0; i = 0;
bkey_for_each_ptr_decode(k.k, ptrs, p, entry) { bkey_for_each_ptr_decode(k.k, ptrs, p, entry) {
struct bch_dev *ca = bch2_dev_bkey_exists(c, p.ptr.dev); struct bch_dev *ca = bch2_dev_have_ref(c, p.ptr.dev);
struct bpos bucket = PTR_BUCKET_POS(ca, &p.ptr); struct bpos bucket = PTR_BUCKET_POS(ca, &p.ptr);
bool locked; bool locked;
...@@ -664,7 +664,7 @@ int bch2_data_update_init(struct btree_trans *trans, ...@@ -664,7 +664,7 @@ int bch2_data_update_init(struct btree_trans *trans,
err: err:
i = 0; i = 0;
bkey_for_each_ptr_decode(k.k, ptrs, p, entry) { bkey_for_each_ptr_decode(k.k, ptrs, p, entry) {
struct bch_dev *ca = bch2_dev_bkey_exists(c, p.ptr.dev); struct bch_dev *ca = bch2_dev_have_ref(c, p.ptr.dev);
struct bpos bucket = PTR_BUCKET_POS(ca, &p.ptr); struct bpos bucket = PTR_BUCKET_POS(ca, &p.ptr);
if ((1U << i) & ptrs_locked) if ((1U << i) & ptrs_locked)
bch2_bucket_nocow_unlock(&c->nocow_locks, bucket, 0); bch2_bucket_nocow_unlock(&c->nocow_locks, bucket, 0);
......
...@@ -1303,7 +1303,7 @@ static void bch2_nocow_write(struct bch_write_op *op) ...@@ -1303,7 +1303,7 @@ static void bch2_nocow_write(struct bch_write_op *op)
bch2_cut_back(POS(op->pos.inode, op->pos.offset + bio_sectors(bio)), op->insert_keys.top); bch2_cut_back(POS(op->pos.inode, op->pos.offset + bio_sectors(bio)), op->insert_keys.top);
darray_for_each(buckets, i) { darray_for_each(buckets, i) {
struct bch_dev *ca = bch2_dev_bkey_exists(c, i->b.inode); struct bch_dev *ca = bch2_dev_have_ref(c, i->b.inode);
__bch2_bucket_nocow_lock(&c->nocow_locks, i->l, __bch2_bucket_nocow_lock(&c->nocow_locks, i->l,
bucket_to_u64(i->b), bucket_to_u64(i->b),
...@@ -1380,7 +1380,7 @@ static void bch2_nocow_write(struct bch_write_op *op) ...@@ -1380,7 +1380,7 @@ static void bch2_nocow_write(struct bch_write_op *op)
return; return;
err_get_ioref: err_get_ioref:
darray_for_each(buckets, i) darray_for_each(buckets, i)
percpu_ref_put(&bch2_dev_bkey_exists(c, i->b.inode)->io_ref); percpu_ref_put(&bch2_dev_have_ref(c, i->b.inode)->io_ref);
/* Fall back to COW path: */ /* Fall back to COW path: */
goto out; goto out;
......
...@@ -1386,7 +1386,7 @@ int bch2_journal_read(struct bch_fs *c, ...@@ -1386,7 +1386,7 @@ int bch2_journal_read(struct bch_fs *c,
continue; continue;
darray_for_each(i->ptrs, ptr) { darray_for_each(i->ptrs, ptr) {
struct bch_dev *ca = bch2_dev_bkey_exists(c, ptr->dev); struct bch_dev *ca = bch2_dev_have_ref(c, ptr->dev);
if (!ptr->csum_good) if (!ptr->csum_good)
bch_err_dev_offset(ca, ptr->sector, bch_err_dev_offset(ca, ptr->sector,
...@@ -1396,7 +1396,7 @@ int bch2_journal_read(struct bch_fs *c, ...@@ -1396,7 +1396,7 @@ int bch2_journal_read(struct bch_fs *c,
} }
ret = jset_validate(c, ret = jset_validate(c,
bch2_dev_bkey_exists(c, i->ptrs.data[0].dev), bch2_dev_have_ref(c, i->ptrs.data[0].dev),
&i->j, &i->j,
i->ptrs.data[0].sector, i->ptrs.data[0].sector,
READ); READ);
......
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