SD_READAHEAD(3)                 sd_readahead                 SD_READAHEAD(3)

NAME         top

       sd_readahead - Control ongoing disk boot-time read-ahead operations

SYNOPSIS         top

       #include "sd-readahead.h"

       int sd_readahead(const char *action);

DESCRIPTION         top

       sd_readahead() may be called by programs involved with early boot-up
       to control ongoing boot-time 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:

           Terminates read-ahead data collection, and drops all read-ahead
           data collected during this boot-up.

           Terminates read-ahead data collection, but keeps all read-ahead
           data collected during this boot-up around for use during
           subsequent boot-ups.

           Terminates read-ahead replay.

RETURN VALUE         top

       On failure, these calls return a negative errno-style error code. It
       is generally recommended to ignore the return value of this call.

NOTES         top

       This function is provided by the reference implementation of APIs for
       controlling boot-time read-ahead 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 /run/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: 

       sd_readahead() is implemented in the reference implementation's
       drop-in sd-readahead.c and sd-readahead.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-readahead(3)

       If -DDISABLE_SYSTEMD is set during compilation, this function will
       always return 0 and otherwise become a NOP.

EXAMPLES         top

       Example 1. 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.


SEE ALSO         top

       systemd(1), sd-readahead(3), daemon(7)

COLOPHON         top

       This page is part of the systemd (systemd system and service manager)
       project.  Information about the project can be found at 
       ⟨⟩.  If you have a bug
       report for this manual page, see 
       ⟨⟩.  This
       page was obtained from the project's upstream Git repository
       (git:// on 2015-12-05.  If
       you discover any rendering problems in this HTML version of the page,
       or you believe there is a better or more up-to-date source for the
       page, or you have corrections or improvements to the information in
       this COLOPHON (which is not part of the original manual page), send a
       mail to

systemd 216                                                  SD_READAHEAD(3)