Skip to content

Harden pread and pwrite short I/O handling - #1110

Open
fallintoplace wants to merge 1 commit into
rapidsai:mainfrom
fallintoplace:fix/robust-posix-io-loops
Open

Harden pread and pwrite short I/O handling#1110
fallintoplace wants to merge 1 commit into
rapidsai:mainfrom
fallintoplace:fix/robust-posix-io-loops

Conversation

@fallintoplace

Copy link
Copy Markdown

Summary

Harden the POSIX pread/pwrite paths in CuFileDriver against EINTR, short transfers, EOF, and error propagation.

What changed

  • add centralized retrying helpers for pread/pwrite
  • add shared buffered read/write helpers that stop cleanly on EOF or partial transfer instead of assuming the requested byte count always completed
  • update the internal POSIX and O_DIRECT buffered/page/block paths to copy only the bytes that were actually transferred
  • add a regression test for reading past EOF that verifies unread bytes in the destination buffer stay untouched

Why

Several loops in cufile_driver.cpp assumed that each pread/pwrite returned the full requested size.

When that assumption breaks, the old code could:

  • subtract a negative count from an unsigned remaining size
  • copy more bytes to host/device buffers than were actually read
  • keep advancing totals as if a short transfer had succeeded
  • get stuck or report misleading success counts

This change keeps the public behavior close to POSIX short-read semantics while making the internal buffered/page-aligned logic robust against partial transfers and interruptions.

Validation

  • reviewed and refactored the internal POSIX/O_DIRECT read/write paths in cufile_driver.cpp
  • added a regression case in test_cufile.cpp for a short read near EOF
  • ran git diff --check
  • attempted local CMake configure, but this machine cannot build the project because FindCUDAToolkit fails to locate nvcc

@fallintoplace
fallintoplace requested a review from a team as a code owner June 27, 2026 21:25
@copy-pr-bot

copy-pr-bot Bot commented Jun 27, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant