Huang Kuan Hao created HDDS-16326:
-------------------------------------

             Summary: Cache the container chunks directory instead of stat-ing 
it on every chunk operation
                 Key: HDDS-16326
                 URL: https://issues.apache.org/jira/browse/HDDS-16326
             Project: Apache Ozone
          Issue Type: Improvement
            Reporter: Huang Kuan Hao
            Assignee: Huang Kuan Hao


ContainerUtils.getChunkDir builds a new File and calls exists() on the
container's chunks directory on every call:

    File chunksDir = new File(chunksPath);
    if (!chunksDir.exists()) {
      throw new StorageContainerException(..., UNABLE_TO_FIND_DATA_DIR);
    }

It is reached through ContainerLayoutVersion.getChunkFile (line 115), which
FilePerBlockStrategy calls on every WriteChunk (line 153) and every ReadChunk
(line 240), plus the stream/finish/delete paths. So every chunk operation
resolves and stat()s a directory that is fixed for the container's lifetime.
On the read path the stat is pure added work: the read otherwise goes straight
to open().

Fix: resolve and validate the chunks directory once (e.g. cache the File on
KeyValueContainerData when the container is opened/loaded) and reuse it on the
data plane, instead of new File + exists() per operation.

Note on behavior: the per-op exists() currently front-runs a missing or
unmounted chunks dir with UNABLE_TO_FIND_DATA_DIR. After caching, a chunks dir
that disappears mid-life is still caught by the subsequent open()/writeData,
which triggers volume-failure handling (onFailure) - only the error code
differs in that rare case. The container scanner (KeyValueContainerCheck) is
unaffected: it stats getChunksPath() directly and reports MISSING_CHUNKS_DIR on
its own, without going through getChunkDir.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to