bmap: Initial scaffolding for on-disk block map

This is pretty exploratory work, so I'm going to try to be less thorough
in commit messages until the dust settles.

---

New tag for gbmapdelta:

  LFS3_TAG_GBMAPDELTA   0x0104  v--- ---1 ---- -1rr

New tags for in-bmap block types:

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

New gstate decoding for gbmap:

  .---+- -+- -+- -+- -. cursor: 1 leb128  <=5 bytes
  | cursor            | known:  1 leb128  <=5 bytes
  +---+- -+- -+- -+- -+ block:  1 leb128  <=5 bytes
  | known             | trunk:  1 leb128  <=4 bytes
  +---+- -+- -+- -+- -+ cksum:  1 le32    4 bytes
  | block             | total:            23 bytes
  +---+- -+- -+- -+- -'
  | trunk         |
  +---+- -+- -+- -+
  |     cksum     |
  '---+---+---+---'

New bmap node revdbg string:

  vvv---- -111111- -11---1- -11---1-  (62 62 7e v0  bb~r)  bmap node

New mount/format/info flags (still unsure about these):

  LFS3_M_BMAPMODE     0x03000000  On-disk block map mode
  LFS3_M_BMAPNONE     0x00000000  Don't use the bmap
  LFS3_M_BMAPCACHE    0x01000000  Use the bmap to cache lookahead scans
  LFS3_M_BMAPSLOW     0x02000000  Use the slow bmap algorithm
  LFS3_M_BMAPFAST     0x03000000  Use the fast bmap algorithm

New gbmap wcompat flag:

  LFS3_WCOMPAT_GBMAP  0x00002000  Global block-map in use
This commit is contained in:
Christopher Haster
2025-07-23 15:32:35 -05:00
parent 238dbc705d
commit 88180b6081
13 changed files with 755 additions and 58 deletions
+29
View File
@@ -47,6 +47,9 @@
#ifndef LFS3_GC
#define LFS3_GC
#endif
#ifndef LFS3_BMAP
#define LFS3_BMAP
#endif
#endif
// LFS3_YES_* variants imply the relevant LFS3_* macro
@@ -80,6 +83,26 @@
#ifdef LFS3_YES_GC
#define LFS3_GC
#endif
#ifdef LFS3_YES_BMAP
#define LFS3_BMAP
#endif
// TODO is this the best way to structure this?
// LFS3_BMAP mappings
//
// LFS3_YES_BMAP => LFS3_YES_BMAPFAST
#ifdef LFS3_YES_BMAP
#ifndef LFS3_YES_BMAPFAST
#define LFS3_YES_BMAPFAST
#endif
#endif
// LFS3_YES_BMAP* => LFS3_BMAP
#if defined(LFS3_YES_BMAPFAST) \
|| defined(LFS3_YES_BMAPSLOW) \
|| defined(LFS3_YES_BMAPCACHE) \
|| defined(LFS3_YES_BMAPNONE)
#define LFS3_BMAP
#endif
// LFS3_NO_LOG disables all logging macros
#ifdef LFS3_NO_LOG
@@ -257,6 +280,12 @@
#define LFS3_IFDEF_GC(a, b) (b)
#endif
#ifdef LFS3_BMAP
#define LFS3_IFDEF_BMAP(a, b) (a)
#else
#define LFS3_IFDEF_BMAP(a, b) (b)
#endif
// Some function attributes, no way around these