You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by sh...@apache.org on 2015/12/17 09:16:08 UTC
[4/4] hadoop git commit: HDFS-9516. Truncate file fails with data
dirs on multiple disks. Contributed by Plamen Jeliazkov.
HDFS-9516. Truncate file fails with data dirs on multiple disks. Contributed by Plamen Jeliazkov.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/d97696e4
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/d97696e4
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/d97696e4
Branch: refs/heads/branch-2.7
Commit: d97696e4c49dd5c1638feffb36d693c82bcef71e
Parents: cab5d86
Author: Plamen Jeliazkov <pl...@gmail.com>
Authored: Tue Dec 15 00:10:33 2015 -0800
Committer: Konstantin V Shvachko <sh...@apache.org>
Committed: Thu Dec 17 00:09:48 2015 -0800
----------------------------------------------------------------------
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++
.../server/datanode/fsdataset/impl/FsDatasetImpl.java | 14 +++++++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/d97696e4/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index f0a083d..b7b3cda 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -33,6 +33,9 @@ Release 2.7.3 - UNRELEASED
HDFS-9314. Improve BlockPlacementPolicyDefault's picking of excess
replicas. (Xiao Chen via zhz)
+ HDFS-9516. Truncate file fails with data dirs on multiple disks.
+ (Plamen Jeliazkov via shv)
+
Release 2.7.2 - UNRELEASED
INCOMPATIBLE CHANGES
http://git-wip-us.apache.org/repos/asf/hadoop/blob/d97696e4/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java
index fdee4e1..3228629 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java
@@ -2442,8 +2442,14 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
} else {
// Copying block to a new block with new blockId.
// Not truncating original block.
+ FsVolumeSpi volume = rur.getVolume();
+ String blockPath = blockFile.getAbsolutePath();
+ String volumePath = volume.getBasePath();
+ assert blockPath.startsWith(volumePath) :
+ "New block file: " + blockPath + " must be on " +
+ "same volume as recovery replica: " + volumePath;
ReplicaBeingWritten newReplicaInfo = new ReplicaBeingWritten(
- newBlockId, recoveryId, rur.getVolume(), blockFile.getParentFile(),
+ newBlockId, recoveryId, volume, blockFile.getParentFile(),
newlength);
newReplicaInfo.setNumBytes(newlength);
volumeMap.add(bpid, newReplicaInfo);
@@ -2459,10 +2465,8 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
ReplicaUnderRecovery replicaInfo, String bpid, long newBlkId, long newGS)
throws IOException {
String blockFileName = Block.BLOCK_FILE_PREFIX + newBlkId;
- FsVolumeReference v = volumes.getNextVolume(
- replicaInfo.getVolume().getStorageType(), replicaInfo.getNumBytes());
- final File tmpDir = ((FsVolumeImpl) v.getVolume())
- .getBlockPoolSlice(bpid).getTmpDir();
+ FsVolumeImpl v = (FsVolumeImpl) replicaInfo.getVolume();
+ final File tmpDir = v.getBlockPoolSlice(bpid).getTmpDir();
final File destDir = DatanodeUtil.idToBlockDir(tmpDir, newBlkId);
final File dstBlockFile = new File(destDir, blockFileName);
final File dstMetaFile = FsDatasetUtil.getMetaFile(dstBlockFile, newGS);