Commit 60194645 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 25ba5b0f
...@@ -692,15 +692,17 @@ func traceZWatch(format string, argv ...interface{}) { ...@@ -692,15 +692,17 @@ func traceZWatch(format string, argv ...interface{}) {
// zwatcher watches for ZODB changes. // zwatcher watches for ZODB changes.
// //
// see "4) when we receive an invalidation message from ZODB ..." // see "4) when we receive an invalidation message from ZODB ..."
/*
func (root *Root) zwatcher(ctx context.Context, zwatchq chan zodb.Event) { func (root *Root) zwatcher(ctx context.Context, zwatchq chan zodb.Event) {
err := root._zwatcher(ctx, zwatchq) err := root._zwatcher(ctx, zwatchq)
if err != nil { if err != nil {
panic(err) // XXX -> wg.Wait in main panic(err) // XXX -> wg.Wait in main
} }
} }
*/
func (root *Root) _zwatcher(ctx context.Context, zwatchq chan zodb.Event) (err error) { func (root *Root) zwatcher(ctx context.Context, zwatchq chan zodb.Event) (err error) {
defer xerr.Contextf(&err, "zwatch %s", root.zstor.URL()) defer xerr.Contextf(&err, "zwatch %s", root.zstor.URL()) // XXX err ctx recheck
// XXX error -> always EIO for data operations // XXX error -> always EIO for data operations
// XXX unmount -> stop // XXX unmount -> stop
traceZWatch(">>>") traceZWatch(">>>")
...@@ -2163,7 +2165,7 @@ func _main() (err error) { ...@@ -2163,7 +2165,7 @@ func _main() (err error) {
NoPool: true, NoPool: true,
}) })
if err != nil { if err != nil {
log.Fatal(err) return err
} }
zhead.Cache().Lock() zhead.Cache().Lock()
zhead.Cache().SetControl(&zodbCacheControl{}) zhead.Cache().SetControl(&zodbCacheControl{})
...@@ -2220,7 +2222,7 @@ func _main() (err error) { ...@@ -2220,7 +2222,7 @@ func _main() (err error) {
fssrv, fsconn, err := mount(mntpt, root, opts) fssrv, fsconn, err := mount(mntpt, root, opts)
if err != nil { if err != nil {
log.Fatal(err) return err
} }
groot = root // FIXME temp workaround (see ^^^) groot = root // FIXME temp workaround (see ^^^)
gfsconn = fsconn // FIXME ----//---- gfsconn = fsconn // FIXME ----//----
...@@ -2231,7 +2233,7 @@ func _main() (err error) { ...@@ -2231,7 +2233,7 @@ func _main() (err error) {
kfuse := fmt.Sprintf("kernel FUSE (API %d.%d)", kinit.Major, kinit.Minor) kfuse := fmt.Sprintf("kernel FUSE (API %d.%d)", kinit.Major, kinit.Minor)
supports := kinit.SupportsNotify supports := kinit.SupportsNotify
if !(supports(fuse.NOTIFY_STORE_CACHE) && supports(fuse.NOTIFY_RETRIEVE_CACHE)) { if !(supports(fuse.NOTIFY_STORE_CACHE) && supports(fuse.NOTIFY_RETRIEVE_CACHE)) {
log.Fatalf("%s does not support pagecache control", kfuse) return fmt.Errorf("%s does not support pagecache control", kfuse)
} }
// make a bold warning if kernel does not support explicit cache invalidation // make a bold warning if kernel does not support explicit cache invalidation
// (patch sent upstream; see notes.txt -> "Notes on OS pagecache control") // (patch sent upstream; see notes.txt -> "Notes on OS pagecache control")
...@@ -2265,32 +2267,39 @@ func _main() (err error) { ...@@ -2265,32 +2267,39 @@ func _main() (err error) {
fsNode: newFSNode(fSticky), fsNode: newFSNode(fSticky),
}) })
// XXX place = ok?
// XXX ctx = ok? XXX -> joined ctx for fs.Serve + zwatcher ?
// XXX wait for zwatcher shutdown + log from it error
go root.zwatcher(ctx, zwatchq)
// TODO handle autoexit // TODO handle autoexit
// (exit when kernel forgets all our inodes - wcfs.py keeps .wcfs/zurl // (exit when kernel forgets all our inodes - wcfs.py keeps .wcfs/zurl
// opened, so when all inodes has been forgotten - we know all wcfs.py clients exited) // opened, so when all inodes has been forgotten - we know all wcfs.py clients exited)
_ = autoexit _ = autoexit
// serve client requests. // spawn filesystem server.
// //
// use `go serve` + `waitMount` not just `serve` - because waitMount // use `go serve` + `waitMount` not just `serve` - because waitMount
// cares to disable OS calling poll on us. // cares to disable OS calling poll on us.
// ( if we don't disable polling - fs serving can get stuck - see // ( if we don't disable polling - fs serving can get stuck - see
// https://github.com/hanwen/go-fuse/commit/4f10e248eb for details ) // https://github.com/hanwen/go-fuse/commit/4f10e248eb for details )
done := make(chan struct{}) serveCtx, serveCancel := context.WithCancel(context.Background())
go func () { go func () {
defer serveCancel()
fssrv.Serve() fssrv.Serve()
close(done)
}() }()
err = fssrv.WaitMount() err = fssrv.WaitMount()
if err != nil { if err != nil {
log.Fatal(err) // XXX err ctx? return err // XXX err ctx?
}
// filesystem server is serving requests.
// run zwatcher and wait for it to complete.
// zwatcher completes either normally - due to filesystem unmount, or fails.
// if zwatcher fails - switch filesystem to return EIO instead of stale data.
err = root.zwatcher(serveCtx, zwatchq)
if errors.Cause(err) != context.Canceled {
log.Error(err)
log.Errorf("-> switching filesystem to EIO mode")
// XXX switch fs to EIO mode
} }
<-done
// wait for unmount
<-serveCtx.Done()
return nil return nil
} }
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