Commit b20a26cb authored by Kirill Smelkov's avatar Kirill Smelkov Committed by Levin Zimmermann

wcfs: Cleanup wlinkTab entry when client drops opened head/watch handle

The code was already behaving like that but there was XXX to do it. Add
test to verify it is actually done.

Opened WatchLink handle is released after RELEASE because
read in WatchLink.serve, after RELEASE, returns EOF and then the code
inside WCFS does all necessary WatchLink-related cleanup:

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

/reviewed-by @levin.zimmermann
/reviewed-on nexedi/wendelin.core!18
parent 87818b0d
...@@ -1831,7 +1831,6 @@ func (wnode *WatchNode) Open(flags uint32, fctx *fuse.Context) (nodefs.File, fus ...@@ -1831,7 +1831,6 @@ func (wnode *WatchNode) Open(flags uint32, fctx *fuse.Context) (nodefs.File, fus
} }
head.wlinkMu.Lock() head.wlinkMu.Lock()
// XXX del wlinkTab[w] on w.sk.File.Release
head.wlinkTab[wlink] = struct{}{} head.wlinkTab[wlink] = struct{}{}
head.wlinkMu.Unlock() head.wlinkMu.Unlock()
......
...@@ -541,7 +541,7 @@ class tDB(tWCFS): ...@@ -541,7 +541,7 @@ class tDB(tWCFS):
assert len(t._wlinks) == 0 assert len(t._wlinks) == 0
t._wc_zheadfh.close() t._wc_zheadfh.close()
t.assertStats({'PinnedBlk': 0, 'ZHeadLink': 0}) # FIXME + WatchLink, Watch t.assertStats({'WatchLink': 0, 'Watch': 0, 'PinnedBlk': 0, 'ZHeadLink': 0})
# open opens wcfs file corresponding to zf@at and starts to track it. # open opens wcfs file corresponding to zf@at and starts to track it.
# see returned tFile for details. # see returned tFile for details.
...@@ -955,8 +955,11 @@ class tWatchLink(wcfs.WatchLink): ...@@ -955,8 +955,11 @@ class tWatchLink(wcfs.WatchLink):
# this tWatchLink currently watches the following files at particular state. # this tWatchLink currently watches the following files at particular state.
t._watching = {} # {} foid -> tWatch t._watching = {} # {} foid -> tWatch
tdb.assertStats({'WatchLink': len(tdb._wlinks)})
def close(t): def close(t):
t.tdb._wlinks.remove(t) tdb = t.tdb
tdb._wlinks.remove(t)
super(tWatchLink, t).close() super(tWatchLink, t).close()
# disable all established watches # disable all established watches
...@@ -965,6 +968,8 @@ class tWatchLink(wcfs.WatchLink): ...@@ -965,6 +968,8 @@ class tWatchLink(wcfs.WatchLink):
w.pinned = {} w.pinned = {}
t._watching = {} t._watching = {}
tdb.assertStats({'WatchLink': len(tdb._wlinks)})
# ---- infrastructure: watch setup/adjust ---- # ---- infrastructure: watch setup/adjust ----
......
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