amaliujia commented on code in PR #11724:
URL: https://github.com/apache/ozone/pull/11724#discussion_r4521021427
##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/StreamBlockInputStream.java:
##########
@@ -195,21 +199,19 @@ public int readPositioned(long blockOffset, ByteBuffer
dst) throws IOException {
if (!dst.hasRemaining()) {
return 0;
}
- updateBlockLength();
+ // updateBlockLength() sets blockLength before it clears the volatile
flag, so blockLength is safe to read here.
+ if (needUpdateBlockLength) {
+ updateBlockLength();
+ }
Review Comment:
`public synchronized void updateBlockLength() throws IOException`:
`updateBlockLength` is already synchronized, and calling it would get a lock
blindly and weaken or lose the optimization here.
To simplify the code and drop the if , maybe we move the lock into the while
loop inside `updateBlockLength` and remove `synchronized` from
`updateBlockLength`?
--
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]