overlay: use index=off to fix EBUSY on mount
kernel version > 4.13rc1 support index=on feature, it will be failed with EBUSY when trying to mount. Related: https://github.com/moby/moby/pull/37993 Signed-off-by: Rudy Zhang <rudyflyzhang@gmail.com>
This commit is contained in:
parent
38cb1c1a54
commit
d36810d66d
@ -70,6 +70,7 @@ type snapshotter struct {
|
|||||||
root string
|
root string
|
||||||
ms *storage.MetaStore
|
ms *storage.MetaStore
|
||||||
asyncRemove bool
|
asyncRemove bool
|
||||||
|
indexOff bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSnapshotter returns a Snapshotter which uses overlayfs. The overlayfs
|
// NewSnapshotter returns a Snapshotter which uses overlayfs. The overlayfs
|
||||||
@ -102,10 +103,17 @@ func NewSnapshotter(root string, opts ...Opt) (snapshots.Snapshotter, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// figure out whether "index=off" option is recognized by the kernel
|
||||||
|
var indexOff bool
|
||||||
|
if _, err = os.Stat("/sys/module/overlay/parameters/index"); err == nil {
|
||||||
|
indexOff = true
|
||||||
|
}
|
||||||
|
|
||||||
return &snapshotter{
|
return &snapshotter{
|
||||||
root: root,
|
root: root,
|
||||||
ms: ms,
|
ms: ms,
|
||||||
asyncRemove: config.asyncRemove,
|
asyncRemove: config.asyncRemove,
|
||||||
|
indexOff: indexOff,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,6 +473,11 @@ func (o *snapshotter) mounts(s storage.Snapshot) []mount.Mount {
|
|||||||
}
|
}
|
||||||
var options []string
|
var options []string
|
||||||
|
|
||||||
|
// set index=off when mount overlayfs
|
||||||
|
if o.indexOff {
|
||||||
|
options = append(options, "index=off")
|
||||||
|
}
|
||||||
|
|
||||||
if s.Kind == snapshots.KindActive {
|
if s.Kind == snapshots.KindActive {
|
||||||
options = append(options,
|
options = append(options,
|
||||||
fmt.Sprintf("workdir=%s", o.workPath(s.ID)),
|
fmt.Sprintf("workdir=%s", o.workPath(s.ID)),
|
||||||
|
Loading…
Reference in New Issue
Block a user