-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HDFS-16524. Add configuration to control blocks deletion asynchronous… #4139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
f3f6e9a
3c835c1
e741926
8f55bb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -501,6 +501,8 @@ private boolean isClientPortInfoAbsent(CallerContext ctx){ | |
private final String supergroup; | ||
private final boolean standbyShouldCheckpoint; | ||
private final boolean isSnapshotTrashRootEnabled; | ||
private final boolean blockDeletionAsync; | ||
private final int blockDeletionIncrement; | ||
private final int snapshotDiffReportLimit; | ||
|
||
/** | ||
|
@@ -1064,6 +1066,12 @@ static FSNamesystem loadFromDisk(Configuration conf) throws IOException { | |
this.allowOwnerSetQuota = conf.getBoolean( | ||
DFSConfigKeys.DFS_PERMISSIONS_ALLOW_OWNER_SET_QUOTA_KEY, | ||
DFSConfigKeys.DFS_PERMISSIONS_ALLOW_OWNER_SET_QUOTA_DEFAULT); | ||
this.blockDeletionAsync = conf.getBoolean( | ||
DFSConfigKeys.DFS_NAMENODE_BLOCK_DELETION_ASYNC_KEY, | ||
DFSConfigKeys.DFS_NAMENODE_BLOCK_DELETION_ASYNC_DEFAULT); | ||
this.blockDeletionIncrement = conf.getInt( | ||
DFSConfigKeys.DFS_NAMENODE_BLOCK_DELETION_INCREMENT_KEY, | ||
DFSConfigKeys.DFS_NAMENODE_BLOCK_DELETION_INCREMENT_DEFAULT); | ||
this.isGetBlocksCheckOperationEnabled = conf.getBoolean( | ||
DFSConfigKeys.DFS_NAMENODE_GETBLOCKS_CHECK_OPERATION_KEY, | ||
DFSConfigKeys.DFS_NAMENODE_GETBLOCKS_CHECK_OPERATION_DEFAULT); | ||
|
@@ -2380,8 +2388,7 @@ boolean truncate(String src, long newLength, String clientName, | |
} | ||
getEditLog().logSync(); | ||
if (!toRemoveBlocks.getToDeleteList().isEmpty()) { | ||
blockManager.addBLocksToMarkedDeleteQueue( | ||
toRemoveBlocks.getToDeleteList()); | ||
removeBlocks(toRemoveBlocks.getToDeleteList()); | ||
} | ||
logAuditEvent(true, operationName, src, null, status); | ||
} catch (AccessControlException e) { | ||
|
@@ -2828,8 +2835,7 @@ private HdfsFileStatus startFileInt(String src, | |
if (!skipSync) { | ||
getEditLog().logSync(); | ||
if (toRemoveBlocks != null) { | ||
blockManager.addBLocksToMarkedDeleteQueue( | ||
toRemoveBlocks.getToDeleteList()); | ||
removeBlocks(toRemoveBlocks.getToDeleteList()); | ||
} | ||
} | ||
} | ||
|
@@ -3352,8 +3358,7 @@ void renameTo(final String src, final String dst, | |
assert res != null; | ||
BlocksMapUpdateInfo collectedBlocks = res.collectedBlocks; | ||
if (!collectedBlocks.getToDeleteList().isEmpty()) { | ||
blockManager.addBLocksToMarkedDeleteQueue( | ||
collectedBlocks.getToDeleteList()); | ||
removeBlocks(collectedBlocks.getToDeleteList()); | ||
} | ||
|
||
logAuditEvent(true, operationName + " (options=" + | ||
|
@@ -3392,8 +3397,7 @@ boolean delete(String src, boolean recursive, boolean logRetryCache) | |
getEditLog().logSync(); | ||
logAuditEvent(ret, operationName, src); | ||
if (toRemovedBlocks != null) { | ||
blockManager.addBLocksToMarkedDeleteQueue( | ||
toRemovedBlocks.getToDeleteList()); | ||
removeBlocks(toRemovedBlocks.getToDeleteList()); | ||
} | ||
return ret; | ||
} | ||
|
@@ -3403,6 +3407,33 @@ FSPermissionChecker getPermissionChecker() | |
return dir.getPermissionChecker(); | ||
} | ||
|
||
/** | ||
* If blockDeletionAsync enables, blocks will be deleted asynchronously. | ||
* If not, 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 | ||
* | ||
* @param toDeleteList | ||
* a list of blocks that need to be removed from blocksMap | ||
*/ | ||
void removeBlocks(List<BlockInfo> toDeleteList) { | ||
if (this.blockDeletionAsync) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable blockDeletionAsync doesn't seem to be declared. |
||
blockManager.addBLocksToMarkedDeleteQueue(toDeleteList); | ||
} else { | ||
Iterator<BlockInfo> iter = toDeleteList.iterator(); | ||
while (iter.hasNext()) { | ||
writeLock(); | ||
try { | ||
for (int i = 0; i < blockDeletionIncrement && iter.hasNext(); i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed blockDeletionIncrement in HDFS-16554 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. About "blockDeletionIncrement", in my opinion, why we removed it in HDFS-16554 is that we decided to use delete async to replace the previous method, so the "blockDeletionIncrement" won't be used any more. But when we add a switch to control blocks deletion async, we need to save the previous block deletion method, so we still need it. |
||
blockManager.removeBlock(iter.next()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Compared with the previous one, the following code is missing: toRemoveBlocks.clear(); |
||
} | ||
} finally { | ||
writeUnlock("removeBlocks"); | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Remove leases and inodes related to a given path | ||
* @param removedUCFiles INodes whose leases need to be released | ||
|
@@ -4609,8 +4640,7 @@ private void clearCorruptLazyPersistFiles() | |
INodesInPath.fromINode((INodeFile) bc), false); | ||
changed |= toRemoveBlocks != null; | ||
if (toRemoveBlocks != null) { | ||
blockManager.addBLocksToMarkedDeleteQueue( | ||
toRemoveBlocks.getToDeleteList()); | ||
removeBlocks(toRemoveBlocks.getToDeleteList()); | ||
} | ||
} | ||
} finally { | ||
|
@@ -7348,8 +7378,7 @@ void deleteSnapshot(String snapshotRoot, String snapshotName, | |
// Breaking the pattern as removing blocks have to happen outside of the | ||
// global lock | ||
if (blocksToBeDeleted != null) { | ||
blockManager.addBLocksToMarkedDeleteQueue( | ||
blocksToBeDeleted.getToDeleteList()); | ||
removeBlocks(blocksToBeDeleted.getToDeleteList()); | ||
} | ||
logAuditEvent(true, operationName, rootPath, null, null); | ||
} | ||
|
@@ -7375,8 +7404,7 @@ public void gcDeletedSnapshot(String snapshotRoot, String snapshotName) | |
} finally { | ||
writeUnlock(operationName, getLockReportInfoSupplier(rootPath)); | ||
} | ||
blockManager.addBLocksToMarkedDeleteQueue( | ||
blocksToBeDeleted.getToDeleteList()); | ||
removeBlocks(blocksToBeDeleted.getToDeleteList()); | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use dfs.namenode.block.deletion.async not blockDeletionAsync