You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2026/10/10 13:43:00 UTC
[jira] [Updated] (HDDS-16844) Remove duplicate overwrite checks in ChunkUtils
[ https://issues.apache.org/jira/browse/HDDS-16844?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
ASF GitHub Bot updated HDDS-16844:
----------------------------------
Labels: pull-request-available (was: )
> Remove duplicate overwrite checks in ChunkUtils
> -----------------------------------------------
>
> Key: HDDS-16844
> URL: https://issues.apache.org/jira/browse/HDDS-16844
> Project: Apache Ozone
> Issue Type: Improvement
> Reporter: Chu Cheng Li
> Assignee: Chu Cheng Li
> Priority: Minor
> Labels: pull-request-available
>
> *Background*
> HDDS-16327 added {{validateChunkForOverwrite(long fileLen, ChunkInfo)}} and {{isOverWriteRequested(long fileLen, ChunkInfo)}} to {{{}ChunkUtils{}}}. The caller gives the file length, so the method does not read it again.
> *Problem*
> The old {{File}} overloads of these two methods are still in {{{}ChunkUtils{}}}. Their bodies are copies of the {{long}} versions. Both copies have the same "Duplicate write chunk request" warning and the same TODO. Only {{FilePerChunkStrategy}} calls the {{File}} version. No code outside {{ChunkUtils}} calls {{{}isOverWriteRequested{}}}.
> *Changes*
> * Keep only {{{}validateChunkForOverwrite(long fileLen, ChunkInfo){}}}. Put the check {{info.getOffset() < fileLen}} directly in this method.
> * Remove the two {{isOverWriteRequested}} overloads.
> * {{FilePerChunkStrategy.writeChunk}} calls {{{}validateChunkForOverwrite(chunkFile.length(), info){}}}.
> {{File.length()}} returns 0 when the file does not exist. Thus, the {{exists()}} check in the old {{File}} version has no effect when the offset is 0 or more. {{File.length()}} also returns 0 on an I/O error, and the old code had the same behavior. The change removes one file system call for each chunk write in the FilePerChunk layout.
> One edge case changes. For a negative offset on a chunk file that does not exist, the result is now true. Before, it was false. The offset is a {{uint64}} in the protocol, and {{FilePerBlockStrategy}} already gives true in this case.
> *Tests*
> {{TestChunkUtils.validateChunkForOverwrite}} tests only the {{long}} version.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org