diff options
| author | wusong <75450248+wusongANKANG@users.noreply.github.com> | 2024-07-16 22:59:55 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-16 07:59:55 -0700 |
| commit | ce61a66b651f83b851e85d68e91f62e0aea00ec7 (patch) | |
| tree | 3abeaca3f7dc0546fd05f7c22a29c35bdef72a5b | |
| parent | 794a5aa67de3033ddfc9c77b962d75fa668798ed (diff) | |
| download | seaweedfs-ce61a66b651f83b851e85d68e91f62e0aea00ec7.tar.xz seaweedfs-ce61a66b651f83b851e85d68e91f62e0aea00ec7.zip | |
Fix mmap write fail (#5791)
* [mount] fix GetAttr blocks count
Signed-off-by: wang wusong <wangwusong@virtaitech.com>
* [mount] fix mmap read
Signed-off-by: wang wusong <wangwusong@virtaitech.com>
---------
Signed-off-by: wang wusong <wangwusong@virtaitech.com>
Co-authored-by: wang wusong <wangwusong@virtaitech.com>
| -rw-r--r-- | weed/filer/filechunk_group.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/weed/filer/filechunk_group.go b/weed/filer/filechunk_group.go index c89527710..dbd08b42b 100644 --- a/weed/filer/filechunk_group.go +++ b/weed/filer/filechunk_group.go @@ -1,10 +1,11 @@ package filer import ( + "sync" + "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/util/chunk_cache" "github.com/seaweedfs/seaweedfs/weed/wdclient" - "sync" ) type ChunkGroup struct { @@ -54,9 +55,11 @@ func (group *ChunkGroup) ReadDataAt(fileSize int64, buff []byte, offset int64) ( section, found := group.sections[si] rangeStart, rangeStop := max(offset, int64(si*SectionSize)), min(offset+int64(len(buff)), int64((si+1)*SectionSize)) if !found { + rangeStop = min(rangeStop, fileSize) for i := rangeStart; i < rangeStop; i++ { buff[i-offset] = 0 } + n = int(int64(n) + rangeStop - rangeStart) continue } xn, xTsNs, xErr := section.readDataAt(group, fileSize, buff[rangeStart-offset:rangeStop-offset], rangeStart) |
