bcachefs: bch2_dev_have_ref()
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 1 May 2024 07:59:45 +0000 (03:59 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Wed, 8 May 2024 21:29:24 +0000 (17:29 -0400)
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 <kent.overstreet@linux.dev>
fs/bcachefs/data_update.c
fs/bcachefs/io_write.c
fs/bcachefs/journal_io.c

index 1dee93eee7add377d743ed75158e7050e13d769d..0d807c2ce9c67a00ffc36fef20d1b3c68aecc2c4 100644 (file)
@@ -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));
 
        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)
                        bch2_bucket_nocow_unlock(&c->nocow_locks,
                                                 PTR_BUCKET_POS(ca, ptr), 0);
@@ -559,7 +559,7 @@ int bch2_data_update_init(struct btree_trans *trans,
 
        i = 0;
        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);
                bool locked;
 
@@ -664,7 +664,7 @@ int bch2_data_update_init(struct btree_trans *trans,
 err:
        i = 0;
        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);
                if ((1U << i) & ptrs_locked)
                        bch2_bucket_nocow_unlock(&c->nocow_locks, bucket, 0);
index 285e1a23bde5b5a622049ed53e9945814b41a585..33202b77f6cf0cb8abc05c48905e296cda56ece3 100644 (file)
@@ -1303,7 +1303,7 @@ retry:
                        bch2_cut_back(POS(op->pos.inode, op->pos.offset + bio_sectors(bio)), op->insert_keys.top);
 
                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,
                                                 bucket_to_u64(i->b),
@@ -1380,7 +1380,7 @@ err:
        return;
 err_get_ioref:
        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: */
        goto out;
index e76eb98af74a20508911c07c17c10f1ca7620443..9561f1c2ce1acf148d9cb9e5337ab014e8adcf97 100644 (file)
@@ -1386,7 +1386,7 @@ int bch2_journal_read(struct bch_fs *c,
                        continue;
 
                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)
                                bch_err_dev_offset(ca, ptr->sector,
@@ -1396,7 +1396,7 @@ int bch2_journal_read(struct bch_fs *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->ptrs.data[0].sector,
                                    READ);