]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bcachefs: bch_acct_btree
authorKent Overstreet <kent.overstreet@linux.dev>
Thu, 29 Feb 2024 03:37:21 +0000 (22:37 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 14 Jul 2024 23:00:14 +0000 (19:00 -0400)
Add counters for how much disk space we're using per btree.

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

index caa79e84f2cc3a04631f723346963658a0208164..e4a9bd29e93c83e0ed98d3eae2ea9f44570f9c02 100644 (file)
@@ -798,6 +798,16 @@ static int __trigger_extent(struct btree_trans *trans,
                        return ret;
        }
 
+       if (level) {
+               struct disk_accounting_pos acc_btree_key = {
+                       .type           = BCH_DISK_ACCOUNTING_btree,
+                       .btree.id       = btree_id,
+               };
+               ret = bch2_disk_accounting_mod(trans, &acc_btree_key, &replicas_sectors, 1, gc);
+               if (ret)
+                       return ret;
+       }
+
        return 0;
 }
 
index f980cd5af41dc496bc0b43fd064ad9addbd5133c..ed3b368ea1af27cc58472c630caeeb3e923631da 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "bcachefs.h"
 #include "bcachefs_ioctl.h"
+#include "btree_cache.h"
 #include "btree_journal_iter.h"
 #include "btree_update.h"
 #include "btree_write_buffer.h"
@@ -149,6 +150,9 @@ void bch2_accounting_key_to_text(struct printbuf *out, struct disk_accounting_po
        case BCH_DISK_ACCOUNTING_snapshot:
                prt_printf(out, "id=%u", k->snapshot.id);
                break;
+       case BCH_DISK_ACCOUNTING_btree:
+               prt_printf(out, "btree=%s", bch2_btree_id_str(k->btree.id));
+               break;
        }
 }
 
index 355b8545df88d6143b495feac8eacc657b67bf87..057d82c7e0b149b991e65240663e8adfb6fe81c7 100644 (file)
@@ -101,7 +101,8 @@ static inline bool data_type_is_hidden(enum bch_data_type type)
        x(replicas,             2)              \
        x(dev_data_type,        3)              \
        x(compression,          4)              \
-       x(snapshot,             5)
+       x(snapshot,             5)              \
+       x(btree,                6)
 
 enum disk_accounting_type {
 #define x(f, nr)       BCH_DISK_ACCOUNTING_##f = nr,
@@ -134,6 +135,10 @@ struct bch_acct_snapshot {
        __u32                   id;
 };
 
+struct bch_acct_btree {
+       __u32                   id;
+};
+
 struct disk_accounting_pos {
        union {
        struct {
@@ -146,6 +151,7 @@ struct disk_accounting_pos {
                struct bch_dev_stripe_buckets   dev_stripe_buckets;
                struct bch_acct_compression     compression;
                struct bch_acct_snapshot        snapshot;
+               struct bch_acct_btree           btree;
                };
        };
                struct bpos                     _pad;