1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-10 05:52:20 +08:00

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>
This commit is contained in:
Juan Batiz-Benet
2015-07-29 01:36:50 -07:00
parent 7a41dcb620
commit 578fd02ce3
4 changed files with 26 additions and 5 deletions

View File

@ -96,7 +96,7 @@ func (m *mount) unmount() error {
if err == nil {
return nil
}
log.Debug("fuse unmount err: %s", err)
log.Warningf("fuse unmount err: %s", err)
// try closing the fuseConn
err = m.fuseConn.Close()
@ -104,7 +104,7 @@ func (m *mount) unmount() error {
return nil
}
if err != nil {
log.Debug("fuse conn error: %s", err)
log.Warningf("fuse conn error: %s", err)
}
// try mount.ForceUnmountManyTimes

View File

@ -3,6 +3,7 @@ package mount
import (
"fmt"
"io"
"os/exec"
"runtime"
"time"
@ -33,7 +34,7 @@ type Mount interface {
// It does so by calling diskutil or fusermount directly.
func ForceUnmount(m Mount) error {
point := m.MountPoint()
log.Infof("Force-Unmounting %s...", point)
log.Warningf("Force-Unmounting %s...", point)
var cmd *exec.Cmd
switch runtime.GOOS {
@ -59,7 +60,7 @@ func ForceUnmount(m Mount) error {
}()
select {
case <-time.After(2 * time.Second):
case <-time.After(7 * time.Second):
return fmt.Errorf("umount timeout")
case err := <-errc:
return err
@ -81,3 +82,16 @@ func ForceUnmountManyTimes(m Mount, attempts int) error {
}
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}
}