mirror of
https://github.com/littlefs-project/littlefs.git
synced 2025-12-26 01:07:23 +00:00
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:
@@ -33,19 +33,19 @@ FLAGS = [
|
||||
('O', 'FLUSH', 0x00000040, "Flush data on every write" ),
|
||||
('O', 'SYNC', 0x00000080, "Sync metadata on every write" ),
|
||||
('O', 'DESYNC', 0x00000100, "Do not sync or recieve file updates" ),
|
||||
('O', 'CKMETA', 0x00010000, "Check metadata checksums" ),
|
||||
('O', 'CKDATA', 0x00020000, "Check metadata + data checksums" ),
|
||||
('O', 'CKMETA', 0x00100000, "Check metadata checksums" ),
|
||||
('O', 'CKDATA', 0x00200000, "Check metadata + data checksums" ),
|
||||
|
||||
('o', 'TYPE', 0xff000000, "The file's type" ),
|
||||
('^', 'REG', 0x01000000, "Type = regular-file" ),
|
||||
('^', 'DIR', 0x02000000, "Type = directory" ),
|
||||
('^', 'BOOKMARK', 0x04000000, "Type = bookmark" ),
|
||||
('^', 'STICKYNOTE',0x05000000, "Type = stickynote" ),
|
||||
('^', 'TRAVERSAL', 0x09000000, "Type = traversal" ),
|
||||
('o', 'UNFLUSH', 0x00100000, "File's data does not match disk" ),
|
||||
('o', 'UNSYNC', 0x00200000, "File's metadata does not match disk" ),
|
||||
('o', 'UNCREAT', 0x00400000, "File does not exist yet" ),
|
||||
('o', 'ZOMBIE', 0x00800000, "File has been removed" ),
|
||||
('o', 'TYPE', 0xf0000000, "The file's type" ),
|
||||
('^', 'REG', 0x10000000, "Type = regular-file" ),
|
||||
('^', 'DIR', 0x20000000, "Type = directory" ),
|
||||
('^', 'BOOKMARK', 0x40000000, "Type = bookmark" ),
|
||||
('^', 'STICKYNOTE',0x50000000, "Type = stickynote" ),
|
||||
('^', 'TRAVERSAL', 0x90000000, "Type = traversal" ),
|
||||
('o', 'UNFLUSH', 0x01000000, "File's data does not match disk" ),
|
||||
('o', 'UNSYNC', 0x02000000, "File's metadata does not match disk" ),
|
||||
('o', 'UNCREAT', 0x04000000, "File does not exist yet" ),
|
||||
('o', 'ZOMBIE', 0x08000000, "File has been removed" ),
|
||||
|
||||
# Custom attribute flags
|
||||
('A', 'MODE', 3, "The attr's access mode" ),
|
||||
@@ -57,14 +57,14 @@ FLAGS = [
|
||||
# Filesystem format flags
|
||||
('F', 'MODE', 1, "Format's access mode" ),
|
||||
('^', 'RDWR', 0, "Format the filesystem as read and write" ),
|
||||
('F', 'CKPROGS', 0x00100000, "Check progs by reading back progged data" ),
|
||||
('F', 'CKFETCHES', 0x00200000, "Check block checksums before first use" ),
|
||||
('F', 'CKPARITY', 0x00400000, "Check metadata tag parity bits" ),
|
||||
('F', 'CKPROGS', 0x00000800, "Check progs by reading back progged data" ),
|
||||
('F', 'CKFETCHES', 0x00001000, "Check block checksums before first use" ),
|
||||
('F', 'CKPARITY', 0x00002000, "Check metadata tag parity bits" ),
|
||||
('F', 'CKDATACKSUMS',
|
||||
0x08000000, "Check data checksums on reads" ),
|
||||
0x00008000, "Check data checksums on reads" ),
|
||||
|
||||
('F', 'CKMETA', 0x00010000, "Check metadata checksums" ),
|
||||
('F', 'CKDATA', 0x00020000, "Check metadata + data checksums" ),
|
||||
('F', 'CKMETA', 0x00100000, "Check metadata checksums" ),
|
||||
('F', 'CKDATA', 0x00200000, "Check metadata + data checksums" ),
|
||||
|
||||
# Filesystem mount flags
|
||||
('M', 'MODE', 1, "Mount's access mode" ),
|
||||
@@ -72,55 +72,61 @@ FLAGS = [
|
||||
('^', 'RDONLY', 1, "Mount the filesystem as read only" ),
|
||||
('M', 'FLUSH', 0x00000040, "Open all files with LFS_O_FLUSH" ),
|
||||
('M', 'SYNC', 0x00000080, "Open all files with LFS_O_SYNC" ),
|
||||
('M', 'CKPROGS', 0x00100000, "Check progs by reading back progged data" ),
|
||||
('M', 'CKFETCHES', 0x00200000, "Check block checksums before first use" ),
|
||||
('M', 'CKPARITY', 0x00400000, "Check metadata tag parity bits" ),
|
||||
('M', 'CKPROGS', 0x00000800, "Check progs by reading back progged data" ),
|
||||
('M', 'CKFETCHES', 0x00001000, "Check block checksums before first use" ),
|
||||
('M', 'CKPARITY', 0x00002000, "Check metadata tag parity bits" ),
|
||||
('M', 'CKDATACKSUMS',
|
||||
0x08000000, "Check data checksums on reads" ),
|
||||
0x00008000, "Check data checksums on reads" ),
|
||||
|
||||
('M', 'MKCONSISTENT',
|
||||
0x00001000, "Make the filesystem consistent" ),
|
||||
('M', 'LOOKAHEAD', 0x00002000, "Populate lookahead buffer" ),
|
||||
('M', 'COMPACT', 0x00008000, "Compact metadata logs" ),
|
||||
('M', 'CKMETA', 0x00010000, "Check metadata checksums" ),
|
||||
('M', 'CKDATA', 0x00020000, "Check metadata + data checksums" ),
|
||||
0x00010000, "Make the filesystem consistent" ),
|
||||
('M', 'LOOKAHEAD', 0x00020000, "Populate lookahead buffer" ),
|
||||
('M', 'COMPACT', 0x00080000, "Compact metadata logs" ),
|
||||
('M', 'CKMETA', 0x00100000, "Check metadata checksums" ),
|
||||
('M', 'CKDATA', 0x00200000, "Check metadata + data checksums" ),
|
||||
|
||||
('m', 'UNTIDY', 0x00001000, "Filesystem may have orphaned stickynotes" ),
|
||||
('m', 'UNTIDY', 0x00010000, "Filesystem may have orphaned stickynotes" ),
|
||||
|
||||
# GC flags
|
||||
('GC', 'MKCONSISTENT',
|
||||
0x00001000, "Make the filesystem consistent" ),
|
||||
('GC', 'LOOKAHEAD',0x00002000, "Populate lookahead buffer" ),
|
||||
('GC', 'COMPACT', 0x00008000, "Compact metadata logs" ),
|
||||
('GC', 'CKMETA', 0x00010000, "Check metadata checksums" ),
|
||||
('GC', 'CKDATA', 0x00020000, "Check metadata + data checksums" ),
|
||||
0x00010000, "Make the filesystem consistent" ),
|
||||
('GC', 'LOOKAHEAD',0x00020000, "Populate lookahead buffer" ),
|
||||
('GC', 'COMPACT', 0x00080000, "Compact metadata logs" ),
|
||||
('GC', 'CKMETA', 0x00100000, "Check metadata checksums" ),
|
||||
('GC', 'CKDATA', 0x00200000, "Check metadata + data checksums" ),
|
||||
|
||||
# Filesystem info flags
|
||||
('I', 'RDONLY', 0x00000001, "Mounted read only" ),
|
||||
('I', 'FLUSH', 0x00000040, "Mounted with LFS_M_FLUSH" ),
|
||||
('I', 'SYNC', 0x00000080, "Mounted with LFS_M_SYNC" ),
|
||||
('I', 'CKPROGS', 0x00100000, "Mounted with LFS_M_CKPROGS" ),
|
||||
('I', 'CKFETCHES', 0x00200000, "Mounted with LFS_M_CKFETCHES" ),
|
||||
('I', 'CKPARITY', 0x00400000, "Mounted with LFS_M_CKPARITY" ),
|
||||
('I', 'CKPROGS', 0x00000800, "Mounted with LFS_M_CKPROGS" ),
|
||||
('I', 'CKFETCHES', 0x00001000, "Mounted with LFS_M_CKFETCHES" ),
|
||||
('I', 'CKPARITY', 0x00002000, "Mounted with LFS_M_CKPARITY" ),
|
||||
('I', 'CKDATACKSUMS',
|
||||
0x08000000, "Mounted with LFS_M_CKDATACKSUMS" ),
|
||||
0x00008000, "Mounted with LFS_M_CKDATACKSUMS" ),
|
||||
|
||||
('I', 'MKCONSISTENT',
|
||||
0x00001000, "Filesystem needs mkconsistent to write" ),
|
||||
('I', 'LOOKAHEAD', 0x00002000, "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" ),
|
||||
0x00010000, "Filesystem needs mkconsistent to write" ),
|
||||
('I', 'LOOKAHEAD', 0x00020000, "Lookahead buffer is not full" ),
|
||||
('I', 'COMPACT', 0x00080000, "Filesystem may have uncompacted metadata" ),
|
||||
('I', 'CKMETA', 0x00100000, "Metadata checksums not checked recently" ),
|
||||
('I', 'CKDATA', 0x00200000, "Data checksums not checked recently" ),
|
||||
|
||||
# Traversal flags
|
||||
('T', 'MTREEONLY', 0x00000800, "Only traverse the mtree" ),
|
||||
('T', 'MTREEONLY', 0x00000010, "Only traverse the mtree" ),
|
||||
('T', 'MKCONSISTENT',
|
||||
0x00001000, "Make the filesystem consistent" ),
|
||||
('T', 'LOOKAHEAD', 0x00002000, "Populate lookahead buffer" ),
|
||||
('T', 'COMPACT', 0x00008000, "Compact metadata logs" ),
|
||||
('T', 'CKMETA', 0x00010000, "Check metadata checksums" ),
|
||||
('T', 'CKDATA', 0x00020000, "Check metadata + data checksums" ),
|
||||
0x00010000, "Make the filesystem consistent" ),
|
||||
('T', 'LOOKAHEAD', 0x00020000, "Populate lookahead buffer" ),
|
||||
('T', 'COMPACT', 0x00080000, "Compact metadata logs" ),
|
||||
('T', 'CKMETA', 0x00100000, "Check metadata checksums" ),
|
||||
('T', 'CKDATA', 0x00200000, "Check metadata + data checksums" ),
|
||||
|
||||
('t', 'TYPE', 0xf0000000, "The file's type" ),
|
||||
('^', 'REG', 0x10000000, "Type = regular-file" ),
|
||||
('^', 'DIR', 0x20000000, "Type = directory" ),
|
||||
('^', 'BOOKMARK', 0x40000000, "Type = bookmark" ),
|
||||
('^', 'STICKYNOTE',0x50000000, "Type = stickynote" ),
|
||||
('^', 'TRAVERSAL', 0x90000000, "Type = traversal" ),
|
||||
('t', 'TSTATE', 0x0000000f, "The traversal's current tstate" ),
|
||||
('^', 'MROOTANCHOR',
|
||||
0x00000000, "Tstate = mroot-anchor" ),
|
||||
@@ -132,12 +138,13 @@ FLAGS = [
|
||||
('^', 'OMDIRS', 0x00000006, "Tstate = open-mdirs" ),
|
||||
('^', 'OBTREE', 0x00000007, "Tstate = open-btree" ),
|
||||
('^', 'DONE', 0x00000008, "Tstate = done" ),
|
||||
('t', 'BTYPE', 0x000000f0, "The traversal's current btype" ),
|
||||
('^', 'MDIR', 0x00000010, "Btype = mdir" ),
|
||||
('^', 'BTREE', 0x00000020, "Btype = btree" ),
|
||||
('^', 'DATA', 0x00000030, "Btype = data" ),
|
||||
('t', 'DIRTY', 0x00000100, "Filesystem modified during traversal" ),
|
||||
('t', 'MUTATED', 0x00000200, "Filesystem modified by traversal" ),
|
||||
('t', 'BTYPE', 0x00000f00, "The traversal's current btype" ),
|
||||
('^', 'MDIR', 0x00000100, "Btype = mdir" ),
|
||||
('^', 'BTREE', 0x00000200, "Btype = btree" ),
|
||||
('^', 'DATA', 0x00000300, "Btype = data" ),
|
||||
('t', 'DIRTY', 0x01000000, "Filesystem modified during traversal" ),
|
||||
('t', 'MUTATED', 0x02000000, "Filesystem modified by traversal" ),
|
||||
('t', 'ZOMBIE', 0x08000000, "File has been removed" ),
|
||||
|
||||
# Read-compat flags
|
||||
('RCOMPAT', 'NONSTANDARD',
|
||||
|
||||
Reference in New Issue
Block a user