Skip to content

Commit

Permalink
Allow user to disable readahead by setting max-readahead smaller th…
Browse files Browse the repository at this point in the history
…an blocksize (#5229)

Signed-off-by: Changxin Miao <[email protected]>
  • Loading branch information
polyrabbit authored Oct 14, 2024
1 parent b4db05b commit c011d62
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func dataCacheFlags() []cli.Flag {
},
&cli.StringFlag{
Name: "max-readahead",
Usage: "max buffering for read ahead in MiB",
Usage: "max buffering for read ahead in MiB per read session",
},
&cli.IntFlag{
Name: "prefetch",
Expand Down
2 changes: 1 addition & 1 deletion pkg/vfs/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ func (f *fileReader) checkReadahead(block *frange) int {
seqdata := ses.total
readahead := ses.readahead
used := uint64(atomic.LoadInt64(&readBufferUsed))
if readahead == 0 && (block.off == 0 || seqdata > block.len) { // begin with read-ahead turned on
if readahead == 0 && f.r.blockSize <= f.r.readAheadMax && (block.off == 0 || seqdata > block.len) { // begin with read-ahead turned on
ses.readahead = f.r.blockSize
} else if readahead < f.r.readAheadMax && seqdata >= readahead && f.r.readAheadTotal-used > readahead*4 {
ses.readahead *= 2
Expand Down

0 comments on commit c011d62

Please sign in to comment.