mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-19 13:07:53 +08:00
mount: file handle locks entry better
related to https://github.com/chrislusf/seaweedfs/issues/2952
This commit is contained in:
@@ -13,12 +13,12 @@ import (
|
||||
type FileHandleId uint64
|
||||
|
||||
type FileHandle struct {
|
||||
fh FileHandleId
|
||||
counter int64
|
||||
entry *filer_pb.Entry
|
||||
chunkAddLock sync.Mutex
|
||||
inode uint64
|
||||
wfs *WFS
|
||||
fh FileHandleId
|
||||
counter int64
|
||||
entry *filer_pb.Entry
|
||||
entryLock sync.Mutex
|
||||
inode uint64
|
||||
wfs *WFS
|
||||
|
||||
// cache file has been written to
|
||||
dirtyMetadata bool
|
||||
@@ -53,7 +53,20 @@ func (fh *FileHandle) FullPath() util.FullPath {
|
||||
return fp
|
||||
}
|
||||
|
||||
func (fh *FileHandle) addChunks(chunks []*filer_pb.FileChunk) {
|
||||
func (fh *FileHandle) GetEntry() *filer_pb.Entry {
|
||||
fh.entryLock.Lock()
|
||||
defer fh.entryLock.Unlock()
|
||||
return fh.entry
|
||||
}
|
||||
func (fh *FileHandle) SetEntry(entry *filer_pb.Entry) {
|
||||
fh.entryLock.Lock()
|
||||
defer fh.entryLock.Unlock()
|
||||
fh.entry = entry
|
||||
}
|
||||
|
||||
func (fh *FileHandle) AddChunks(chunks []*filer_pb.FileChunk) {
|
||||
fh.entryLock.Lock()
|
||||
defer fh.entryLock.Unlock()
|
||||
|
||||
// find the earliest incoming chunk
|
||||
newChunks := chunks
|
||||
@@ -82,10 +95,8 @@ func (fh *FileHandle) addChunks(chunks []*filer_pb.FileChunk) {
|
||||
|
||||
glog.V(4).Infof("%s existing %d chunks adds %d more", fh.FullPath(), len(fh.entry.Chunks), len(chunks))
|
||||
|
||||
fh.chunkAddLock.Lock()
|
||||
fh.entry.Chunks = append(fh.entry.Chunks, newChunks...)
|
||||
fh.entryViewCache = nil
|
||||
fh.chunkAddLock.Unlock()
|
||||
}
|
||||
|
||||
func (fh *FileHandle) Release() {
|
||||
|
Reference in New Issue
Block a user