Skip to content

Commit

Permalink
Fix deadlocks during concurrent r/w
Browse files Browse the repository at this point in the history
  • Loading branch information
Woellchen committed Aug 31, 2022
1 parent 5365da5 commit 91e8458
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions weed/mount/filehandle.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ func (fh *FileHandle) AddChunks(chunks []*filer_pb.FileChunk) {
fh.entryLock.Lock()
defer fh.entryLock.Unlock()

if fh.entry == nil {
return
}

// find the earliest incoming chunk
newChunks := chunks
earliestChunk := newChunks[0]
Expand All @@ -86,10 +90,6 @@ func (fh *FileHandle) AddChunks(chunks []*filer_pb.FileChunk) {
}
}

if fh.entry == nil {
return
}

// pick out-of-order chunks from existing chunks
for _, chunk := range fh.entry.Chunks {
if lessThan(earliestChunk, chunk) {
Expand Down
4 changes: 2 additions & 2 deletions weed/mount/weedfs_file_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func (wfs *WFS) Read(cancel <-chan struct{}, in *fuse.ReadIn, buff []byte) (fuse
return nil, fuse.ENOENT
}

fh.entryLock.Lock()
defer fh.entryLock.Unlock()
fh.Lock()
defer fh.Unlock()

offset := int64(in.Offset)
totalRead, err := readDataByFileHandle(buff, fh, offset)
Expand Down

0 comments on commit 91e8458

Please sign in to comment.