Skip to content

Commit 2d68db9

Browse files
committed
Rearranged on-disk compat flags
Other than moving things around to make space for planned features, this also adopts the idea of allowing compat flags to be ored into a single 32-bit integer, at least in the short-term. Note though that these are still stored in separate wcompat/rcompat tags, to make compat tests easier, and we may introduce conflicting flags in the future if we run out of 32-bits. This is just an indulgence to potentially make tooling/debugging easier until that happens. Rcompat flags: RCOMPAT_NONSTANDARD+ 0x00000001 ---- ---- ---- ---- ---- ---- ---- ---1 RCOMPAT_WRONLY+ 0x00000004 ---- ---- ---- ---- ---- ---- ---- -1-- RCOMPAT_MMOSS 0x00000010 ---- ---- ---- ---- ---- ---- ---1 ---- RCOMPAT_MSPROUT+ 0x00000020 ---- ---- ---- ---- ---- ---- --1- ---- RCOMPAT_MSHRUB+ 0x00000040 ---- ---- ---- ---- ---- ---- -1-- ---- RCOMPAT_MTREE 0x00000080 ---- ---- ---- ---- ---- ---- 1--- ---- RCOMPAT_BMOSS+ 0x00000100 ---- ---- ---- ---- ---- ---1 ---- ---- RCOMPAT_BSPROUT+ 0x00000200 ---- ---- ---- ---- ---- --1- ---- ---- RCOMPAT_BSHRUB 0x00000400 ---- ---- ---- ---- ---- -1-- ---- ---- RCOMPAT_BTREE 0x00000800 ---- ---- ---- ---- ---- 1--- ---- ---- RCOMPAT_MDIRR1* 0x00001000 ---- ---- ---- ---- ---1 ---- ---- ---- RCOMPAT_MDIRR2* 0x00002000 ---- ---- ---- ---- --1- ---- ---- ---- RCOMPAT_MDIRR3* 0x00003000 ---- ---- ---- ---- --11 ---- ---- ---- RCOMPAT_BTREER1* 0x00004000 ---- ---- ---- ---- -1-- ---- ---- ---- RCOMPAT_BTREER2* 0x00008000 ---- ---- ---- ---- 1--- ---- ---- ---- RCOMPAT_BTREER3* 0x0000c000 ---- ---- ---- ---- 11-- ---- ---- ---- RCOMPAT_GRM 0x00010000 ---- ---- ---- ---1 ---- ---- ---- ---- RCOMPAT_GMV? 0x00020000 ---- ---- ---- --1- ---- ---- ---- ---- RCOMPAT_GDDTREE* 0x00100000 ---- ---- ---1 ---- ---- ---- ---- ---- RCOMPAT_GPTREE* 0x00200000 ---- ---- --1- ---- ---- ---- ---- ---- RCOMPAT_DATAR1* 0x00400000 ---- ---- -1-- ---- ---- ---- ---- ---- RCOMPAT_DATAR2* 0x00800000 ---- ---- 1--- ---- ---- ---- ---- ---- RCOMPAT_DATAR3* 0x00c00000 ---- ---- 11-- ---- ---- ---- ---- ---- rcompat_OVERFLOW+ 0x80000000 1--- ---- ---- ---- ---- ---- ---- ---- * Planned + Reserved ? Hypothetical Wcompat flags: WCOMPAT_NONSTANDARD+ 0x00000001 ---- ---- ---- ---- ---- ---- ---- ---1 WCOMPAT_RDONLY+ 0x00000002 ---- ---- ---- ---- ---- ---- ---- --1- WCOMPAT_GCKSUM 0x00040000 ---- ---- ---- -1-- ---- ---- ---- ---- WCOMPAT_GBMAP 0x00080000 ---- ---- ---- 1--- ---- ---- ---- ---- WCOMPAT_DIR 0x01000000 ---- ---1 ---- ---- ---- ---- ---- ---- WCOMPAT_SYMLINK? 0x02000000 ---- --1- ---- ---- ---- ---- ---- ---- WCOMPAT_SNAPSHOT? 0x04000000 ---- -1-- ---- ---- ---- ---- ---- ---- wcompat_OVERFLOW+ 0x80000000 1--- ---- ---- ---- ---- ---- ---- ---- + Reserved ? Hypothetical Ocompat flags: OCOMPAT_NONSTANDARD+ 0x00000001 ---- ---- ---- ---- ---- ---- ---- ---1 ocompat_OVERFLOW+ 0x80000000 1--- ---- ---- ---- ---- ---- ---- ---- + Reserved Other notes: - M* and B* struct flags were reordered to match META -> DATA order elsewhere. This no longer matches the tag ordering, but there's an argument the B* tags apply more generally (all btrees) than the B* compat flag (only file btrees). - MDIR/BTREE/DATA redund flags were moved near relevant flags, rather than sticking them in the higher-order bits as we are planning to do in the M_*/F_* flags. The compat flags already won't match because of the mdir/btree split (which is IMO too much detail to include in M_*/F_* flags, but hard to argue against in the compat flags), and this keeps the highest bit free for OVERFLOW, which is useful internally. - Moving DIR to the current-highest bit makes it easy to add 6 more file types (7 if you ignore OVERFLOW), before things start getting cramped. No code changes.
1 parent 8233ac9 commit 2d68db9

