|
@@ -14,6 +14,7 @@ import (
|
|
"path/filepath"
|
|
"path/filepath"
|
|
"strconv"
|
|
"strconv"
|
|
"strings"
|
|
"strings"
|
|
|
|
+ "sync"
|
|
"syscall"
|
|
"syscall"
|
|
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
"github.com/Sirupsen/logrus"
|
|
@@ -102,6 +103,9 @@ type Driver struct {
|
|
var (
|
|
var (
|
|
backingFs = "<unknown>"
|
|
backingFs = "<unknown>"
|
|
projectQuotaSupported = false
|
|
projectQuotaSupported = false
|
|
|
|
+
|
|
|
|
+ useNaiveDiffLock sync.Once
|
|
|
|
+ useNaiveDiffOnly bool
|
|
)
|
|
)
|
|
|
|
|
|
func init() {
|
|
func init() {
|
|
@@ -235,6 +239,16 @@ func supportsOverlay() error {
|
|
return graphdriver.ErrNotSupported
|
|
return graphdriver.ErrNotSupported
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func useNaiveDiff(home string) bool {
|
|
|
|
+ useNaiveDiffLock.Do(func() {
|
|
|
|
+ if err := hasOpaqueCopyUpBug(home); err != nil {
|
|
|
|
+ logrus.Warnf("Not using native diff for overlay2: %v", err)
|
|
|
|
+ useNaiveDiffOnly = true
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ return useNaiveDiffOnly
|
|
|
|
+}
|
|
|
|
+
|
|
func (d *Driver) String() string {
|
|
func (d *Driver) String() string {
|
|
return driverName
|
|
return driverName
|
|
}
|
|
}
|
|
@@ -245,6 +259,7 @@ func (d *Driver) Status() [][2]string {
|
|
return [][2]string{
|
|
return [][2]string{
|
|
{"Backing Filesystem", backingFs},
|
|
{"Backing Filesystem", backingFs},
|
|
{"Supports d_type", strconv.FormatBool(d.supportsDType)},
|
|
{"Supports d_type", strconv.FormatBool(d.supportsDType)},
|
|
|
|
+ {"Native Overlay Diff", strconv.FormatBool(!useNaiveDiff(d.home))},
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -606,7 +621,7 @@ func (d *Driver) getDiffPath(id string) string {
|
|
// and its parent and returns the size in bytes of the changes
|
|
// and its parent and returns the size in bytes of the changes
|
|
// relative to its base filesystem directory.
|
|
// relative to its base filesystem directory.
|
|
func (d *Driver) DiffSize(id, parent string) (size int64, err error) {
|
|
func (d *Driver) DiffSize(id, parent string) (size int64, err error) {
|
|
- if !d.isParent(id, parent) {
|
|
|
|
|
|
+ if useNaiveDiff(d.home) || !d.isParent(id, parent) {
|
|
return d.naiveDiff.DiffSize(id, parent)
|
|
return d.naiveDiff.DiffSize(id, parent)
|
|
}
|
|
}
|
|
return directory.Size(d.getDiffPath(id))
|
|
return directory.Size(d.getDiffPath(id))
|
|
@@ -615,7 +630,7 @@ func (d *Driver) DiffSize(id, parent string) (size int64, err error) {
|
|
// Diff produces an archive of the changes between the specified
|
|
// Diff produces an archive of the changes between the specified
|
|
// layer and its parent layer which may be "".
|
|
// layer and its parent layer which may be "".
|
|
func (d *Driver) Diff(id, parent string) (io.ReadCloser, error) {
|
|
func (d *Driver) Diff(id, parent string) (io.ReadCloser, error) {
|
|
- if !d.isParent(id, parent) {
|
|
|
|
|
|
+ if useNaiveDiff(d.home) || !d.isParent(id, parent) {
|
|
return d.naiveDiff.Diff(id, parent)
|
|
return d.naiveDiff.Diff(id, parent)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -632,7 +647,7 @@ func (d *Driver) Diff(id, parent string) (io.ReadCloser, error) {
|
|
// Changes produces a list of changes between the specified layer
|
|
// Changes produces a list of changes between the specified layer
|
|
// and its parent layer. If parent is "", then all changes will be ADD changes.
|
|
// and its parent layer. If parent is "", then all changes will be ADD changes.
|
|
func (d *Driver) Changes(id, parent string) ([]archive.Change, error) {
|
|
func (d *Driver) Changes(id, parent string) ([]archive.Change, error) {
|
|
- if !d.isParent(id, parent) {
|
|
|
|
|
|
+ if useNaiveDiff(d.home) || !d.isParent(id, parent) {
|
|
return d.naiveDiff.Changes(id, parent)
|
|
return d.naiveDiff.Changes(id, parent)
|
|
}
|
|
}
|
|
// Overlay doesn't have snapshots, so we need to get changes from all parent
|
|
// Overlay doesn't have snapshots, so we need to get changes from all parent
|