[ 
https://issues.apache.org/jira/browse/HDFS-4292?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13528186#comment-13528186
 ] 

Todd Lipcon commented on HDFS-4292:
-----------------------------------

I'm a bit hazy on this code, having not looked at it for a little while. So, I 
had to write out some notes for myself, which I'll include here for anyone else 
who wants to follow along.

The explanation of these variables is that {{firstChunkOffset}} represents the 
byte offset of what the DN will start sending, and {{startOffset}} is the byte 
offset that the client has requested. Then {{checksum.getBytesPerChecksum()}} 
is the 'checksum chunk size', typically 512 bytes. So, for example, if the 
client wanted to read starting at byte 1026, we would have:
- {{firstChunkOffset == 1024}} (since the DN always aligns backwards to the 
beginning of a chunk)
- {{startOffset == 1026}}
- {{checksum.getBytesPerChecksum() == 512}}

The new logic says that if {{firstChunkOffset <= (startOffset - 
checksum.getBytesPerChecksum())}} it is an error -- in other words, that the 
{{firstChunkOffset}} should be no more than a single chunk backward from the 
requested start offset. That seems right to me.

So, +1. I'll commit this momentarily
                
> Sanity check not correct in RemoteBlockReader2.newBlockReader
> -------------------------------------------------------------
>
>                 Key: HDFS-4292
>                 URL: https://issues.apache.org/jira/browse/HDFS-4292
>             Project: Hadoop HDFS
>          Issue Type: Bug
>            Reporter: Binglin Chang
>            Assignee: Binglin Chang
>            Priority: Minor
>         Attachments: HDFS-4292.patch
>
>
> {code}
>     if ( firstChunkOffset < 0 || firstChunkOffset > startOffset ||
>         firstChunkOffset >= (startOffset + checksum.getBytesPerChecksum())) {
> {code}
> should be:
> {code}
>     if ( firstChunkOffset < 0 || firstChunkOffset > startOffset ||
>         firstChunkOffset <= (startOffset - checksum.getBytesPerChecksum())) {
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to