Commit bcd2a7d
committed
fix(vfs): resolve modtime race conditions in cache layer
Fix multiple interrelated race conditions in VFS modtime handling that
caused incorrect timestamps to be returned after file modifications,
particularly when using the VFS cache.
Issues fixed:
1. Pending vs dirty item priority: pendingModTime (from explicit
SetModTime calls) now takes precedence over dirty item modtime.
Previously, dirty item modtime could override an explicit setting.
2. Virtual modtime race: The deferred function setting virtualModTime
now acquires the mutex and re-checks the condition, preventing
races between concurrent ModTime() calls.
3. Stale fd stat: Cache item _stat() now always uses os.Stat() on the
path instead of fd.Stat(). File descriptor stat can return stale
cached values after os.Chtimes() updates the file's modtime.
4. Remote modtime sync: After uploading a dirty cache item, explicitly
sync the remote object's modtime to match item.info.ModTime. This
handles the case where no explicit SetModTime was called but the
cache has a modtime that should be preserved.
5. Dirty file GetModTime: For dirty files, return the metadata modtime
directly rather than stat'ing the filesystem, avoiding races with
concurrent modtime updates.
6. Save failure rollback: setModTime() now rolls back the in-memory
modtime if the disk metadata save fails, keeping memory and disk
state consistent.
Signed-off-by: Anagh Kumar Baranwal <[email protected]>1 parent 4f25443 commit bcd2a7d
2 files changed
+58
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | | - | |
390 | | - | |
391 | | - | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
392 | 397 | | |
393 | 398 | | |
394 | 399 | | |
395 | 400 | | |
396 | 401 | | |
397 | 402 | | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
398 | 407 | | |
399 | 408 | | |
400 | 409 | | |
| |||
406 | 415 | | |
407 | 416 | | |
408 | 417 | | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | 418 | | |
413 | | - | |
| 419 | + | |
414 | 420 | | |
415 | 421 | | |
416 | 422 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
370 | | - | |
371 | | - | |
372 | | - | |
| 370 | + | |
| 371 | + | |
373 | 372 | | |
374 | 373 | | |
375 | 374 | | |
| |||
624 | 623 | | |
625 | 624 | | |
626 | 625 | | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
627 | 648 | | |
628 | 649 | | |
629 | 650 | | |
| |||
650 | 671 | | |
651 | 672 | | |
652 | 673 | | |
| 674 | + | |
653 | 675 | | |
654 | 676 | | |
655 | 677 | | |
656 | 678 | | |
657 | 679 | | |
658 | 680 | | |
659 | 681 | | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
660 | 685 | | |
661 | 686 | | |
662 | 687 | | |
| |||
719 | 744 | | |
720 | 745 | | |
721 | 746 | | |
722 | | - | |
| 747 | + | |
723 | 748 | | |
724 | 749 | | |
725 | 750 | | |
| |||
1220 | 1245 | | |
1221 | 1246 | | |
1222 | 1247 | | |
| 1248 | + | |
| 1249 | + | |
1223 | 1250 | | |
1224 | 1251 | | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
1225 | 1256 | | |
1226 | 1257 | | |
1227 | 1258 | | |
| 1259 | + | |
| 1260 | + | |
1228 | 1261 | | |
1229 | 1262 | | |
1230 | | - | |
1231 | 1263 | | |
1232 | 1264 | | |
1233 | 1265 | | |
1234 | 1266 | | |
1235 | 1267 | | |
1236 | 1268 | | |
1237 | 1269 | | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
1238 | 1278 | | |
1239 | 1279 | | |
1240 | 1280 | | |
| |||
0 commit comments