Does FreeBSD have replacement for posix_fadvice() or fcntl(F_RDADVISE)?

mdf at mdf at
Thu May 12 20:05:03 UTC 2011

2011/5/12 Lev Serebryakov <lev at>:
> Hello, Mdf.
> You wrote 12 мая 2011 г., 15:40:25:
>>>>    Does FreeBSD have some custom call, which can be used where Linux
>>>>  programs uses posix_fadvice() and DARWIN ones fcntl(F_RDADVISE)?
>>>>    It is like madvise(2) but for file descriptors.
>>> No, it does not (and I think the function is spelled posix_fadvise()).
>>> mdf reserved the syscall slot for posix_fadvise in his recent work
>>> on posix_fallocate(). Might be, he could comment more.
>> Whoops, I replied bot forgot to reply-all.
>> Adding a stub for posix_fadvise() is on my list of things to do, since
>> we use it at $WORK in our custom filesystem, but the list is long and
>> spare time is short.
>> Nominally a technically correct implementation can do error checking
>> and then nothing.  Even after a stub is added to the OS, each
>> filesystem must implement a VOP to do the work.
>  transmission Torrents client rely on this syscall. It could be beuilt
> without it, of course (it is in our ports!), but it seems, that it
> produce much more sane disk load on Linux, because uses pre-fetch via
> posix_fadvise(). My profiling shows that pread() could take about 40%
> of it CPU time (8 seconds out of 20 with turned on ktrace, for
> example), even if throughput is very modest (700KiB/s, for example).
> Authors say, that they didn't observe such behavior on Linux (which
> has posix_fadvise()) or MacOS X (with fcntl(F_RDADVISE))...
>  May be, we should go to fs@ with this thread now?

Probably; the interface and a few unit tests are a start but the
common filesystems (presumably ufs and zfs and perhaps others) will
need support and I do not have any knowledge of the internals of those


More information about the freebsd-hackers mailing list