1READAHEAD(2)               Linux Programmer's Manual              READAHEAD(2)
2
3
4

NAME

6       readahead - initiate file readahead into page cache
7

SYNOPSIS

9       #define _GNU_SOURCE             /* See feature_test_macros(7) */
10       #include <fcntl.h>
11
12       ssize_t readahead(int fd, off64_t offset, size_t count);
13

DESCRIPTION

15       readahead() initiates readahead on a file so that subsequent reads from
16       that file will be satisfied from the cache, and not block on  disk  I/O
17       (assuming  the  readahead  was  initiated  early  enough and that other
18       activity on the system did not in the meantime  flush  pages  from  the
19       cache).
20
21       The  fd  argument is a file descriptor identifying the file which is to
22       be read.  The offset argument specifies the starting point  from  which
23       data  is to be read and count specifies the number of bytes to be read.
24       I/O is performed in whole pages, so that offset is effectively  rounded
25       down to a page boundary and bytes are read up to the next page boundary
26       greater than or equal to (offset+count).   readahead()  does  not  read
27       beyond  the end of the file.  The file offset of the open file descrip‐
28       tion referred to by fd is left unchanged.
29

RETURN VALUE

31       On success, readahead() returns 0; on failure,  -1  is  returned,  with
32       errno set to indicate the cause of the error.
33

ERRORS

35       EBADF  fd is not a valid file descriptor or is not open for reading.
36
37       EINVAL fd  does  not  refer  to a file type to which readahead() can be
38              applied.
39

VERSIONS

41       The readahead() system call appeared in Linux 2.4.13; glibc support has
42       been provided since version 2.3.
43

CONFORMING TO

45       The  readahead()  system  call is Linux-specific, and its use should be
46       avoided in portable applications.
47

NOTES

49       On some 32-bit architectures, the calling  signature  for  this  system
50       call differs, for the reasons described in syscall(2).
51

BUGS

53       readahead() attempts to schedule the reads in the background and return
54       immediately.  However, it may block while it reads the filesystem meta‐
55       data  needed  to  locate  the requested blocks.  This occurs frequently
56       with ext[234] on large files using indirect blocks instead of  extents,
57       giving the appearance that the call blocks until the requested data has
58       been read.
59

SEE ALSO

61       lseek(2), madvise(2), mmap(2), posix_fadvise(2), read(2)
62

COLOPHON

64       This page is part of release 4.15 of the Linux  man-pages  project.   A
65       description  of  the project, information about reporting bugs, and the
66       latest    version    of    this    page,    can     be     found     at
67       https://www.kernel.org/doc/man-pages/.
68
69
70
71Linux                             2017-09-15                      READAHEAD(2)
Impressum