1 .\" This manpage is Copyright (C) 2004, Michael Kerrisk
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" 2004-05-40 Created by Michael Kerrisk <mtk.manpages@gmail.com>
6 .\" 2004-10-05 aeb, minor correction
8 .TH READAHEAD 2 2021-03-22 "Linux man-pages (unreleased)" "Linux Programmer's Manual"
10 readahead \- initiate file readahead into page cache
13 .RI ( libc ", " \-lc )
16 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
19 .BI "ssize_t readahead(int " fd ", off64_t " offset ", size_t " count );
23 initiates readahead on a file so that subsequent reads from that file will
24 be satisfied from the cache, and not block on disk I/O
25 (assuming the readahead was initiated early enough and that other activity
26 on the system did not in the meantime flush pages from the cache).
30 argument is a file descriptor identifying the file which is
34 argument specifies the starting point from which data is to be read
37 specifies the number of bytes to be read.
38 I/O is performed in whole pages, so that
40 is effectively rounded down to a page boundary
41 and bytes are read up to the next page boundary greater than or
43 .IR "(offset+count)" .
45 does not read beyond the end of the file.
46 The file offset of the open file description referred to by the file descriptor
52 returns 0; on failure, \-1 is returned, with
54 set to indicate the error.
59 is not a valid file descriptor or is not open for reading.
63 does not refer to a file type to which
69 system call appeared in Linux 2.4.13;
70 glibc support has been provided since version 2.3.
74 system call is Linux-specific, and its use should be avoided
75 in portable applications.
77 On some 32-bit architectures,
78 the calling signature for this system call differs,
79 for the reasons described in
83 attempts to schedule the reads in the background and return immediately.
84 However, it may block while it reads the filesystem metadata needed
85 to locate the requested blocks.
86 This occurs frequently with ext[234] on large files
87 using indirect blocks instead of extents,
88 giving the appearance that the call blocks until the requested data has
94 .BR posix_fadvise (2),