|
@ -16,7 +16,7 @@ type FileHandle struct { |
|
|
fh FileHandleId |
|
|
fh FileHandleId |
|
|
counter int64 |
|
|
counter int64 |
|
|
entry *filer_pb.Entry |
|
|
entry *filer_pb.Entry |
|
|
chunkAddLock sync.Mutex |
|
|
|
|
|
|
|
|
entryLock sync.Mutex |
|
|
inode uint64 |
|
|
inode uint64 |
|
|
wfs *WFS |
|
|
wfs *WFS |
|
|
|
|
|
|
|
@ -53,7 +53,20 @@ func (fh *FileHandle) FullPath() util.FullPath { |
|
|
return fp |
|
|
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
|
|
|
// find the earliest incoming chunk
|
|
|
newChunks := chunks |
|
|
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)) |
|
|
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.entry.Chunks = append(fh.entry.Chunks, newChunks...) |
|
|
fh.entryViewCache = nil |
|
|
fh.entryViewCache = nil |
|
|
fh.chunkAddLock.Unlock() |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (fh *FileHandle) Release() { |
|
|
func (fh *FileHandle) Release() { |
|
|