Commit 380a8793 authored by Kirill Smelkov's avatar Kirill Smelkov

wcfs: Fix wlinkTab locking

ZWatcher says it does not need to lock wlinkMu because it is already
holding zheadMu and setupWatch runs with zheadMu locked. That is indeed
true, but the mistake here is that it i not only setupWatch that makes
access to wlinkTab. For example WatchNode.Open registers new entries
there only under wlinkMu:

https://lab.nexedi.com/nexedi/wendelin.core/-/blob/wendelin.core-2.0.alpha3-26-g79e6f7b9/wcfs/wcfs.go#L1819-1822

-> Fix it by always using wlinkMu when accessing wlinkTab.

My mistake from 6f0cdaff (wcfs: Provide isolation to clients)

Test is, hopefully, TODO.
parent eb700acc
...@@ -973,12 +973,11 @@ retry: ...@@ -973,12 +973,11 @@ retry:
// shrink δFtail not to grow indefinitely. // shrink δFtail not to grow indefinitely.
// cover history for at least 1 minute, but including all watches. // cover history for at least 1 minute, but including all watches.
// No need to lock anything because we are holding zheadMu and
// setupWatch too runs with zheadMu locked.
// //
// TODO shrink δFtail only once in a while - there is no need to compute // TODO shrink δFtail only once in a while - there is no need to compute
// revCut and cut δFtail on every transaction. // revCut and cut δFtail on every transaction.
revCut := zodb.TidFromTime(zhead.At().Time().Add(-1*time.Minute)) revCut := zodb.TidFromTime(zhead.At().Time().Add(-1*time.Minute))
head.wlinkMu.Lock()
for wlink := range head.wlinkTab { for wlink := range head.wlinkTab {
for _, w := range wlink.byfile { for _, w := range wlink.byfile {
if w.at < revCut { if w.at < revCut {
...@@ -986,6 +985,7 @@ retry: ...@@ -986,6 +985,7 @@ retry:
} }
} }
} }
head.wlinkMu.Unlock()
bfdir.δFtail.ForgetPast(revCut) bfdir.δFtail.ForgetPast(revCut)
// notify zhead.At waiters // notify zhead.At waiters
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment