mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Allow loopback and base fs sizes set by env var
This commit is contained in:
parent
b440ec0136
commit
c3f1bb3287
1 changed files with 29 additions and 8 deletions
|
@ -12,11 +12,11 @@ import (
|
|||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"sync"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
const (
|
||||
var (
|
||||
defaultDataLoopbackSize int64 = 100 * 1024 * 1024 * 1024
|
||||
defaultMetaDataLoopbackSize int64 = 2 * 1024 * 1024 * 1024
|
||||
defaultBaseFsSize uint64 = 10 * 1024 * 1024 * 1024
|
||||
|
@ -47,6 +47,30 @@ type DeviceSetDM struct {
|
|||
activeMounts map[string]int
|
||||
}
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
|
||||
rawMetaSize := os.Getenv("DOCKER_LOOPBACK_META_SIZE")
|
||||
rawDataSize := os.Getenv("DOCKER_LOOPBACK_DATA_SIZE")
|
||||
rawBaseFSSize := os.Getenv("DOCKER_BASE_FS_SIZE")
|
||||
|
||||
if rawMetaSize != "" {
|
||||
if defaultMetaDataLoopbackSize, err = strconv.ParseInt(rawMetaSize, 0, 0); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
if rawDataSize != "" {
|
||||
if defaultDataLoopbackSize, err = strconv.ParseInt(rawDataSize, 0, 0); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
if rawBaseFSSize != "" {
|
||||
if defaultBaseFsSize, err = strconv.ParseUint(rawBaseFSSize, 0, 0); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getDevName(name string) string {
|
||||
return "/dev/mapper/" + name
|
||||
}
|
||||
|
@ -317,7 +341,7 @@ func setCloseOnExec(name string) {
|
|||
if fileInfos != nil {
|
||||
for _, i := range fileInfos {
|
||||
link, _ := os.Readlink(filepath.Join("/proc/self/fd", i.Name()))
|
||||
if link == name {
|
||||
if link == name {
|
||||
fd, err := strconv.Atoi(i.Name())
|
||||
if err == nil {
|
||||
syscall.CloseOnExec(fd)
|
||||
|
@ -327,7 +351,7 @@ func setCloseOnExec(name string) {
|
|||
}
|
||||
}
|
||||
|
||||
func (devices *DeviceSetDM) log(level int, file string, line int, dmError int, message string) {
|
||||
func (devices *DeviceSetDM) log(level int, file string, line int, dmError int, message string) {
|
||||
if level >= 7 {
|
||||
return // Ignore _LOG_DEBUG
|
||||
}
|
||||
|
@ -335,7 +359,6 @@ func (devices *DeviceSetDM) log(level int, file string, line int, dmError int, m
|
|||
utils.Debugf("libdevmapper(%d): %s:%d (%d) %s", level, file, line, dmError, message)
|
||||
}
|
||||
|
||||
|
||||
func (devices *DeviceSetDM) initDevmapper() error {
|
||||
logInit(devices)
|
||||
|
||||
|
@ -495,7 +518,6 @@ func (devices *DeviceSetDM) RemoveDevice(hash string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
|
||||
return devices.removeDevice(hash)
|
||||
}
|
||||
|
||||
|
@ -530,10 +552,9 @@ func (devices *DeviceSetDM) DeactivateDevice(hash string) error {
|
|||
}
|
||||
|
||||
utils.Debugf("DeactivateDevice %s", hash)
|
||||
return devices.deactivateDevice(hash);
|
||||
return devices.deactivateDevice(hash)
|
||||
}
|
||||
|
||||
|
||||
func (devices *DeviceSetDM) Shutdown() error {
|
||||
devices.Lock()
|
||||
defer devices.Unlock()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue