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=f0710e5ddf7ef1cb7d1cac95b5dcef88179c4940;hb=f41c094c9fb6760b27996aacfe1e66f2f2f415cb;hpb=858209c51f3c5eadd5489edc3154d84f24e1f00a diff --git a/src/readahead-replay.c b/src/readahead-replay.c index f0710e5dd..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; @@ -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;