man-pages/man2/readahead.2.html
2021-03-31 01:06:50 +01:00

177 lines
4.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of READAHEAD</TITLE>
</HEAD><BODY>
<H1>READAHEAD</H1>
Section: Linux Programmer's Manual (2)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
readahead - initiate file readahead into page cache
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#define _GNU_SOURCE</B> /* See <A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A>(7) */
<B>#include &lt;<A HREF="file:///usr/include/fcntl.h">fcntl.h</A>&gt;</B>
<B>ssize_t readahead(int </B><I>fd</I><B>, off64_t </B><I>offset</I><B>, size_t </B><I>count</I><B>);</B>
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<B>readahead</B>()
initiates readahead on a file so that subsequent reads from that file will
be satisfied from the cache, and not block on disk I/O
(assuming the readahead was initiated early enough and that other activity
on the system did not in the meantime flush pages from the cache).
<P>
The
<I>fd</I>
argument is a file descriptor identifying the file which is
to be read.
The
<I>offset</I>
argument specifies the starting point from which data is to be read
and
<I>count</I>
specifies the number of bytes to be read.
I/O is performed in whole pages, so that
<I>offset</I>
is effectively rounded down to a page boundary
and bytes are read up to the next page boundary greater than or
equal to
<I>(offset+count)</I>.
<B>readahead</B>()
does not read beyond the end of the file.
The file offset of the open file description referred to by the file descriptor
<I>fd</I>
is left unchanged.
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
On success,
<B>readahead</B>()
returns 0; on failure, -1 is returned, with
<I>errno</I>
set to indicate the cause of the error.
<A NAME="lbAF">&nbsp;</A>
<H2>ERRORS</H2>
<DL COMPACT>
<DT id="1"><B>EBADF</B>
<DD>
<I>fd</I>
is not a valid file descriptor or is not open for reading.
<DT id="2"><B>EINVAL</B>
<DD>
<I>fd</I>
does not refer to a file type to which
<B>readahead</B>()
can be applied.
</DL>
<A NAME="lbAG">&nbsp;</A>
<H2>VERSIONS</H2>
The
<B>readahead</B>()
system call appeared in Linux 2.4.13;
glibc support has been provided since version 2.3.
<A NAME="lbAH">&nbsp;</A>
<H2>CONFORMING TO</H2>
The
<B>readahead</B>()
system call is Linux-specific, and its use should be avoided
in portable applications.
<A NAME="lbAI">&nbsp;</A>
<H2>NOTES</H2>
On some 32-bit architectures,
the calling signature for this system call differs,
for the reasons described in
<B><A HREF="/cgi-bin/man/man2html?2+syscall">syscall</A></B>(2).
<A NAME="lbAJ">&nbsp;</A>
<H2>BUGS</H2>
<B>readahead</B>()
attempts to schedule the reads in the background and return immediately.
However, it may block while it reads the filesystem metadata needed
to locate the requested blocks.
This occurs frequently with ext[234] on large files
using indirect blocks instead of extents,
giving the appearance that the call blocks until the requested data has
been read.
<A NAME="lbAK">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?2+lseek">lseek</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+madvise">madvise</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+mmap">mmap</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+posix_fadvise">posix_fadvise</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+read">read</A></B>(2)
<A NAME="lbAL">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="3"><A HREF="#lbAB">NAME</A><DD>
<DT id="4"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="5"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="6"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="7"><A HREF="#lbAF">ERRORS</A><DD>
<DT id="8"><A HREF="#lbAG">VERSIONS</A><DD>
<DT id="9"><A HREF="#lbAH">CONFORMING TO</A><DD>
<DT id="10"><A HREF="#lbAI">NOTES</A><DD>
<DT id="11"><A HREF="#lbAJ">BUGS</A><DD>
<DT id="12"><A HREF="#lbAK">SEE ALSO</A><DD>
<DT id="13"><A HREF="#lbAL">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:34 GMT, March 31, 2021
</BODY>
</HTML>