diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-02-29 04:37:21 +0100 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-07-15 01:00:14 +0200 |
commit | 6af91147b6b90552cdf1dd400eeb9da66920f3ce (patch) | |
tree | 3d9f5d24b1a060094fbcd95c06ddfd77a93c692e /fs | |
parent | bcachefs: bch_acct_snapshot (diff) | |
download | linux-6af91147b6b90552cdf1dd400eeb9da66920f3ce.tar.xz linux-6af91147b6b90552cdf1dd400eeb9da66920f3ce.zip |
bcachefs: bch_acct_btree
Add counters for how much disk space we're using per btree.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/buckets.c | 10 | ||||
-rw-r--r-- | fs/bcachefs/disk_accounting.c | 4 | ||||
-rw-r--r-- | fs/bcachefs/disk_accounting_format.h | 8 |
3 files changed, 21 insertions, 1 deletions
diff --git a/fs/bcachefs/buckets.c b/fs/bcachefs/buckets.c index caa79e84f2cc..e4a9bd29e93c 100644 --- a/fs/bcachefs/buckets.c +++ b/fs/bcachefs/buckets.c @@ -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; } diff --git a/fs/bcachefs/disk_accounting.c b/fs/bcachefs/disk_accounting.c index f980cd5af41d..ed3b368ea1af 100644 --- a/fs/bcachefs/disk_accounting.c +++ b/fs/bcachefs/disk_accounting.c @@ -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; } } diff --git a/fs/bcachefs/disk_accounting_format.h b/fs/bcachefs/disk_accounting_format.h index 355b8545df88..057d82c7e0b1 100644 --- a/fs/bcachefs/disk_accounting_format.h +++ b/fs/bcachefs/disk_accounting_format.h @@ -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; |