Skip to content

Commit f8b082b

Browse files
intelfxbehlendorf
authored andcommitted
zdb: adjust block histogram binning strategy
Previously, a bin included all blocks _starting_ from given size (e.g., a "4K" bin would include all blocks within the [4K; 8K) region). This is counter-intuitive and does not match the typical use-case of the block histogram (that is, to estimate disk usage considering how ZFS' block allocation works). In other words, if I'm looking at the "4K" row, I'm interested in records that _fit into_ a 4K block. Adjust the binning strategy such that a bin includes all blocks _up to_ given size, such that e.g. a "4K" bin would include all blocks within the (2K; 4K] region. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ivan Shapovalov <[email protected]> Closes #16999
1 parent 3a1a22a commit f8b082b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cmd/zdb/zdb.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6254,7 +6254,12 @@ zdb_count_block(zdb_cb_t *zcb, zilog_t *zilog, const blkptr_t *bp,
62546254
*/
62556255
int bin;
62566256

6257-
#define BIN(size) (highbit64(size) - 1)
6257+
/*
6258+
* Binning strategy: each bin includes blocks up to and including
6259+
* the given size (excluding blocks that fit into the previous bin).
6260+
* This way, the "4K" bin includes blocks within the (2K; 4K] range.
6261+
*/
6262+
#define BIN(size) (highbit64((size) - 1))
62586263

62596264
switch (block_bin_mode) {
62606265
case BIN_PSIZE: bin = BIN(BP_GET_PSIZE(bp)); break;

0 commit comments

Comments
 (0)