2
0
mirror of https://github.com/xcat2/xcat-dep.git synced 2026-11-30 06:12:16 +00:00
Files
xcat-dep/lib
Daniel Hilst af2a271fdd fix(nfslock): reclaiming a borrow by path can put two processes in one lock
_reap_borrow validated a borrow's metadata and then removed the borrow by
path. rmdir names a path and not the inode that was validated, so a
contender stopped between the two steps removes whatever is at the path
when it resumes. Measured: it validated inode 157 and removed inode
33554970, a borrow a live taker held. Both contenders then took the lock,
and the ordered pair of children in the test reports 11 where it must
report 01.

The borrow is now numbered. lock.borrow is generation 0 and lock.borrow.N
is generation N, the taker is whoever holds the highest generation, and a
transition whose taker is provably dead is ended by creating the NEXT
generation rather than by removing the one that was validated. mkdir is
exclusive, so one contender wins a generation, and a process removes only
a generation it created and still holds. No process can delete another
process's claim, which is the property the old shape could not have.

The rule that reclaimed a borrow with no metadata, when two attempts found
it unchanged, is withdrawn. Its argument covered a healthy participant, not
one that pauses: a live taker can wait any length of time between its mkdir
and its first write, and superseding it puts two processes in the
transition. A generation with no valid metadata now blocks, and
sweep_stranded removes it under an exclusive claim on the root, which is
the disposition a lock.d with no metadata already has.

acquire set identity before writing the replacement lock metadata. A write
that left partial metadata and threw therefore gave DESTROY a lock to
release, and release retried for ever because lock.d existed and its
metadata could not be validated. identity is now set only after that write
succeeds, so a failed acquire leaves the destructor nothing to act on, and
release stops after R retries.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-22 13:35:38 -03:00
..