]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: trans_mark now takes bkey_s
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 28 Dec 2023 04:19:09 +0000 (23:19 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 6 Jan 2024 04:24:19 +0000 (23:24 -0500)
Prep work for disk space accounting rewrite: we're going to want to use
a single callback for both of our current triggers, so we need to change
them to have the same type signature first.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
12 files changed:
fs/bcachefs/alloc_background.c
fs/bcachefs/alloc_background.h
fs/bcachefs/bkey_methods.h
fs/bcachefs/btree_gc.c
fs/bcachefs/btree_trans_commit.c
fs/bcachefs/btree_update_interior.c
fs/bcachefs/buckets.c
fs/bcachefs/buckets.h
fs/bcachefs/inode.c
fs/bcachefs/inode.h
fs/bcachefs/reflink.c
fs/bcachefs/reflink.h

index 1a127b0a08b314e4f9f14289ba01fa57ae827d1c..1446501258abef17860e49f37d5fa7dbcbb73d97 100644 (file)
@@ -751,7 +751,7 @@ static noinline int bch2_bucket_gen_update(struct btree_trans *trans,
 
 int bch2_trans_mark_alloc(struct btree_trans *trans,
                          enum btree_id btree_id, unsigned level,
-                         struct bkey_s_c old, struct bkey_i *new,
+                         struct bkey_s_c old, struct bkey_new,
                          unsigned flags)
 {
        struct bch_fs *c = trans->c;
@@ -764,10 +764,10 @@ int bch2_trans_mark_alloc(struct btree_trans *trans,
         * Deletion only happens in the device removal path, with
         * BTREE_TRIGGER_NORUN:
         */
-       BUG_ON(new->k.type != KEY_TYPE_alloc_v4);
+       BUG_ON(new.k->type != KEY_TYPE_alloc_v4);
 
        old_a = bch2_alloc_to_v4(old, &old_a_convert);
-       new_a = &bkey_i_to_alloc_v4(new)->v;
+       new_a = bkey_s_to_alloc_v4(new).v;
 
        new_a->data_type = alloc_data_type(*new_a, new_a->data_type);
 
@@ -780,7 +780,7 @@ int bch2_trans_mark_alloc(struct btree_trans *trans,
 
        if (data_type_is_empty(new_a->data_type) &&
            BCH_ALLOC_V4_NEED_INC_GEN(new_a) &&
-           !bch2_bucket_is_open_safe(c, new->k.p.inode, new->k.p.offset)) {
+           !bch2_bucket_is_open_safe(c, new.k->p.inode, new.k->p.offset)) {
                new_a->gen++;
                SET_BCH_ALLOC_V4_NEED_INC_GEN(new_a, false);
        }
@@ -789,7 +789,7 @@ int bch2_trans_mark_alloc(struct btree_trans *trans,
            (new_a->data_type == BCH_DATA_free &&
             alloc_freespace_genbits(*old_a) != alloc_freespace_genbits(*new_a))) {
                ret =   bch2_bucket_do_index(trans, old, old_a, false) ?:
-                       bch2_bucket_do_index(trans, bkey_i_to_s_c(new), new_a, true);
+                       bch2_bucket_do_index(trans, new.s_c, new_a, true);
                if (ret)
                        return ret;
        }
@@ -802,27 +802,27 @@ int bch2_trans_mark_alloc(struct btree_trans *trans,
        new_lru = alloc_lru_idx_read(*new_a);
 
        if (old_lru != new_lru) {
-               ret = bch2_lru_change(trans, new->k.p.inode,
-                                     bucket_to_u64(new->k.p),
+               ret = bch2_lru_change(trans, new.k->p.inode,
+                                     bucket_to_u64(new.k->p),
                                      old_lru, new_lru);
                if (ret)
                        return ret;
        }
 
        new_a->fragmentation_lru = alloc_lru_idx_fragmentation(*new_a,
-                                       bch_dev_bkey_exists(c, new->k.p.inode));
+                                       bch_dev_bkey_exists(c, new.k->p.inode));
 
        if (old_a->fragmentation_lru != new_a->fragmentation_lru) {
                ret = bch2_lru_change(trans,
                                BCH_LRU_FRAGMENTATION_START,
-                               bucket_to_u64(new->k.p),
+                               bucket_to_u64(new.k->p),
                                old_a->fragmentation_lru, new_a->fragmentation_lru);
                if (ret)
                        return ret;
        }
 
        if (old_a->gen != new_a->gen) {
-               ret = bch2_bucket_gen_update(trans, new->k.p, new_a->gen);
+               ret = bch2_bucket_gen_update(trans, new.k->p, new_a->gen);
                if (ret)
                        return ret;
        }
@@ -834,7 +834,7 @@ int bch2_trans_mark_alloc(struct btree_trans *trans,
 
        if ((flags & BTREE_TRIGGER_BUCKET_INVALIDATE) &&
            old_a->cached_sectors) {
-               ret = bch2_update_cached_sectors_list(trans, new->k.p.inode,
+               ret = bch2_update_cached_sectors_list(trans, new.k->p.inode,
                                                      -((s64) old_a->cached_sectors));
                if (ret)
                        return ret;
index 96671f166dd8053a7842fdda13e9afd14e62144b..7be590a4fa81e4ec686250e85a1376321caf0379 100644 (file)
@@ -233,7 +233,7 @@ static inline bool bkey_is_alloc(const struct bkey *k)
 int bch2_alloc_read(struct bch_fs *);
 
 int bch2_trans_mark_alloc(struct btree_trans *, enum btree_id, unsigned,
-                         struct bkey_s_c, struct bkey_i *, unsigned);
+                         struct bkey_s_c, struct bkey_s, unsigned);
 int bch2_check_alloc_info(struct bch_fs *);
 int bch2_check_alloc_to_lru_refs(struct bch_fs *);
 void bch2_do_discards(struct bch_fs *);
index 912adadfb4dd40a3435d7f6a82eba365a750fa67..fa68e28c4f8215776d6c5d9143cb5e996de17784 100644 (file)
@@ -29,7 +29,7 @@ struct bkey_ops {
        bool            (*key_normalize)(struct bch_fs *, struct bkey_s);
        bool            (*key_merge)(struct bch_fs *, struct bkey_s, struct bkey_s_c);
        int             (*trans_trigger)(struct btree_trans *, enum btree_id, unsigned,
-                                        struct bkey_s_c, struct bkey_i *, unsigned);
+                                        struct bkey_s_c, struct bkey_s, unsigned);
        int             (*atomic_trigger)(struct btree_trans *, enum btree_id, unsigned,
                                          struct bkey_s_c, struct bkey_s_c, unsigned);
        void            (*compat)(enum btree_id id, unsigned version,
@@ -120,10 +120,10 @@ enum btree_update_flags {
 
 static inline int bch2_trans_mark_key(struct btree_trans *trans,
                                      enum btree_id btree_id, unsigned level,
-                                     struct bkey_s_c old, struct bkey_i *new,
+                                     struct bkey_s_c old, struct bkey_new,
                                      unsigned flags)
 {
-       const struct bkey_ops *ops = bch2_bkey_type_ops(old.k->type ?: new->k.type);
+       const struct bkey_ops *ops = bch2_bkey_type_ops(old.k->type ?: new.k->type);
 
        return ops->trans_trigger
                ? ops->trans_trigger(trans, btree_id, level, old, new, flags)
@@ -139,18 +139,18 @@ static inline int bch2_trans_mark_old(struct btree_trans *trans,
        bkey_init(&deleted.k);
        deleted.k.p = old.k->p;
 
-       return bch2_trans_mark_key(trans, btree_id, level, old, &deleted,
+       return bch2_trans_mark_key(trans, btree_id, level, old, bkey_i_to_s(&deleted),
                                   BTREE_TRIGGER_OVERWRITE|flags);
 }
 
 static inline int bch2_trans_mark_new(struct btree_trans *trans,
                                      enum btree_id btree_id, unsigned level,
-                                     struct bkey_i *new, unsigned flags)
+                                     struct bkey_new, unsigned flags)
 {
        struct bkey_i deleted;
 
        bkey_init(&deleted.k);
-       deleted.k.p = new->k.p;
+       deleted.k.p = new.k->p;
 
        return bch2_trans_mark_key(trans, btree_id, level, bkey_i_to_s_c(&deleted), new,
                                   BTREE_TRIGGER_INSERT|flags);
index 9f27cb3ea5633c355dc07a936408908389ac10d7..3143544ca24c00451de6782b42243df3596925da 100644 (file)
@@ -1589,7 +1589,7 @@ static int bch2_gc_write_reflink_key(struct btree_trans *trans,
                if (!r->refcount)
                        new->k.type = KEY_TYPE_deleted;
                else
-                       *bkey_refcount(new) = cpu_to_le64(r->refcount);
+                       *bkey_refcount(bkey_i_to_s(new)) = cpu_to_le64(r->refcount);
        }
 fsck_err:
        printbuf_exit(&buf);
index 6e872c817dce1ea96e8e4e29af0dfa964efae128..b62eba04e0be2def32da7f9db4865cacef3a6faa 100644 (file)
@@ -494,7 +494,7 @@ static int run_one_trans_trigger(struct btree_trans *trans, struct btree_insert_
            old_ops->trans_trigger == new_ops->trans_trigger) {
                i->overwrite_trigger_run = true;
                i->insert_trigger_run = true;
-               return bch2_trans_mark_key(trans, i->btree_id, i->level, old, i->k,
+               return bch2_trans_mark_key(trans, i->btree_id, i->level, old, bkey_i_to_s(i->k),
                                           BTREE_TRIGGER_INSERT|
                                           BTREE_TRIGGER_OVERWRITE|
                                           i->flags) ?: 1;
@@ -503,7 +503,7 @@ static int run_one_trans_trigger(struct btree_trans *trans, struct btree_insert_
                return bch2_trans_mark_old(trans, i->btree_id, i->level, old, i->flags) ?: 1;
        } else if (!overwrite && !i->insert_trigger_run) {
                i->insert_trigger_run = true;
-               return bch2_trans_mark_new(trans, i->btree_id, i->level, i->k, i->flags) ?: 1;
+               return bch2_trans_mark_new(trans, i->btree_id, i->level, bkey_i_to_s(i->k), i->flags) ?: 1;
        } else {
                return 0;
        }
index 2a93eb92d1129680724681ef62c12bd207c56ae9..7447949abbb0852a838ba59a88686c9dd4857770 100644 (file)
@@ -576,7 +576,7 @@ static int btree_update_nodes_written_trans(struct btree_trans *trans,
        for_each_keylist_key(&as->new_keys, k) {
                unsigned level = bkey_i_to_btree_ptr_v2(k)->v.mem_ptr;
 
-               ret = bch2_trans_mark_new(trans, as->btree_id, level, k, 0);
+               ret = bch2_trans_mark_new(trans, as->btree_id, level, bkey_i_to_s(k), 0);
                if (ret)
                        return ret;
        }
@@ -2162,7 +2162,7 @@ static int __bch2_btree_node_update_key(struct btree_trans *trans,
                        return ret;
 
                ret = bch2_trans_mark_new(trans, b->c.btree_id, b->c.level + 1,
-                                         new_key, 0);
+                                         bkey_i_to_s(new_key), 0);
                if (ret)
                        return ret;
        }
index c0dac04253f7c8787570fdb50f137b0ae20ba26a..e96e418918780a67baf372b93fb1a2cc77c3003a 100644 (file)
@@ -1423,15 +1423,15 @@ static int __trans_mark_extent(struct btree_trans *trans,
 
 int bch2_trans_mark_extent(struct btree_trans *trans,
                           enum btree_id btree_id, unsigned level,
-                          struct bkey_s_c old, struct bkey_i *new,
+                          struct bkey_s_c old, struct bkey_new,
                           unsigned flags)
 {
        struct bch_fs *c = trans->c;
-       int mod = (int) bch2_bkey_needs_rebalance(c, bkey_i_to_s_c(new)) -
+       int mod = (int) bch2_bkey_needs_rebalance(c, new.s_c) -
                  (int) bch2_bkey_needs_rebalance(c, old);
 
        if (mod) {
-               int ret = bch2_btree_bit_mod(trans, BTREE_ID_rebalance_work, new->k.p, mod > 0);
+               int ret = bch2_btree_bit_mod(trans, BTREE_ID_rebalance_work, new.k->p, mod > 0);
                if (ret)
                        return ret;
        }
@@ -1519,7 +1519,7 @@ err:
 
 int bch2_trans_mark_stripe(struct btree_trans *trans,
                           enum btree_id btree_id, unsigned level,
-                          struct bkey_s_c old, struct bkey_i *new,
+                          struct bkey_s_c old, struct bkey_new,
                           unsigned flags)
 {
        const struct bch_stripe *old_s = NULL;
@@ -1530,8 +1530,8 @@ int bch2_trans_mark_stripe(struct btree_trans *trans,
 
        if (old.k->type == KEY_TYPE_stripe)
                old_s = bkey_s_c_to_stripe(old).v;
-       if (new->k.type == KEY_TYPE_stripe)
-               new_s = &bkey_i_to_stripe(new)->v;
+       if (new.k->type == KEY_TYPE_stripe)
+               new_s = bkey_s_to_stripe(new).v;
 
        /*
         * If the pointers aren't changing, we don't need to do anything:
@@ -1552,7 +1552,7 @@ int bch2_trans_mark_stripe(struct btree_trans *trans,
        if (new_s) {
                s64 sectors = le16_to_cpu(new_s->sectors);
 
-               bch2_bkey_to_replicas(&r.e, bkey_i_to_s_c(new));
+               bch2_bkey_to_replicas(&r.e, new.s_c);
                ret = bch2_update_replicas_list(trans, &r.e, sectors * new_s->nr_redundant);
                if (ret)
                        return ret;
@@ -1576,7 +1576,7 @@ int bch2_trans_mark_stripe(struct btree_trans *trans,
 
                if (new_s) {
                        ret = bch2_trans_mark_stripe_bucket(trans,
-                                       bkey_i_to_s_c_stripe(new), i, false);
+                                       bkey_s_to_stripe(new).c, i, false);
                        if (ret)
                                break;
                }
@@ -1620,7 +1620,7 @@ static int __trans_mark_reservation(struct btree_trans *trans,
 int bch2_trans_mark_reservation(struct btree_trans *trans,
                                enum btree_id btree_id, unsigned level,
                                struct bkey_s_c old,
-                               struct bkey_i *new,
+                               struct bkey_new,
                                unsigned flags)
 {
        return trigger_run_overwrite_then_insert(__trans_mark_reservation, trans, btree_id, level, old, new, flags);
index 379101d7e585b414de3757fc161a4c4f407b14a7..c7168b86bb2e497060c05a2823d85ae37c9ec07f 100644 (file)
@@ -336,9 +336,9 @@ int bch2_mark_stripe(struct btree_trans *, enum btree_id, unsigned,
 int bch2_mark_reservation(struct btree_trans *, enum btree_id, unsigned,
                          struct bkey_s_c, struct bkey_s_c, unsigned);
 
-int bch2_trans_mark_extent(struct btree_trans *, enum btree_id, unsigned, struct bkey_s_c, struct bkey_i *, unsigned);
-int bch2_trans_mark_stripe(struct btree_trans *, enum btree_id, unsigned, struct bkey_s_c, struct bkey_i *, unsigned);
-int bch2_trans_mark_reservation(struct btree_trans *, enum btree_id, unsigned, struct bkey_s_c, struct bkey_i *, unsigned);
+int bch2_trans_mark_extent(struct btree_trans *, enum btree_id, unsigned, struct bkey_s_c, struct bkey_s, unsigned);
+int bch2_trans_mark_stripe(struct btree_trans *, enum btree_id, unsigned, struct bkey_s_c, struct bkey_s, unsigned);
+int bch2_trans_mark_reservation(struct btree_trans *, enum btree_id, unsigned, struct bkey_s_c, struct bkey_s, unsigned);
 #define mem_trigger_run_overwrite_then_insert(_fn, _trans, _btree_id, _level, _old, _new, _flags)\
 ({                                                                                             \
        int ret = 0;                                                                            \
@@ -351,7 +351,7 @@ int bch2_trans_mark_reservation(struct btree_trans *, enum btree_id, unsigned, s
 })
 
 #define trigger_run_overwrite_then_insert(_fn, _trans, _btree_id, _level, _old, _new, _flags)  \
-       mem_trigger_run_overwrite_then_insert(_fn, _trans, _btree_id, _level, _old, bkey_i_to_s_c(_new), _flags)
+       mem_trigger_run_overwrite_then_insert(_fn, _trans, _btree_id, _level, _old, _new.s_c, _flags)
 
 void bch2_trans_fs_usage_revert(struct btree_trans *, struct replicas_delta_list *);
 int bch2_trans_fs_usage_apply(struct btree_trans *, struct replicas_delta_list *);
index c39844b8e596b41bd1a106718b3e756db0359bda..32e0736ba71869d8d82d34e8079c913356e9997e 100644 (file)
@@ -564,12 +564,12 @@ static inline bool bkey_is_deleted_inode(struct bkey_s_c k)
 int bch2_trans_mark_inode(struct btree_trans *trans,
                          enum btree_id btree_id, unsigned level,
                          struct bkey_s_c old,
-                         struct bkey_i *new,
+                         struct bkey_new,
                          unsigned flags)
 {
-       int nr = bkey_is_inode(&new->k) - bkey_is_inode(old.k);
+       s64 nr = bkey_is_inode(new.k) - bkey_is_inode(old.k);
        bool old_deleted = bkey_is_deleted_inode(old);
-       bool new_deleted = bkey_is_deleted_inode(bkey_i_to_s_c(new));
+       bool new_deleted = bkey_is_deleted_inode(new.s_c);
 
        if (nr) {
                int ret = bch2_replicas_deltas_realloc(trans, 0);
@@ -582,7 +582,7 @@ int bch2_trans_mark_inode(struct btree_trans *trans,
        }
 
        if (old_deleted != new_deleted) {
-               int ret = bch2_btree_bit_mod(trans, BTREE_ID_deleted_inodes, new->k.p, new_deleted);
+               int ret = bch2_btree_bit_mod(trans, BTREE_ID_deleted_inodes, new.k->p, new_deleted);
                if (ret)
                        return ret;
        }
index 88818a332b1e5fcaa5fd9b350d958ef582c05161..7533a16a78cb3cf1663da29381b3f71387286625 100644 (file)
@@ -18,7 +18,7 @@ int bch2_inode_v3_invalid(struct bch_fs *, struct bkey_s_c,
 void bch2_inode_to_text(struct printbuf *, struct bch_fs *, struct bkey_s_c);
 
 int bch2_trans_mark_inode(struct btree_trans *, enum btree_id, unsigned,
-                         struct bkey_s_c, struct bkey_i *, unsigned);
+                         struct bkey_s_c, struct bkey_s, unsigned);
 int bch2_mark_inode(struct btree_trans *, enum btree_id, unsigned,
                    struct bkey_s_c, struct bkey_s_c, unsigned);
 
index 9f9c8a244c80aac3cd989706ae09d10f2c2c8737..aa2ff7ee801ffd4e721343be8964d34cfe7aaa43 100644 (file)
@@ -93,7 +93,7 @@ static int trans_mark_reflink_p_segment(struct btree_trans *trans,
        if (ret)
                goto err;
 
-       refcount = bkey_refcount(k);
+       refcount = bkey_refcount(bkey_i_to_s(k));
        if (!refcount) {
                bch2_bkey_val_to_text(&buf, c, p.s_c);
                bch2_trans_inconsistent(trans,
@@ -161,11 +161,11 @@ static int __trans_mark_reflink_p(struct btree_trans *trans,
 int bch2_trans_mark_reflink_p(struct btree_trans *trans,
                              enum btree_id btree_id, unsigned level,
                              struct bkey_s_c old,
-                             struct bkey_i *new,
+                             struct bkey_new,
                              unsigned flags)
 {
        if (flags & BTREE_TRIGGER_INSERT) {
-               struct bch_reflink_p *v = &bkey_i_to_reflink_p(new)->v;
+               struct bch_reflink_p *v = bkey_s_to_reflink_p(new).v;
 
                v->front_pad = v->back_pad = 0;
        }
@@ -305,29 +305,29 @@ bool bch2_reflink_v_merge(struct bch_fs *c, struct bkey_s _l, struct bkey_s_c _r
 }
 #endif
 
-static inline void check_indirect_extent_deleting(struct bkey_i *new, unsigned *flags)
+static inline void check_indirect_extent_deleting(struct bkey_new, unsigned *flags)
 {
        if ((*flags & BTREE_TRIGGER_INSERT) && !*bkey_refcount(new)) {
-               new->k.type = KEY_TYPE_deleted;
-               new->k.size = 0;
-               set_bkey_val_u64s(&new->k, 0);
+               new.k->type = KEY_TYPE_deleted;
+               new.k->size = 0;
+               set_bkey_val_u64s(new.k, 0);
                *flags &= ~BTREE_TRIGGER_INSERT;
        }
 }
 
 int bch2_trans_mark_reflink_v(struct btree_trans *trans,
                              enum btree_id btree_id, unsigned level,
-                             struct bkey_s_c old, struct bkey_i *new,
+                             struct bkey_s_c old, struct bkey_new,
                              unsigned flags)
 {
        check_indirect_extent_deleting(new, &flags);
 
        if (old.k->type == KEY_TYPE_reflink_v &&
-           new->k.type == KEY_TYPE_reflink_v &&
-           old.k->u64s == new->k.u64s &&
+           new.k->type == KEY_TYPE_reflink_v &&
+           old.k->u64s == new.k->u64s &&
            !memcmp(bkey_s_c_to_reflink_v(old).v->start,
-                   bkey_i_to_reflink_v(new)->v.start,
-                   bkey_val_bytes(&new->k) - 8))
+                   bkey_s_to_reflink_v(new).v->start,
+                   bkey_val_bytes(new.k) - 8))
                return 0;
 
        return bch2_trans_mark_extent(trans, btree_id, level, old, new, flags);
@@ -355,7 +355,7 @@ void bch2_indirect_inline_data_to_text(struct printbuf *out,
 
 int bch2_trans_mark_indirect_inline_data(struct btree_trans *trans,
                              enum btree_id btree_id, unsigned level,
-                             struct bkey_s_c old, struct bkey_i *new,
+                             struct bkey_s_c old, struct bkey_new,
                              unsigned flags)
 {
        check_indirect_extent_deleting(new, &flags);
@@ -398,7 +398,7 @@ static int bch2_make_extent_indirect(struct btree_trans *trans,
 
        set_bkey_val_bytes(&r_v->k, sizeof(__le64) + bkey_val_bytes(&orig->k));
 
-       refcount        = bkey_refcount(r_v);
+       refcount        = bkey_refcount(bkey_i_to_s(r_v));
        *refcount       = 0;
        memcpy(refcount + 1, &orig->v, bkey_val_bytes(&orig->k));
 
index 6cc9c4a77265988081c21aa006ee63a64bfff521..fa2ec7f8314ae8043daa4641c55aea214b29a841 100644 (file)
@@ -10,7 +10,7 @@ void bch2_reflink_p_to_text(struct printbuf *, struct bch_fs *,
                            struct bkey_s_c);
 bool bch2_reflink_p_merge(struct bch_fs *, struct bkey_s, struct bkey_s_c);
 int bch2_trans_mark_reflink_p(struct btree_trans *, enum btree_id, unsigned,
-                             struct bkey_s_c, struct bkey_i *, unsigned);
+                             struct bkey_s_c, struct bkey_s, unsigned);
 int bch2_mark_reflink_p(struct btree_trans *, enum btree_id, unsigned,
                        struct bkey_s_c, struct bkey_s_c, unsigned);
 
@@ -28,7 +28,7 @@ int bch2_reflink_v_invalid(struct bch_fs *, struct bkey_s_c,
 void bch2_reflink_v_to_text(struct printbuf *, struct bch_fs *,
                            struct bkey_s_c);
 int bch2_trans_mark_reflink_v(struct btree_trans *, enum btree_id, unsigned,
-                             struct bkey_s_c, struct bkey_i *, unsigned);
+                             struct bkey_s_c, struct bkey_s, unsigned);
 
 #define bch2_bkey_ops_reflink_v ((struct bkey_ops) {           \
        .key_invalid    = bch2_reflink_v_invalid,               \
@@ -45,7 +45,7 @@ void bch2_indirect_inline_data_to_text(struct printbuf *,
                                struct bch_fs *, struct bkey_s_c);
 int bch2_trans_mark_indirect_inline_data(struct btree_trans *,
                                         enum btree_id, unsigned,
-                             struct bkey_s_c, struct bkey_i *,
+                             struct bkey_s_c, struct bkey_s,
                              unsigned);
 
 #define bch2_bkey_ops_indirect_inline_data ((struct bkey_ops) {        \
@@ -67,13 +67,13 @@ static inline const __le64 *bkey_refcount_c(struct bkey_s_c k)
        }
 }
 
-static inline __le64 *bkey_refcount(struct bkey_i *k)
+static inline __le64 *bkey_refcount(struct bkey_k)
 {
-       switch (k->k.type) {
+       switch (k.k->type) {
        case KEY_TYPE_reflink_v:
-               return &bkey_i_to_reflink_v(k)->v.refcount;
+               return &bkey_s_to_reflink_v(k).v->refcount;
        case KEY_TYPE_indirect_inline_data:
-               return &bkey_i_to_indirect_inline_data(k)->v.refcount;
+               return &bkey_s_to_indirect_inline_data(k).v->refcount;
        default:
                return NULL;
        }