summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_gc.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-03-05 00:20:16 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:08:57 +0300
commit4cf91b0270dc16a6637db4c200c7fb745b941065 (patch)
tree4efb82acf29d4919bd9a384c38eb05886160b915 /fs/bcachefs/btree_gc.h
parent43d002432dbb093b2155ebce7f12f79b844817f1 (diff)
downloadlinux-4cf91b0270dc16a6637db4c200c7fb745b941065.tar.xz
bcachefs: Split out bpos_cmp() and bkey_cmp()
With snapshots, we're going to need to differentiate between comparisons that should and shouldn't include the snapshot field. bpos_cmp is now the comparison function that does include the snapshot field, used by core btree code. Upper level filesystem code generally does _not_ want to compare against the snapshot field - that code wants keys to compare as equal even when one of them is in an ancestor snapshot. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_gc.h')
-rw-r--r--fs/bcachefs/btree_gc.h10
1 files changed, 3 insertions, 7 deletions
diff --git a/fs/bcachefs/btree_gc.h b/fs/bcachefs/btree_gc.h
index d5559827ed7f..44b7d121610f 100644
--- a/fs/bcachefs/btree_gc.h
+++ b/fs/bcachefs/btree_gc.h
@@ -45,13 +45,9 @@ static inline struct gc_pos gc_phase(enum gc_phase phase)
static inline int gc_pos_cmp(struct gc_pos l, struct gc_pos r)
{
- if (l.phase != r.phase)
- return l.phase < r.phase ? -1 : 1;
- if (bkey_cmp(l.pos, r.pos))
- return bkey_cmp(l.pos, r.pos);
- if (l.level != r.level)
- return l.level < r.level ? -1 : 1;
- return 0;
+ return cmp_int(l.phase, r.phase) ?:
+ bpos_cmp(l.pos, r.pos) ?:
+ cmp_int(l.level, r.level);
}
static inline enum gc_phase btree_id_to_gc_phase(enum btree_id id)