bmap: Tweaked bmap ranges, dropped in-flight tag for now

New bmap range tags:

  LFS3_TAG_BMRANGE      0x033u  v--- --11 --11 uuuu
  LFS3_TAG_BMFREE       0x0330  v--- --11 --11 ----
  LFS3_TAG_BMINUSE      0x0331  v--- --11 --11 ---1
  LFS3_TAG_BMERASED     0x0332  v--- --11 --11 --1-
  LFS3_TAG_BMBAD        0x0333  v--- --11 --11 --11

Note 0x334-0x33f are still reserved for future bmap tags, but the new
encoding fits in the surprisingly common 2-bit subfield that may
deduplicate some decoding code.

Fitting in 2-bits is the main reason for this, now that in-flight ranges
look like they won't be worth exploring further. Worst case we can
always add more bm tags in the future. And it may even make sense to use
an entire bit for in-flight tags, since in theory the concept can apply
to more than just in-use blocks.

---

Another benefit of this encoding: In-use vs free is a bit check, and I
like the implication that an in-use + erased block can only be a bad
block.

No code changes:

                code          stack          ctx
  before:      37172           2352          684
  after:       37172 (+0.0%)   2352 (+0.0%)  684 (+0.0%)

                code          stack          ctx
  bmap before: 38844           2456          800
  bmap after:  38844 (+0.0%)   2456 (+0.0%)  800 (+0.0%)
This commit is contained in:
Christopher Haster
2025-10-04 12:49:39 -05:00
parent 43a6053d5e
commit e622656538
9 changed files with 29 additions and 44 deletions
+3 -5
View File
@@ -51,10 +51,9 @@ TAG_MDIR = 0x0325 # 0x0324 v--- --11 --1- -1rr
TAG_MTREE = 0x032c # 0x032c v--- --11 --1- 11rr
TAG_BMRANGE = 0x0330 # 0x033u v--- --11 --11 uuuu
TAG_BMFREE = 0x0330 # 0x0330 v--- --11 --11 ----
TAG_BMINFLIGHT = 0x0331 # 0x0331 v--- --11 --11 ---1
TAG_BMINUSE = 0x0332 # 0x0332 v--- --11 --11 --1-
TAG_BMINUSE = 0x0331 # 0x0331 v--- --11 --11 ---1
TAG_BMERASED = 0x0332 # 0x0332 v--- --11 --11 --1-
TAG_BMBAD = 0x0333 # 0x0333 v--- --11 --11 --11
TAG_BMERASED = 0x0334 # 0x0334 v--- --11 --11 -1--
TAG_ATTR = 0x0400 ## 0x04aa v--- -1-a -aaa aaaa
TAG_UATTR = 0x0400 # 0x04aa v--- -1-- -aaa aaaa
TAG_SATTR = 0x0500 # 0x05aa v--- -1-1 -aaa aaaa
@@ -305,10 +304,9 @@ def tagrepr(tag, weight=None, size=None, *,
else 'mdir' if (tag & 0xfff) == TAG_MDIR
else 'mtree' if (tag & 0xfff) == TAG_MTREE
else 'bmfree' if (tag & 0xfff) == TAG_BMFREE
else 'bminflight' if (tag & 0xfff) == TAG_BMINFLIGHT
else 'bminuse' if (tag & 0xfff) == TAG_BMINUSE
else 'bmbad' if (tag & 0xfff) == TAG_BMBAD
else 'bmerased' if (tag & 0xfff) == TAG_BMERASED
else 'bmbad' if (tag & 0xfff) == TAG_BMBAD
else 'bmrange 0x%x' % (tag & 0xf)
if (tag & 0xff0) == TAG_BMRANGE
else 'struct 0x%02x' % (tag & 0xff),