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


##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java:
##########
@@ -468,7 +455,6 @@ public int readPositioned(long blockRelativePosition, 
ByteBuffer dst) throws IOE
   private int readChunkAt(ChunkInputStream chunk, long chunkOffset, int 
readLength, ByteBuffer dst) throws IOException {
     int preadRetries = 0;
     while (true) {
-      checkOpen();

Review Comment:
   Any reason to drop `checkOpen()` here instead of making it lock-free? On EC 
failover, a short-circuit pread now retries and sleeps on a closed stream. A 
volatile `closed` check before `shouldRetryRead()` would avoid that. What do 
you think?



##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java:
##########
@@ -417,6 +406,9 @@ protected synchronized int 
readWithStrategy(ByteReaderStrategy strategy)
    * without mutating this stream's cursor ({@code chunkIndex},
    * {@code blockPosition}) or the sequential chunk streams' buffered state.
    * Reuses each chunk's range reader, whose buffers and client references 
belong to the request.
+   * Takes this stream's lock only to initialize it or to refresh the block 
info after a read error,
+   * so it does not wait for a sequential read in progress.
+   * It does not check that this stream is open: {@link MultipartInputStream} 
checks that before it calls this method.

Review Comment:
   nit: Could this state the contract instead of naming a caller? EC calls this 
directly too.
   ```suggestion
      * It does not check that this stream is open, so callers must check that 
first.
   ```



##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/StreamBlockInputStream.java:
##########
@@ -561,7 +563,7 @@ protected synchronized void releaseClient() {
   @Override
   public synchronized void close() throws IOException {
     releaseClient();
-    xceiverClientFactory = null;
+    closed = true;

Review Comment:
   Could we add a test for this flag? With the factory now final, it is the 
only guard against reading after `close()`, and removing it keeps all current 
tests green.



##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/StreamBlockInputStream.java:
##########
@@ -185,6 +186,9 @@ synchronized int readFully(ByteBuffer targetBuf, boolean 
preRead) throws IOExcep
   /**
    * Positioned read served by a dedicated one-shot streaming read which never 
touches the
    * cursor, the pre-read buffer or the sequential reader.
+   * Once the block length is known, it does not take this stream's lock, so 
it does not wait for a sequential read
+   * in progress. It does not check that this stream is open: {@link 
MultipartInputStream} checks that before it
+   * calls this method.

Review Comment:
   nit: Same here, could this state the contract instead of naming a caller?
   ```suggestion
      * in progress. It does not check that this stream is open, so callers 
must check that first.
   ```



-- 
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