1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-07-03 23:56:41 +02:00

FUSE mount: fix file id written twice?

fix https://github.com/chrislusf/seaweedfs/issues/1373
This commit is contained in:
Chris Lu 2020-06-25 20:11:49 -07:00
parent 212c64241b
commit 3cec4b3c49
3 changed files with 8 additions and 3 deletions

View file

@ -90,6 +90,9 @@ func (c *ChunkReadAt) doReadAt(p []byte, offset int64) (n int, err error) {
found = true
if c.bufferOffset != chunk.LogicOffset {
c.buffer, err = c.fetchChunkData(chunk)
if err != nil {
glog.Errorf("fetching chunk %+v: %v\n", chunk, err)
}
c.bufferOffset = chunk.LogicOffset
}
break
@ -99,7 +102,9 @@ func (c *ChunkReadAt) doReadAt(p []byte, offset int64) (n int, err error) {
return 0, io.EOF
}
n = copy(p, c.buffer[offset-c.bufferOffset:])
if err == nil {
n = copy(p, c.buffer[offset-c.bufferOffset:])
}
// fmt.Printf("> doReadAt [%d,%d), buffer:[%d,%d)\n", offset, offset+int64(n), c.bufferOffset, c.bufferOffset+int64(len(c.buffer)))

View file

@ -212,7 +212,7 @@ func (file *File) Fsync(ctx context.Context, req *fuse.FsyncRequest) error {
func (file *File) Forget() {
t := util.NewFullPath(file.dir.FullPath(), file.Name)
glog.V(3).Infof("Forget file %s", t)
glog.V(4).Infof("Forget file %s", t)
}
func (file *File) maybeLoadEntry(ctx context.Context) error {

View file

@ -60,7 +60,7 @@ func (c *ChunkCache) doGetChunk(fileId string, chunkSize uint64) (data []byte) {
for _, diskCache := range c.diskCaches {
data := diskCache.getChunk(fid.Key)
if len(data) != 0 {
if len(data) != 0 && len(data) >= int(chunkSize) {
return data
}
}