[PATCH v2 4/4] server: Implement file access hints using posix_fadvise
Luke Deller
luke at deller.id.au
Mon Aug 2 10:03:52 CDT 2021
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 at deller.id.au>
---
v2: spotted a typo: set the offset argument of posix_fadvise to 0 not 1
(this has no effect on linux, where the call affects the entire file
and not just the region specified)
---
server/fd.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/server/fd.c b/server/fd.c
index b953da2ab85..873a94b048a 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, 0, 0, POSIX_FADV_RANDOM );
+#endif
+
if (root_fd != -1) fchdir( server_dir_fd ); /* go back to the server dir */
return fd;
--
2.25.1
More information about the wine-devel
mailing list