Skip to content

Commit d8585a7

Browse files
author
Kent Overstreet
committed
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: Kent Overstreet <[email protected]>
1 parent 222eaca commit d8585a7

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

fs/bcachefs/data_update.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void bch2_data_update_exit(struct data_update *update)
360360
bch2_bkey_ptrs_c(bkey_i_to_s_c(update->k.k));
361361

362362
bkey_for_each_ptr(ptrs, ptr) {
363-
struct bch_dev *ca = bch2_dev_bkey_exists(c, ptr->dev);
363+
struct bch_dev *ca = bch2_dev_have_ref(c, ptr->dev);
364364
if (c->opts.nocow_enabled)
365365
bch2_bucket_nocow_unlock(&c->nocow_locks,
366366
PTR_BUCKET_POS(ca, ptr), 0);
@@ -559,7 +559,7 @@ int bch2_data_update_init(struct btree_trans *trans,
559559

560560
i = 0;
561561
bkey_for_each_ptr_decode(k.k, ptrs, p, entry) {
562-
struct bch_dev *ca = bch2_dev_bkey_exists(c, p.ptr.dev);
562+
struct bch_dev *ca = bch2_dev_have_ref(c, p.ptr.dev);
563563
struct bpos bucket = PTR_BUCKET_POS(ca, &p.ptr);
564564
bool locked;
565565

@@ -664,7 +664,7 @@ int bch2_data_update_init(struct btree_trans *trans,
664664
err:
665665
i = 0;
666666
bkey_for_each_ptr_decode(k.k, ptrs, p, entry) {
667-
struct bch_dev *ca = bch2_dev_bkey_exists(c, p.ptr.dev);
667+
struct bch_dev *ca = bch2_dev_have_ref(c, p.ptr.dev);
668668
struct bpos bucket = PTR_BUCKET_POS(ca, &p.ptr);
669669
if ((1U << i) & ptrs_locked)
670670
bch2_bucket_nocow_unlock(&c->nocow_locks, bucket, 0);

fs/bcachefs/io_write.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ static void bch2_nocow_write(struct bch_write_op *op)
13031303
bch2_cut_back(POS(op->pos.inode, op->pos.offset + bio_sectors(bio)), op->insert_keys.top);
13041304

13051305
darray_for_each(buckets, i) {
1306-
struct bch_dev *ca = bch2_dev_bkey_exists(c, i->b.inode);
1306+
struct bch_dev *ca = bch2_dev_have_ref(c, i->b.inode);
13071307

13081308
__bch2_bucket_nocow_lock(&c->nocow_locks, i->l,
13091309
bucket_to_u64(i->b),
@@ -1380,7 +1380,7 @@ static void bch2_nocow_write(struct bch_write_op *op)
13801380
return;
13811381
err_get_ioref:
13821382
darray_for_each(buckets, i)
1383-
percpu_ref_put(&bch2_dev_bkey_exists(c, i->b.inode)->io_ref);
1383+
percpu_ref_put(&bch2_dev_have_ref(c, i->b.inode)->io_ref);
13841384

13851385
/* Fall back to COW path: */
13861386
goto out;

fs/bcachefs/journal_io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ int bch2_journal_read(struct bch_fs *c,
13861386
continue;
13871387

13881388
darray_for_each(i->ptrs, ptr) {
1389-
struct bch_dev *ca = bch2_dev_bkey_exists(c, ptr->dev);
1389+
struct bch_dev *ca = bch2_dev_have_ref(c, ptr->dev);
13901390

13911391
if (!ptr->csum_good)
13921392
bch_err_dev_offset(ca, ptr->sector,
@@ -1396,7 +1396,7 @@ int bch2_journal_read(struct bch_fs *c,
13961396
}
13971397

13981398
ret = jset_validate(c,
1399-
bch2_dev_bkey_exists(c, i->ptrs.data[0].dev),
1399+
bch2_dev_have_ref(c, i->ptrs.data[0].dev),
14001400
&i->j,
14011401
i->ptrs.data[0].sector,
14021402
READ);

0 commit comments

Comments
 (0)