Skip to content

Commit d1dc5ba

Browse files
committed
BACKPORT: devmapper: Log fstype and mount options during mount error
Upstream reference: moby#35732 Signed-off-by: Antonio Murdaca <runcom@redhat.com>
1 parent be5610c commit d1dc5ba

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

daemon/graphdriver/devmapper/deviceset.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import (
2020
"time"
2121

2222
"github.com/Sirupsen/logrus"
23-
2423
"github.com/docker/docker/daemon/graphdriver"
2524
"github.com/docker/docker/dockerversion"
2625
"github.com/docker/docker/pkg/devicemapper"
26+
"github.com/docker/docker/pkg/dmesg"
2727
"github.com/docker/docker/pkg/idtools"
2828
"github.com/docker/docker/pkg/loopback"
2929
"github.com/docker/docker/pkg/mount"
@@ -1191,7 +1191,7 @@ func (devices *DeviceSet) growFS(info *devInfo) error {
11911191
options = joinMountOptions(options, devices.mountOptions)
11921192

11931193
if err := mount.Mount(info.DevName(), fsMountPoint, devices.BaseDeviceFilesystem, options); err != nil {
1194-
return fmt.Errorf("Error mounting '%s' on '%s': %s", info.DevName(), fsMountPoint, err)
1194+
return fmt.Errorf("Error mounting '%s' on '%s'. fstype=%s options=%s: %s\n%v", info.DevName(), fsMountPoint, devices.BaseDeviceFilesystem, options, err, string(dmesg.Dmesg(256)))
11951195
}
11961196

11971197
defer syscall.Unmount(fsMountPoint, syscall.MNT_DETACH)
@@ -2365,7 +2365,7 @@ func (devices *DeviceSet) MountDevice(hash, path, mountLabel string) error {
23652365
options = joinMountOptions(options, label.FormatMountLabel("", mountLabel))
23662366

23672367
if err := mount.Mount(info.DevName(), path, fstype, options); err != nil {
2368-
return fmt.Errorf("devmapper: Error mounting '%s' on '%s': %s", info.DevName(), path, err)
2368+
return fmt.Errorf("devmapper: Error mounting '%s' on '%s'. fstype=%s options=%s: %s\n%v", info.DevName(), path, fstype, options, err, string(dmesg.Dmesg(256)))
23692369
}
23702370

23712371
if fstype == "xfs" && devices.xfsNospaceRetries != "" {

pkg/dmesg/dmesg_linux.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// +build linux
2+
3+
package dmesg
4+
5+
import (
6+
"syscall"
7+
"unsafe"
8+
)
9+
10+
// Dmesg returns last messages from the kernel log, up to size bytes
11+
func Dmesg(size int) []byte {
12+
t := uintptr(3) // SYSLOG_ACTION_READ_ALL
13+
b := make([]byte, size)
14+
amt, _, err := syscall.Syscall(syscall.SYS_SYSLOG, t, uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)))
15+
if err != 0 {
16+
return []byte{}
17+
}
18+
return b[:amt]
19+
}

pkg/dmesg/dmesg_linux_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package dmesg
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestDmesg(t *testing.T) {
8+
t.Logf("dmesg output follows:\n%v", string(Dmesg(512)))
9+
}

0 commit comments

Comments
 (0)