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:
@ -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
|
||||
|
@ -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}
|
||||
}
|
||||
|
Reference in New Issue
Block a user