Repository navigation
HDDS-16844. Remove duplicate overwrite checks in ChunkUtils - #11465
Merged
Merged
Conversation
chihsuan
approved these changes
Oct 11, 2026
chihsuan
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the patch! @peterxcli LGTM +1
| public static boolean validateChunkForOverwrite(long fileLen, ChunkInfo info) { | ||
|
|
||
| if (isOverWriteRequested(fileLen, info)) { | ||
| if (info.getOffset() < fileLen) { |
Contributor
There was a problem hiding this 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.
Member
Author
|
@chihsuan thanks for the filing followup and merging! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
cleanup after #11150
With this change:
ChunkUtilskeeps a singlevalidateChunkForOverwrite(long fileLen, ChunkInfo), with theinfo.getOffset() < fileLencheck written inline.isOverWriteRequestedoverloads are removed. Nothing outsideChunkUtilscalled them.FilePerChunkStrategy.writeChunkpasseschunkFile.length()to thelongversion.This does not change behavior for real requests.
File.length()returns 0 for a file that does not exist, so the oldexists()check made no difference for any offset of 0 or more.File.length()also returns 0 on an I/O error, which the old code already relied on. As a side effect, each write in the FilePerChunk layout does one fewer file system call.The only input that behaves differently is a negative offset on a chunk file that does not exist yet. It now counts as an overwrite, where before it did not. The offset is a
uint64on the wire, andFilePerBlockStrategyalready treats this case the same way.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-16844
How was this patch tested?
TestChunkUtils.validateChunkForOverwritenow checks only thelongmethod. Its file-based asserts used the same length and offsets as thelongcases that were already there.