Browse Source

HDFS-15080. Fix the issue in reading persistent memory cached data with an offset. Contributed by Feilong He.

Rakesh Radhakrishnan 5 years ago
parent
commit
7030722e5d

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java

@@ -822,7 +822,7 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
       if (addr != -1) {
       if (addr != -1) {
         LOG.debug("Get InputStream by cache address.");
         LOG.debug("Get InputStream by cache address.");
         return FsDatasetUtil.getDirectInputStream(
         return FsDatasetUtil.getDirectInputStream(
-            addr, info.getBlockDataLength());
+            addr + seekOffset, info.getBlockDataLength() - seekOffset);
       }
       }
       LOG.debug("Get InputStream by cache file path.");
       LOG.debug("Get InputStream by cache file path.");
       return FsDatasetUtil.getInputStreamAndSeek(
       return FsDatasetUtil.getInputStreamAndSeek(