mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Mark some kernfs inode as Anonymous.
These inodes can never be part of a filesystem tree. They are nameless and never have a parent. This allows us to avoid taking a lock in kernfs.InotifyWithParent for such anonymous inodes. PiperOrigin-RevId: 538823227
This commit is contained in:
committed by
gVisor bot
parent
5fed8c81b8
commit
8c975e6e6e
@@ -496,11 +496,12 @@ func (*implStatFS) StatFS(context.Context, *vfs.Filesystem) (linux.Statfs, error
|
||||
//
|
||||
// +stateify savable
|
||||
type dir struct {
|
||||
kernfs.InodeNoopRefCount
|
||||
kernfs.InodeAlwaysValid
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeDirectoryNoNewChildren
|
||||
kernfs.InodeNoopRefCount
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeWatches
|
||||
kernfs.OrderedChildren
|
||||
implStatFS
|
||||
|
||||
@@ -150,6 +150,7 @@ type rootInode struct {
|
||||
kernfs.InodeAlwaysValid
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeDirectoryNoNewChildren
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeTemporary // This holds no meaning as this inode can't be Looked up and is always valid.
|
||||
kernfs.InodeWatches
|
||||
|
||||
@@ -36,6 +36,7 @@ type masterInode struct {
|
||||
implStatFS
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeNoopRefCount
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeNotDirectory
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeWatches
|
||||
|
||||
@@ -35,6 +35,7 @@ type replicaInode struct {
|
||||
implStatFS
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeNoopRefCount
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeNotDirectory
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeWatches
|
||||
|
||||
@@ -45,6 +45,7 @@ type fileHandle struct {
|
||||
type inode struct {
|
||||
inodeRefs
|
||||
kernfs.InodeAlwaysValid
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeWatches
|
||||
kernfs.OrderedChildren
|
||||
|
||||
@@ -94,10 +94,11 @@ func isEpollable(fd int) bool {
|
||||
//
|
||||
// +stateify savable
|
||||
type inode struct {
|
||||
kernfs.CachedMappable
|
||||
kernfs.InodeNoStatFS
|
||||
kernfs.InodeAnonymous // inode is effectively anonymous because it represents a donated FD.
|
||||
kernfs.InodeNotDirectory
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.CachedMappable
|
||||
kernfs.InodeTemporary // This holds no meaning as this inode can't be Looked up and is always valid.
|
||||
kernfs.InodeWatches
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ type DynamicBytesFile struct {
|
||||
InodeAttrs
|
||||
InodeNoStatFS
|
||||
InodeNoopRefCount
|
||||
InodeNotAnonymous
|
||||
InodeNotDirectory
|
||||
InodeNotSymlink
|
||||
InodeWatches
|
||||
|
||||
@@ -724,6 +724,7 @@ type StaticDirectory struct {
|
||||
InodeAttrs
|
||||
InodeDirectoryNoNewChildren
|
||||
InodeNoStatFS
|
||||
InodeNotAnonymous
|
||||
InodeNotSymlink
|
||||
InodeTemporary
|
||||
InodeWatches
|
||||
@@ -819,3 +820,23 @@ type InodeWatches struct {
|
||||
func (i *InodeWatches) Watches() *vfs.Watches {
|
||||
return &i.watches
|
||||
}
|
||||
|
||||
// InodeAnonymous partially implements Inode.
|
||||
//
|
||||
// +stateify savable
|
||||
type InodeAnonymous struct{}
|
||||
|
||||
// Anonymous implements Inode.Anonymous
|
||||
func (*InodeAnonymous) Anonymous() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// InodeNotAnonymous partially implements Inode.
|
||||
//
|
||||
// +stateify savable
|
||||
type InodeNotAnonymous struct{}
|
||||
|
||||
// Anonymous implements Inode.Anonymous
|
||||
func (*InodeNotAnonymous) Anonymous() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -514,12 +514,18 @@ func (d *Dentry) InotifyWithParent(ctx context.Context, events, cookie uint32, e
|
||||
events |= linux.IN_ISDIR
|
||||
}
|
||||
|
||||
d.fs.mu.RLock()
|
||||
defer d.fs.mu.RUnlock()
|
||||
// The ordering below is important, Linux always notifies the parent first.
|
||||
if d.parent != nil {
|
||||
d.parent.inode.Watches().Notify(ctx, d.name, events, cookie, et, d.isDeleted())
|
||||
// Linux always notifies the parent first.
|
||||
|
||||
// Don't bother looking for a parent if the inode is anonymous. It
|
||||
// won't have one.
|
||||
if !d.inode.Anonymous() {
|
||||
d.fs.mu.RLock()
|
||||
if d.parent != nil {
|
||||
d.parent.inode.Watches().Notify(ctx, d.name, events, cookie, et, d.isDeleted())
|
||||
}
|
||||
d.fs.mu.RUnlock()
|
||||
}
|
||||
|
||||
d.inode.Watches().Notify(ctx, "", events, cookie, et, d.isDeleted())
|
||||
}
|
||||
|
||||
@@ -704,6 +710,10 @@ type Inode interface {
|
||||
|
||||
// Watches returns the set of inotify watches associated with this inode.
|
||||
Watches() *vfs.Watches
|
||||
|
||||
// Anonymous indicates that the Inode is anonymous. It will never have
|
||||
// a name or parent.
|
||||
Anonymous() bool
|
||||
}
|
||||
|
||||
type inodeRefs interface {
|
||||
|
||||
@@ -104,6 +104,7 @@ type readonlyDir struct {
|
||||
kernfs.InodeAlwaysValid
|
||||
kernfs.InodeDirectoryNoNewChildren
|
||||
kernfs.InodeNoStatFS
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeTemporary
|
||||
kernfs.InodeWatches
|
||||
@@ -139,8 +140,9 @@ type dir struct {
|
||||
dirRefs
|
||||
attrs
|
||||
kernfs.InodeAlwaysValid
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeNoStatFS
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeTemporary
|
||||
kernfs.InodeWatches
|
||||
kernfs.OrderedChildren
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
type StaticSymlink struct {
|
||||
InodeAttrs
|
||||
InodeNoopRefCount
|
||||
InodeNotAnonymous
|
||||
InodeSymlink
|
||||
InodeNoStatFS
|
||||
InodeWatches
|
||||
|
||||
@@ -32,6 +32,7 @@ type syntheticDirectory struct {
|
||||
InodeAlwaysValid
|
||||
InodeAttrs
|
||||
InodeNoStatFS
|
||||
InodeNotAnonymous
|
||||
InodeNotSymlink
|
||||
InodeWatches
|
||||
OrderedChildren
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
type rootInode struct {
|
||||
rootInodeRefs
|
||||
kernfs.InodeAlwaysValid
|
||||
kernfs.InodeAnonymous
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeDirectoryNoNewChildren
|
||||
kernfs.InodeNotSymlink
|
||||
|
||||
@@ -89,6 +89,7 @@ func (fs *filesystem) MountOptions() string {
|
||||
//
|
||||
// +stateify savable
|
||||
type inode struct {
|
||||
kernfs.InodeAnonymous
|
||||
kernfs.InodeNotDirectory
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeNoopRefCount
|
||||
|
||||
@@ -35,6 +35,7 @@ type subtasksInode struct {
|
||||
kernfs.InodeAlwaysValid
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeDirectoryNoNewChildren
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeTemporary
|
||||
kernfs.InodeWatches
|
||||
|
||||
@@ -35,6 +35,7 @@ type taskInode struct {
|
||||
implStatFS
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeDirectoryNoNewChildren
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeTemporary
|
||||
kernfs.InodeWatches
|
||||
|
||||
@@ -113,6 +113,7 @@ type fdDirInode struct {
|
||||
kernfs.InodeAlwaysValid
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeDirectoryNoNewChildren
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeTemporary
|
||||
kernfs.InodeWatches
|
||||
@@ -198,6 +199,7 @@ type fdSymlink struct {
|
||||
implStatFS
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeNoopRefCount
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeSymlink
|
||||
kernfs.InodeWatches
|
||||
|
||||
@@ -257,6 +259,7 @@ type fdInfoDirInode struct {
|
||||
kernfs.InodeAlwaysValid
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeDirectoryNoNewChildren
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeTemporary
|
||||
kernfs.InodeWatches
|
||||
|
||||
@@ -410,6 +410,7 @@ type memInode struct {
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeNoStatFS
|
||||
kernfs.InodeNoopRefCount
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeNotDirectory
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeWatches
|
||||
@@ -730,6 +731,7 @@ type statusInode struct {
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeNoStatFS
|
||||
kernfs.InodeNoopRefCount
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeNotDirectory
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeWatches
|
||||
@@ -963,6 +965,7 @@ type exeSymlink struct {
|
||||
implStatFS
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeNoopRefCount
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeSymlink
|
||||
kernfs.InodeWatches
|
||||
|
||||
@@ -1035,6 +1038,7 @@ type cwdSymlink struct {
|
||||
implStatFS
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeNoopRefCount
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeSymlink
|
||||
kernfs.InodeWatches
|
||||
|
||||
@@ -1096,6 +1100,7 @@ type rootSymlink struct {
|
||||
implStatFS
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeNoopRefCount
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeSymlink
|
||||
kernfs.InodeWatches
|
||||
|
||||
@@ -1269,6 +1274,7 @@ type namespaceInode struct {
|
||||
implStatFS
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeNoopRefCount
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeNotDirectory
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeWatches
|
||||
|
||||
@@ -41,6 +41,7 @@ type tasksInode struct {
|
||||
kernfs.InodeAlwaysValid
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeDirectoryNoNewChildren
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeNotSymlink
|
||||
kernfs.InodeTemporary // This holds no meaning as this inode can't be Looked up and is always valid.
|
||||
kernfs.InodeWatches
|
||||
|
||||
@@ -37,6 +37,7 @@ type selfSymlink struct {
|
||||
implStatFS
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeNoopRefCount
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeSymlink
|
||||
kernfs.InodeWatches
|
||||
|
||||
@@ -79,6 +80,7 @@ type threadSelfSymlink struct {
|
||||
implStatFS
|
||||
kernfs.InodeAttrs
|
||||
kernfs.InodeNoopRefCount
|
||||
kernfs.InodeNotAnonymous
|
||||
kernfs.InodeSymlink
|
||||
kernfs.InodeWatches
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user