summaryrefslogtreecommitdiff
path: root/fs/bcachefs/reflink.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-05-23 09:31:33 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:09:05 +0300
commit890b74f03d70946e46f8169c94232fb717f46989 (patch)
tree353c9e2c7cf117149f6c2ad30a8f0c08689d52e1 /fs/bcachefs/reflink.h
parentc0ebe3e48c75ab075eb1c67aef957109c67e1643 (diff)
downloadlinux-890b74f03d70946e46f8169c94232fb717f46989.tar.xz
bcachefs: Fsck for reflink refcounts
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/reflink.h')
-rw-r--r--fs/bcachefs/reflink.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/fs/bcachefs/reflink.h b/fs/bcachefs/reflink.h
index 9d5e7dc58f2b..bfc785619ee8 100644
--- a/fs/bcachefs/reflink.h
+++ b/fs/bcachefs/reflink.h
@@ -34,6 +34,30 @@ void bch2_indirect_inline_data_to_text(struct printbuf *,
.val_to_text = bch2_indirect_inline_data_to_text, \
}
+static inline const __le64 *bkey_refcount_c(struct bkey_s_c k)
+{
+ switch (k.k->type) {
+ case KEY_TYPE_reflink_v:
+ return &bkey_s_c_to_reflink_v(k).v->refcount;
+ case KEY_TYPE_indirect_inline_data:
+ return &bkey_s_c_to_indirect_inline_data(k).v->refcount;
+ default:
+ return NULL;
+ }
+}
+
+static inline __le64 *bkey_refcount(struct bkey_i *k)
+{
+ switch (k->k.type) {
+ case KEY_TYPE_reflink_v:
+ return &bkey_i_to_reflink_v(k)->v.refcount;
+ case KEY_TYPE_indirect_inline_data:
+ return &bkey_i_to_indirect_inline_data(k)->v.refcount;
+ default:
+ return NULL;
+ }
+}
+
s64 bch2_remap_range(struct bch_fs *, struct bpos, struct bpos,
u64, u64 *, u64, s64 *);