Commit f3578e3
committed
Removed clamping to block size in ctz linked-list
Initially, I was concerned that the number of pointers in the ctz
linked-list could exceed the storage in a block. Long story short
this isn't really possible outside of extremely small block sizes.
Since clamping impacts the layout of files on disk, removing the
block size removed quite a bit of logic and corner cases. Replaced
with an assert on block size during initialization.
---
Long story long, the minimum block size needed to store all ctz
pointers in a filesystem can be found with this formula:
B = (w/8)*log2(2^w / (B - 2*(w/8)))
where:
B = block size in bytes
w = pointer width in bits
It's not a very pretty formula, but does give us some useful info
if we apply some math:
min block size:
32 bit ctz linked-list = 104 bytes
64 bit ctz linked-list = 448 bytes
For littlefs, 128 bytes is a perfectly reasonable minimum block size.1 parent 83d4c61 commit f3578e3
1 file changed
+7
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1005 | 1005 | | |
1006 | 1006 | | |
1007 | 1007 | | |
1008 | | - | |
1009 | 1008 | | |
1010 | 1009 | | |
1011 | 1010 | | |
1012 | 1011 | | |
1013 | | - | |
| 1012 | + | |
1014 | 1013 | | |
1015 | 1014 | | |
1016 | 1015 | | |
| |||
1028 | 1027 | | |
1029 | 1028 | | |
1030 | 1029 | | |
1031 | | - | |
1032 | 1030 | | |
1033 | 1031 | | |
1034 | 1032 | | |
1035 | 1033 | | |
1036 | | - | |
| 1034 | + | |
1037 | 1035 | | |
1038 | 1036 | | |
1039 | 1037 | | |
| |||
1102 | 1100 | | |
1103 | 1101 | | |
1104 | 1102 | | |
1105 | | - | |
1106 | | - | |
| 1103 | + | |
1107 | 1104 | | |
1108 | 1105 | | |
1109 | 1106 | | |
| |||
1880 | 1877 | | |
1881 | 1878 | | |
1882 | 1879 | | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
1883 | 1884 | | |
1884 | 1885 | | |
1885 | 1886 | | |
| |||
0 commit comments