share/mk/: Remove unused variable
[man-pages.git] / man2 / readahead.2
blobe857fde6640c4c76b4dc8dfe66bebfd54916ac4a
1 .\" This manpage is Copyright (C) 2004, Michael Kerrisk
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .\" 2004-05-40 Created by Michael Kerrisk <mtk.manpages@gmail.com>
6 .\" 2004-10-05 aeb, minor correction
7 .\"
8 .TH readahead 2 (date) "Linux man-pages (unreleased)"
9 .SH NAME
10 readahead \- initiate file readahead into page cache
11 .SH LIBRARY
12 Standard C library
13 .RI ( libc ", " \-lc )
14 .SH SYNOPSIS
15 .nf
16 .BR "#define _GNU_SOURCE" "             /* See feature_test_macros(7) */"
17 .B #define _FILE_OFFSET_BITS 64
18 .B #include <fcntl.h>
20 .BI "ssize_t readahead(int " fd ", off_t " offset ", size_t " count );
21 .fi
22 .SH DESCRIPTION
23 .BR readahead ()
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).
29 The
30 .I fd
31 argument is a file descriptor identifying the file which is
32 to be read.
33 The
34 .I offset
35 argument specifies the starting point from which data is to be read
36 and
37 .I count
38 specifies the number of bytes to be read.
39 I/O is performed in whole pages, so that
40 .I offset
41 is effectively rounded down to a page boundary
42 and bytes are read up to the next page boundary greater than or
43 equal to
44 .IR "(offset+count)" .
45 .BR readahead ()
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
48 .I fd
49 is left unchanged.
50 .SH RETURN VALUE
51 On success,
52 .BR readahead ()
53 returns 0; on failure, \-1 is returned, with
54 .I errno
55 set to indicate the error.
56 .SH ERRORS
57 .TP
58 .B EBADF
59 .I fd
60 is not a valid file descriptor or is not open for reading.
61 .TP
62 .B EINVAL
63 .I fd
64 does not refer to a file type to which
65 .BR readahead ()
66 can be applied.
67 .SH VERSIONS
68 On some 32-bit architectures,
69 the calling signature for this system call differs,
70 for the reasons described in
71 .BR syscall (2).
72 .SH STANDARDS
73 Linux.
74 .SH HISTORY
75 Linux 2.4.13,
76 glibc 2.3.
77 .SH NOTES
78 .B _FILE_OFFSET_BITS
79 should be defined to be 64 in code that uses a pointer to
80 .BR readahead ,
81 if the code is intended to be portable
82 to traditional 32-bit x86 and ARM platforms where
83 .BR off_t 's
84 width defaults to 32 bits.
85 .SH BUGS
86 .BR readahead ()
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
93 been read.
94 .SH SEE ALSO
95 .BR lseek (2),
96 .BR madvise (2),
97 .BR mmap (2),
98 .BR posix_fadvise (2),
99 .BR read (2)