Reorganized traversal flags again

One nice thing about merging LOOKAHEAD + LOOKGBMAP, is now our core
traversal flags fit in a single byte. This is useful for organizing
things, especially so as the traversal flags seem to permeate into
basically every flag set.

The main change was to actually group these flags into a byte, which
helps readability and in theory could make some bulk accesses cheaper
(in practice I don't think we currently leverage this):

  T_MODE             0x00000001  ---- ---- ---- ---- ---- ---- ---- ---1
  T_RDONLY           0x00000000  ---- ---- ---- ---- ---- ---- ---- ----
  T_RDWR             0x00000001  ---- ---- ---- ---- ---- ---- ---- ---1
  T_MTREEONLY        0x00000002  ---- ---- ---- ---- ---- ---- ---- --1-
  T_EXCL             0x00000008  ---- ---- ---- ---- ---- ---- ---- 1---
  T_MKCONSISTENT     0x00000100  ---- ---- ---- ---- ---- ---1 ---- ----
  T_LOOKAHEAD        0x00000200  ---- ---- ---- ---- ---- --1- ---- ----
  T_PREERASE*        0x00000400  ---- ---- ---- ---- ---- -1-- ---- ----
  T_COMPACT          0x00000800  ---- ---- ---- ---- ---- 1--- ---- ----
  T_CKMETA           0x00001000  ---- ---- ---- ---- ---1 ---- ---- ----
  T_CKDATA           0x00002000  ---- ---- ---- ---- --1- ---- ---- ----
  T_REPAIRMETA*      0x00004000  ---- ---- ---- ---- -1-- ---- ---- ----
  T_REPAIRDATA*      0x00008000  ---- ---- ---- ---- 1--- ---- ---- ----

  t_EVICT*           0x00000010  ---- ---- ---- ---- ---- ---- ---1 ----
  t_TYPE             0xf0000000  1111 ---- ---- ---- ---- ---- ---- ----
  t_ZOMBIE           0x08000000  ---- 1--- ---- ---- ---- ---- ---- ----
  t_CKPOINTED        0x04000000  ---- -1-- ---- ---- ---- ---- ---- ----
  t_DIRTY            0x02000000  ---- --1- ---- ---- ---- ---- ---- ----
  t_STALE            0x01000000  ---- ---1 ---- ---- ---- ---- ---- ----
  t_BTYPE            0x00ff0000  ---- ---- 1111 1111 ---- ---- ---- ----

  * Planned

This gives btype a full byte as well, which is a bit overkill, but can
be reduced in the future if we run into traversal flag pressure.

This also pushes some future planned flags (DEDUP, COMPR, etc) into
higher-order bits, but that's not the end of the world.

Code changes basically nothing:

                 code          stack          ctx
  before:       35152           2136          660
  after:        35152 (+0.0%)   2136 (+0.0%)  660 (+0.0%)

                 code          stack          ctx
  gbmap before: 38080           2136          776
  gbmap after:  38076 (-0.0%)   2136 (+0.0%)  776 (+0.0%)
This commit is contained in:
Christopher Haster
2025-12-05 01:19:35 -06:00
parent 7a57b1e2bd
commit d54fef8099
3 changed files with 71 additions and 71 deletions
+2 -2
View File
@@ -7255,11 +7255,11 @@ static inline bool lfs3_t_isckdata(uint32_t flags) {
// internal traversal flags
static inline uint8_t lfs3_t_btype(uint32_t flags) {
return (flags >> 20) & 0xf;
return (flags >> 16) & 0xff;
}
static inline uint32_t lfs3_t_btypeflags(uint8_t btype) {
return (uint32_t)btype << 20;
return (uint32_t)btype << 16;
}
static inline void lfs3_t_setbtype(uint32_t *flags, uint8_t btype) {
+33 -33
View File
@@ -140,8 +140,8 @@ enum lfs3_type {
#define LFS3_O_FLUSH 0x00000040 // Flush data on every write
#define LFS3_O_SYNC 0x00000080 // Sync metadata on every write
#define LFS3_O_DESYNC 0x00100000 // Do not sync or recieve file updates
#define LFS3_O_CKMETA 0x00010000 // Check metadata checksums
#define LFS3_O_CKDATA 0x00020000 // Check metadata + data checksums
#define LFS3_O_CKMETA 0x00001000 // Check metadata checksums
#define LFS3_O_CKDATA 0x00002000 // Check metadata + data checksums
// internally used flags, don't use these
#define LFS3_o_WRSET 3 // Open a file as an atomic write
@@ -202,20 +202,20 @@ enum lfs3_type {
#endif
#ifndef LFS3_RDONLY
#define LFS3_F_MKCONSISTENT \
0x00000800 // Make the filesystem consistent
0x00000100 // Make the filesystem consistent
#endif
#ifndef LFS3_RDONLY
#define LFS3_F_LOOKAHEAD \
0x00001000 // Repopulate lookahead/gbmap
0x00000200 // Repopulate lookahead/gbmap
#endif
#ifndef LFS3_RDONLY
#define LFS3_F_COMPACT 0x00008000 // Compact metadata logs
#define LFS3_F_COMPACT 0x00000800 // Compact metadata logs
#endif
#ifndef LFS3_RDONLY
#define LFS3_F_CKMETA 0x00010000 // Check metadata checksums
#define LFS3_F_CKMETA 0x00001000 // Check metadata checksums
#endif
#ifndef LFS3_RDONLY
#define LFS3_F_CKDATA 0x00020000 // Check metadata + data checksums
#define LFS3_F_CKDATA 0x00002000 // Check metadata + data checksums
#endif
// Filesystem mount flags
@@ -249,17 +249,17 @@ enum lfs3_type {
#endif
#ifndef LFS3_RDONLY
#define LFS3_M_MKCONSISTENT \
0x00000800 // Make the filesystem consistent
0x00000100 // Make the filesystem consistent
#endif
#ifndef LFS3_RDONLY
#define LFS3_M_LOOKAHEAD \
0x00001000 // Repopulate lookahead/gbmap
0x00000200 // Repopulate lookahead/gbmap
#endif
#ifndef LFS3_RDONLY
#define LFS3_M_COMPACT 0x00008000 // Compact metadata logs
#define LFS3_M_COMPACT 0x00000800 // Compact metadata logs
#endif
#define LFS3_M_CKMETA 0x00010000 // Check metadata checksums
#define LFS3_M_CKDATA 0x00020000 // Check metadata + data checksums
#define LFS3_M_CKMETA 0x00001000 // Check metadata checksums
#define LFS3_M_CKDATA 0x00002000 // Check metadata + data checksums
// Filesystem info flags
#define LFS3_I_RDONLY 0x00000001 // Mounted read only
@@ -291,17 +291,17 @@ enum lfs3_type {
#endif
#ifndef LFS3_RDONLY
#define LFS3_I_MKCONSISTENT \
0x00000800 // Filesystem needs mkconsistent to write
0x00000100 // Filesystem needs mkconsistent to write
#endif
#ifndef LFS3_RDONLY
#define LFS3_I_LOOKAHEAD \
0x00001000 // Lookahead/gbmap is not full
0x00000200 // Lookahead/gbmap is not full
#endif
#ifndef LFS3_RDONLY
#define LFS3_I_COMPACT 0x00008000 // Filesystem may have uncompacted metadata
#define LFS3_I_COMPACT 0x00000800 // Filesystem may have uncompacted metadata
#endif
#define LFS3_I_CKMETA 0x00010000 // Metadata checksums not checked recently
#define LFS3_I_CKDATA 0x00020000 // Data checksums not checked recently
#define LFS3_I_CKMETA 0x00001000 // Metadata checksums not checked recently
#define LFS3_I_CKDATA 0x00002000 // Data checksums not checked recently
// Block types
enum lfs3_btype {
@@ -321,21 +321,21 @@ enum lfs3_btype {
#define LFS3_T_EXCL 0x00000008 // Error if filesystem modified
#ifndef LFS3_RDONLY
#define LFS3_T_MKCONSISTENT \
0x00000800 // Make the filesystem consistent
0x00000100 // Make the filesystem consistent
#endif
#ifndef LFS3_RDONLY
#define LFS3_T_LOOKAHEAD \
0x00001000 // Repopulate lookahead/gbmap
0x00000200 // Repopulate lookahead/gbmap
#endif
#ifndef LFS3_RDONLY
#define LFS3_T_COMPACT 0x00008000 // Compact metadata logs
#define LFS3_T_COMPACT 0x00000800 // Compact metadata logs
#endif
#define LFS3_T_CKMETA 0x00010000 // Check metadata checksums
#define LFS3_T_CKDATA 0x00020000 // Check metadata + data checksums
#define LFS3_T_CKMETA 0x00001000 // Check metadata checksums
#define LFS3_T_CKDATA 0x00002000 // Check metadata + data checksums
// internally used flags, don't use these
#define LFS3_t_TYPE 0xf0000000 // The traversal's type
#define LFS3_t_BTYPE 0x00f00000 // The current block type
#define LFS3_t_BTYPE 0x00ff0000 // The current block type
#define LFS3_t_ZOMBIE 0x08000000 // File has been removed
#define LFS3_t_CKPOINTED \
0x04000000 // Filesystem ckpointed during traversal
@@ -345,32 +345,32 @@ enum lfs3_btype {
// File/filesystem check flags
#ifndef LFS3_RDONLY
#define LFS3_CK_MKCONSISTENT \
0x00000800 // Make the filesystem consistent
0x00000100 // Make the filesystem consistent
#endif
#ifndef LFS3_RDONLY
#define LFS3_CK_LOOKAHEAD \
0x00001000 // Repopulate lookahead/gbmap
0x00000200 // Repopulate lookahead/gbmap
#endif
#ifndef LFS3_RDONLY
#define LFS3_CK_COMPACT 0x00008000 // Compact metadata logs
#define LFS3_CK_COMPACT 0x00000800 // Compact metadata logs
#endif
#define LFS3_CK_CKMETA 0x00010000 // Check metadata checksums
#define LFS3_CK_CKDATA 0x00020000 // Check metadata + data checksums
#define LFS3_CK_CKMETA 0x00001000 // Check metadata checksums
#define LFS3_CK_CKDATA 0x00002000 // Check metadata + data checksums
// GC flags
#ifndef LFS3_RDONLY
#define LFS3_GC_MKCONSISTENT \
0x00000800 // Make the filesystem consistent
0x00000100 // Make the filesystem consistent
#endif
#ifndef LFS3_RDONLY
#define LFS3_GC_LOOKAHEAD \
0x00001000 // Repopulate lookahead/gbmap
0x00000200 // Repopulate lookahead/gbmap
#endif
#ifndef LFS3_RDONLY
#define LFS3_GC_COMPACT 0x00008000 // Compact metadata logs
#define LFS3_GC_COMPACT 0x00000800 // Compact metadata logs
#endif
#define LFS3_GC_CKMETA 0x00010000 // Check metadata checksums
#define LFS3_GC_CKDATA 0x00020000 // Check metadata + data checksums
#define LFS3_GC_CKMETA 0x00001000 // Check metadata checksums
#define LFS3_GC_CKDATA 0x00002000 // Check metadata + data checksums
// an alias for all possible GC work
#define LFS3_GC_ALL ( \
+36 -36
View File
@@ -37,8 +37,8 @@ O_FLUSH = 0x00000040 # y- Flush data on every write
O_SYNC = 0x00000080 # y- Sync metadata on every write
O_DESYNC = 0x00100000 # -- Do not sync or recieve file updates
O_CKMETA = 0x00010000 # -- Check metadata checksums
O_CKDATA = 0x00020000 # -- Check metadata + data checksums
O_CKMETA = 0x00001000 # -- Check metadata checksums
O_CKDATA = 0x00002000 # -- Check metadata + data checksums
o_WRSET = 3 # i- Open a file as an atomic write
o_TYPE = 0xf0000000 # im The file's type
@@ -81,11 +81,11 @@ F_CKFETCHES = 0x00200000 # y- Check block checksums before first use
F_CKMETAPARITY = 0x00400000 # y- Check metadata tag parity bits
F_CKDATACKSUMS = 0x01000000 # y- Check data checksums on reads
F_MKCONSISTENT = 0x00000800 # y- Make the filesystem consistent
F_LOOKAHEAD = 0x00001000 # y- Repopulate lookahead buffer
F_COMPACT = 0x00008000 # y- Compact metadata logs
F_CKMETA = 0x00010000 # y- Check metadata checksums
F_CKDATA = 0x00020000 # y- Check metadata + data checksums
F_MKCONSISTENT = 0x00000100 # y- Make the filesystem consistent
F_LOOKAHEAD = 0x00000200 # y- Repopulate lookahead buffer
F_COMPACT = 0x00000800 # y- Compact metadata logs
F_CKMETA = 0x00001000 # y- Check metadata checksums
F_CKDATA = 0x00002000 # y- Check metadata + data checksums
# Filesystem mount flags
M_MODE = 1 # -m Mount's access mode
@@ -100,25 +100,25 @@ M_CKFETCHES = 0x00200000 # y- Check block checksums before first use
M_CKMETAPARITY = 0x00400000 # y- Check metadata tag parity bits
M_CKDATACKSUMS = 0x01000000 # y- Check data checksums on reads
M_MKCONSISTENT = 0x00000800 # y- Make the filesystem consistent
M_LOOKAHEAD = 0x00001000 # y- Repopulate lookahead buffer
M_COMPACT = 0x00008000 # y- Compact metadata logs
M_CKMETA = 0x00010000 # y- Check metadata checksums
M_CKDATA = 0x00020000 # y- Check metadata + data checksums
M_MKCONSISTENT = 0x00000100 # y- Make the filesystem consistent
M_LOOKAHEAD = 0x00000200 # y- Repopulate lookahead buffer
M_COMPACT = 0x00000800 # y- Compact metadata logs
M_CKMETA = 0x00001000 # y- Check metadata checksums
M_CKDATA = 0x00002000 # y- Check metadata + data checksums
# File/filesystem check flags
CK_MKCONSISTENT = 0x00000800 # -- Make the filesystem consistent
CK_LOOKAHEAD = 0x00001000 # -- Repopulate lookahead buffer
CK_COMPACT = 0x00008000 # -- Compact metadata logs
CK_CKMETA = 0x00010000 # -- Check metadata checksums
CK_CKDATA = 0x00020000 # -- Check metadata + data checksums
CK_MKCONSISTENT = 0x00000100 # -- Make the filesystem consistent
CK_LOOKAHEAD = 0x00000200 # -- Repopulate lookahead buffer
CK_COMPACT = 0x00000800 # -- Compact metadata logs
CK_CKMETA = 0x00001000 # -- Check metadata checksums
CK_CKDATA = 0x00002000 # -- Check metadata + data checksums
# GC flags
GC_MKCONSISTENT = 0x00000800 # -- Make the filesystem consistent
GC_LOOKAHEAD = 0x00001000 # -- Repopulate lookahead buffer
GC_COMPACT = 0x00008000 # -- Compact metadata logs
GC_CKMETA = 0x00010000 # -- Check metadata checksums
GC_CKDATA = 0x00020000 # -- Check metadata + data checksums
GC_MKCONSISTENT = 0x00000100 # -- Make the filesystem consistent
GC_LOOKAHEAD = 0x00000200 # -- Repopulate lookahead buffer
GC_COMPACT = 0x00000800 # -- Compact metadata logs
GC_CKMETA = 0x00001000 # -- Check metadata checksums
GC_CKDATA = 0x00002000 # -- Check metadata + data checksums
# Filesystem info flags
I_RDONLY = 0x00000001 # -- Mounted read only
@@ -133,11 +133,11 @@ I_CKFETCHES = 0x00200000 # -- Mounted with LFS3_M_CKFETCHES
I_CKMETAPARITY = 0x00400000 # -- Mounted with LFS3_M_CKMETAPARITY
I_CKDATACKSUMS = 0x01000000 # -- Mounted with LFS3_M_CKDATACKSUMS
I_MKCONSISTENT = 0x00000800 # -- Filesystem needs mkconsistent to write
I_LOOKAHEAD = 0x00001000 # -- Lookahead buffer is not full
I_COMPACT = 0x00008000 # -- Filesystem may have uncompacted metadata
I_CKMETA = 0x00010000 # -- Metadata checksums not checked recently
I_CKDATA = 0x00020000 # -- Data checksums not checked recently
I_MKCONSISTENT = 0x00000100 # -- Filesystem needs mkconsistent to write
I_LOOKAHEAD = 0x00000200 # -- Lookahead buffer is not full
I_COMPACT = 0x00000800 # -- Filesystem may have uncompacted metadata
I_CKMETA = 0x00001000 # -- Metadata checksums not checked recently
I_CKDATA = 0x00002000 # -- Data checksums not checked recently
# Traversal flags
T_MODE = 1 # -m The traversal's access mode
@@ -145,11 +145,11 @@ T_RDWR = 0 # -^ Open traversal as read and write
T_RDONLY = 1 # -^ Open traversal as read only
T_MTREEONLY = 0x00000002 # -- Only traverse the mtree
T_EXCL = 0x00000008 # -- Error if filesystem modified
T_MKCONSISTENT = 0x00000800 # -- Make the filesystem consistent
T_LOOKAHEAD = 0x00001000 # -- Repopulate lookahead buffer
T_COMPACT = 0x00008000 # -- Compact metadata logs
T_CKMETA = 0x00010000 # -- Check metadata checksums
T_CKDATA = 0x00020000 # -- Check metadata + data checksums
T_MKCONSISTENT = 0x00000100 # -- Make the filesystem consistent
T_LOOKAHEAD = 0x00000200 # -- Repopulate lookahead buffer
T_COMPACT = 0x00000800 # -- Compact metadata logs
T_CKMETA = 0x00001000 # -- Check metadata checksums
T_CKDATA = 0x00002000 # -- Check metadata + data checksums
t_TYPE = 0xf0000000 # im The traversal's type
t_REG = 0x10000000 # i^ Type = regular-file
@@ -159,10 +159,10 @@ t_BOOKMARK = 0x40000000 # i^ Type = bookmark
t_ORPHAN = 0x50000000 # i^ Type = orphan
t_TRAVERSAL = 0x60000000 # i^ Type = traversal
t_UNKNOWN = 0x70000000 # i^ Type = unknown
t_BTYPE = 0x00f00000 # im The current block type
t_MDIR = 0x00100000 # i^ Btype = mdir
t_BTREE = 0x00200000 # i^ Btype = btree
t_DATA = 0x00300000 # i^ Btype = data
t_BTYPE = 0x00ff0000 # im The current block type
t_MDIR = 0x00010000 # i^ Btype = mdir
t_BTREE = 0x00020000 # i^ Btype = btree
t_DATA = 0x00030000 # i^ Btype = data
t_ZOMBIE = 0x08000000 # i- File has been removed
t_CKPOINTED = 0x04000000 # i- Filesystem ckpointed during traversal
t_DIRTY = 0x02000000 # i- Filesystem ckpointed outside traversal