[PATCH v4 4/4] server: Implement file access hints using posix_fadvise

Chip Davis cdavis at codeweavers.com
Tue Aug 3 21:28:29 CDT 2021


August 3, 2021 10:31 AM, "Luke Deller" <luke at deller.id.au> wrote:

> diff --git a/server/fd.c b/server/fd.c
> index b953da2ab85..b20fa97229c 100644
> --- a/server/fd.c
> +++ b/server/fd.c
> @@ -2036,6 +2037,15 @@ 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

This really needs a configure check. Under certain circumstances, _POSIX_C_SOURCE can be 200809L on macOS, but AFAIK it still doesn't have posix_fadvise(2/3) even on macOS 12.

> +    cache_hint = options & (FILE_SEQUENTIAL_ONLY | FILE_RANDOM_ACCESS);
> +    if (cache_hint == FILE_SEQUENTIAL_ONLY)
> +        posix_fadvise( fd->unix_fd, 0, 0, POSIX_FADV_SEQUENTIAL );
> +    else if (cache_hint == 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;


Chip



More information about the wine-devel mailing list