From 50d9383c3b50e3139ae2d479dd58d25c3e7a4883 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sat, 15 Jan 2022 18:48:05 -0800 Subject: [PATCH] adjust logging --- weed/filesys/filehandle.go | 2 +- weed/filesys/page_writer.go | 15 ++++++++------- weed/filesys/page_writer/debug_content.go | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go index 738423b6a..ab0f58b42 100644 --- a/weed/filesys/filehandle.go +++ b/weed/filesys/filehandle.go @@ -161,7 +161,7 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) { glog.Errorf("file handle read %s: %v", fileFullPath, err) } - // glog.V(4).Infof("file handle read %s [%d,%d] %d : %v", fileFullPath, offset, offset+int64(totalRead), totalRead, err) + glog.V(4).Infof("file handle read %s [%d,%d] %d : %v", fileFullPath, offset, offset+int64(totalRead), totalRead, err) return int64(totalRead), err } diff --git a/weed/filesys/page_writer.go b/weed/filesys/page_writer.go index df3d16116..0cdb3c527 100644 --- a/weed/filesys/page_writer.go +++ b/weed/filesys/page_writer.go @@ -70,24 +70,25 @@ 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 + originalData := data + originalOffset := offset chunkIndex := offset / pw.chunkSize - for i := chunkIndex; len(dataSlice) > 0; i++ { - readSize := min(int64(len(dataSlice)), (i+1)*pw.chunkSize-offset) + for i := chunkIndex; len(data) > 0; i++ { + readSize := min(int64(len(data)), (i+1)*pw.chunkSize-offset) if pw.streamWriter != nil { - m1 := pw.streamWriter.ReadDirtyDataAt(dataSlice[:readSize], offset) + m1 := pw.streamWriter.ReadDirtyDataAt(data[:readSize], offset) maxStop = max(maxStop, m1) } - m2 := pw.randomWriter.ReadDirtyDataAt(dataSlice[:readSize], offset) + m2 := pw.randomWriter.ReadDirtyDataAt(data[:readSize], offset) maxStop = max(maxStop, m2) offset += readSize - dataSlice = dataSlice[readSize:] + data = data[readSize:] } - page_writer.CheckByteZero(fmt.Sprintf("page writer read [%d,%d)", offset, offset+int64(len(data))), data, 0, maxStop-offset) + page_writer.CheckByteZero(fmt.Sprintf("page writer read [%d,%d)", originalOffset, originalOffset+int64(len(data))), originalData, 0, maxStop-originalOffset) return } diff --git a/weed/filesys/page_writer/debug_content.go b/weed/filesys/page_writer/debug_content.go index f6913ed26..54ac9c61d 100644 --- a/weed/filesys/page_writer/debug_content.go +++ b/weed/filesys/page_writer/debug_content.go @@ -10,7 +10,7 @@ func CheckByteZero(message string, p []byte, start, stop int64) { break } } - if isAllZero { + if isAllZero && start != stop { glog.Errorf("%s is all zeros [%d,%d)", message, start, stop) }