bcachefs: bch2_btree_node_to_text() const correctness
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 6 Mar 2023 07:34:59 +0000 (02:34 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:56 +0000 (17:09 -0400)
This is for the Rust interface - Rust cares more about const than C
does.

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

index a7cb12e..a4c06e8 100644 (file)
@@ -1533,9 +1533,9 @@ struct bkey_s_c bch2_btree_node_iter_peek_unpack(struct btree_node_iter *iter,
 
 /* Mergesort */
 
-void bch2_btree_keys_stats(struct btree *b, struct bset_stats *stats)
+void bch2_btree_keys_stats(const struct btree *b, struct bset_stats *stats)
 {
-       struct bset_tree *t;
+       const struct bset_tree *t;
 
        for_each_bset(b, t) {
                enum bset_aux_tree_type type = bset_aux_tree_type(t);
index 2105e78..632c2b8 100644 (file)
@@ -213,7 +213,7 @@ static inline size_t btree_aux_data_u64s(const struct btree *b)
             _k != btree_bkey_last(_b, _t);                             \
             _k = bkey_p_next(_k))
 
-static inline bool bset_has_ro_aux_tree(struct bset_tree *t)
+static inline bool bset_has_ro_aux_tree(const struct bset_tree *t)
 {
        return bset_aux_tree_type(t) == BSET_RO_AUX_TREE;
 }
@@ -504,7 +504,7 @@ struct bset_stats {
        size_t failed;
 };
 
-void bch2_btree_keys_stats(struct btree *, struct bset_stats *);
+void bch2_btree_keys_stats(const struct btree *, struct bset_stats *);
 void bch2_bfloat_to_text(struct printbuf *, struct btree *,
                         struct bkey_packed *);
 
index 9b331c3..6218a00 100644 (file)
@@ -1150,7 +1150,7 @@ wait_on_io:
 }
 
 void bch2_btree_node_to_text(struct printbuf *out, struct bch_fs *c,
-                            struct btree *b)
+                            const struct btree *b)
 {
        const struct bkey_format *f = &b->format;
        struct bset_stats stats;
@@ -1195,7 +1195,7 @@ void bch2_btree_node_to_text(struct printbuf *out, struct bch_fs *c,
               stats.failed);
 }
 
-void bch2_btree_cache_to_text(struct printbuf *out, struct bch_fs *c)
+void bch2_btree_cache_to_text(struct printbuf *out, const struct bch_fs *c)
 {
        prt_printf(out, "nr nodes:\t\t%u\n", c->btree_cache.used);
        prt_printf(out, "nr dirty:\t\t%u\n", atomic_read(&c->btree_cache.dirty));
index 56ea273..ea375ae 100644 (file)
@@ -100,7 +100,7 @@ static inline unsigned btree_blocks(struct bch_fs *c)
 #define btree_node_root(_c, _b)        ((_c)->btree_roots[(_b)->c.btree_id].b)
 
 void bch2_btree_node_to_text(struct printbuf *, struct bch_fs *,
-                            struct btree *);
-void bch2_btree_cache_to_text(struct printbuf *, struct bch_fs *);
+                            const struct btree *);
+void bch2_btree_cache_to_text(struct printbuf *, const struct bch_fs *);
 
 #endif /* _BCACHEFS_BTREE_CACHE_H */