Skip to content

Commit 9a29075

Browse files
authored
HDFS-16776 Erasure Coding: The length of targets should be checked when DN gets a reconstruction task (#4901)
1 parent e526f48 commit 9a29075

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/StripedReconstructor.java

+4
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,10 @@ RawErasureDecoder getDecoder() {
288288
return decoder;
289289
}
290290

291+
int getNumLiveBlocks(){
292+
return liveBitSet.cardinality();
293+
}
294+
291295
void cleanup() {
292296
if (decoder != null) {
293297
decoder.release();

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/StripedWriter.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ class StripedWriter {
8282
assert targetStorageIds != null;
8383

8484
writers = new StripedBlockWriter[targets.length];
85-
8685
targetIndices = new short[targets.length];
86+
Preconditions.checkArgument(
87+
targetIndices.length <= dataBlkNum + parityBlkNum - reconstructor.getNumLiveBlocks(),
88+
"Reconstruction work gets too much targets.");
8789
Preconditions.checkArgument(targetIndices.length <= parityBlkNum,
8890
"Too much missed striped blocks.");
8991
initTargetIndices();

0 commit comments

Comments
 (0)