sd_readahead.xml revision 56ba3c78ae35065064c4289a0c8e22a81256af20
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames<?xml version='1.0'?> <!--*-nxml-*-->
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames<!--
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames This file is part of systemd.
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames Copyright 2010 Lennart Poettering
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames systemd is free software; you can redistribute it and/or modify it
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames under the terms of the GNU Lesser General Public License as published by
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames the Free Software Foundation; either version 2.1 of the License, or
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames (at your option) any later version.
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames systemd is distributed in the hope that it will be useful, but
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames WITHOUT ANY WARRANTY; without even the implied warranty of
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames Lesser General Public License for more details.
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames You should have received a copy of the GNU Lesser General Public License
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames along with systemd; If not, see <http://www.gnu.org/licenses/>.
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames-->
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames<refentry id="sd_notify" conditional='ENABLE_READAHEAD'>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <refentryinfo>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <title>sd_readahead</title>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <productname>systemd</productname>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <authorgroup>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <author>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <contrib>Developer</contrib>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <firstname>Lennart</firstname>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <surname>Poettering</surname>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <email>lennart@poettering.net</email>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames </author>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames </authorgroup>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames </refentryinfo>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <refmeta>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <refentrytitle>sd_readahead</refentrytitle>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <manvolnum>3</manvolnum>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames </refmeta>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <refnamediv>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <refname>sd_readahead</refname>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <refpurpose>Control ongoing disk boot-time read-ahead operations</refpurpose>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames </refnamediv>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <refsynopsisdiv>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <funcsynopsis>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <funcsynopsisinfo>#include "sd-readahead.h"</funcsynopsisinfo>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <funcprototype>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <funcdef>int <function>sd_readahead</function></funcdef>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <paramdef>const char *<parameter>action</parameter></paramdef>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames </funcprototype>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames </funcsynopsis>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames </refsynopsisdiv>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <refsect1>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <title>Description</title>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <para><function>sd_readahead()</function> may be
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames called by programs involved with early boot-up to
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames control ongoing boot-time disk read-ahead operations. It may be
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames used to terminate read-ahead operations in case an
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames uncommon disk access pattern is to be expected and
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames hence read-ahead replay or collection is unlikely to
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames have the desired speed-up effect on the current or
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames future boot-ups.</para>
43162230430f8144afe9c32cd0e60b927f4e0a60gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <para>The <parameter>action</parameter> should be one
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames of the following strings:</para>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <variablelist>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <varlistentry>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <term>cancel</term>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <listitem><para>Terminates read-ahead
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames data collection, and drops all
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames read-ahead data collected during this
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames boot-up.</para></listitem>
43162230430f8144afe9c32cd0e60b927f4e0a60gregames </varlistentry>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <varlistentry>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <term>done</term>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <listitem><para>Terminates read-ahead
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames data collection, but keeps all
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames read-ahead data collected during this
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames boot-up around for use during
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames subsequent boot-ups.</para></listitem>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames </varlistentry>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <varlistentry>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <term>noreplay</term>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <listitem><para>Terminates read-ahead
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames replay.</para></listitem>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames </varlistentry>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames </variablelist>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames </refsect1>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <refsect1>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <title>Return Value</title>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <para>On failure, these calls return a negative
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames errno-style error code. It is generally recommended to
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames ignore the return value of this call.</para>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames </refsect1>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <refsect1>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <title>Notes</title>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <para>This function is provided by the reference
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames implementation of APIs for controlling boot-time
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames read-ahead and distributed with the systemd
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames package. The algorithm it implements is simple, and
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames can easily be reimplemented in daemons if it is
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames important to support this interface without using the
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames reference implementation.</para>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <para>Internally, this function creates a file in
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <filename>/run/systemd/readahead/</filename> which is
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames then used as flag file to notify the read-ahead
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames subsystem.</para>
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames <para>For details about the algorithm check the
3d0434b7f8ce3bfce252ebbe3cabe626ba750d83gregames liberally licensed reference implementation sources:
<ulink url="http://cgit.freedesktop.org/systemd/systemd/plain/src/readahead/sd-readahead.c"/>
and <ulink
url="http://cgit.freedesktop.org/systemd/systemd/plain/src/systemd/sd-readahead.h"/></para>
<para><function>sd_readahead()</function> is
implemented in the reference implementation's drop-in
<filename>sd-readahead.c</filename> and
<filename>sd-readahead.h</filename> files. It is
recommended that applications consuming this API copy
the implementation into their source tree. For more
details about the reference implementation see
<citerefentry><refentrytitle>sd-readahead</refentrytitle><manvolnum>3</manvolnum></citerefentry></para>
<para>If -DDISABLE_SYSTEMD is set during compilation
this function will always return 0 and otherwise
become a NOP.</para>
</refsect1>
<refsect1>
<title>Examples</title>
<example>
<title>Cancelling all read-ahead operations</title>
<para>During boots where SELinux has to
relabel the file system hierarchy, it will
create a large amount of disk accesses that
are not necessary during normal boots. Hence
it is a good idea to disable both read-ahead replay and read-ahead collection.
</para>
<programlisting>sd_readahead("cancel");
sd_readahead("noreplay");</programlisting>
</example>
</refsect1>
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-readahead</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>daemon</refentrytitle><manvolnum>7</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>