From ab61386d29e0e478e2e1fcca92d5ee4a66a249f7 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sat, 15 Jan 2022 15:01:36 -0800 Subject: [PATCH] fix checking --- weed/filesys/page_writer.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/weed/filesys/page_writer.go b/weed/filesys/page_writer.go index 1547bce26..55ed25f96 100644 --- a/weed/filesys/page_writer.go +++ b/weed/filesys/page_writer.go @@ -1,6 +1,7 @@ package filesys import ( + "fmt" "github.com/chrislusf/seaweedfs/weed/filesys/page_writer" "github.com/chrislusf/seaweedfs/weed/glog" ) @@ -69,22 +70,24 @@ func (pw *PageWriter) FlushData() error { func (pw *PageWriter) ReadDirtyDataAt(data []byte, offset int64) (maxStop int64) { glog.V(4).Infof("ReadDirtyDataAt %v [%d, %d)", pw.f.fullpath(), offset, offset+int64(len(data))) + dataSlice := data + chunkIndex := offset / pw.chunkSize - for i := chunkIndex; len(data) > 0; i++ { - readSize := min(int64(len(data)), (i+1)*pw.chunkSize-offset) + for i := chunkIndex; len(dataSlice) > 0; i++ { + readSize := min(int64(len(dataSlice)), (i+1)*pw.chunkSize-offset) if pw.streamWriter != nil { - m1 := pw.streamWriter.ReadDirtyDataAt(data[:readSize], offset) + m1 := pw.streamWriter.ReadDirtyDataAt(dataSlice[:readSize], offset) maxStop = max(maxStop, m1) } - m2 := pw.randomWriter.ReadDirtyDataAt(data[:readSize], offset) + m2 := pw.randomWriter.ReadDirtyDataAt(dataSlice[:readSize], offset) maxStop = max(maxStop, m2) offset += readSize - data = data[readSize:] + data = dataSlice[readSize:] } - page_writer.CheckByteZero("page writer read", data, 0, maxStop-offset) + page_writer.CheckByteZero(fmt.Sprintf("page writer read [%d,%d)", offset, offset+int64(len(data))), data, 0, maxStop-offset) return }