Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

FUSE mount: fix file id written twice?

Chris Lu3cec4b3c49b4
diff --git a/weed/filer2/reader_at.go b/weed/filer2/reader_at.go
index 2771f878cc..697e3f6305 100644
--- a/weed/filer2/reader_at.go
+++ b/weed/filer2/reader_at.go
@@ -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)))
diff --git a/weed/filesys/file.go b/weed/filesys/file.go
index 2932d49101..0f788a8880 100644
--- a/weed/filesys/file.go
+++ b/weed/filesys/file.go
@@ -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 {
diff --git a/weed/util/chunk_cache/chunk_cache.go b/weed/util/chunk_cache/chunk_cache.go
index e1d4b639f6..9421ac15c1 100644
--- a/weed/util/chunk_cache/chunk_cache.go
+++ b/weed/util/chunk_cache/chunk_cache.go
@@ -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
}
}