From e692c7dd92c0d0fef50ce08edd972000151a9fe4 Mon Sep 17 00:00:00 2001 From: Jing Zhao Date: Thu, 9 Jul 2015 14:07:37 -0700 Subject: [PATCH] HDFS-8484. Erasure coding: Two contiguous blocks occupy IDs belong to same striped group. Contributed by Walter Su. --- .../hadoop-hdfs/CHANGES-HDFS-EC-7285.txt | 3 +++ .../server/blockmanagement/BlockManager.java | 22 ++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt index 7db7f153439..90f6732da3a 100755 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-EC-7285.txt @@ -338,3 +338,6 @@ HDFS-8563. Erasure Coding: fsck handles file smaller than a full stripe. (Walter Su via jing9) + + HDFS-8484. Erasure coding: Two contiguous blocks occupy IDs belong to same + striped group. (Walter Su via jing9) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java index c98bdb04649..968dc0c9d42 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java @@ -3690,17 +3690,19 @@ public class BlockManager { } public BlockInfo getStoredBlock(Block block) { - BlockInfo info = null; - if (BlockIdManager.isStripedBlockID(block.getBlockId())) { - info = blocksMap.getStoredBlock( - new Block(BlockIdManager.convertToStripedID(block.getBlockId()))); - if ((info == null) && hasNonEcBlockUsingStripedID){ - info = blocksMap.getStoredBlock(block); - } - } else { - info = blocksMap.getStoredBlock(block); + if (!BlockIdManager.isStripedBlockID(block.getBlockId())) { + return blocksMap.getStoredBlock(block); } - return info; + if (!hasNonEcBlockUsingStripedID) { + return blocksMap.getStoredBlock( + new Block(BlockIdManager.convertToStripedID(block.getBlockId()))); + } + BlockInfo info = blocksMap.getStoredBlock(block); + if (info != null) { + return info; + } + return blocksMap.getStoredBlock( + new Block(BlockIdManager.convertToStripedID(block.getBlockId()))); } /** updates a block in under replication queue */