Luke Deller : server: Implement file access hints using posix_fadvise.
Alexandre Julliard
julliard at winehq.org
Tue Aug 24 15:56:12 CDT 2021
Module: wine
Branch: master
Commit: a87bafc5b92c9f2deaa399e32a8ec42d28f7ea45
URL: https://source.winehq.org/git/wine.git/?a=commit;h=a87bafc5b92c9f2deaa399e32a8ec42d28f7ea45
Author: Luke Deller <luke at deller.id.au>
Date: Fri Aug 20 21:12:53 2021 +1000
server: Implement file access hints using posix_fadvise.
Signed-off-by: Luke Deller <luke at deller.id.au>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
configure | 1 +
configure.ac | 1 +
include/config.h.in | 3 +++
server/fd.c | 13 +++++++++++++
4 files changed, 18 insertions(+)
diff --git a/configure b/configure
index 2e61fcbc685..a53367f0172 100755
--- a/configure
+++ b/configure
@@ -18010,6 +18010,7 @@ for ac_func in \
pipe2 \
poll \
port_create \
+ posix_fadvise \
prctl \
pread \
proc_pidinfo \
diff --git a/configure.ac b/configure.ac
index a9750330443..837f41c34aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2186,6 +2186,7 @@ AC_CHECK_FUNCS(\
pipe2 \
poll \
port_create \
+ posix_fadvise \
prctl \
pread \
proc_pidinfo \
diff --git a/include/config.h.in b/include/config.h.in
index b1918d46ed1..2b488894a49 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -513,6 +513,9 @@
/* Define to 1 if you have the <port.h> header file. */
#undef HAVE_PORT_H
+/* Define to 1 if you have the `posix_fadvise' function. */
+#undef HAVE_POSIX_FADVISE
+
/* Define to 1 if you have the `prctl' function. */
#undef HAVE_PRCTL
diff --git a/server/fd.c b/server/fd.c
index de7c5d7e36d..a09fc9edfcf 100644
--- a/server/fd.c
+++ b/server/fd.c
@@ -2026,6 +2026,19 @@ struct fd *open_fd( struct fd *root, const char *name, struct unicode_str nt_nam
free( closed_fd );
fd->cacheable = 1;
}
+
+#ifdef HAVE_POSIX_FADVISE
+ switch (options & (FILE_SEQUENTIAL_ONLY | FILE_RANDOM_ACCESS))
+ {
+ case FILE_SEQUENTIAL_ONLY:
+ posix_fadvise( fd->unix_fd, 0, 0, POSIX_FADV_SEQUENTIAL );
+ break;
+ case FILE_RANDOM_ACCESS:
+ posix_fadvise( fd->unix_fd, 0, 0, POSIX_FADV_RANDOM );
+ break;
+ }
+#endif
+
if (root_fd != -1) fchdir( server_dir_fd ); /* go back to the server dir */
return fd;
More information about the wine-cvs
mailing list