Skip to content

Commit

Permalink
Fix to not use O_DIRECT by default (#2579)
Browse files Browse the repository at this point in the history
* fix bug to not use O_DIRECT by default

* one more change

* dummy commit

* dummy commit to run tes

* review comment
  • Loading branch information
sethiay authored Oct 15, 2024
1 parent 4ce3945 commit 8a8ce0d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/cache/file/downloader/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func (job *Job) createCacheFile() (*os.File, error) {
var err error
// Try using O_DIRECT while opening file when parallel downloads are enabled
// and O_DIRECT use is not disabled.
if job.fileCacheConfig.EnableParallelDownloads && !job.fileCacheConfig.EnableODirect {
if job.fileCacheConfig.EnableParallelDownloads && job.fileCacheConfig.EnableODirect {
cacheFile, err = cacheutil.CreateFile(job.fileSpec, openFileFlags|syscall.O_DIRECT)
if errors.Is(err, fs.ErrInvalid) || errors.Is(err, syscall.EINVAL) {
logger.Warnf("downloadObjectAsync: failure in opening file with O_DIRECT, falling back to without O_DIRECT")
Expand Down
5 changes: 3 additions & 2 deletions internal/cache/file/downloader/parallel_downloads_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ func (job *Job) downloadRange(ctx context.Context, dstWriter io.Writer, start, e

monitor.CaptureGCSReadMetrics(ctx, util.Parallel, end-start)

// Use of memory aligned buffer is not required if use of O_DIRECT is disabled.
if job.fileCacheConfig.EnableODirect {
// Use standard copy function if O_DIRECT is disabled and memory aligned
// buffer otherwise.
if !job.fileCacheConfig.EnableODirect {
_, err = io.CopyN(dstWriter, newReader, end-start)
} else {
_, err = cacheutil.CopyUsingMemoryAlignedBuffer(ctx, newReader, dstWriter, end-start,
Expand Down

0 comments on commit 8a8ce0d

Please sign in to comment.