HDFS-7936. Erasure coding: resolving conflicts when merging with HDFS-7903, HDFS-7435 and HDFS-7930 (this commit is for HDFS-7930 only)
This commit is contained in:
parent
df297245a7
commit
544f75d651
|
@ -2135,17 +2135,18 @@ public class BlockManager {
|
||||||
* Mark block replicas as corrupt except those on the storages in
|
* Mark block replicas as corrupt except those on the storages in
|
||||||
* newStorages list.
|
* newStorages list.
|
||||||
*/
|
*/
|
||||||
public void markBlockReplicasAsCorrupt(BlockInfoContiguous block,
|
public void markBlockReplicasAsCorrupt(Block oldBlock,
|
||||||
|
BlockInfo block,
|
||||||
long oldGenerationStamp, long oldNumBytes,
|
long oldGenerationStamp, long oldNumBytes,
|
||||||
DatanodeStorageInfo[] newStorages) throws IOException {
|
DatanodeStorageInfo[] newStorages) throws IOException {
|
||||||
assert namesystem.hasWriteLock();
|
assert namesystem.hasWriteLock();
|
||||||
BlockToMarkCorrupt b = null;
|
BlockToMarkCorrupt b = null;
|
||||||
if (block.getGenerationStamp() != oldGenerationStamp) {
|
if (block.getGenerationStamp() != oldGenerationStamp) {
|
||||||
b = new BlockToMarkCorrupt(block, oldGenerationStamp,
|
b = new BlockToMarkCorrupt(oldBlock, block, oldGenerationStamp,
|
||||||
"genstamp does not match " + oldGenerationStamp
|
"genstamp does not match " + oldGenerationStamp
|
||||||
+ " : " + block.getGenerationStamp(), Reason.GENSTAMP_MISMATCH);
|
+ " : " + block.getGenerationStamp(), Reason.GENSTAMP_MISMATCH);
|
||||||
} else if (block.getNumBytes() != oldNumBytes) {
|
} else if (block.getNumBytes() != oldNumBytes) {
|
||||||
b = new BlockToMarkCorrupt(block,
|
b = new BlockToMarkCorrupt(oldBlock, block,
|
||||||
"length does not match " + oldNumBytes
|
"length does not match " + oldNumBytes
|
||||||
+ " : " + block.getNumBytes(), Reason.SIZE_MISMATCH);
|
+ " : " + block.getNumBytes(), Reason.SIZE_MISMATCH);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2630,7 +2630,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
/** Compute quota change for converting a complete block to a UC block */
|
/** Compute quota change for converting a complete block to a UC block */
|
||||||
private QuotaCounts computeQuotaDeltaForUCBlock(INodeFile file) {
|
private QuotaCounts computeQuotaDeltaForUCBlock(INodeFile file) {
|
||||||
final QuotaCounts delta = new QuotaCounts.Builder().build();
|
final QuotaCounts delta = new QuotaCounts.Builder().build();
|
||||||
final BlockInfoContiguous lastBlock = file.getLastBlock();
|
final BlockInfo lastBlock = file.getLastBlock();
|
||||||
if (lastBlock != null) {
|
if (lastBlock != null) {
|
||||||
final long diff = file.getPreferredBlockSize() - lastBlock.getNumBytes();
|
final long diff = file.getPreferredBlockSize() - lastBlock.getNumBytes();
|
||||||
final short repl = file.getPreferredBlockReplication();
|
final short repl = file.getPreferredBlockReplication();
|
||||||
|
@ -3854,8 +3854,9 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
|
||||||
} else {
|
} else {
|
||||||
iFile.convertLastBlockToUC(storedBlock, trimmedStorageInfos);
|
iFile.convertLastBlockToUC(storedBlock, trimmedStorageInfos);
|
||||||
if (closeFile) {
|
if (closeFile) {
|
||||||
blockManager.markBlockReplicasAsCorrupt(storedBlock,
|
blockManager.markBlockReplicasAsCorrupt(oldBlock.getLocalBlock(),
|
||||||
oldGenerationStamp, oldNumBytes, trimmedStorageInfos);
|
storedBlock, oldGenerationStamp, oldNumBytes,
|
||||||
|
trimmedStorageInfos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -982,7 +982,7 @@ public class INodeFile extends INodeWithAdditionalFields
|
||||||
void computeQuotaDeltaForTruncate(
|
void computeQuotaDeltaForTruncate(
|
||||||
long newLength, BlockStoragePolicy bsps,
|
long newLength, BlockStoragePolicy bsps,
|
||||||
QuotaCounts delta) {
|
QuotaCounts delta) {
|
||||||
final BlockInfoContiguous[] blocks = getBlocks();
|
final BlockInfo[] blocks = getBlocks();
|
||||||
if (blocks == null || blocks.length == 0) {
|
if (blocks == null || blocks.length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1001,7 +1001,7 @@ public class INodeFile extends INodeWithAdditionalFields
|
||||||
|
|
||||||
for (int i = blocks.length - 1; i >= 0 && size > newLength;
|
for (int i = blocks.length - 1; i >= 0 && size > newLength;
|
||||||
size -= blocks[i].getNumBytes(), --i) {
|
size -= blocks[i].getNumBytes(), --i) {
|
||||||
BlockInfoContiguous bi = blocks[i];
|
BlockInfo bi = blocks[i];
|
||||||
long truncatedBytes;
|
long truncatedBytes;
|
||||||
if (size - newLength < bi.getNumBytes()) {
|
if (size - newLength < bi.getNumBytes()) {
|
||||||
// Record a full block as the last block will be copied during
|
// Record a full block as the last block will be copied during
|
||||||
|
|
Loading…
Reference in New Issue