snapshots|pkg: umount without DETACH and nosync after umount

Signed-off-by: Wei Fu <fuweid89@gmail.com>
This commit is contained in:
Wei Fu 2023-06-15 06:12:22 +00:00
parent 72b7d16505
commit 6dfb16f99a
10 changed files with 5 additions and 95 deletions

View File

@ -28,6 +28,8 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
const umountflags int = 0
var rootEnabled bool var rootEnabled bool
func init() { func init() {

View File

@ -1,21 +0,0 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package testutil
import "golang.org/x/sys/unix"
const umountflags int = unix.MNT_DETACH

View File

@ -1,22 +0,0 @@
//go:build !linux
// +build !linux
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package testutil
const umountflags int = 0

View File

@ -102,7 +102,7 @@ func boltSnapshotter(t *testing.T) func(context.Context, string) (snapshots.Snap
if err := snapshotter.Close(); err != nil { if err := snapshotter.Close(); err != nil {
return err return err
} }
err := mount.UnmountAll(root, unix.MNT_DETACH) err := mount.UnmountAll(root, 0)
if cerr := loop.Close(); cerr != nil { if cerr := loop.Close(); cerr != nil {
err = fmt.Errorf("device cleanup failed: %w", cerr) err = fmt.Errorf("device cleanup failed: %w", cerr)
} }

View File

@ -27,6 +27,8 @@ import (
"github.com/containerd/continuity/fs/fstest" "github.com/containerd/continuity/fs/fstest"
) )
const umountflags int = 0
func applyToMounts(m []mount.Mount, work string, a fstest.Applier) (err error) { func applyToMounts(m []mount.Mount, work string, a fstest.Applier) (err error) {
td, err := os.MkdirTemp(work, "prepare") td, err := os.MkdirTemp(work, "prepare")
if err != nil { if err != nil {

View File

@ -1,21 +0,0 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package testsuite
import "golang.org/x/sys/unix"
const umountflags int = unix.MNT_DETACH

View File

@ -1,21 +0,0 @@
//go:build !linux
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package testsuite
const umountflags int = 0

View File

@ -959,7 +959,6 @@ func check128LayersMount(name string) func(ctx context.Context, t *testing.T, sn
t.Fatalf("[layer %d] preparing doesn't equal to flat after apply: %+v", i, err) t.Fatalf("[layer %d] preparing doesn't equal to flat after apply: %+v", i, err)
} }
sync()
testutil.Unmount(t, preparing) testutil.Unmount(t, preparing)
parent = filepath.Join(work, fmt.Sprintf("committed-%d", i)) parent = filepath.Join(work, fmt.Sprintf("committed-%d", i))

View File

@ -20,8 +20,6 @@ package testsuite
import ( import (
"syscall" "syscall"
"golang.org/x/sys/unix"
) )
func clearMask() func() { func clearMask() func() {
@ -30,7 +28,3 @@ func clearMask() func() {
syscall.Umask(oldumask) syscall.Umask(oldumask)
} }
} }
func sync() {
unix.Sync()
}

View File

@ -19,5 +19,3 @@ package testsuite
func clearMask() func() { func clearMask() func() {
return func() {} return func() {}
} }
func sync() {}