Merged
Conversation
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
Isteb4k
approved these changes
Mar 5, 2026
Collaborator
Author
|
/backport v1.5.2 |
Contributor
|
Failure: cherry-pick commit 82246e3 to the branch release-1.5 failed. See Job for details. |
nevermarine
added a commit
that referenced
this pull request
Mar 5, 2026
Signed-off-by: Maksim Fedotov <maksim.fedotov@flant.com>
This was referenced Mar 5, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
NFS: use O_DIRECT and qemu-img cache=none with fallback
NFS detection
Added
util.IsPathOnNFS(path)(Linux:statfs+NFS_SUPER_MAGIC; other OS: always false) so we can detect when the destination is on NFS.Importer write path (io.Copy)
In
streamDataToFile(pkg/importer/util.go), when the destination is on NFS we first open the file with O_DIRECT (util.OpenFileOrBlockDeviceWithDirectIOon Linux) and useio.Copy. If opening with O_DIRECT fails, we fall back to a normal open and copy. AddedOpenFileOrBlockDeviceWithDirectIOinpkg/util(Linux implementation + stub on other platforms).qemu-img convert
For NFS destinations,
ConvertToFormatStreamnow runs qemu-img with-t none -T none. If that fails, it retries with-t writeback -T writeback. The internal helper isconvertTo(format, src, dest, preallocate, cacheMode); the public API is a singleConvertToFormatStream(..., useDirectIO bool).Where it’s used
Data processor convert phase and uploadserver clone flow call
IsPathOnNFSon the destination and pass the result asuseDirectIOintoConvertToFormatStream. NFS is checked once per flow; O_DIRECT and cache=none are tried first, with fallback only when open or convert fails.Logging
NFS detection, O_DIRECT usage, and fallbacks are logged at
klog.V(1).Why do we need it, and what problem does it solve?
When CDI imports or clones disk images onto NFS-backed PVCs, the importer writes through the page cache (normal
io.Copyand qemu-img with default cache mode). On NFS this can lead to high memory use and OOMs because data is buffered in the client’s page cache before being sent over the network, and qemu-img also uses the page cache when writing the converted image. To reduce memory pressure and improve behaviour on NFS, we should bypass the page cache where the filesystem allows it: use O_DIRECT for the importer’s file writes and qemu-img convert -t none -T none so that both source and target use direct I/O. This PR adds NFS detection (viastatfsandNFS_SUPER_MAGIC) and, when the destination is on NFS, tries O_DIRECT forio.Copyand cache=none for qemu-img convert, with an automatic fallback to the previous behaviour if either fails (e.g. if the NFS server or mount does not support direct I/O). After merging, imports and clones to NFS volumes use less memory and are less likely to hit OOM, while non-NFS and unsupported NFS setups keep working as before.What is the expected result?
NFS destination
-v=1you should see messages such as: destination on NFS, attempt to write with O_DIRECT; and for convert: “Destination on NFS, running qemu-img convert with -t none -T none”.Fallback when direct I/O is not supported
-v=1should show fallback messages (e.g. “O_DIRECT open failed … falling back to normal write” and/or “qemu-img convert with -t none -T none failed … falling back to writeback”).Non-NFS destination
Checklist
Changelog entries