scripts: dbgbmap[d3].py: Reverted percentages to entire bmap

So percentages now include unused blocks, instead of being derived from
only blocks in use.

This is a bit inconsistent with tracebd.py, where we show ops as
percentages of all ops, but it's more useful:

- mdir+btree+data gives you the total usage, which is useful if you want
  to know how full disk is. You can't get this info from in-use
  percentages.

  Note that total field is sticking around, so you can show the total
  usage directly if you provide your own title string:

    $ ./scripts/dbgbmap.py disk \
        --title="bd %(block_size)sx%(block_count)s, %(total_percent)s"

- You can derive the in-use percentages from total percentages if you
  need them: in-use-mdir = mdir/(mdir+btree+data).

  Maybe this should be added to the --title fields, but I can't think of
  a good name at the moment...

Attempting to make tracebd.py consistent with dbgbmap.py doesn't really
make sense either: Showing op percentages of total bmap will usually be
an extremely small number.

At least dbgbmap.py is consistent with tracebd.py's --wear percentage,
which is out of all erase state in the bmap.
This commit is contained in:
Christopher Haster
2025-04-10 13:26:33 -05:00
parent 465fdd1fca
commit edc6c7ec99
3 changed files with 31 additions and 31 deletions

View File

@@ -4724,15 +4724,17 @@ def main_(f, disk, mroots=None, *,
lfs.cksum,
'' if lfs.ckgcksum() else '?'),
'total': total_count,
'total_percent': '%.1f%%' % (
100*total_count / max(len(bmap), 1)),
'mdir': mdir_count,
'mdir_percent': '%.1f%%' % (
100*(mdir_count / max(total_count, 1))),
100*mdir_count / max(len(bmap), 1)),
'btree': btree_count,
'btree_percent': '%.1f%%' % (
100*(btree_count / max(total_count, 1))),
100*btree_count / max(len(bmap), 1)),
'data': data_count,
'data_percent': '%.1f%%' % (
100*(data_count / max(total_count, 1))),
100*data_count / max(len(bmap), 1)),
}))
elif title_littlefs:
f.writeln('littlefs%s v%s.%s %sx%s %s w%s.%s, cksum %08x%s' % (
@@ -4749,9 +4751,9 @@ def main_(f, disk, mroots=None, *,
f.writeln('bd %sx%s, %6s mdir, %6s btree, %6s data' % (
lfs.block_size if lfs.block_size is not None else '?',
lfs.block_count if lfs.block_count is not None else '?',
'%.1f%%' % (100*(mdir_count / max(total_count, 1))),
'%.1f%%' % (100*(btree_count / max(total_count, 1))),
'%.1f%%' % (100*(data_count / max(total_count, 1)))))
'%.1f%%' % (100*mdir_count / max(len(bmap), 1)),
'%.1f%%' % (100*btree_count / max(len(bmap), 1)),
'%.1f%%' % (100*data_count / max(len(bmap), 1))))
# draw canvas
for row in range(canvas.height//canvas.yscale):