Commit e611cf5
committed
Fix incorrect lookahead population before ack
Rather than tracking all in-flight blocks blocks during a lookahead,
littlefs uses an ack scheme to mark the first allocated block that
hasn't reached the disk yet. littlefs assumes all blocks since the
last ack are bad or in-flight, and uses this to know when it's out
of storage.
However, these unacked allocations were still being populated in the
lookahead buffer. If the whole block device fits in the lookahead
buffer, _and_ littlefs managed to scan around the whole storage while
an unacked block was still in-flight, it would assume the block was
free and misallocate it.
The fix is to only fill the lookahead buffer up to the last ack.
The internal free structure was restructured to simplify the runtime
calculation of lookahead size.1 parent a25743a commit e611cf5
3 files changed
+54
-21
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
281 | | - | |
| 281 | + | |
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
| 290 | + | |
302 | 291 | | |
303 | 292 | | |
304 | 293 | | |
| |||
309 | 298 | | |
310 | 299 | | |
311 | 300 | | |
312 | | - | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
313 | 310 | | |
314 | 311 | | |
315 | 312 | | |
| |||
322 | 319 | | |
323 | 320 | | |
324 | 321 | | |
325 | | - | |
| 322 | + | |
326 | 323 | | |
327 | 324 | | |
328 | 325 | | |
| |||
2035 | 2032 | | |
2036 | 2033 | | |
2037 | 2034 | | |
| 2035 | + | |
2038 | 2036 | | |
2039 | | - | |
| 2037 | + | |
2040 | 2038 | | |
2041 | 2039 | | |
2042 | | - | |
2043 | 2040 | | |
2044 | 2041 | | |
2045 | 2042 | | |
| |||
2112 | 2109 | | |
2113 | 2110 | | |
2114 | 2111 | | |
2115 | | - | |
2116 | | - | |
2117 | | - | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
2118 | 2116 | | |
2119 | 2117 | | |
2120 | 2118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
263 | | - | |
| 263 | + | |
264 | 264 | | |
| 265 | + | |
265 | 266 | | |
266 | 267 | | |
267 | 268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
266 | 266 | | |
267 | 267 | | |
268 | 268 | | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
269 | 303 | | |
270 | 304 | | |
271 | 305 | | |
0 commit comments