bcachefs: Inline fast path of check_pos_snapshot_overwritten()
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 26 Sep 2022 22:13:29 +0000 (18:13 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:42 +0000 (17:09 -0400)
This moves the slowpath of check_pos_snapshot_overwritten() to a
separate function, and inlines the fast path - helping performance on
btrees that don't use snapshot and for users that aren't using
snapshots.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_update_leaf.c

index ad46c887185b9ff09f5266382e92ada26d2aa6ab..31b60864b6da85a3bf8d86d29947dc6c35b080c1 100644 (file)
@@ -1113,7 +1113,7 @@ err:
        goto retry;
 }
 
-static int check_pos_snapshot_overwritten(struct btree_trans *trans,
+static noinline int __check_pos_snapshot_overwritten(struct btree_trans *trans,
                                          enum btree_id id,
                                          struct bpos pos)
 {
@@ -1122,12 +1122,6 @@ static int check_pos_snapshot_overwritten(struct btree_trans *trans,
        struct bkey_s_c k;
        int ret;
 
-       if (!btree_type_has_snapshots(id))
-               return 0;
-
-       if (!snapshot_t(c, pos.snapshot)->children[0])
-               return 0;
-
        bch2_trans_iter_init(trans, &iter, id, pos,
                             BTREE_ITER_NOT_EXTENTS|
                             BTREE_ITER_ALL_SNAPSHOTS);
@@ -1153,6 +1147,18 @@ static int check_pos_snapshot_overwritten(struct btree_trans *trans,
        return ret;
 }
 
+static inline int check_pos_snapshot_overwritten(struct btree_trans *trans,
+                                         enum btree_id id,
+                                         struct bpos pos)
+{
+       if (!btree_type_has_snapshots(id) ||
+           pos.snapshot == U32_MAX ||
+           !snapshot_t(trans->c, pos.snapshot)->children[0])
+               return 0;
+
+       return __check_pos_snapshot_overwritten(trans, id, pos);
+}
+
 static noinline int extent_front_merge(struct btree_trans *trans,
                                       struct btree_iter *iter,
                                       struct bkey_s_c k,