mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
devmapper: Fail to start container if xfs_nospace_max_retries can't be enforced
We just introduced a new tunable dm.xfs_nospace_max_retries. But this tunable will work only on new kernels where xfs supports this feature. On older kernels xfs does not allow tuning this behavior. There are two issues. First one is that if xfsSetNospaceRetries() fails, it returns error but leaves the device activated and mounted. We should be unmounting the device and deactivate it before returning. Second issue is, if docker is started on older kernel, with dm.xfs_nospace_max_retries specified, then docker will silently ignore the fact that /sys file to tweak this behavior is not present and will continue. But I think it might be better to fail container creation/start if kernel does not support this feature. This patch fixes it. After this patch, user will get an error like following when container is run. # docker run -ti fedora bash docker: Error response from daemon: devmapper: user specified daemon option dm.xfs_nospace_max_retries but it does not seem to be supported on this system :open /sys/fs/xfs/dm-5/error/metadata/ENOSPC/max_retries: no such file or directory. Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
parent
e73e37f112
commit
6cc55dd65b
1 changed files with 3 additions and 5 deletions
|
@ -2325,11 +2325,7 @@ func (devices *DeviceSet) xfsSetNospaceRetries(info *devInfo) error {
|
|||
filePath := "/sys/fs/xfs/" + dmDeviceName + "/error/metadata/ENOSPC/max_retries"
|
||||
maxRetriesFile, err := os.OpenFile(filePath, os.O_WRONLY, 0)
|
||||
if err != nil {
|
||||
// Older kernels don't have this feature/file
|
||||
if os.IsNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("devmapper: Failed to open file %v:%v", filePath, err)
|
||||
return fmt.Errorf("devmapper: user specified daemon option dm.xfs_nospace_max_retries but it does not seem to be supported on this system :%v", err)
|
||||
}
|
||||
defer maxRetriesFile.Close()
|
||||
|
||||
|
@ -2383,6 +2379,8 @@ func (devices *DeviceSet) MountDevice(hash, path, mountLabel string) error {
|
|||
|
||||
if fstype == "xfs" && devices.xfsNospaceRetries != "" {
|
||||
if err := devices.xfsSetNospaceRetries(info); err != nil {
|
||||
syscall.Unmount(path, syscall.MNT_DETACH)
|
||||
devices.deactivateDevice(info)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue