Browse Source

HDFS-7831. Fix the starting index and end condition of the loop in FileDiffList.findEarlierSnapshotBlocks(). Contributed by Konstantin Shvachko.

(cherry picked from commit 73bcfa99af61e5202f030510db8954c17cba43cc)
Jing Zhao 10 năm trước cách đây
mục cha
commit
8346427929

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -717,6 +717,9 @@ Release 2.7.0 - UNRELEASED
     HDFS-7008. xlator should be closed upon exit from DFSAdmin#genericRefresh().
     HDFS-7008. xlator should be closed upon exit from DFSAdmin#genericRefresh().
     (ozawa)
     (ozawa)
 
 
+    HDFS-7831. Fix the starting index and end condition of the loop in
+    FileDiffList.findEarlierSnapshotBlocks(). (Konstantin Shvachko via jing9)
+
     BREAKDOWN OF HDFS-7584 SUBTASKS AND RELATED JIRAS
     BREAKDOWN OF HDFS-7584 SUBTASKS AND RELATED JIRAS
 
 
       HDFS-7720. Quota by Storage Type API, tools and ClientNameNode
       HDFS-7720. Quota by Storage Type API, tools and ClientNameNode

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/FileDiffList.java

@@ -63,7 +63,7 @@ public class FileDiffList extends
     List<FileDiff> diffs = this.asList();
     List<FileDiff> diffs = this.asList();
     int i = Collections.binarySearch(diffs, snapshotId);
     int i = Collections.binarySearch(diffs, snapshotId);
     BlockInfoContiguous[] blocks = null;
     BlockInfoContiguous[] blocks = null;
-    for(i = i >= 0 ? i : -i; i < diffs.size(); i--) {
+    for(i = i >= 0 ? i : -i-2; i >= 0; i--) {
       blocks = diffs.get(i).getBlocks();
       blocks = diffs.get(i).getBlocks();
       if(blocks != null) {
       if(blocks != null) {
         break;
         break;