@cryptotaxi247 / kubo / commits / 578fd02ce

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: Juan Batiz-Benet <juan@benet.ai>

Juan Batiz-Benet committed Jul 29, 2015 at 01:36 UTC 578fd02ce374c7a0604f7d21a1ba5d25e561a762
4 files changed +26 -5
core/commands/mount_unix.go
+1 -1
@@ -216,7 +216,7 @@ func doMount(node *core.IpfsNode, fsdir, nsdir string) error {
216 <-done
217
218 if err1 != nil || err2 != nil {
219 - log.Infof("error mounting: %s %s", err1, err2)
219 + log.Errorf("error mounting: %s %s", err1, err2)
220 if fsmount != nil {
221 fsmount.Unmount()
222 }
core/core.go
+7
@@ -382,6 +382,13 @@ func (n *IpfsNode) teardown() error {
382 n.Repo,
383 }
384
385 + if n.Mounts.Ipfs != nil {
386 + closers = append(closers, mount.Closer(n.Mounts.Ipfs))
387 + }
388 + if n.Mounts.Ipns != nil {
389 + closers = append(closers, mount.Closer(n.Mounts.Ipns))
390 + }
391 +
392 // Filesystem needs to be closed before network, dht, and blockservice
393 // so it can use them as its shutting down
394 if n.IpnsFs != nil {
fuse/mount/fuse.go
+2 -2
@@ -96,7 +96,7 @@ func (m *mount) unmount() error {
96 if err == nil {
97 return nil
98 }
99 - log.Debug("fuse unmount err: %s", err)
99 + log.Warningf("fuse unmount err: %s", err)
100
101 // try closing the fuseConn
102 err = m.fuseConn.Close()
@@ -104,7 +104,7 @@ func (m *mount) unmount() error {
104 return nil
105 }
106 if err != nil {
107 - log.Debug("fuse conn error: %s", err)
107 + log.Warningf("fuse conn error: %s", err)
108 }
109
110 // try mount.ForceUnmountManyTimes
fuse/mount/mount.go
+16 -2
@@ -3,6 +3,7 @@ package mount
3
4 import (
5 "fmt"
6 + "io"
7 "os/exec"
8 "runtime"
9 "time"
@@ -33,7 +34,7 @@ type Mount interface {
34 // It does so by calling diskutil or fusermount directly.
35 func ForceUnmount(m Mount) error {
36 point := m.MountPoint()
36 - log.Infof("Force-Unmounting %s...", point)
37 + log.Warningf("Force-Unmounting %s...", point)
38
39 var cmd *exec.Cmd
40 switch runtime.GOOS {
@@ -59,7 +60,7 @@ func ForceUnmount(m Mount) error {
60 }()
61
62 select {
62 - case <-time.After(2 * time.Second):
63 + case <-time.After(7 * time.Second):
64 return fmt.Errorf("umount timeout")
65 case err := <-errc:
66 return err
@@ -81,3 +82,16 @@ func ForceUnmountManyTimes(m Mount, attempts int) error {
82 }
83 return fmt.Errorf("Unmount %s failed after 10 seconds of trying.", m.MountPoint())
84 }
85 +
86 +type closer struct {
87 + M Mount
88 +}
89 +
90 +func (c *closer) Close() error {
91 + log.Error(" (c *closer) Close(),", c.M.MountPoint())
92 + return c.M.Unmount()
93 +}
94 +
95 +func Closer(m Mount) io.Closer {
96 + return &closer{m}
97 +}