Reworked o/f/m/gc/i/t flags
This is mainly to free up space for flags, we're pretty close to running
out of 32-bits with future planned features:
1. Reduced file type info from 8 -> 4 bits
We don't really need more than this, but it does mean type info is
no longer a simple byte load.
2. Moved most internal file-state flags into the next 4 bits
These are mostly file-type specific (except LFS_o_ZOMBIE), so we
don't need to worry too much about overlap.
3. Compacted ck-flags into 5 bits:
LFS_M_CKPROGS 0x00000800
LFS_M_CKFETCHES 0x00001000
LFS_M_CKPARITY 0x00002000
LFS_M_CKMETAREDUND* 0x00004000
LFS_M_CKDATACKSUMS 0x00008000
*Planned
Now that ck-flags are a bit more mature, it's pretty clear we'll
probably never have CKMETACKSUMS (ckcksums + small tag reads is
crazy expensive) or CKDATAREDUND (non-trivial parity fanout makes
this crazy expensives. So reserving bits for these just wastes bits.
This also moves things around so ck-flags no longer overlap with open
flags.
It's a tight fit, and I still think file-specific ck-flags are out-of-
scope, but this at least decreases flag ambiguity.
New jenga:
8 8 8 8
.----++----++----++----.
.-..-..-.-------.------.
o_flags: |t||f||t| | o |
|-||-||-|-------:--.---'
|-||-||-'--.----.------.
t_flags: |t||f|| t | | tstt |
'-''-'|----|----'------'
.----.|----|.--.:--:.--.
m_flags: | f || t ||c ||o ||m |
|----||-.--'|--|'--''--'
|----||-|---|--|.------.
f_flags: | f ||t| |c || f |
'----''-'---'--''------'
Fortunately no major code costs:
code stack ctx
before: 37792 2608 620
after: 37788 (-0.0%) 2608 (+0.0%) 620 (+0.0%)
This commit is contained in:
@@ -137,15 +137,15 @@ enum lfs_type {
|
||||
#define LFS_O_FLUSH 0x00000040 // Flush data on every write
|
||||
#define LFS_O_SYNC 0x00000080 // Sync metadata on every write
|
||||
#define LFS_O_DESYNC 0x00000100 // Do not sync or recieve file updates
|
||||
#define LFS_O_CKMETA 0x00010000 // Check metadata checksums
|
||||
#define LFS_O_CKDATA 0x00020000 // Check metadata + data checksums
|
||||
#define LFS_O_CKMETA 0x00100000 // Check metadata checksums
|
||||
#define LFS_O_CKDATA 0x00200000 // Check metadata + data checksums
|
||||
|
||||
// internally used flags, don't use these
|
||||
#define LFS_o_TYPE 0xff000000 // The file's type
|
||||
#define LFS_o_UNFLUSH 0x00100000 // File's data does not match disk
|
||||
#define LFS_o_UNSYNC 0x00200000 // File's metadata does not match disk
|
||||
#define LFS_o_UNCREAT 0x00400000 // File does not exist yet
|
||||
#define LFS_o_ZOMBIE 0x00800000 // File has been removed
|
||||
#define LFS_o_TYPE 0xf0000000 // The file's type
|
||||
#define LFS_o_UNFLUSH 0x01000000 // File's data does not match disk
|
||||
#define LFS_o_UNSYNC 0x02000000 // File's metadata does not match disk
|
||||
#define LFS_o_UNCREAT 0x04000000 // File does not exist yet
|
||||
#define LFS_o_ZOMBIE 0x08000000 // File has been removed
|
||||
|
||||
// File seek flags
|
||||
#define LFS_SEEK_SET 0 // Seek relative to an absolute position
|
||||
@@ -163,21 +163,21 @@ enum lfs_type {
|
||||
#define LFS_F_MODE 1 // Format's access mode
|
||||
#define LFS_F_RDWR 0 // Format the filesystem as read and write
|
||||
#ifdef LFS_CKPROGS
|
||||
#define LFS_F_CKPROGS 0x00100000 // Check progs by reading back progged data
|
||||
#define LFS_F_CKPROGS 0x00000800 // Check progs by reading back progged data
|
||||
#endif
|
||||
#ifdef LFS_CKFETCHES
|
||||
#define LFS_F_CKFETCHES 0x00200000 // Check block checksums before first use
|
||||
#define LFS_F_CKFETCHES 0x00001000 // Check block checksums before first use
|
||||
#endif
|
||||
#ifdef LFS_CKPARITY
|
||||
#define LFS_F_CKPARITY 0x00400000 // Check metadata tag parity bits
|
||||
#define LFS_F_CKPARITY 0x00002000 // Check metadata tag parity bits
|
||||
#endif
|
||||
#ifdef LFS_CKDATACKSUMS
|
||||
#define LFS_F_CKDATACKSUMS \
|
||||
0x08000000 // Check data checksums on reads
|
||||
0x00008000 // Check data checksums on reads
|
||||
#endif
|
||||
|
||||
#define LFS_F_CKMETA 0x00010000 // Check metadata checksums
|
||||
#define LFS_F_CKDATA 0x00020000 // Check metadata + data checksums
|
||||
#define LFS_F_CKMETA 0x00100000 // Check metadata checksums
|
||||
#define LFS_F_CKDATA 0x00200000 // Check metadata + data checksums
|
||||
|
||||
// Filesystem mount flags
|
||||
#define LFS_M_MODE 1 // Mount's access mode
|
||||
@@ -186,53 +186,53 @@ enum lfs_type {
|
||||
#define LFS_M_FLUSH 0x00000040 // Open all files with LFS_O_FLUSH
|
||||
#define LFS_M_SYNC 0x00000080 // Open all files with LFS_O_SYNC
|
||||
#ifdef LFS_CKPROGS
|
||||
#define LFS_M_CKPROGS 0x00100000 // Check progs by reading back progged data
|
||||
#define LFS_M_CKPROGS 0x00000800 // Check progs by reading back progged data
|
||||
#endif
|
||||
#ifdef LFS_CKFETCHES
|
||||
#define LFS_M_CKFETCHES 0x00200000 // Check block checksums before first use
|
||||
#define LFS_M_CKFETCHES 0x00001000 // Check block checksums before first use
|
||||
#endif
|
||||
#ifdef LFS_CKPARITY
|
||||
#define LFS_M_CKPARITY 0x00400000 // Check metadata tag parity bits
|
||||
#define LFS_M_CKPARITY 0x00002000 // Check metadata tag parity bits
|
||||
#endif
|
||||
#ifdef LFS_CKDATACKSUMS
|
||||
#define LFS_M_CKDATACKSUMS \
|
||||
0x08000000 // Check data checksums on reads
|
||||
0x00008000 // Check data checksums on reads
|
||||
#endif
|
||||
|
||||
#define LFS_M_MKCONSISTENT \
|
||||
0x00001000 // Make the filesystem consistent
|
||||
#define LFS_M_LOOKAHEAD 0x00002000 // Populate lookahead buffer
|
||||
#define LFS_M_COMPACT 0x00008000 // Compact metadata logs
|
||||
#define LFS_M_CKMETA 0x00010000 // Check metadata checksums
|
||||
#define LFS_M_CKDATA 0x00020000 // Check metadata + data checksums
|
||||
0x00010000 // Make the filesystem consistent
|
||||
#define LFS_M_LOOKAHEAD 0x00020000 // Populate lookahead buffer
|
||||
#define LFS_M_COMPACT 0x00080000 // Compact metadata logs
|
||||
#define LFS_M_CKMETA 0x00100000 // Check metadata checksums
|
||||
#define LFS_M_CKDATA 0x00200000 // Check metadata + data checksums
|
||||
|
||||
// Filesystem info flags
|
||||
#define LFS_I_RDONLY 0x00000001 // Mounted read only
|
||||
#define LFS_I_FLUSH 0x00000040 // Mounted with LFS_M_FLUSH
|
||||
#define LFS_I_SYNC 0x00000080 // Mounted with LFS_M_SYNC
|
||||
#ifdef LFS_CKPROGS
|
||||
#define LFS_I_CKPROGS 0x00100000 // Mounted with LFS_M_CKPROGS
|
||||
#define LFS_I_CKPROGS 0x00000800 // Mounted with LFS_M_CKPROGS
|
||||
#endif
|
||||
#ifdef LFS_CKFETCHES
|
||||
#define LFS_I_CKFETCHES 0x00200000 // Mounted with LFS_M_CKFETCHES
|
||||
#define LFS_I_CKFETCHES 0x00001000 // Mounted with LFS_M_CKFETCHES
|
||||
#endif
|
||||
#ifdef LFS_CKPARITY
|
||||
#define LFS_I_CKPARITY 0x00400000 // Mounted with LFS_M_CKPARITY
|
||||
#define LFS_I_CKPARITY 0x00002000 // Mounted with LFS_M_CKPARITY
|
||||
#endif
|
||||
#ifdef LFS_CKDATACKSUMS
|
||||
#define LFS_I_CKDATACKSUMS \
|
||||
0x08000000 // Mounted with LFS_M_CKDATACKSUMS
|
||||
0x00008000 // Mounted with LFS_M_CKDATACKSUMS
|
||||
#endif
|
||||
|
||||
#define LFS_I_MKCONSISTENT \
|
||||
0x00001000 // Filesystem needs mkconsistent to write
|
||||
#define LFS_I_LOOKAHEAD 0x00002000 // Lookahead buffer is not full
|
||||
#define LFS_I_COMPACT 0x00008000 // Filesystem may have uncompacted metadata
|
||||
#define LFS_I_CKMETA 0x00010000 // Metadata checksums not checked recently
|
||||
#define LFS_I_CKDATA 0x00020000 // Data checksums not checked recently
|
||||
0x00010000 // Filesystem needs mkconsistent to write
|
||||
#define LFS_I_LOOKAHEAD 0x00020000 // Lookahead buffer is not full
|
||||
#define LFS_I_COMPACT 0x00080000 // Filesystem may have uncompacted metadata
|
||||
#define LFS_I_CKMETA 0x00100000 // Metadata checksums not checked recently
|
||||
#define LFS_I_CKDATA 0x00200000 // Data checksums not checked recently
|
||||
|
||||
// internally used flags, don't use these
|
||||
#define LFS_i_UNTIDY 0x00001000 // Filesystem may have orphaned stickynotes
|
||||
#define LFS_i_UNTIDY 0x00010000 // Filesystem may have orphaned stickynotes
|
||||
|
||||
|
||||
// Block types
|
||||
@@ -243,28 +243,29 @@ enum lfs_btype {
|
||||
};
|
||||
|
||||
// Traversal flags
|
||||
#define LFS_T_MTREEONLY 0x00000800 // Only traverse the mtree
|
||||
#define LFS_T_MTREEONLY 0x00000010 // Only traverse the mtree
|
||||
#define LFS_T_MKCONSISTENT \
|
||||
0x00001000 // Make the filesystem consistent
|
||||
#define LFS_T_LOOKAHEAD 0x00002000 // Populate lookahead buffer
|
||||
#define LFS_T_COMPACT 0x00008000 // Compact metadata logs
|
||||
#define LFS_T_CKMETA 0x00010000 // Check metadata checksums
|
||||
#define LFS_T_CKDATA 0x00020000 // Check metadata + data checksums
|
||||
0x00010000 // Make the filesystem consistent
|
||||
#define LFS_T_LOOKAHEAD 0x00020000 // Populate lookahead buffer
|
||||
#define LFS_T_COMPACT 0x00080000 // Compact metadata logs
|
||||
#define LFS_T_CKMETA 0x00100000 // Check metadata checksums
|
||||
#define LFS_T_CKDATA 0x00200000 // Check metadata + data checksums
|
||||
|
||||
// internally used flags, don't use these
|
||||
#define LFS_t_TSTATE 0x0000000f // The traversal's current tstate
|
||||
#define LFS_t_BTYPE 0x000000f0 // The traversal's current btype
|
||||
#define LFS_t_DIRTY 0x00000100 // Filesystem modified during traversal
|
||||
#define LFS_t_MUTATED 0x00000200 // Filesystem modified by traversal
|
||||
#define LFS_t_BTYPE 0x00000f00 // The traversal's current btype
|
||||
#define LFS_t_DIRTY 0x01000000 // Filesystem modified during traversal
|
||||
#define LFS_t_MUTATED 0x02000000 // Filesystem modified by traversal
|
||||
#define LFS_t_ZOMBIE 0x08000000 // File has been removed
|
||||
|
||||
// GC flags
|
||||
#define LFS_GC_MKCONSISTENT \
|
||||
0x00001000 // Make the filesystem consistent
|
||||
0x00010000 // Make the filesystem consistent
|
||||
#define LFS_GC_LOOKAHEAD \
|
||||
0x00002000 // Populate lookahead buffer
|
||||
#define LFS_GC_COMPACT 0x00008000 // Compact metadata logs
|
||||
#define LFS_GC_CKMETA 0x00010000 // Check metadata checksums
|
||||
#define LFS_GC_CKDATA 0x00020000 // Check metadata + data checksums
|
||||
0x00020000 // Populate lookahead buffer
|
||||
#define LFS_GC_COMPACT 0x00080000 // Compact metadata logs
|
||||
#define LFS_GC_CKMETA 0x00100000 // Check metadata checksums
|
||||
#define LFS_GC_CKDATA 0x00200000 // Check metadata + data checksums
|
||||
|
||||
|
||||
// Configuration provided during initialization of the littlefs
|
||||
|
||||
Reference in New Issue
Block a user