提交 578fd02c 作者: Juan Batiz-Benet

fuse unmount fixes

unmounting wasn't happening, mostly because of a recent bug in
goprocess.SetTeardown. This commit bumps up some messages to
log.Warnings, as users may want to see them, and makes sure to
Unmount when a node shuts down.

License: MIT
Signed-off-by: 's avatarJuan Batiz-Benet <juan@benet.ai>
上级 7a41dcb6
...@@ -216,7 +216,7 @@ func doMount(node *core.IpfsNode, fsdir, nsdir string) error { ...@@ -216,7 +216,7 @@ func doMount(node *core.IpfsNode, fsdir, nsdir string) error {
<-done <-done
if err1 != nil || err2 != nil { if err1 != nil || err2 != nil {
log.Infof("error mounting: %s %s", err1, err2) log.Errorf("error mounting: %s %s", err1, err2)
if fsmount != nil { if fsmount != nil {
fsmount.Unmount() fsmount.Unmount()
} }
......
...@@ -382,6 +382,13 @@ func (n *IpfsNode) teardown() error { ...@@ -382,6 +382,13 @@ func (n *IpfsNode) teardown() error {
n.Repo, n.Repo,
} }
if n.Mounts.Ipfs != nil {
closers = append(closers, mount.Closer(n.Mounts.Ipfs))
}
if n.Mounts.Ipns != nil {
closers = append(closers, mount.Closer(n.Mounts.Ipns))
}
// Filesystem needs to be closed before network, dht, and blockservice // Filesystem needs to be closed before network, dht, and blockservice
// so it can use them as its shutting down // so it can use them as its shutting down
if n.IpnsFs != nil { if n.IpnsFs != nil {
......
...@@ -96,7 +96,7 @@ func (m *mount) unmount() error { ...@@ -96,7 +96,7 @@ func (m *mount) unmount() error {
if err == nil { if err == nil {
return nil return nil
} }
log.Debug("fuse unmount err: %s", err) log.Warningf("fuse unmount err: %s", err)
// try closing the fuseConn // try closing the fuseConn
err = m.fuseConn.Close() err = m.fuseConn.Close()
...@@ -104,7 +104,7 @@ func (m *mount) unmount() error { ...@@ -104,7 +104,7 @@ func (m *mount) unmount() error {
return nil return nil
} }
if err != nil { if err != nil {
log.Debug("fuse conn error: %s", err) log.Warningf("fuse conn error: %s", err)
} }
// try mount.ForceUnmountManyTimes // try mount.ForceUnmountManyTimes
......
...@@ -3,6 +3,7 @@ package mount ...@@ -3,6 +3,7 @@ package mount
import ( import (
"fmt" "fmt"
"io"
"os/exec" "os/exec"
"runtime" "runtime"
"time" "time"
...@@ -33,7 +34,7 @@ type Mount interface { ...@@ -33,7 +34,7 @@ type Mount interface {
// It does so by calling diskutil or fusermount directly. // It does so by calling diskutil or fusermount directly.
func ForceUnmount(m Mount) error { func ForceUnmount(m Mount) error {
point := m.MountPoint() point := m.MountPoint()
log.Infof("Force-Unmounting %s...", point) log.Warningf("Force-Unmounting %s...", point)
var cmd *exec.Cmd var cmd *exec.Cmd
switch runtime.GOOS { switch runtime.GOOS {
...@@ -59,7 +60,7 @@ func ForceUnmount(m Mount) error { ...@@ -59,7 +60,7 @@ func ForceUnmount(m Mount) error {
}() }()
select { select {
case <-time.After(2 * time.Second): case <-time.After(7 * time.Second):
return fmt.Errorf("umount timeout") return fmt.Errorf("umount timeout")
case err := <-errc: case err := <-errc:
return err return err
...@@ -81,3 +82,16 @@ func ForceUnmountManyTimes(m Mount, attempts int) error { ...@@ -81,3 +82,16 @@ func ForceUnmountManyTimes(m Mount, attempts int) error {
} }
return fmt.Errorf("Unmount %s failed after 10 seconds of trying.", m.MountPoint()) return fmt.Errorf("Unmount %s failed after 10 seconds of trying.", m.MountPoint())
} }
type closer struct {
M Mount
}
func (c *closer) Close() error {
log.Error(" (c *closer) Close(),", c.M.MountPoint())
return c.M.Unmount()
}
func Closer(m Mount) io.Closer {
return &closer{m}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论