HDFS-2938. Merging change 1244752 from trunk to 0.23
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1244754 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
97a2b5a1bf
commit
7c6f6b0d2b
|
@ -41,6 +41,9 @@ Release 0.23.2 - UNRELEASED
|
||||||
HDFS-2525. Race between BlockPoolSliceScanner and append. (Brandon Li
|
HDFS-2525. Race between BlockPoolSliceScanner and append. (Brandon Li
|
||||||
via jitendra)
|
via jitendra)
|
||||||
|
|
||||||
|
HDFS-2938. Recursive delete of a large directory make namenode
|
||||||
|
unresponsive. (Hari Mankude via suresh)
|
||||||
|
|
||||||
Release 0.23.1 - 2012-02-08
|
Release 0.23.1 - 2012-02-08
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -1928,15 +1928,8 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
} finally {
|
} finally {
|
||||||
writeUnlock();
|
writeUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
getEditLog().logSync();
|
getEditLog().logSync();
|
||||||
|
|
||||||
writeLock();
|
|
||||||
try {
|
|
||||||
removeBlocks(collectedBlocks); // Incremental deletion of blocks
|
removeBlocks(collectedBlocks); // Incremental deletion of blocks
|
||||||
} finally {
|
|
||||||
writeUnlock();
|
|
||||||
}
|
|
||||||
collectedBlocks.clear();
|
collectedBlocks.clear();
|
||||||
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
if (NameNode.stateChangeLog.isDebugEnabled()) {
|
||||||
NameNode.stateChangeLog.debug("DIR* Namesystem.delete: "
|
NameNode.stateChangeLog.debug("DIR* Namesystem.delete: "
|
||||||
|
@ -1945,17 +1938,25 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** From the given list, incrementally remove the blocks from blockManager */
|
/**
|
||||||
|
* From the given list, incrementally remove the blocks from blockManager
|
||||||
|
* Writelock is dropped and reacquired every BLOCK_DELETION_INCREMENT to
|
||||||
|
* ensure that other waiters on the lock can get in. See HDFS-2938
|
||||||
|
*/
|
||||||
private void removeBlocks(List<Block> blocks) {
|
private void removeBlocks(List<Block> blocks) {
|
||||||
assert hasWriteLock();
|
|
||||||
int start = 0;
|
int start = 0;
|
||||||
int end = 0;
|
int end = 0;
|
||||||
while (start < blocks.size()) {
|
while (start < blocks.size()) {
|
||||||
end = BLOCK_DELETION_INCREMENT + start;
|
end = BLOCK_DELETION_INCREMENT + start;
|
||||||
end = end > blocks.size() ? blocks.size() : end;
|
end = end > blocks.size() ? blocks.size() : end;
|
||||||
for (int i=start; i<end; i++) {
|
writeLock();
|
||||||
|
try {
|
||||||
|
for (int i = start; i < end; i++) {
|
||||||
blockManager.removeBlock(blocks.get(i));
|
blockManager.removeBlock(blocks.get(i));
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
writeUnlock();
|
||||||
|
}
|
||||||
start = end;
|
start = end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,8 +117,11 @@ public class TestLargeDirectoryDelete {
|
||||||
try {
|
try {
|
||||||
int blockcount = getBlockCount();
|
int blockcount = getBlockCount();
|
||||||
if (blockcount < TOTAL_BLOCKS && blockcount > 0) {
|
if (blockcount < TOTAL_BLOCKS && blockcount > 0) {
|
||||||
synchronized(mc.getNamesystem()) {
|
mc.getNamesystem().writeLock();
|
||||||
|
try {
|
||||||
lockOps++;
|
lockOps++;
|
||||||
|
} finally {
|
||||||
|
mc.getNamesystem().writeUnlock();
|
||||||
}
|
}
|
||||||
Thread.sleep(1);
|
Thread.sleep(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue