mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
feat(host): mount post_overlay with metacopy feature (#21880)
This commit is contained in:
@@ -161,7 +161,9 @@ func (d diskPostOverlay) mountPostOverlay(pod volume_mount.IPodInfo, ctrId strin
|
||||
return errors.Wrapf(err, "get post overlay mountpoint for container %s", ctrId)
|
||||
}
|
||||
|
||||
return mountutils.MountOverlay(ov.HostLowerDir, upperDir, workDir, mergedDir)
|
||||
return mountutils.MountOverlayWithFeatures(ov.HostLowerDir, upperDir, workDir, mergedDir, &mountutils.MountOverlayFeatures{
|
||||
MetaCopy: true,
|
||||
})
|
||||
}
|
||||
|
||||
func (d diskPostOverlay) unmountPostOverlay(pod volume_mount.IPodInfo, ctrId string, vm *hostapi.ContainerVolumeMount, ov *apis.ContainerVolumeMountDiskPostOverlay, useLazy bool, cleanLayers bool) error {
|
||||
|
||||
@@ -56,10 +56,28 @@ func Mount(devPath string, mountPoint string, fsType string) error {
|
||||
}
|
||||
|
||||
func MountOverlay(lowerDir []string, upperDir string, workDir string, mergedDir string) error {
|
||||
return mountOverlay(lowerDir, upperDir, workDir, mergedDir, nil)
|
||||
}
|
||||
|
||||
type MountOverlayFeatures struct {
|
||||
MetaCopy bool
|
||||
}
|
||||
|
||||
func MountOverlayWithFeatures(lowerDir []string, upperDir string, workDir string, mergedDir string, features *MountOverlayFeatures) error {
|
||||
return mountOverlay(lowerDir, upperDir, workDir, mergedDir, features)
|
||||
}
|
||||
|
||||
func mountOverlay(lowerDir []string, upperDir string, workDir string, mergedDir string, features *MountOverlayFeatures) error {
|
||||
return mountWrap(mergedDir, func() error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
overlayArgs := []string{"-t", "overlay", "overlay", "-o", fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", strings.Join(lowerDir, ":"), upperDir, workDir), mergedDir}
|
||||
optStr := fmt.Sprintf("lowerdir=%s,upperdir=%s,workdir=%s", strings.Join(lowerDir, ":"), upperDir, workDir)
|
||||
if features != nil {
|
||||
if features.MetaCopy {
|
||||
optStr += ",metacopy=on"
|
||||
}
|
||||
}
|
||||
overlayArgs := []string{"-t", "overlay", "overlay", "-o", optStr, mergedDir}
|
||||
if out, err := procutils.NewRemoteCommandContextAsFarAsPossible(ctx, "mount", overlayArgs...).Output(); err != nil {
|
||||
return errors.Wrapf(err, "mount %v: %s", overlayArgs, out)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user