feat: add best-effort O_DIRECT support for posix put/get-object put-part

This change introduces an opt-in O_DIRECT mode for POSIX object data paths while
keeping behavior safe and predictable across different filesystems and kernel
constraints. We now use direct I/O when available and beneficial, but preserve
correctness by falling back to buffered I/O when runtime read behavior indicates
alignment or capability mismatches.

The implementation keeps fast paths available for full-object reads and
descriptor-to-descriptor copy operations so kernel-level optimizations can still
be used where possible. At the same time, it avoids global assumptions from
single runtime failures and performs fallback at the stream level so requests
can continue successfully without broad feature disablement.
This commit is contained in:
Ben McClelland
2026-07-31 13:29:48 -07:00
parent 029a002777
commit 062bf0bf47
14 changed files with 651 additions and 62 deletions
+15
View File
@@ -602,6 +602,12 @@ ROOT_SECRET_ACCESS_KEY=
# memory use.
#VGW_POSIX_CONCURRENCY=5000
# The VGW_POSIX_IO_BUFFER_SIZE option sets the data transfer buffer size used
# by the posix backend for PutObject, UploadPart, and GetObject read/write
# paths. The default is 1048576 bytes (1 MiB). When set to 0 or a negative
# value, the backend falls back to the same default.
#VGW_POSIX_IO_BUFFER_SIZE=1048576
# The gateway will use O_TMPFILE for writing objects while uploading and
# link the file to the final object name when the upload is complete if the
# filesystem supports O_TMPFILE. This creates an atomic object creation
@@ -623,6 +629,15 @@ ROOT_SECRET_ACCESS_KEY=
# NFS servers that may hang on this call.
#VGW_DISABLE_COPY_FILE_RANGE=false
# The VGW_ENABLE_O_DIRECT option enables best-effort O_DIRECT for object data
# reads and writes. This is disabled by default. When enabled, versitygw
# attempts to open object data files with O_DIRECT and automatically falls back
# to buffered I/O when O_DIRECT is not supported by the filesystem/open call.
# Some systems may still enforce alignment constraints for direct I/O. The
# VGW_POSIX_IO_BUFFER_SIZE setting can be used to tune buffered read/write
# chunk sizing while keeping O_DIRECT best-effort behavior enabled.
#VGW_ENABLE_O_DIRECT=false
# The VGW_DEFAULT_ETAG option sets the ETag value returned for objects that do
# not have a stored etag attribute. This applies to files that were placed on
# the filesystem outside of versitygw and therefore lack S3 metadata. Some S3