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 (date) "Linux man-pages (unreleased)"
10 readahead \- initiate file readahead into page cache
13 .RI ( libc ", " \-lc )
16 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
17 .B #define _FILE_OFFSET_BITS 64
20 .BI "ssize_t readahead(int " fd ", off_t " offset ", size_t " count );
24 initiates readahead on a file so that subsequent reads from that file will
25 be satisfied from the cache, and not block on disk I/O
26 (assuming the readahead was initiated early enough and that other activity
27 on the system did not in the meantime flush pages from the cache).
31 argument is a file descriptor identifying the file which is
35 argument specifies the starting point from which data is to be read
38 specifies the number of bytes to be read.
39 I/O is performed in whole pages, so that
41 is effectively rounded down to a page boundary
42 and bytes are read up to the next page boundary greater than or
44 .IR "(offset+count)" .
46 does not read beyond the end of the file.
47 The file offset of the open file description referred to by the file descriptor
53 returns 0; on failure, \-1 is returned, with
55 set to indicate the error.
60 is not a valid file descriptor or is not open for reading.
64 does not refer to a file type to which
68 On some 32-bit architectures,
69 the calling signature for this system call differs,
70 for the reasons described in
79 should be defined to be 64 in code that uses a pointer to
81 if the code is intended to be portable
82 to traditional 32-bit x86 and ARM platforms where
84 width defaults to 32 bits.
87 attempts to schedule the reads in the background and return immediately.
88 However, it may block while it reads the filesystem metadata needed
89 to locate the requested blocks.
90 This occurs frequently with ext[234] on large files
91 using indirect blocks instead of extents,
92 giving the appearance that the call blocks until the requested data has
98 .BR posix_fadvise (2),