Add counters for how much disk space we're using per btree.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
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;
}
#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"
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;
}
}
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,
__u32 id;
};
+struct bch_acct_btree {
+ __u32 id;
+};
+
struct disk_accounting_pos {
union {
struct {
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;