sd_readahead
systemd
Developer
Lennart
Poettering
lennart@poettering.net
sd_readahead
3
sd_readahead
Control ongoing disk read-ahead operations
#include "sd-daemon.h"
int sd_readahead
const char *action
Description
sd_readahead() may be
called by programs involved with early boot-up to
control ongoing disk read-ahead operations. It may be
used to terminate read-ahead operations in case an
uncommon disk access pattern is to be expected and
hence read-ahead replay or collection is unlikely to
have the desired speed-up effect on the current or
future boot-ups.
The action should be one
of the following strings:
cancel
Terminates read-ahead
data collection, and drops all
read-ahead data collected during this
boot-up.
done
Terminates read-ahead
data collection, but keeps all
read-ahead data collected during this
boot-up around for use during
subsequent boot-ups.
noreplay
Terminates read-ahead
replay.
Return Value
On failure, these calls return a negative
errno-style error code. It is generally recommended to
ignore the return value of this call.
Notes
This function is provided by the reference
implementation of APIs for new-style daemons and
distributed with the systemd package. The algorithm
it implements is simple, and can easily be
reimplemented in daemons if it is important to support
this interface without using the reference
implementation.
Internally, this function creates a file in
/dev/.systemd/readahead/ which is
then used as flag file to notify the read-ahead
subsystem.
For details about the algorithm check the
liberally licensed reference implementation sources:
resp.
sd_readahead() is
implemented in the reference implementation's drop-in
sd-daemon.c and
sd-daemon.h files. It is
recommended that applications consuming this API copy
the implementation into their source tree. For more
details about the reference implementation see
sd_daemon7
If -DDISABLE_SYSTEMD is set during compilation
this function will always return 0 and otherwise
become a NOP.
Examples
Cancelling all read-ahead operations
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.
sd_readahead("cancel");
sd_readahead("noreplay");
See Also
systemd1,
sd_daemon7,
daemon7