]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/readahead.2
sched_setattr.2: tfix
[thirdparty/man-pages.git] / man2 / readahead.2
CommitLineData
fea681da
MK
1.\" This manpage is Copyright (C) 2004, Michael Kerrisk
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
fea681da
MK
4.\" Permission is granted to make and distribute verbatim copies of this
5.\" manual provided the copyright notice and this permission notice are
6.\" preserved on all copies.
7.\"
8.\" Permission is granted to copy and distribute modified versions of this
9.\" manual under the conditions for verbatim copying, provided that the
10.\" entire resulting derived work is distributed under the terms of a
11.\" permission notice identical to this one.
c13182ef 12.\"
fea681da
MK
13.\" Since the Linux kernel and libraries are constantly changing, this
14.\" manual page may be incorrect or out-of-date. The author(s) assume no
15.\" responsibility for errors or omissions, or for damages resulting from
10d76543
MK
16.\" the use of the information contained herein. The author(s) may not
17.\" have taken the same level of care in the production of this manual,
18.\" which is licensed free of charge, as they might when working
19.\" professionally.
c13182ef 20.\"
fea681da
MK
21.\" Formatted or processed versions of this manual, if unaccompanied by
22.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 23.\" %%%LICENSE_END
fea681da 24.\"
c11b1abf 25.\" 2004-05-40 Created by Michael Kerrisk <mtk.manpages@gmail.com>
fea681da
MK
26.\" 2004-10-05 aeb, minor correction
27.\"
9ba01802 28.TH READAHEAD 2 2019-03-06 "Linux" "Linux Programmer's Manual"
fea681da 29.SH NAME
afc9c3a0 30readahead \- initiate file readahead into page cache
fea681da
MK
31.SH SYNOPSIS
32.nf
86b91fdf 33.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
fea681da 34.B #include <fcntl.h>
68e4db0a 35.PP
37cd82ad 36.BI "ssize_t readahead(int " fd ", off64_t " offset ", size_t " count );
fea681da
MK
37.fi
38.SH DESCRIPTION
63aa9df0 39.BR readahead ()
0226bea1 40initiates readahead on a file so that subsequent reads from that file will
6a7c9c0a
MK
41be satisfied from the cache, and not block on disk I/O
42(assuming the readahead was initiated early enough and that other activity
43on the system did not in the meantime flush pages from the cache).
efeece04 44.PP
fea681da
MK
45The
46.I fd
47argument is a file descriptor identifying the file which is
48to be read.
49The
50.I offset
51argument specifies the starting point from which data is to be read
52and
53.I count
54specifies the number of bytes to be read.
c13182ef 55I/O is performed in whole pages, so that
fea681da
MK
56.I offset
57is effectively rounded down to a page boundary
58and bytes are read up to the next page boundary greater than or
59equal to
60.IR "(offset+count)" .
63aa9df0 61.BR readahead ()
fea681da 62does not read beyond the end of the file.
7f11e32c 63The file offset of the open file description referred to by the file descriptor
fea681da
MK
64.I fd
65is left unchanged.
47297adb 66.SH RETURN VALUE
c13182ef 67On success,
63aa9df0 68.BR readahead ()
fea681da
MK
69returns 0; on failure, \-1 is returned, with
70.I errno
71set to indicate the cause of the error.
72.SH ERRORS
73.TP
74.B EBADF
75.I fd
76is not a valid file descriptor or is not open for reading.
77.TP
78.B EINVAL
79.I fd
80does not refer to a file type to which
e511ffb6 81.BR readahead ()
fea681da 82can be applied.
0f940346
MK
83.SH VERSIONS
84The
85.BR readahead ()
86system call appeared in Linux 2.4.13;
87glibc support has been provided since version 2.3.
47297adb 88.SH CONFORMING TO
c13182ef 89The
63aa9df0 90.BR readahead ()
8382f16d 91system call is Linux-specific, and its use should be avoided
fea681da 92in portable applications.
63ec43ae
MK
93.SH NOTES
94On some 32-bit architectures,
95the calling signature for this system call differs,
96for the reasons described in
97.BR syscall (2).
c41881de 98.SH BUGS
6a7c9c0a
MK
99.BR readahead ()
100attempts to schedule the reads in the background and return immediately.
101However, it may block while it reads the filesystem metadata needed
102to locate the requested blocks.
103This occurs frequently with ext[234] on large files
104using indirect blocks instead of extents,
b3a695fc 105giving the appearance that the call blocks until the requested data has
afc9c3a0 106been read.
47297adb 107.SH SEE ALSO
fea681da
MK
108.BR lseek (2),
109.BR madvise (2),
110.BR mmap (2),
cedfddcd 111.BR posix_fadvise (2),
fea681da 112.BR read (2)