1

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>
This commit is contained in:
Kent Overstreet 2024-02-28 22:37:21 -05:00
parent 6675c37662
commit 6af91147b6
3 changed files with 21 additions and 1 deletions

View 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;
}

View 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;
}
}

View 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;