diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2024-06-03 19:33:03 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-06-03 20:08:06 -0400 |
commit | 0916d3866454cc6f67cf4ea52cb79e9455138f7a (patch) | |
tree | 408caf3571a44a22b07ba5575d3d0dc9116ea38d /c_src/libbcachefs.h | |
parent | da5435b0ccdc9ac5c1933f3a36e7556e77c0bf1a (diff) |
cmd_fs_usage: Use now BCH_IOCTL_QUERY_ACCOUNTING
We can now report on compression type/ratio, btree usage, and pending
rebalance work.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'c_src/libbcachefs.h')
-rw-r--r-- | c_src/libbcachefs.h | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/c_src/libbcachefs.h b/c_src/libbcachefs.h index 05720573..5c7ef6c7 100644 --- a/c_src/libbcachefs.h +++ b/c_src/libbcachefs.h @@ -168,6 +168,35 @@ static inline struct bch_ioctl_fs_usage *bchu_fs_usage(struct bchfs_handle fs) } } +static inline struct bch_ioctl_query_accounting *bchu_fs_accounting(struct bchfs_handle fs, + unsigned typemask) +{ + unsigned accounting_u64s = 128; + struct bch_ioctl_query_accounting *ret = NULL; + + while (1) { + ret = xrealloc(ret, sizeof(*ret) + accounting_u64s * sizeof(u64)); + + memset(ret, 0, sizeof(*ret)); + + ret->accounting_u64s = accounting_u64s; + ret->accounting_types_mask = typemask; + + if (!ioctl(fs.ioctl_fd, BCH_IOCTL_QUERY_ACCOUNTING, ret)) + return ret; + + if (errno == ENOTTY) + return NULL; + + if (errno == ERANGE) { + accounting_u64s *= 2; + continue; + } + + die("BCH_IOCTL_USAGE error: %m"); + } +} + static inline struct bch_ioctl_dev_usage_v2 *bchu_dev_usage(struct bchfs_handle fs, unsigned idx) { |