bcachefs: bkey_copy() is no longer a macro
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 2 Nov 2023 23:33:48 +0000 (19:33 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 5 Nov 2023 18:12:18 +0000 (13:12 -0500)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/bkey.h
fs/bcachefs/bkey_sort.c
fs/bcachefs/btree_io.c
fs/bcachefs/btree_update_interior.h

index 5184502092369d963f076383ee9bf3ca5a358f6c..831be01809f2c9271d4db159377decd1b8686bb6 100644 (file)
@@ -92,19 +92,15 @@ enum bkey_lr_packed {
 #define bkey_lr_packed(_l, _r)                                         \
        ((_l)->format + ((_r)->format << 1))
 
-#define bkey_copy(_dst, _src)                                  \
-do {                                                           \
-       BUILD_BUG_ON(!type_is(_dst, struct bkey_i *) &&         \
-                    !type_is(_dst, struct bkey_packed *));     \
-       BUILD_BUG_ON(!type_is(_src, struct bkey_i *) &&         \
-                    !type_is(_src, struct bkey_packed *));     \
-       EBUG_ON((u64 *) (_dst) > (u64 *) (_src) &&              \
-               (u64 *) (_dst) < (u64 *) (_src) +               \
-               ((struct bkey *) (_src))->u64s);                \
-                                                               \
-       memcpy_u64s_small((_dst), (_src),                       \
-                         ((struct bkey *) (_src))->u64s);      \
-} while (0)
+static inline void bkey_p_copy(struct bkey_packed *dst, const struct bkey_packed *src)
+{
+       memcpy_u64s_small(dst, src, src->u64s);
+}
+
+static inline void bkey_copy(struct bkey_i *dst, const struct bkey_i *src)
+{
+       memcpy_u64s_small(dst, src, src->k.u64s);
+}
 
 struct btree;
 
index b9aa027c881b14458394ae8fdad6d93f53e1cbbf..bcca9e76a0b4bf40f20903c856e7559e60b87da1 100644 (file)
@@ -106,7 +106,7 @@ bch2_key_sort_fix_overlapping(struct bch_fs *c, struct bset *dst,
        while ((k = sort_iter_peek(iter))) {
                if (!bkey_deleted(k) &&
                    !should_drop_next_key(iter)) {
-                       bkey_copy(out, k);
+                       bkey_p_copy(out, k);
                        btree_keys_account_key_add(&nr, 0, out);
                        out = bkey_p_next(out);
                }
@@ -137,7 +137,7 @@ bch2_sort_repack(struct bset *dst, struct btree *src,
                        continue;
 
                if (!transform)
-                       bkey_copy(out, in);
+                       bkey_p_copy(out, in);
                else if (bch2_bkey_transform(out_f, out, bkey_packed(in)
                                             ? in_f : &bch2_bkey_format_current, in))
                        out->format = KEY_FORMAT_LOCAL_BTREE;
@@ -191,7 +191,7 @@ unsigned bch2_sort_keys(struct bkey_packed *dst,
                        memcpy_u64s_small(out, in, bkeyp_key_u64s(f, in));
                        set_bkeyp_val_u64s(f, out, 0);
                } else {
-                       bkey_copy(out, in);
+                       bkey_p_copy(out, in);
                }
                out->needs_whiteout |= needs_whiteout;
                out = bkey_p_next(out);
index 4d2d6f93500d22008a1ce031b134494c52812212..37d896edb06e0475cc7146e31a2790321f842394 100644 (file)
@@ -184,7 +184,7 @@ static void bch2_sort_whiteouts(struct bch_fs *c, struct btree *b)
        k = new_whiteouts;
 
        while (ptrs != ptrs_end) {
-               bkey_copy(k, *ptrs);
+               bkey_p_copy(k, *ptrs);
                k = bkey_p_next(k);
                ptrs++;
        }
@@ -260,7 +260,7 @@ static bool bch2_drop_whiteouts(struct btree *b, enum compact_mode mode)
                        n = bkey_p_next(k);
 
                        if (!bkey_deleted(k)) {
-                               bkey_copy(out, k);
+                               bkey_p_copy(out, k);
                                out = bkey_p_next(out);
                        } else {
                                BUG_ON(k->needs_whiteout);
index d92b3cf5f5e0f26b823d32a8719bf0f879cf994b..c2ffeb30884d795ebbdcdc08f7804c1803779352 100644 (file)
@@ -303,7 +303,7 @@ static inline void push_whiteout(struct bch_fs *c, struct btree *b,
        k.needs_whiteout = true;
 
        b->whiteout_u64s += k.u64s;
-       bkey_copy(unwritten_whiteouts_start(c, b), &k);
+       bkey_p_copy(unwritten_whiteouts_start(c, b), &k);
 }
 
 /*