You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/11/01 19:10:53 UTC

[GitHub] [ozone] DaveTeng0 commented on a diff in pull request #3923: HDDS-7446. Cleanup possibly onDisk unreferenced blocks

DaveTeng0 commented on code in PR #3923:
URL: https://github.com/apache/ozone/pull/3923#discussion_r1010804546


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java:
##########
@@ -1110,6 +1113,51 @@ public void deleteBlock(Container container, BlockData blockData)
     }
   }
 
+  @Override
+  public void deleteUnreferenced(Container container, long localID)
+      throws IOException {
+    // Since the block/chunk is already checked that is unreferenced, no
+    // need to lock the container here.
+    StringBuilder prefixBuilder = new StringBuilder();
+    ContainerLayoutVersion layoutVersion = container.getContainerData().
+        getLayoutVersion();
+    long containerID = container.getContainerData().getContainerID();
+    // Only supports the default chunk/block name format now
+    switch (layoutVersion) {
+    case FILE_PER_BLOCK:
+      prefixBuilder.append(localID).append(".block");
+      break;
+    case FILE_PER_CHUNK:
+      prefixBuilder.append(localID).append("_chunk_");
+      break;
+    default:
+      throw new IOException("Unsupported container layout version " +
+          layoutVersion + " for the container " + containerID);
+    }
+    String prefix = prefixBuilder.toString();
+    File chunkDir = ContainerUtils.getChunkDir(container.getContainerData());
+    String[] chunkNames = getFilesWithPrefix(prefix, chunkDir);
+    if (chunkNames.length == 0) {
+      LOG.warn("Missing delete block(Container = {}, Block = {}",

Review Comment:
   just curious~ when will this happen? Is the unreferenced block deleted by other thread?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org