chihsuan commented on code in PR #11465:
URL: https://github.com/apache/ozone/pull/11465#discussion_r4239845513


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/ChunkUtils.java:
##########
@@ -332,44 +332,18 @@ private static List<ByteBuf> readDataNettyChunkedNioFile(
     return buffers;
   }
 
-  /**
-   * Validates chunk data and returns a file object to Chunk File that we are
-   * expected to write data to.
-   *
-   * @param chunkFile - chunkFile to write data into.
-   * @param info - chunk info.
-   * @return true if the chunkFile exists and chunkOffset &lt; chunkFile 
length,
-   *         false otherwise.
-   */
-  public static boolean validateChunkForOverwrite(File chunkFile,
-      ChunkInfo info) {
-
-    if (isOverWriteRequested(chunkFile, info)) {
-      if (!isOverWritePermitted(info)) {
-        LOG.warn("Duplicate write chunk request. Chunk overwrite " +
-            "without explicit request. {}", info);
-      }
-      return true;
-    }
-
-    // TODO: when overwriting a chunk, we should ensure that the new chunk
-    //  size is same as the old chunk size
-
-    return false;
-  }
-
   /**
    * Validates chunk data and returns a boolean value that indicates if the
    * chunk data should be overwritten.
    *
-   * @param fileLen - current length of the block file.
+   * @param fileLen - current length of the chunk or block file.
    * @param info - chunk info.
    * @return true if the chunkOffset is less than the chunkFile length,
    *         false otherwise.
    */
   public static boolean validateChunkForOverwrite(long fileLen, ChunkInfo 
info) {
 
-    if (isOverWriteRequested(fileLen, info)) {
+    if (info.getOffset() < fileLen) {

Review Comment:
   Not related to this PR, but I noticed that comparing file length with the 
block-relative offset may miss overwrites in chunks after the first. Filed 
HDDS-16874 as a follow-up.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to