Remove argument from vfs.MountNamespace.DecRef()

Updates #1035

PiperOrigin-RevId: 293194631
This commit is contained in:
Fabricio Voznika
2020-02-04 11:48:36 -08:00
committed by gVisor bot
parent 492229d017
commit dcffddf0ca
6 changed files with 8 additions and 7 deletions
+1 -1
View File
@@ -86,7 +86,7 @@ func NewAccessor(ctx context.Context, vfsObj *vfs.VirtualFilesystem, creds *auth
// Release must be called when a is no longer in use.
func (a *Accessor) Release() {
a.root.DecRef()
a.mntns.DecRef(a.vfsObj)
a.mntns.DecRef()
}
// accessorContext implements context.Context by extending an existing
+1 -1
View File
@@ -45,7 +45,7 @@ func TestDevtmpfs(t *testing.T) {
if err != nil {
t.Fatalf("failed to create tmpfs root mount: %v", err)
}
defer mntns.DecRef(vfsObj)
defer mntns.DecRef()
root := mntns.Root()
defer root.DecRef()
devpop := vfs.PathOperation{
+1 -1
View File
@@ -98,7 +98,7 @@ func (s *System) WithTemporaryContext(ctx context.Context) *System {
// Destroy release resources associated with a test system.
func (s *System) Destroy() {
s.Root.DecRef()
s.mns.DecRef(s.VFS) // Reference on mns passed to NewSystem.
s.mns.DecRef() // Reference on mns passed to NewSystem.
}
// ReadToEnd reads the contents of fd until EOF to a string.
+2 -2
View File
@@ -183,7 +183,7 @@ func BenchmarkVFS2MemfsStat(b *testing.B) {
if err != nil {
b.Fatalf("failed to create tmpfs root mount: %v", err)
}
defer mntns.DecRef(vfsObj)
defer mntns.DecRef()
var filePathBuilder strings.Builder
filePathBuilder.WriteByte('/')
@@ -374,7 +374,7 @@ func BenchmarkVFS2MemfsMountStat(b *testing.B) {
if err != nil {
b.Fatalf("failed to create tmpfs root mount: %v", err)
}
defer mntns.DecRef(vfsObj)
defer mntns.DecRef()
var filePathBuilder strings.Builder
filePathBuilder.WriteByte('/')
+1 -1
View File
@@ -51,7 +51,7 @@ func newTmpfsRoot(ctx context.Context) (*vfs.VirtualFilesystem, vfs.VirtualDentr
root := mntns.Root()
return vfsObj, root, func() {
root.DecRef()
mntns.DecRef(vfsObj)
mntns.DecRef()
}, nil
}
+2 -1
View File
@@ -423,7 +423,8 @@ func (mntns *MountNamespace) IncRef() {
}
// DecRef decrements mntns' reference count.
func (mntns *MountNamespace) DecRef(vfs *VirtualFilesystem) {
func (mntns *MountNamespace) DecRef() {
vfs := mntns.root.fs.VirtualFilesystem()
if refs := atomic.AddInt64(&mntns.refs, -1); refs == 0 {
vfs.mountMu.Lock()
vfs.mounts.seq.BeginWrite()