vfs: reduce memory usage by re-ordering commonly used structures
This commit is contained in:
parent
e749bc58f4
commit
a07d376fb1
4 changed files with 13 additions and 13 deletions
|
@ -39,19 +39,19 @@ type File struct {
|
||||||
inode uint64 // inode number - read only
|
inode uint64 // inode number - read only
|
||||||
size int64 // size of file - read and written with atomic int64 - must be 64 bit aligned
|
size int64 // size of file - read and written with atomic int64 - must be 64 bit aligned
|
||||||
|
|
||||||
|
muRW sync.Mutex // synchronize RWFileHandle.openPending(), RWFileHandle.close() and File.Remove
|
||||||
|
|
||||||
mu sync.RWMutex // protects the following
|
mu sync.RWMutex // protects the following
|
||||||
d *Dir // parent directory
|
d *Dir // parent directory
|
||||||
dPath string // path of parent directory. NB dir rename means all Files are flushed
|
dPath string // path of parent directory. NB dir rename means all Files are flushed
|
||||||
o fs.Object // NB o may be nil if file is being written
|
o fs.Object // NB o may be nil if file is being written
|
||||||
leaf string // leaf name of the object
|
leaf string // leaf name of the object
|
||||||
writers []Handle // writers for this file
|
writers []Handle // writers for this file
|
||||||
nwriters int32 // len(writers) which is read/updated with atomic
|
|
||||||
pendingModTime time.Time // will be applied once o becomes available, i.e. after file was written
|
pendingModTime time.Time // will be applied once o becomes available, i.e. after file was written
|
||||||
pendingRenameFun func(ctx context.Context) error // will be run/renamed after all writers close
|
pendingRenameFun func(ctx context.Context) error // will be run/renamed after all writers close
|
||||||
appendMode bool // file was opened with O_APPEND
|
|
||||||
sys atomic.Value // user defined info to be attached here
|
sys atomic.Value // user defined info to be attached here
|
||||||
|
nwriters int32 // len(writers) which is read/updated with atomic
|
||||||
muRW sync.Mutex // synchronize RWFileHandle.openPending(), RWFileHandle.close() and File.Remove
|
appendMode bool // file was opened with O_APPEND
|
||||||
}
|
}
|
||||||
|
|
||||||
// newFile creates a new File
|
// newFile creates a new File
|
||||||
|
|
10
vfs/read.go
10
vfs/read.go
|
@ -21,18 +21,18 @@ type ReadFileHandle struct {
|
||||||
done func(ctx context.Context, err error)
|
done func(ctx context.Context, err error)
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
cond sync.Cond // cond lock for out of sequence reads
|
cond sync.Cond // cond lock for out of sequence reads
|
||||||
closed bool // set if handle has been closed
|
|
||||||
r *accounting.Account
|
r *accounting.Account
|
||||||
readCalled bool // set if read has been called
|
|
||||||
size int64 // size of the object (0 for unknown length)
|
size int64 // size of the object (0 for unknown length)
|
||||||
offset int64 // offset of read of o
|
offset int64 // offset of read of o
|
||||||
roffset int64 // offset of Read() calls
|
roffset int64 // offset of Read() calls
|
||||||
noSeek bool
|
|
||||||
sizeUnknown bool // set if size of source is not known
|
|
||||||
file *File
|
file *File
|
||||||
hash *hash.MultiHasher
|
hash *hash.MultiHasher
|
||||||
opened bool
|
|
||||||
remote string
|
remote string
|
||||||
|
closed bool // set if handle has been closed
|
||||||
|
readCalled bool // set if read has been called
|
||||||
|
noSeek bool
|
||||||
|
sizeUnknown bool // set if size of source is not known
|
||||||
|
opened bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check interfaces
|
// Check interfaces
|
||||||
|
|
|
@ -63,10 +63,10 @@ type Item struct {
|
||||||
downloaders *downloaders.Downloaders // a record of the downloaders in action - may be nil
|
downloaders *downloaders.Downloaders // a record of the downloaders in action - may be nil
|
||||||
o fs.Object // object we are caching - may be nil
|
o fs.Object // object we are caching - may be nil
|
||||||
fd *os.File // handle we are using to read and write to the file
|
fd *os.File // handle we are using to read and write to the file
|
||||||
modified bool // set if the file has been modified since the last Open
|
|
||||||
info Info // info about the file to persist to backing store
|
info Info // info about the file to persist to backing store
|
||||||
writeBackID writeback.Handle // id of any writebacks in progress
|
writeBackID writeback.Handle // id of any writebacks in progress
|
||||||
pendingAccesses int // number of threads - cache reset not allowed if not zero
|
pendingAccesses int // number of threads - cache reset not allowed if not zero
|
||||||
|
modified bool // set if the file has been modified since the last Open
|
||||||
beingReset bool // cache cleaner is resetting the cache file, access not allowed
|
beingReset bool // cache cleaner is resetting the cache file, access not allowed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,16 +16,16 @@ type WriteFileHandle struct {
|
||||||
baseHandle
|
baseHandle
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
cond sync.Cond // cond lock for out of sequence writes
|
cond sync.Cond // cond lock for out of sequence writes
|
||||||
closed bool // set if handle has been closed
|
|
||||||
remote string
|
remote string
|
||||||
pipeWriter *io.PipeWriter
|
pipeWriter *io.PipeWriter
|
||||||
o fs.Object
|
o fs.Object
|
||||||
result chan error
|
result chan error
|
||||||
file *File
|
file *File
|
||||||
writeCalled bool // set the first time Write() is called
|
|
||||||
offset int64
|
offset int64
|
||||||
opened bool
|
|
||||||
flags int
|
flags int
|
||||||
|
closed bool // set if handle has been closed
|
||||||
|
writeCalled bool // set the first time Write() is called
|
||||||
|
opened bool
|
||||||
truncated bool
|
truncated bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue