yandrey321 commented on code in PR #10764:
URL: https://github.com/apache/ozone/pull/10764#discussion_r3763107757
##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/StreamBlockInputStream.java:
##########
@@ -628,5 +634,46 @@ public void setStreamingReadResponse(StreamingReadResponse
streamingReadResponse
public String toString() {
return name;
}
+
+ private void verifyChecksumForReadBlock(
+ ByteBuffer data, ChecksumData checksumData, ReadBlockResponseProto
readBlock)
+ throws OzoneChecksumException {
+ if (!checksumData.getChecksumType().equals(ChecksumType.NONE)) {
+ int bytesPerChecksum = checksumData.getBytesPerChecksum();
+ long blockOffset = readBlock.getOffset();
+ long readLength = data.remaining();
+ long currentChunkOffset = 0;
+ int checksumIndex = 0;
+ int dataOffset = 0;
+
+ for (ContainerProtos.ChunkInfo chunk :
readBlock.getChunkInfoList().getChunksList()) {
+ long chunkStart = currentChunkOffset;
+ long chunkEnd = chunkStart + chunk.getLen();
+
+ long overlapStart = Math.max(blockOffset, chunkStart);
+ long overlapEnd = Math.min(blockOffset + readLength, chunkEnd);
+
+ if (overlapStart < overlapEnd) {
+ int overlapLen = Math.toIntExact(overlapEnd - overlapStart);
+ ByteBuffer chunkData = data.duplicate();
+ chunkData.position(data.position() + dataOffset);
+ chunkData.limit(data.position() + dataOffset + overlapLen);
+
+ Checksum.verifyChecksum(chunkData, checksumData, checksumIndex);
Review Comment:
This assumes the read offset lands on a chunk's internal checksum boundary,
but reads are only aligned to the global bytesPerChecksum grid. Once a short
chunk shifts later chunks off that grid, a partial read starting inside a chunk
selects/computes checksums over the wrong byte range and throws a false mismatch
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]