Skip to content

Commit 3a1a22a

Browse files
intelfxbehlendorf
authored andcommitted
zdb: factor out block histogram bin number computation
Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ivan Shapovalov <[email protected]> Closes #16999
1 parent c0a874f commit 3a1a22a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

cmd/zdb/zdb.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6254,35 +6254,39 @@ 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)
6258+
62576259
switch (block_bin_mode) {
6258-
case BIN_PSIZE: bin = highbit64(BP_GET_PSIZE(bp)) - 1; break;
6259-
case BIN_LSIZE: bin = highbit64(BP_GET_LSIZE(bp)) - 1; break;
6260-
case BIN_ASIZE: bin = highbit64(BP_GET_ASIZE(bp)) - 1; break;
6260+
case BIN_PSIZE: bin = BIN(BP_GET_PSIZE(bp)); break;
6261+
case BIN_LSIZE: bin = BIN(BP_GET_LSIZE(bp)); break;
6262+
case BIN_ASIZE: bin = BIN(BP_GET_ASIZE(bp)); break;
62616263
case BIN_AUTO: break;
62626264
default: PANIC("bad block_bin_mode"); abort();
62636265
}
62646266

62656267
if (block_bin_mode == BIN_AUTO)
6266-
bin = highbit64(BP_GET_PSIZE(bp)) - 1;
6268+
bin = BIN(BP_GET_PSIZE(bp));
62676269

62686270
zcb->zcb_psize_count[bin]++;
62696271
zcb->zcb_psize_len[bin] += BP_GET_PSIZE(bp);
62706272
zcb->zcb_psize_total += BP_GET_PSIZE(bp);
62716273

62726274
if (block_bin_mode == BIN_AUTO)
6273-
bin = highbit64(BP_GET_LSIZE(bp)) - 1;
6275+
bin = BIN(BP_GET_LSIZE(bp));
62746276

62756277
zcb->zcb_lsize_count[bin]++;
62766278
zcb->zcb_lsize_len[bin] += BP_GET_LSIZE(bp);
62776279
zcb->zcb_lsize_total += BP_GET_LSIZE(bp);
62786280

62796281
if (block_bin_mode == BIN_AUTO)
6280-
bin = highbit64(BP_GET_ASIZE(bp)) - 1;
6282+
bin = BIN(BP_GET_ASIZE(bp));
62816283

62826284
zcb->zcb_asize_count[bin]++;
62836285
zcb->zcb_asize_len[bin] += BP_GET_ASIZE(bp);
62846286
zcb->zcb_asize_total += BP_GET_ASIZE(bp);
62856287

6288+
#undef BIN
6289+
62866290
hist_skipped:
62876291
if (!do_claim)
62886292
return;

0 commit comments

Comments
 (0)