Skip to content

Commit c9f01ce

Browse files
authored
Merge pull request #33 from LightBitsLabs/rmenke/lbm1-19873-locking
Avoid global locking by locking subtrees. Each directory immediately below the root directory has its own mutex. When modifying the structure of the file system, do not lock globally unless you are adding or removing from the root directory. All other objects inherit their lock from their parent. Special case: when a subtree of the root is removed, it may be necessary to hold multiple locks while descending the tree. This is handled with the addition of a parameter to `item_put_locked()` / `item_put_children_locked()` that holds a pointer to the currently locked mutex. Should this not be the same as the mutex associated with the directory, that mutex is locked and becomes the currently locked mutex for the purposes of the recursive calls and is unlocked as the stack is unwound. As mutexes are obtained while descending the tree structure, there is no chance of deadlock.
2 parents 32af7d0 + 48642c0 commit c9f01ce

File tree

2 files changed

+167
-99
lines changed

2 files changed

+167
-99
lines changed

0 commit comments

Comments
 (0)