X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Freadahead-replay.c;h=ab0c8084c8414c73daded01ca8664565d3937f8a;hp=32941c144d5553dddcda4ca6dc7e88f04caf50b0;hb=f41c094c9fb6760b27996aacfe1e66f2f2f415cb;hpb=6e66797af44164c002127c4664064bf60a2fc13b diff --git a/src/readahead-replay.c b/src/readahead-replay.c index 32941c144..ab0c8084c 100644 --- a/src/readahead-replay.c +++ b/src/readahead-replay.c @@ -44,6 +44,8 @@ static off_t arg_file_size_max = READAHEAD_FILE_SIZE_MAX; +static ReadaheadShared *shared = NULL; + static int unpack_file(FILE *pack) { char fn[PATH_MAX]; int r = 0, fd = -1; @@ -114,7 +116,7 @@ finish: } static int replay(const char *root) { - FILE *pack; + FILE *pack = NULL; char line[LINE_MAX]; int r = 0; char *pack_fn = NULL, c; @@ -125,6 +127,7 @@ static int replay(const char *root) { assert(root); write_one_line_file("/proc/self/oom_score_adj", "1000"); + bump_request_nr(root); if (asprintf(&pack_fn, "%s/.readahead", root) < 0) { log_error("Out of memory"); @@ -143,6 +146,8 @@ static int replay(const char *root) { goto finish; } + posix_fadvise(fileno(pack), 0, 0, POSIX_FADV_WILLNEED); + if ((inotify_fd = open_inotify()) < 0) { r = inotify_fd; goto finish; @@ -338,6 +343,12 @@ int main(int argc, char*argv[]) { return 0; } + if (!(shared = shared_get())) + return 1; + + shared->replay = getpid(); + __sync_synchronize(); + if (replay(optind < argc ? argv[optind] : "/") < 0) return 1;