bcachefs: BKEY_PADDED_ONSTACK()
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 5 Mar 2023 03:36:02 +0000 (22:36 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:55 +0000 (17:09 -0400)
Rust bindgen doesn't do anonymous structs very nicely: BKEY_PADDED()
only needs the anonymous struct when it's used on the stack, to
guarantee layout, not when it's embedded in another struct.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/bcachefs.h
fs/bcachefs/bcachefs_format.h
fs/bcachefs/btree_io.c
fs/bcachefs/btree_update_interior.c

index 509a164696131adcdb6d901839d01684a42b2fbf..baaa4cd3caa790b9e6dfbe0c51d274581622ab46 100644 (file)
@@ -1123,4 +1123,7 @@ static inline bool bch2_dev_exists2(const struct bch_fs *c, unsigned dev)
        return dev < c->sb.nr_devices && c->devs[dev];
 }
 
+#define BKEY_PADDED_ONSTACK(key, pad)                          \
+       struct { struct bkey_i key; __u64 key ## _pad[pad]; }
+
 #endif /* _BCACHEFS_H */
index 4d3c5e2f7ea6815afbc619c2cad2a623d9258e17..f5587ed7dfd2c8e090f2cdfa3f83b2ddc43d5fc2 100644 (file)
@@ -322,7 +322,7 @@ static inline void bkey_init(struct bkey *k)
 #define bkey_bytes(_k)         ((_k)->u64s * sizeof(__u64))
 
 #define __BKEY_PADDED(key, pad)                                        \
-       struct { struct bkey_i key; __u64 key ## _pad[pad]; }
+       struct bkey_i key; __u64 key ## _pad[pad]
 
 /*
  * - DELETED keys are used internally to mark keys that should be ignored but
index 358a285c3bcfed8546b4ea7e20789584cb668170..159a97596052a3b967c27f603049a94c9a3312f8 100644 (file)
@@ -1847,7 +1847,7 @@ static void btree_write_submit(struct work_struct *work)
 {
        struct btree_write_bio *wbio = container_of(work, struct btree_write_bio, work);
        struct bch_extent_ptr *ptr;
-       __BKEY_PADDED(k, BKEY_BTREE_PTR_VAL_U64s_MAX) tmp;
+       BKEY_PADDED_ONSTACK(k, BKEY_BTREE_PTR_VAL_U64s_MAX) tmp;
 
        bkey_copy(&tmp.k, &wbio->key);
 
index bce6a9d7795c1057ff67ece94aaea100f88b9cbc..9e77d2e3b421aebbc769b083aa2d32218f6f4c33 100644 (file)
@@ -242,7 +242,7 @@ static struct btree *__bch2_btree_node_alloc(struct btree_trans *trans,
        struct bch_fs *c = trans->c;
        struct write_point *wp;
        struct btree *b;
-       __BKEY_PADDED(k, BKEY_BTREE_PTR_VAL_U64s_MAX) tmp;
+       BKEY_PADDED_ONSTACK(k, BKEY_BTREE_PTR_VAL_U64s_MAX) tmp;
        struct open_buckets ob = { .nr = 0 };
        struct bch_devs_list devs_have = (struct bch_devs_list) { 0 };
        unsigned nr_reserve;