File tree 1 file changed +15
-3
lines changed
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -2066,9 +2066,14 @@ _dispatch_disk_perform(void *ctxt)
2066
2066
static void
2067
2067
_dispatch_operation_advise (dispatch_operation_t op , size_t chunk_size )
2068
2068
{
2069
- #ifndef F_RDADVISE
2070
- LINUX_PORT_ERROR ();
2071
- #else
2069
+ #ifdef __linux__
2070
+ // linux does not support fcntl (F_RDAVISE)
2071
+ // define necessary datastructure and use readahead
2072
+ struct radvisory {
2073
+ off_t ra_offset ;
2074
+ int ra_count ;
2075
+ };
2076
+ #endif
2072
2077
int err ;
2073
2078
struct radvisory advise ;
2074
2079
// No point in issuing a read advise for the next chunk if we are already
@@ -2088,6 +2093,13 @@ _dispatch_operation_advise(dispatch_operation_t op, size_t chunk_size)
2088
2093
}
2089
2094
advise .ra_offset = op -> advise_offset ;
2090
2095
op -> advise_offset += advise .ra_count ;
2096
+ #ifdef __linux__
2097
+ _dispatch_io_syscall_switch (err ,
2098
+ readahead (op -> fd_entry -> fd , advise .ra_offset , advise .ra_count ),
2099
+ case EINVAL : break ; // fd does refer to a non-supported filetype
2100
+ default : (void )dispatch_assume_zero (err ); break ;
2101
+ );
2102
+ #else
2091
2103
_dispatch_io_syscall_switch (err ,
2092
2104
fcntl (op -> fd_entry -> fd , F_RDADVISE , & advise ),
2093
2105
case EFBIG : break ; // advised past the end of the file rdar://10415691
You can’t perform that action at this time.
0 commit comments