Implement file access pattern hints for sequential or random file access using posix_fadvise if available. On Linux this will influence the kernel's readahead behaviour.
Signed-off-by: Luke Deller luke@deller.id.au --- server/fd.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/server/fd.c b/server/fd.c index b953da2ab85..e266744581a 100644 --- a/server/fd.c +++ b/server/fd.c @@ -2036,6 +2036,14 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam free( closed_fd ); fd->cacheable = 1; } + +#if _POSIX_C_SOURCE > 200112L + if (options & FILE_SEQUENTIAL_ONLY) + posix_fadvise( fd->unix_fd, 0, 0, POSIX_FADV_SEQUENTIAL ); + else if (options & FILE_RANDOM_ACCESS) + posix_fadvise( fd->unix_fd, 1, 0, POSIX_FADV_RANDOM ); +#endif + if (root_fd != -1) fchdir( server_dir_fd ); /* go back to the server dir */ return fd;