readahead() which is Linux-only vs. posix_fadvise()

derrell at samba.org derrell at samba.org
Thu May 10 19:16:35 GMT 2007


Jeremy Allison <jra at samba.org> writes:

> On Wed, May 09, 2007 at 09:35:29PM -0400, derrell at samba.org wrote:
>> 
>> The only place that readahead() is used, I think, is in vfs_readahead.c.
>> It might make sense for the maintainer of this module to look into using
>> posix_fadvise() instead of readahead().
>
> Did you look at the code here :-) ? I'm guessing not....

Clearly I hadn't noticed that further down it tries posix_fadvise().  Thanks
for pointing it out.  Based on the fact that there's possibly no reliable
declaration for readahead() and that there is a POSIX-compliant alternative,
would it make sense to swap the order... try to use posix_fadvise() first, and
if it doesn't exist, then look for readahead()?  (Also, since Linux provides
posix_fadvise(), maybe there's no reason for readahead() at all?)

Derrell


> #if defined(HAVE_LINUX_READAHEAD)
>                 int err = readahead(fromfd, offset, (size_t)rhd->len);
>                 DEBUG(10,("readahead_sendfile: readahead on fd %u,
> offset %llu, len %u returned %d\n",
>                         (unsigned int)fromfd,
>                         (unsigned long long)offset,
>                         (unsigned int)rhd->len,
>                         err ));
> #elif defined(HAVE_POSIX_FADVISE)
>                 int err = posix_fadvise(fromfd, offset, (off_t)rhd->len,
> POSIX_FADV_WILLNEED);
>                 DEBUG(10,("readahead_sendfile: posix_fadvise on fd %u,
> offset %llu, len %u returned %d\n",
>                         (unsigned int)fromfd,
>                         (unsigned long long)offset,
>                         (unsigned int)rhd->len,
>                         err ));
> #else
>                 if (!rhd->didmsg) {
>                         DEBUG(0,("readahead_sendfile: no readahead on
> this platform\n"));
>                         rhd->didmsg = True;
>                 }
> #endif
>

-- 


More information about the samba-technical mailing list