Change namespace cloning so that it clones mounts depth-first.

This saves on allocations.

This change is a subset of the changes in cl/563529897 and cl/563752003.
Committing this change in more discrete parts will help narrow down the
causes of b/299603749.

PiperOrigin-RevId: 565484026
This commit is contained in:
Lucas Manning
2023-09-14 14:53:26 -07:00
committed by gVisor bot
parent c0a9bb7b3a
commit 73f4b821a1
+2 -2
View File
@@ -180,8 +180,8 @@ func (vfs *VirtualFilesystem) CloneMountNamespace(
queue := []cloneEntry{cloneEntry{ns.root, newns.root}}
for len(queue) != 0 {
p := queue[0]
queue = queue[1:]
p := queue[len(queue)-1]
queue = queue[:len(queue)-1]
for c := range p.prevMount.children {
m := vfs.cloneMount(c, c.root, nil)
vd := VirtualDentry{