9. Callback Interface#

9.1. CUObjIOOps Structure#

User-defined callback operations structure.

typedef struct CUObjIOOps {
    ssize_t (*get)(const void* handle, char* ptr, size_t size, loff_t offset,
                   const cufileRDMAInfo_t* rdma_info);
    ssize_t (*put)(const void* handle, const char* ptr, size_t size, loff_t offset,
                   const cufileRDMAInfo_t* rdma_info);
} CUObjOps_t;

9.2. GET Callback#

Called during a cuObjGet() operation to handle data retrieval.

ssize_t (*get)(const void* handle, char* ptr, size_t size, loff_t offset,
               const cufileRDMAInfo_t* rdma_info);

Parameters:

  • handle: Cookie to user context. Use cuObjClient::getCtx(handle) to extract the context.

  • ptr: Pointer to the memory chunk to be filled with data.

  • size: Size of the memory chunk being read.

  • offset: Starting object offset for this chunk.

  • rdma_info: RDMA memory descriptor string for out-of-band communication.

Returns:

  • Size of data read on success.

  • Negative failure value on failure.

  • One of the retryable negative errno values listed in the RDMA Multipathing section to allow retry on eligible failures.

Notes:

  • offset is 0 when MaxRequestCallbackSize is greater than or equal to the total request size.

  • size equals the total request size when MaxRequestCallbackSize is greater than or equal to the total request size.

  • Multiple callbacks may be invoked for large requests.

  • The callback may be called from a thread other than the caller thread.

  • The callback must communicate with cuObjServer using the RDMA descriptor information.

  • rdma_info and the descriptor string it references are valid only for the duration of the callback invocation.

9.3. PUT Callback#

Called during a cuObjPut() operation to handle data transmission.

ssize_t (*put)(const void* handle, const char* ptr, size_t size, loff_t offset,
               const cufileRDMAInfo_t* rdma_info);

Parameters:

  • handle: Cookie to user context. Use cuObjClient::getCtx(handle) to extract the context.

  • ptr: Pointer to the memory chunk containing data to write.

  • size: Size of the memory chunk being written.

  • offset: Starting object offset for this chunk.

  • rdma_info: RDMA memory descriptor string for out-of-band communication.

Returns:

  • Size of data written on success.

  • Negative failure value on failure.

  • One of the retryable negative errno values listed in the RDMA Multipathing section to allow retry on eligible failures.

Notes:

  • offset is 0 when MaxRequestCallbackSize is greater than or equal to the total request size.

  • size equals the total request size when MaxRequestCallbackSize is greater than or equal to the total request size.

  • Multiple callbacks may be invoked for large requests.

  • The callback may be called from a thread other than the caller thread.

  • The callback must communicate with cuObjServer using the RDMA descriptor information.

  • rdma_info and the descriptor string it references are valid only for the duration of the callback invocation.