| ... | ... |
@@ -12,11 +12,11 @@ import ( |
| 12 | 12 |
"path/filepath" |
| 13 | 13 |
"strconv" |
| 14 | 14 |
"strings" |
| 15 |
- "syscall" |
|
| 16 | 15 |
"sync" |
| 16 |
+ "syscall" |
|
| 17 | 17 |
) |
| 18 | 18 |
|
| 19 |
-const ( |
|
| 19 |
+var ( |
|
| 20 | 20 |
defaultDataLoopbackSize int64 = 100 * 1024 * 1024 * 1024 |
| 21 | 21 |
defaultMetaDataLoopbackSize int64 = 2 * 1024 * 1024 * 1024 |
| 22 | 22 |
defaultBaseFsSize uint64 = 10 * 1024 * 1024 * 1024 |
| ... | ... |
@@ -47,6 +47,30 @@ type DeviceSetDM struct {
|
| 47 | 47 |
activeMounts map[string]int |
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 |
+func init() {
|
|
| 51 |
+ var err error |
|
| 52 |
+ |
|
| 53 |
+ rawMetaSize := os.Getenv("DOCKER_LOOPBACK_META_SIZE")
|
|
| 54 |
+ rawDataSize := os.Getenv("DOCKER_LOOPBACK_DATA_SIZE")
|
|
| 55 |
+ rawBaseFSSize := os.Getenv("DOCKER_BASE_FS_SIZE")
|
|
| 56 |
+ |
|
| 57 |
+ if rawMetaSize != "" {
|
|
| 58 |
+ if defaultMetaDataLoopbackSize, err = strconv.ParseInt(rawMetaSize, 0, 0); err != nil {
|
|
| 59 |
+ panic(err) |
|
| 60 |
+ } |
|
| 61 |
+ } |
|
| 62 |
+ if rawDataSize != "" {
|
|
| 63 |
+ if defaultDataLoopbackSize, err = strconv.ParseInt(rawDataSize, 0, 0); err != nil {
|
|
| 64 |
+ panic(err) |
|
| 65 |
+ } |
|
| 66 |
+ } |
|
| 67 |
+ if rawBaseFSSize != "" {
|
|
| 68 |
+ if defaultBaseFsSize, err = strconv.ParseUint(rawBaseFSSize, 0, 0); err != nil {
|
|
| 69 |
+ panic(err) |
|
| 70 |
+ } |
|
| 71 |
+ } |
|
| 72 |
+} |
|
| 73 |
+ |
|
| 50 | 74 |
func getDevName(name string) string {
|
| 51 | 75 |
return "/dev/mapper/" + name |
| 52 | 76 |
} |
| ... | ... |
@@ -317,7 +341,7 @@ func setCloseOnExec(name string) {
|
| 317 | 317 |
if fileInfos != nil {
|
| 318 | 318 |
for _, i := range fileInfos {
|
| 319 | 319 |
link, _ := os.Readlink(filepath.Join("/proc/self/fd", i.Name()))
|
| 320 |
- if link == name {
|
|
| 320 |
+ if link == name {
|
|
| 321 | 321 |
fd, err := strconv.Atoi(i.Name()) |
| 322 | 322 |
if err == nil {
|
| 323 | 323 |
syscall.CloseOnExec(fd) |
| ... | ... |
@@ -327,7 +351,7 @@ func setCloseOnExec(name string) {
|
| 327 | 327 |
} |
| 328 | 328 |
} |
| 329 | 329 |
|
| 330 |
-func (devices *DeviceSetDM) log(level int, file string, line int, dmError int, message string) {
|
|
| 330 |
+func (devices *DeviceSetDM) log(level int, file string, line int, dmError int, message string) {
|
|
| 331 | 331 |
if level >= 7 {
|
| 332 | 332 |
return // Ignore _LOG_DEBUG |
| 333 | 333 |
} |
| ... | ... |
@@ -335,7 +359,6 @@ func (devices *DeviceSetDM) log(level int, file string, line int, dmError int, m |
| 335 | 335 |
utils.Debugf("libdevmapper(%d): %s:%d (%d) %s", level, file, line, dmError, message)
|
| 336 | 336 |
} |
| 337 | 337 |
|
| 338 |
- |
|
| 339 | 338 |
func (devices *DeviceSetDM) initDevmapper() error {
|
| 340 | 339 |
logInit(devices) |
| 341 | 340 |
|
| ... | ... |
@@ -495,7 +518,6 @@ func (devices *DeviceSetDM) RemoveDevice(hash string) error {
|
| 495 | 495 |
return err |
| 496 | 496 |
} |
| 497 | 497 |
|
| 498 |
- |
|
| 499 | 498 |
return devices.removeDevice(hash) |
| 500 | 499 |
} |
| 501 | 500 |
|
| ... | ... |
@@ -530,10 +552,9 @@ func (devices *DeviceSetDM) DeactivateDevice(hash string) error {
|
| 530 | 530 |
} |
| 531 | 531 |
|
| 532 | 532 |
utils.Debugf("DeactivateDevice %s", hash)
|
| 533 |
- return devices.deactivateDevice(hash); |
|
| 533 |
+ return devices.deactivateDevice(hash) |
|
| 534 | 534 |
} |
| 535 | 535 |
|
| 536 |
- |
|
| 537 | 536 |
func (devices *DeviceSetDM) Shutdown() error {
|
| 538 | 537 |
devices.Lock() |
| 539 | 538 |
defer devices.Unlock() |