File tree

5 files changed

+72
-71
lines changed

5 files changed

+72
-71
lines changed

lfs3.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15267,24 +15267,24 @@ static int lfs3_deinit(lfs3_t *lfs3) {
1526715267
// note, "understanding" does not necessarily mean support
1526815268
//
1526915269
#define LFS3_RCOMPAT_NONSTANDARD 0x00000001 // Non-standard filesystem format
15270-
#define LFS3_RCOMPAT_WRONLY 0x00000002 // Reading is disallowed
15271-
#define LFS3_RCOMPAT_BMOSS 0x00000010 // Files may use inlined data
15272-
#define LFS3_RCOMPAT_BSPROUT 0x00000020 // Files may use block pointers
15273-
#define LFS3_RCOMPAT_BSHRUB 0x00000040 // Files may use inlined btrees
15274-
#define LFS3_RCOMPAT_BTREE 0x00000080 // Files may use btrees
15275-
#define LFS3_RCOMPAT_MMOSS 0x00000100 // May use an inlined mdir
15276-
#define LFS3_RCOMPAT_MSPROUT 0x00000200 // May use an mdir pointer
15277-
#define LFS3_RCOMPAT_MSHRUB 0x00000400 // May use an inlined mtree
15278-
#define LFS3_RCOMPAT_MTREE 0x00000800 // May use an mtree
15279-
#define LFS3_RCOMPAT_GRM 0x00001000 // Global-remove in use
15270+
#define LFS3_RCOMPAT_WRONLY 0x00000004 // Reading is disallowed
15271+
#define LFS3_RCOMPAT_MMOSS 0x00000010 // May use an inlined mdir
15272+
#define LFS3_RCOMPAT_MSPROUT 0x00000020 // May use an mdir pointer
15273+
#define LFS3_RCOMPAT_MSHRUB 0x00000040 // May use an inlined mtree
15274+
#define LFS3_RCOMPAT_MTREE 0x00000080 // May use an mtree
15275+
#define LFS3_RCOMPAT_BMOSS 0x00000100 // Files may use inlined data
15276+
#define LFS3_RCOMPAT_BSPROUT 0x00000200 // Files may use block pointers
15277+
#define LFS3_RCOMPAT_BSHRUB 0x00000400 // Files may use inlined btrees
15278+
#define LFS3_RCOMPAT_BTREE 0x00000800 // Files may use btrees
15279+
#define LFS3_RCOMPAT_GRM 0x00010000 // Global-remove in use
1528015280
// internal
1528115281
#define LFS3_rcompat_OVERFLOW 0x80000000 // Can't represent all flags
1528215282

1528315283
#define LFS3_WCOMPAT_NONSTANDARD 0x00000001 // Non-standard filesystem format
1528415284
#define LFS3_WCOMPAT_RDONLY 0x00000002 // Writing is disallowed
15285-
#define LFS3_WCOMPAT_DIR 0x00000010 // Directory files in use
15286-
#define LFS3_WCOMPAT_GCKSUM 0x00001000 // Global-checksum in use
15287-
#define LFS3_WCOMPAT_GBMAP 0x00002000 // Global on-disk block-map in use
15285+
#define LFS3_WCOMPAT_GCKSUM 0x00040000 // Global-checksum in use
15286+
#define LFS3_WCOMPAT_GBMAP 0x00080000 // Global on-disk block-map in use
15287+
#define LFS3_WCOMPAT_DIR 0x01000000 // Directory files in use
1528815288
// internal
1528915289
#define LFS3_wcompat_OVERFLOW 0x80000000 // Can't represent all flags
1529015290

@@ -15303,20 +15303,20 @@ static inline bool lfs3_wcompat_isgbmap(lfs3_wcompat_t flags) {
1530315303
// figure out what compat flags the current fs configuration needs
1530415304
static inline lfs3_rcompat_t lfs3_rcompat(const lfs3_t *lfs3) {
1530515305
(void)lfs3;
15306-
return LFS3_RCOMPAT_BSHRUB
15307-
| LFS3_RCOMPAT_BTREE
15308-
| LFS3_RCOMPAT_MMOSS
15306+
return LFS3_RCOMPAT_MMOSS
1530915307
| LFS3_RCOMPAT_MTREE
15308+
| LFS3_RCOMPAT_BSHRUB
15309+
| LFS3_RCOMPAT_BTREE
1531015310
| LFS3_RCOMPAT_GRM;
1531115311
}
1531215312

1531315313
static inline lfs3_wcompat_t lfs3_wcompat(const lfs3_t *lfs3) {
1531415314
(void)lfs3;
15315-
return LFS3_WCOMPAT_DIR
15316-
| LFS3_WCOMPAT_GCKSUM
15315+
return LFS3_WCOMPAT_GCKSUM
1531715316
| LFS3_IFDEF_GBMAP(
1531815317
(lfs3_f_isgbmap(lfs3->flags)) ? LFS3_WCOMPAT_GBMAP : 0,
15319-
0);
15318+
0)
15319+
| LFS3_WCOMPAT_DIR;
1532015320
}
1532115321

1532215322
static inline lfs3_ocompat_t lfs3_ocompat(const lfs3_t *lfs3) {

scripts/dbgbmap.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,22 +95,22 @@
9595

9696

9797
RCOMPAT_NONSTANDARD = 0x00000001 # Non-standard filesystem format
98-
RCOMPAT_WRONLY = 0x00000002 # Reading is disallowed
99-
RCOMPAT_BMOSS = 0x00000010 # Files may use inlined data
100-
RCOMPAT_BSPROUT = 0x00000020 # Files may use block pointers
101-
RCOMPAT_BSHRUB = 0x00000040 # Files may use inlined btrees
102-
RCOMPAT_BTREE = 0x00000080 # Files may use btrees
103-
RCOMPAT_MMOSS = 0x00000100 # May use an inlined mdir
104-
RCOMPAT_MSPROUT = 0x00000200 # May use an mdir pointer
105-
RCOMPAT_MSHRUB = 0x00000400 # May use an inlined mtree
106-
RCOMPAT_MTREE = 0x00000800 # May use an mdir btree
107-
RCOMPAT_GRM = 0x00001000 # Global-remove in use
98+
RCOMPAT_WRONLY = 0x00000004 # Reading is disallowed
99+
RCOMPAT_MMOSS = 0x00000010 # May use an inlined mdir
100+
RCOMPAT_MSPROUT = 0x00000020 # May use an mdir pointer
101+
RCOMPAT_MSHRUB = 0x00000040 # May use an inlined mtree
102+
RCOMPAT_MTREE = 0x00000080 # May use an mdir btree
103+
RCOMPAT_BMOSS = 0x00000100 # Files may use inlined data
104+
RCOMPAT_BSPROUT = 0x00000200 # Files may use block pointers
105+
RCOMPAT_BSHRUB = 0x00000400 # Files may use inlined btrees
106+
RCOMPAT_BTREE = 0x00000800 # Files may use btrees
107+
RCOMPAT_GRM = 0x00010000 # Global-remove in use
108108

109109
WCOMPAT_NONSTANDARD = 0x00000001 # Non-standard filesystem format
110110
WCOMPAT_RDONLY = 0x00000002 # Writing is disallowed
111-
WCOMPAT_DIR = 0x00000010 # Directory file types in use
112-
WCOMPAT_GCKSUM = 0x00001000 # Global-checksum in use
113-
WCOMPAT_GBMAP = 0x00002000 # Global on-disk block-map in use
111+
WCOMPAT_GCKSUM = 0x00040000 # Global-checksum in use
112+
WCOMPAT_GBMAP = 0x00080000 # Global on-disk block-map in use
113+
WCOMPAT_DIR = 0x01000000 # Directory file types in use
114114

115115
TAG_NULL = 0x0000 ## v--- ---- +--- ----
116116
TAG_CONFIG = 0x0000 ## v--- ---- +ttt tttt

scripts/dbgbmapsvg.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,23 +113,24 @@
113113
}
114114

115115

116+
116117
RCOMPAT_NONSTANDARD = 0x00000001 # Non-standard filesystem format
117-
RCOMPAT_WRONLY = 0x00000002 # Reading is disallowed
118-
RCOMPAT_BMOSS = 0x00000010 # Files may use inlined data
119-
RCOMPAT_BSPROUT = 0x00000020 # Files may use block pointers
120-
RCOMPAT_BSHRUB = 0x00000040 # Files may use inlined btrees
121-
RCOMPAT_BTREE = 0x00000080 # Files may use btrees
122-
RCOMPAT_MMOSS = 0x00000100 # May use an inlined mdir
123-
RCOMPAT_MSPROUT = 0x00000200 # May use an mdir pointer
124-
RCOMPAT_MSHRUB = 0x00000400 # May use an inlined mtree
125-
RCOMPAT_MTREE = 0x00000800 # May use an mdir btree
126-
RCOMPAT_GRM = 0x00001000 # Global-remove in use
118+
RCOMPAT_WRONLY = 0x00000004 # Reading is disallowed
119+
RCOMPAT_MMOSS = 0x00000010 # May use an inlined mdir
120+
RCOMPAT_MSPROUT = 0x00000020 # May use an mdir pointer
121+
RCOMPAT_MSHRUB = 0x00000040 # May use an inlined mtree
122+
RCOMPAT_MTREE = 0x00000080 # May use an mdir btree
123+
RCOMPAT_BMOSS = 0x00000100 # Files may use inlined data
124+
RCOMPAT_BSPROUT = 0x00000200 # Files may use block pointers
125+
RCOMPAT_BSHRUB = 0x00000400 # Files may use inlined btrees
126+
RCOMPAT_BTREE = 0x00000800 # Files may use btrees
127+
RCOMPAT_GRM = 0x00010000 # Global-remove in use
127128

128129
WCOMPAT_NONSTANDARD = 0x00000001 # Non-standard filesystem format
129130
WCOMPAT_RDONLY = 0x00000002 # Writing is disallowed
130-
WCOMPAT_DIR = 0x00000010 # Directory file types in use
131-
WCOMPAT_GCKSUM = 0x00001000 # Global-checksum in use
132-
WCOMPAT_GBMAP = 0x00002000 # Global on-disk block-map in use
131+
WCOMPAT_GCKSUM = 0x00040000 # Global-checksum in use
132+
WCOMPAT_GBMAP = 0x00080000 # Global on-disk block-map in use
133+
WCOMPAT_DIR = 0x01000000 # Directory file types in use
133134

134135
TAG_NULL = 0x0000 ## v--- ---- +--- ----
135136
TAG_CONFIG = 0x0000 ## v--- ---- +ttt tttt

scripts/dbgflags.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,24 +170,24 @@
170170

171171
# Read-compat flags
172172
RCOMPAT_NONSTANDARD = 0x00000001 # -- Non-standard filesystem format
173-
RCOMPAT_WRONLY = 0x00000002 # -- Reading is disallowed
174-
RCOMPAT_BMOSS = 0x00000010 # -- Files may use inlined data
175-
RCOMPAT_BSPROUT = 0x00000020 # -- Files may use block pointers
176-
RCOMPAT_BSHRUB = 0x00000040 # -- Files may use inlined btrees
177-
RCOMPAT_BTREE = 0x00000080 # -- Files may use btrees
178-
RCOMPAT_MMOSS = 0x00000100 # -- May use an inlined mdir
179-
RCOMPAT_MSPROUT = 0x00000200 # -- May use an mdir pointer
180-
RCOMPAT_MSHRUB = 0x00000400 # -- May use an inlined mtree
181-
RCOMPAT_MTREE = 0x00000800 # -- May use an mdir btree
182-
RCOMPAT_GRM = 0x00001000 # -- Global-remove in use
173+
RCOMPAT_WRONLY = 0x00000004 # -- Reading is disallowed
174+
RCOMPAT_MMOSS = 0x00000010 # -- May use an inlined mdir
175+
RCOMPAT_MSPROUT = 0x00000020 # -- May use an mdir pointer
176+
RCOMPAT_MSHRUB = 0x00000040 # -- May use an inlined mtree
177+
RCOMPAT_MTREE = 0x00000080 # -- May use an mdir btree
178+
RCOMPAT_BMOSS = 0x00000100 # -- Files may use inlined data
179+
RCOMPAT_BSPROUT = 0x00000200 # -- Files may use block pointers
180+
RCOMPAT_BSHRUB = 0x00000400 # -- Files may use inlined btrees
181+
RCOMPAT_BTREE = 0x00000800 # -- Files may use btrees
182+
RCOMPAT_GRM = 0x00010000 # -- Global-remove in use
183183
rcompat_OVERFLOW = 0x80000000 # i- Can't represent all flags
184184

185185
# Write-compat flags
186186
WCOMPAT_NONSTANDARD = 0x00000001 # -- Non-standard filesystem format
187187
WCOMPAT_RDONLY = 0x00000002 # -- Writing is disallowed
188-
WCOMPAT_DIR = 0x00000010 # -- Directory file types in use
189-
WCOMPAT_GCKSUM = 0x00001000 # -- Global-checksum in use
190-
WCOMPAT_GBMAP = 0x00002000 # -- Global on-disk block-map in use
188+
WCOMPAT_GCKSUM = 0x00040000 # -- Global-checksum in use
189+
WCOMPAT_GBMAP = 0x00080000 # -- Global on-disk block-map in use
190+
WCOMPAT_DIR = 0x01000000 # -- Directory file types in use
191191
wcompat_OVERFLOW = 0x80000000 # i- Can't represent all flags
192192

193193
# Optional-compat flags

scripts/dbglfs3.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@
2020

2121

2222
RCOMPAT_NONSTANDARD = 0x00000001 # Non-standard filesystem format
23-
RCOMPAT_WRONLY = 0x00000002 # Reading is disallowed
24-
RCOMPAT_BMOSS = 0x00000010 # Files may use inlined data
25-
RCOMPAT_BSPROUT = 0x00000020 # Files may use block pointers
26-
RCOMPAT_BSHRUB = 0x00000040 # Files may use inlined btrees
27-
RCOMPAT_BTREE = 0x00000080 # Files may use btrees
28-
RCOMPAT_MMOSS = 0x00000100 # May use an inlined mdir
29-
RCOMPAT_MSPROUT = 0x00000200 # May use an mdir pointer
30-
RCOMPAT_MSHRUB = 0x00000400 # May use an inlined mtree
31-
RCOMPAT_MTREE = 0x00000800 # May use an mdir btree
32-
RCOMPAT_GRM = 0x00001000 # Global-remove in use
23+
RCOMPAT_WRONLY = 0x00000004 # Reading is disallowed
24+
RCOMPAT_MMOSS = 0x00000010 # May use an inlined mdir
25+
RCOMPAT_MSPROUT = 0x00000020 # May use an mdir pointer
26+
RCOMPAT_MSHRUB = 0x00000040 # May use an inlined mtree
27+
RCOMPAT_MTREE = 0x00000080 # May use an mdir btree
28+
RCOMPAT_BMOSS = 0x00000100 # Files may use inlined data
29+
RCOMPAT_BSPROUT = 0x00000200 # Files may use block pointers
30+
RCOMPAT_BSHRUB = 0x00000400 # Files may use inlined btrees
31+
RCOMPAT_BTREE = 0x00000800 # Files may use btrees
32+
RCOMPAT_GRM = 0x00010000 # Global-remove in use
3333

3434
WCOMPAT_NONSTANDARD = 0x00000001 # Non-standard filesystem format
3535
WCOMPAT_RDONLY = 0x00000002 # Writing is disallowed
36-
WCOMPAT_DIR = 0x00000010 # Directory file types in use
37-
WCOMPAT_GCKSUM = 0x00001000 # Global-checksum in use
38-
WCOMPAT_GBMAP = 0x00002000 # Global on-disk block-map in use
36+
WCOMPAT_GCKSUM = 0x00040000 # Global-checksum in use
37+
WCOMPAT_GBMAP = 0x00080000 # Global on-disk block-map in use
38+
WCOMPAT_DIR = 0x01000000 # Directory file types in use
3939

4040
TAG_NULL = 0x0000 ## v--- ---- +--- ----
4141
TAG_CONFIG = 0x0000 ## v--- ---- +ttt tttt

0 commit comments

Comments
 (0)