mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-12-02 04:46:41 -05:00
Use atomic open file reference counts
- Use relaxed increment under the map bucket lock when duplicating file handles. - Use acq_rel decrement when releasing and checking for final references. - Load moved ref_count with relaxed ordering during map insertion.
This commit is contained in:
parent
b13727abde
commit
608cd00764
3 changed files with 27 additions and 4 deletions
|
|
@ -367,10 +367,19 @@ _open(const fuse_req_ctx_t *ctx_,
|
|||
|
||||
// The ref increment keeps fuse_release.cpp from erasing and
|
||||
// freeing the canonical entry while we duplicate its fd.
|
||||
//
|
||||
// memory_order_relaxed is sufficient for the increment. The
|
||||
// concurrent_flat_map bucket lock held inside visit() already
|
||||
// provides the happens-before relationship with other mutators
|
||||
// of the same key (the release() erase_if() callback and other
|
||||
// open() visitors.) The lock's release/acquire semantics
|
||||
// publish the ref_count update to subsequent observers of the
|
||||
// same entry, so we only need atomicity from the fetch_add
|
||||
// itself.
|
||||
of.visit(ctx_->nodeid,
|
||||
[&](auto &v_)
|
||||
{
|
||||
v_.second.ref_count++;
|
||||
v_.second.ref_count.fetch_add(1,std::memory_order_relaxed);
|
||||
fi = v_.second.fi;
|
||||
backing_id = v_.second.backing_id;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue