Skip to content
This repository has been archived by the owner on Sep 22, 2020. It is now read-only.

nbd: don't return error during clean up process #316

Merged
merged 1 commit into from
Sep 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions internal/nbd/nbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ func (nbd *NBD) Serve() error {
}
}(nbd)
}
if err := waitDisconnect(nbd.nbd); err != nil {
return err
}

waitDisconnect(nbd.nbd)

wg.Wait()
return nil
}
Expand Down Expand Up @@ -248,33 +248,23 @@ func (nbd *NBD) Disconnect() error {
return nil
}

func waitDisconnect(f *os.File) error {
func waitDisconnect(f *os.File) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()

// NBD_DO_IT does not return until disconnect
if err := ioctl(f.Fd(), ioctlDoIt, 0); err != nil {
return &os.PathError{
Path: f.Name(),
Op: "ioctl NBD_DO_IT",
Err: err,
}
clog.Errorf("error %s: ioctl returned %v", f.Name(), err)
}

clog.Debugf("Running disconnection to %s", f.Name())

if err := ioctl(f.Fd(), ioctlClearQueue, 0); err != nil {
return &os.PathError{
Path: f.Name(),
Op: "ioctl NBD_CLEAR_QUEUE",
Err: err,
}
clog.Errorf("error clear queue for %s. ioctl returned: %v", f.Name(), err)
}
if err := ioctl(f.Fd(), ioctlClearSock, 0); err != nil {
return &os.PathError{
Path: f.Name(),
Op: "ioctl NBD_CLEAR_SOCK",
Err: err,
}
clog.Errorf("error clear socket for %s. ioctl returned: %v", f.Name(), err)
}
return nil
}

type serverConn struct {
Expand Down