1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 This file is part of systemd.
8 Copyright 2010 Lennart Poettering
10 systemd is free software; you can redistribute it and/or modify it
11 under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 <refentry id="sd_notify">
27 <title>sd_readahead</title>
28 <productname>systemd</productname>
32 <contrib>Developer</contrib>
33 <firstname>Lennart</firstname>
34 <surname>Poettering</surname>
35 <email>lennart@poettering.net</email>
41 <refentrytitle>sd_readahead</refentrytitle>
42 <manvolnum>3</manvolnum>
46 <refname>sd_readahead</refname>
47 <refpurpose>Control ongoing disk boot-time read-ahead operations</refpurpose>
52 <funcsynopsisinfo>#include "sd-daemon.h"</funcsynopsisinfo>
55 <funcdef>int <function>sd_readahead</function></funcdef>
56 <paramdef>const char *<parameter>action</parameter></paramdef>
62 <title>Description</title>
63 <para><function>sd_readahead()</function> may be
64 called by programs involved with early boot-up to
65 control ongoing boot-time disk read-ahead operations. It may be
66 used to terminate read-ahead operations in case an
67 uncommon disk access pattern is to be expected and
68 hence read-ahead replay or collection is unlikely to
69 have the desired speed-up effect on the current or
70 future boot-ups.</para>
72 <para>The <parameter>action</parameter> should be one
73 of the following strings:</para>
79 <listitem><para>Terminates read-ahead
80 data collection, and drops all
81 read-ahead data collected during this
82 boot-up.</para></listitem>
88 <listitem><para>Terminates read-ahead
89 data collection, but keeps all
90 read-ahead data collected during this
91 boot-up around for use during
92 subsequent boot-ups.</para></listitem>
98 <listitem><para>Terminates read-ahead
99 replay.</para></listitem>
107 <title>Return Value</title>
109 <para>On failure, these calls return a negative
110 errno-style error code. It is generally recommended to
111 ignore the return value of this call.</para>
117 <para>This function is provided by the reference
118 implementation of APIs for controlling boot-time
119 read-ahead and distributed with the systemd
120 package. The algorithm it implements is simple, and
121 can easily be reimplemented in daemons if it is
122 important to support this interface without using the
123 reference implementation.</para>
125 <para>Internally, this function creates a file in
126 <filename>/dev/.systemd/readahead/</filename> which is
127 then used as flag file to notify the read-ahead
130 <para>For details about the algorithm check the
131 liberally licensed reference implementation sources:
132 <ulink url="http://cgit.freedesktop.org/systemd/tree/src/sd-readahead.c"/>
134 url="http://cgit.freedesktop.org/systemd/tree/src/sd-readahead.h"/></para>
136 <para><function>sd_readahead()</function> is
137 implemented in the reference implementation's drop-in
138 <filename>sd-readahead.c</filename> and
139 <filename>sd-readahead.h</filename> files. It is
140 recommended that applications consuming this API copy
141 the implementation into their source tree. For more
142 details about the reference implementation see
143 <citerefentry><refentrytitle>sd-readahead</refentrytitle><manvolnum>7</manvolnum></citerefentry></para>
145 <para>If -DDISABLE_SYSTEMD is set during compilation
146 this function will always return 0 and otherwise
151 <title>Examples</title>
154 <title>Cancelling all read-ahead operations</title>
156 <para>During boots where SELinux has to
157 relabel the file system hierarchy, it will
158 create a large amount of disk accesses that
159 are not necessary during normal boots. Hence
160 it is a good idea to disable both read-ahead replay and read-ahead collection.
163 <programlisting>sd_readahead("cancel");
164 sd_readahead("noreplay");</programlisting>
170 <title>See Also</title>
172 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
173 <citerefentry><refentrytitle>sd-readahead</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
174 <citerefentry><refentrytitle>daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>