summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/backpointers.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-01-16 00:08:32 +0100
committerKent Overstreet <kent.overstreet@linux.dev>2024-01-21 19:27:09 +0100
commitba96d36ca526f99b163927115abfec36ef5565e0 (patch)
tree44685458a4378233a757e8fc31d7983cf0cb0924 /fs/bcachefs/backpointers.c
parentbcachefs: Better journal tracepoints (diff)
downloadlinux-ba96d36ca526f99b163927115abfec36ef5565e0.tar.xz
linux-ba96d36ca526f99b163927115abfec36ef5565e0.zip
bcachefs: bkey_and_val_eq()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to '')
-rw-r--r--fs/bcachefs/backpointers.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/bcachefs/backpointers.c b/fs/bcachefs/backpointers.c
index e358a2ffffde..56e5a0e213f9 100644
--- a/fs/bcachefs/backpointers.c
+++ b/fs/bcachefs/backpointers.c
@@ -400,6 +400,13 @@ int bch2_check_btree_backpointers(struct bch_fs *c)
return ret;
}
+static inline bool bkey_and_val_eq(struct bkey_s_c l, struct bkey_s_c r)
+{
+ return bpos_eq(l.k->p, r.k->p) &&
+ bkey_bytes(l.k) == bkey_bytes(r.k) &&
+ !memcmp(l.v, r.v, bkey_val_bytes(l.k));
+}
+
static int check_bp_exists(struct btree_trans *trans,
struct bpos bucket,
struct bch_backpointer bp,
@@ -433,9 +440,7 @@ static int check_bp_exists(struct btree_trans *trans,
if (bp_k.k->type != KEY_TYPE_backpointer ||
memcmp(bkey_s_c_to_backpointer(bp_k).v, &bp, sizeof(bp))) {
- if (!bpos_eq(orig_k.k->p, last_flushed->k->k.p) ||
- bkey_bytes(orig_k.k) != bkey_bytes(&last_flushed->k->k) ||
- memcmp(orig_k.v, &last_flushed->k->v, bkey_val_bytes(orig_k.k))) {
+ if (!bkey_and_val_eq(orig_k, bkey_i_to_s_c(last_flushed->k))) {
bch2_bkey_buf_reassemble(&tmp, c, orig_k);
if (bp.level) {