aboutsummaryrefslogtreecommitdiff
path: root/weed/mount/filehandle.go
diff options
context:
space:
mode:
Diffstat (limited to 'weed/mount/filehandle.go')
-rw-r--r--weed/mount/filehandle.go29
1 files changed, 20 insertions, 9 deletions
diff --git a/weed/mount/filehandle.go b/weed/mount/filehandle.go
index 8ce31a078..49918c104 100644
--- a/weed/mount/filehandle.go
+++ b/weed/mount/filehandle.go
@@ -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() {