diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 41a2bb65230..003578bc5e9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -303,6 +303,9 @@ Release 2.7.1 - UNRELEASED HDFS-8070. Pre-HDFS-7915 DFSClient cannot use short circuit on post-HDFS-7915 DataNode (cmccabe) + HDFS-8273. FSNamesystem#Delete() should not call logSync() when holding the + lock. (wheat9) + Release 2.7.0 - 2015-04-20 INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirDeleteOp.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirDeleteOp.java index 02eb1de9ae1..2192c240ed5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirDeleteOp.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirDeleteOp.java @@ -175,7 +175,6 @@ class FSDirDeleteOp { incrDeletedFileCount(filesRemoved); fsn.removeLeasesAndINodes(src, removedINodes, true); - fsd.getEditLog().logSync(); if (NameNode.stateChangeLog.isDebugEnabled()) { NameNode.stateChangeLog.debug("DIR* Namesystem.delete: " diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index b2b68c6b8ae..d0d5f702cec 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -3686,6 +3686,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, } finally { writeUnlock(); } + getEditLog().logSync(); if (toRemovedBlocks != null) { removeBlocks(toRemovedBlocks); // Incremental deletion of blocks } @@ -4691,22 +4692,21 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, * blocks and unlink them from the namespace. */ private void clearCorruptLazyPersistFiles() - throws SafeModeException, AccessControlException, - UnresolvedLinkException, IOException { + throws IOException { BlockStoragePolicy lpPolicy = blockManager.getStoragePolicy("LAZY_PERSIST"); - List filesToDelete = new ArrayList(); - + List filesToDelete = new ArrayList<>(); + boolean changed = false; writeLock(); - try { final Iterator it = blockManager.getCorruptReplicaBlockIterator(); while (it.hasNext()) { Block b = it.next(); BlockInfoContiguous blockInfo = blockManager.getStoredBlock(b); - if (blockInfo.getBlockCollection().getStoragePolicyID() == lpPolicy.getId()) { + if (blockInfo.getBlockCollection().getStoragePolicyID() + == lpPolicy.getId()) { filesToDelete.add(blockInfo.getBlockCollection()); } } @@ -4714,9 +4714,10 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, for (BlockCollection bc : filesToDelete) { LOG.warn("Removing lazyPersist file " + bc.getName() + " with no replicas."); BlocksMapUpdateInfo toRemoveBlocks = - FSDirDeleteOp.deleteInternal( - FSNamesystem.this, bc.getName(), - INodesInPath.fromINode((INodeFile) bc), false); + FSDirDeleteOp.deleteInternal( + FSNamesystem.this, bc.getName(), + INodesInPath.fromINode((INodeFile) bc), false); + changed |= toRemoveBlocks != null; if (toRemoveBlocks != null) { removeBlocks(toRemoveBlocks); // Incremental deletion of blocks } @@ -4724,6 +4725,9 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, } finally { writeUnlock(); } + if (changed) { + getEditLog().logSync(); + } } @Override