Skip to content

Support for file readahead under linux using readahead #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 28, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2066,9 +2066,14 @@ _dispatch_disk_perform(void *ctxt)
static void
_dispatch_operation_advise(dispatch_operation_t op, size_t chunk_size)
{
#ifndef F_RDADVISE
LINUX_PORT_ERROR();
#else
#ifdef __linux__
// linux does not support fcntl (F_RDAVISE)
// define necessary datastructure and use readahead
struct radvisory {
off_t ra_offset;
int ra_count;
};
#endif
int err;
struct radvisory advise;
// No point in issuing a read advise for the next chunk if we are already
Expand All @@ -2088,6 +2093,13 @@ _dispatch_operation_advise(dispatch_operation_t op, size_t chunk_size)
}
advise.ra_offset = op->advise_offset;
op->advise_offset += advise.ra_count;
#ifdef __linux__
_dispatch_io_syscall_switch(err,
readahead(op->fd_entry->fd, advise.ra_offset, advise.ra_count),
case EINVAL: break; // fd does refer to a non-supported filetype
default: (void)dispatch_assume_zero(err); break;
);
#else
_dispatch_io_syscall_switch(err,
fcntl(op->fd_entry->fd, F_RDADVISE, &advise),
case EFBIG: break; // advised past the end of the file rdar://10415691
Expand Down