mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2026-04-25 05:16:00 +03:00
[GH-ISSUE #2791] CleanupCacheDir(): Clarify lock semantics #1297
Labels
No labels
bug
bug
dataloss
duplicate
enhancement
feature request
help wanted
invalid
need info
performance
pull-request
question
question
testing
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/s3fs-fuse#1297
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @CarstenGrohmann on GitHub (Jan 24, 2026).
Original GitHub issue: https://github.com/s3fs-fuse/s3fs-fuse/issues/2791
Current code
github.com/s3fs-fuse/s3fs-fuse@30c90b6459/src/fdcache.cpp (L827-L844)Observation
The lock/unlock pairing is correct, but the code structure is confusing at first glance because the unlock() is placed outside both branches.
The else-branch acquires the lock (waiting for the other thread) and immediately releases it without performing any cleanup. The comment says "wait for other thread to finish cache cleanup" - so this appears intentional.
Questions
@ggtakec commented on GitHub (Jan 24, 2026):
@CarstenGrohmann
It makes sense that this else statement waits for the other thread to finish (after acquiring the lock) and then immediately exits.
The
cache_cleanup_lockprevents theCleanupCacheDirInternal()method from being invoked multiple times.If the lock cannot be acquired immediately, it means that
CleanupCacheDirInternal()is being executed in another thread.Since cleanup was executed immediately before (by another thread) after acquiring the lock, there should be no need to execute
CleanupCacheDirInternal().Thus, the reason for waiting on the lock is to delegate cleanup to the other thread and simply wait for it to complete.
@CarstenGrohmann commented on GitHub (Jan 24, 2026):
Yes, that makes sense. What do you think about updating the comment at line 840 slightly:
github.com/s3fs-fuse/s3fs-fuse@30c90b6459/src/fdcache.cpp (L839-L843)@ggtakec commented on GitHub (Jan 25, 2026):
@CarstenGrohmann Thank you. I've posted #2793 because it would be better to be detailed comments like your suggestion.
@CarstenGrohmann commented on GitHub (Feb 7, 2026):
Closed with #2793