1SD_READAHEAD(3) sd_readahead SD_READAHEAD(3)
2
3
4
6 sd_readahead - Control ongoing disk boot-time read-ahead operations
7
9 #include "sd-readahead.h"
10
11 int sd_readahead(const char *action);
12
14 sd_readahead() may be called by programs involved with early boot-up to
15 control ongoing boot-time disk read-ahead operations. It may be used to
16 terminate read-ahead operations in case an uncommon disk access pattern
17 is to be expected and hence read-ahead replay or collection is unlikely
18 to have the desired speed-up effect on the current or future boot-ups.
19
20 The action should be one of the following strings:
21
22 cancel
23 Terminates read-ahead data collection, and drops all read-ahead
24 data collected during this boot-up.
25
26 done
27 Terminates read-ahead data collection, but keeps all read-ahead
28 data collected during this boot-up around for use during subsequent
29 boot-ups.
30
31 noreplay
32 Terminates read-ahead replay.
33
35 On failure, these calls return a negative errno-style error code. It is
36 generally recommended to ignore the return value of this call.
37
39 This function is provided by the reference implementation of APIs for
40 controlling boot-time read-ahead and distributed with the systemd
41 package. The algorithm it implements is simple, and can easily be
42 reimplemented in daemons if it is important to support this interface
43 without using the reference implementation.
44
45 Internally, this function creates a file in /run/systemd/readahead/
46 which is then used as flag file to notify the read-ahead subsystem.
47
48 For details about the algorithm check the liberally licensed reference
49 implementation sources:
50 http://cgit.freedesktop.org/systemd/systemd/plain/src/readahead/sd-readahead.c
51 and
52 http://cgit.freedesktop.org/systemd/systemd/plain/src/systemd/sd-readahead.h
53
54 sd_readahead() is implemented in the reference implementation's drop-in
55 sd-readahead.c and sd-readahead.h files. It is recommended that
56 applications consuming this API copy the implementation into their
57 source tree. For more details about the reference implementation, see
58 sd-readahead(3)
59
60 If -DDISABLE_SYSTEMD is set during compilation, this function will
61 always return 0 and otherwise become a NOP.
62
64 Example 1. Cancelling all read-ahead operations
65
66 During boots where SELinux has to relabel the file system hierarchy, it
67 will create a large amount of disk accesses that are not necessary
68 during normal boots. Hence it is a good idea to disable both read-ahead
69 replay and read-ahead collection.
70
71 sd_readahead("cancel");
72 sd_readahead("noreplay");
73
75 systemd(1), sd-readahead(3), daemon(7)
76
77
78
79systemd 219 SD_READAHEAD(3)