fix(client): fix the issue with the timing of triggering the addNextTask task

close:#1000354285

Signed-off-by: chihe <chihe@oppo.com>
(cherry picked from commit de243a2a87)
This commit is contained in:
chihe 2025-09-23 09:58:10 +08:00
parent d1291ff9f0
commit a83b7d2678
2 changed files with 6 additions and 7 deletions

View File

@ -489,9 +489,13 @@ func (s *Streamer) aheadRead(req *ExtentRequest, storageClass uint32) (readSize
readSize += needSize
return
} else {
oldOffset := offset
end := int(cacheBlock.offset) + int(curSize)
bytesToEnd := end - offset
reqID := uuid.New().String()
log.LogDebugf("aheadRead move ahead win inode(%v) FileOffset(%v) offset(%v) need(%v) "+
"cacheBlockOffset(%v) cacheBlockSize(%v) copied(%v) reqID(%v)",
s.inode, req.FileOffset, offset, needSize, cacheBlock.offset, curSize, bytesToEnd, reqID)
go s.aheadReadWindow.addNextTask(offset, dp, req, startTime, reqID, storageClass)
if bytesToEnd > 0 {
copy(req.Data[readSize:readSize+bytesToEnd],
cacheBlock.data[offset-int(cacheBlock.offset):offset-int(cacheBlock.offset)+bytesToEnd])
@ -504,11 +508,6 @@ func (s *Streamer) aheadRead(req *ExtentRequest, storageClass uint32) (readSize
if needSize <= 0 {
return
}
reqID := uuid.New().String()
log.LogDebugf("aheadRead move ahead win inode(%v) FileOffset(%v) offset(%v) need(%v) "+
"cacheBlockOffset(%v) cacheBlockSize(%v) copied(%v) reqID(%v)",
s.inode, req.FileOffset, offset, needSize, cacheBlock.offset, curSize, bytesToEnd, reqID)
go s.aheadReadWindow.addNextTask(oldOffset, dp, req, startTime, reqID, storageClass)
continue
}
}

View File

@ -260,8 +260,8 @@ func (s *Streamer) read(data []byte, offset int, size int, storageClass uint32)
if s.aheadReadEnable && req.ExtentKey.Size > util.CacheReadBlockSize {
bgTime := stat.BeginStat()
readBytes, err = s.aheadRead(req, storageClass)
stat.EndStat("ReadFromMem", err, bgTime, 1)
if err == nil && readBytes == req.Size {
stat.EndStat("ReadFromMem", err, bgTime, 1)
total += readBytes
continue
}