summaryrefslogtreecommitdiffhomepage
path: root/runsc/boot
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2019-05-23 04:15:18 -0700
committerShentubot <shentubot@google.com>2019-05-23 04:16:10 -0700
commit9006304dfecf3670ad03c9629f9a4ac3273c386a (patch)
tree958b4c09c1118cd173675618002a2c1f32384071 /runsc/boot
parent022bd0fd1091a29a41fa4c065ac35e45e3d6c576 (diff)
Initial support for bind mounts
Separate MountSource from Mount. This is needed to allow mounts to be shared by multiple containers within the same pod. PiperOrigin-RevId: 249617810 Change-Id: Id2944feb7e4194951f355cbe6d4944ae3c02e468
Diffstat (limited to 'runsc/boot')
-rw-r--r--runsc/boot/fs.go16
1 files changed, 5 insertions, 11 deletions
diff --git a/runsc/boot/fs.go b/runsc/boot/fs.go
index 1611dda2c..bc05b3491 100644
--- a/runsc/boot/fs.go
+++ b/runsc/boot/fs.go
@@ -685,27 +685,21 @@ func destroyContainerFS(ctx context.Context, cid string, k *kernel.Kernel) error
// Iterate through all submounts and unmount them. We unmount lazily by
// setting detach=true, so we can unmount in any order.
- for _, m := range containerRootDirent.Inode.MountSource.Submounts() {
+ mnt := mns.FindMount(containerRootDirent)
+ for _, m := range mns.AllMountsUnder(mnt) {
root := m.Root()
defer root.DecRef()
// Do a best-effort unmount by flushing the refs and unmount
// with "detach only = true". Unmount returns EINVAL when the mount point
// doesn't exist, i.e. it has already been unmounted.
- log.Debugf("Unmounting container submount %q", root.BaseName())
- m.FlushDirentRefs()
+ log.Debugf("Unmounting container mount %q", root.BaseName())
+ root.Inode.MountSource.FlushDirentRefs()
if err := mns.Unmount(ctx, root, true /* detach only */); err != nil && err != syserror.EINVAL {
- return fmt.Errorf("unmounting container submount %q: %v", root.BaseName(), err)
+ return fmt.Errorf("unmounting container mount %q: %v", root.BaseName(), err)
}
}
- // Unmount the container root itself.
- log.Debugf("Unmounting container root %q", containerRoot)
- containerRootDirent.Inode.MountSource.FlushDirentRefs()
- if err := mns.Unmount(ctx, containerRootDirent, true /* detach only */); err != nil {
- return fmt.Errorf("unmounting container root mount %q: %v", containerRootDirent.BaseName(), err)
- }
-
// Get a reference to the parent directory and remove the root
// container directory.
maxTraversals = 0