Commit d61960c
fix: Simplify generation validation to fix logical inconsistencies
This commit addresses critical flaws in the generation validation logic
identified in code review (confidence score 1/5):
**Problems Fixed:**
1. Race condition: Was capturing inode.dir.generation without holding
inode.mu lock (line 358)
2. Flawed logic: Checking for inodeGen+1 after sealing couldn't
distinguish between "we sealed it" vs "someone else sealed it"
3. Over-validation: Pre-sealing generation checks (line 363) combined
with post-sealing checks (line 371) created logical inconsistencies
4. Same issues in inode==parent case (lines 378-381)
**Solution:**
Simplified approach that only validates what matters:
- For inode != parent: Seal inode unconditionally, only validate parent
generation hasn't changed before marking gap (we care about parent
consistency for gap marking, not inode state)
- For inode == parent: Seal and mark gap while holding lock (no checks
needed as we hold lock throughout)
This eliminates race conditions and logical flaws while maintaining
correct concurrency semantics. The test failure (I/O errors and
timeout) was likely caused by these logical inconsistencies leading
to incorrect gap marking and filesystem state corruption.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 828545e commit d61960c
1 file changed
+9
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
356 | | - | |
| 356 | + | |
357 | 357 | | |
358 | | - | |
359 | 358 | | |
360 | 359 | | |
| 360 | + | |
361 | 361 | | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
| 362 | + | |
366 | 363 | | |
367 | 364 | | |
368 | | - | |
| 365 | + | |
369 | 366 | | |
370 | | - | |
371 | | - | |
372 | | - | |
| 367 | + | |
| 368 | + | |
373 | 369 | | |
374 | 370 | | |
375 | 371 | | |
376 | 372 | | |
377 | | - | |
378 | | - | |
| 373 | + | |
379 | 374 | | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
| 375 | + | |
| 376 | + | |
384 | 377 | | |
385 | 378 | | |
386 | 379 | | |
| |||
0 commit comments