From 6dfb16f99a3bbafb31a93752c61461c77f23db9d Mon Sep 17 00:00:00 2001 From: Wei Fu Date: Thu, 15 Jun 2023 06:12:22 +0000 Subject: [PATCH] snapshots|pkg: umount without DETACH and nosync after umount Signed-off-by: Wei Fu --- pkg/testutil/helpers.go | 2 ++ pkg/testutil/mount_linux.go | 21 --------------------- pkg/testutil/mount_other.go | 22 ---------------------- snapshots/btrfs/btrfs_test.go | 2 +- snapshots/testsuite/helpers.go | 2 ++ snapshots/testsuite/helpers_linux.go | 21 --------------------- snapshots/testsuite/helpers_other.go | 21 --------------------- snapshots/testsuite/testsuite.go | 1 - snapshots/testsuite/testsuite_unix.go | 6 ------ snapshots/testsuite/testsuite_windows.go | 2 -- 10 files changed, 5 insertions(+), 95 deletions(-) delete mode 100644 pkg/testutil/mount_linux.go delete mode 100644 pkg/testutil/mount_other.go delete mode 100644 snapshots/testsuite/helpers_linux.go delete mode 100644 snapshots/testsuite/helpers_other.go diff --git a/pkg/testutil/helpers.go b/pkg/testutil/helpers.go index 850f51f83..81bf54b24 100644 --- a/pkg/testutil/helpers.go +++ b/pkg/testutil/helpers.go @@ -28,6 +28,8 @@ import ( "github.com/stretchr/testify/assert" ) +const umountflags int = 0 + var rootEnabled bool func init() { diff --git a/pkg/testutil/mount_linux.go b/pkg/testutil/mount_linux.go deleted file mode 100644 index 9c4cf8c16..000000000 --- a/pkg/testutil/mount_linux.go +++ /dev/null @@ -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 diff --git a/pkg/testutil/mount_other.go b/pkg/testutil/mount_other.go deleted file mode 100644 index b1aa7d460..000000000 --- a/pkg/testutil/mount_other.go +++ /dev/null @@ -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 diff --git a/snapshots/btrfs/btrfs_test.go b/snapshots/btrfs/btrfs_test.go index 0671d15c4..02eb93d37 100644 --- a/snapshots/btrfs/btrfs_test.go +++ b/snapshots/btrfs/btrfs_test.go @@ -102,7 +102,7 @@ func boltSnapshotter(t *testing.T) func(context.Context, string) (snapshots.Snap if err := snapshotter.Close(); err != nil { return err } - err := mount.UnmountAll(root, unix.MNT_DETACH) + err := mount.UnmountAll(root, 0) if cerr := loop.Close(); cerr != nil { err = fmt.Errorf("device cleanup failed: %w", cerr) } diff --git a/snapshots/testsuite/helpers.go b/snapshots/testsuite/helpers.go index 4315db8ff..8032418fc 100644 --- a/snapshots/testsuite/helpers.go +++ b/snapshots/testsuite/helpers.go @@ -27,6 +27,8 @@ import ( "github.com/containerd/continuity/fs/fstest" ) +const umountflags int = 0 + func applyToMounts(m []mount.Mount, work string, a fstest.Applier) (err error) { td, err := os.MkdirTemp(work, "prepare") if err != nil { diff --git a/snapshots/testsuite/helpers_linux.go b/snapshots/testsuite/helpers_linux.go deleted file mode 100644 index 9e4aac356..000000000 --- a/snapshots/testsuite/helpers_linux.go +++ /dev/null @@ -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 diff --git a/snapshots/testsuite/helpers_other.go b/snapshots/testsuite/helpers_other.go deleted file mode 100644 index d39ec0734..000000000 --- a/snapshots/testsuite/helpers_other.go +++ /dev/null @@ -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 diff --git a/snapshots/testsuite/testsuite.go b/snapshots/testsuite/testsuite.go index 7afbd953e..36982adab 100644 --- a/snapshots/testsuite/testsuite.go +++ b/snapshots/testsuite/testsuite.go @@ -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) } - sync() testutil.Unmount(t, preparing) parent = filepath.Join(work, fmt.Sprintf("committed-%d", i)) diff --git a/snapshots/testsuite/testsuite_unix.go b/snapshots/testsuite/testsuite_unix.go index 8a274ce24..e37cf86a1 100644 --- a/snapshots/testsuite/testsuite_unix.go +++ b/snapshots/testsuite/testsuite_unix.go @@ -20,8 +20,6 @@ package testsuite import ( "syscall" - - "golang.org/x/sys/unix" ) func clearMask() func() { @@ -30,7 +28,3 @@ func clearMask() func() { syscall.Umask(oldumask) } } - -func sync() { - unix.Sync() -} diff --git a/snapshots/testsuite/testsuite_windows.go b/snapshots/testsuite/testsuite_windows.go index 382a85978..a3cb82fbf 100644 --- a/snapshots/testsuite/testsuite_windows.go +++ b/snapshots/testsuite/testsuite_windows.go @@ -19,5 +19,3 @@ package testsuite func clearMask() func() { return func() {} } - -func sync() {}