diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java index faf09355068..1ce29107dc8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java @@ -821,7 +821,7 @@ class FsDatasetImpl implements FsDatasetSpi { if (addr != -1) { LOG.debug("Get InputStream by cache address."); return FsDatasetUtil.getDirectInputStream( - addr, info.getBlockDataLength()); + addr + seekOffset, info.getBlockDataLength() - seekOffset); } LOG.debug("Get InputStream by cache file path."); return FsDatasetUtil.getInputStreamAndSeek(