Browse Source

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>
pull/5792/head
wusong 6 months ago
committed by GitHub
parent
commit
ce61a66b65
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      weed/filer/filechunk_group.go

5
weed/filer/filechunk_group.go

@ -1,10 +1,11 @@
package filer package filer
import ( import (
"sync"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb" "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/seaweedfs/weed/util/chunk_cache" "github.com/seaweedfs/seaweedfs/weed/util/chunk_cache"
"github.com/seaweedfs/seaweedfs/weed/wdclient" "github.com/seaweedfs/seaweedfs/weed/wdclient"
"sync"
) )
type ChunkGroup struct { type ChunkGroup struct {
@ -54,9 +55,11 @@ func (group *ChunkGroup) ReadDataAt(fileSize int64, buff []byte, offset int64) (
section, found := group.sections[si] section, found := group.sections[si]
rangeStart, rangeStop := max(offset, int64(si*SectionSize)), min(offset+int64(len(buff)), int64((si+1)*SectionSize)) rangeStart, rangeStop := max(offset, int64(si*SectionSize)), min(offset+int64(len(buff)), int64((si+1)*SectionSize))
if !found { if !found {
rangeStop = min(rangeStop, fileSize)
for i := rangeStart; i < rangeStop; i++ { for i := rangeStart; i < rangeStop; i++ {
buff[i-offset] = 0 buff[i-offset] = 0
} }
n = int(int64(n) + rangeStop - rangeStart)
continue continue
} }
xn, xTsNs, xErr := section.readDataAt(group, fileSize, buff[rangeStart-offset:rangeStop-offset], rangeStart) xn, xTsNs, xErr := section.readDataAt(group, fileSize, buff[rangeStart-offset:rangeStop-offset], rangeStart)

Loading…
Cancel
Save