char line[LINE_MAX];
int r = 0;
char *pack_fn = NULL, c;
- bool on_ssd;
+ bool on_ssd, ready = false;
int prio;
assert(root);
if (ioprio_set(IOPRIO_WHO_PROCESS, getpid(), prio) < 0)
log_warning("Failed to set IDLE IO priority class: %m");
- sd_notify(0,
- "READY=1\n"
- "STATUS=Replaying readahead data");
+ sd_notify(0, "STATUS=Replaying readahead data");
log_debug("Replaying...");
r = k;
goto finish;
}
+
+ if (!ready) {
+ /* We delay the ready notification until we
+ * queued at least one read */
+ sd_notify(0, "READY=1");
+ ready = true;
+ }
}
+ if (!ready)
+ sd_notify(0, "READY=1");
+
if (ferror(pack)) {
log_error("Failed to read pack file.");
r = -EIO;
}
int main(int argc, char*argv[]) {
+
log_set_target(LOG_TARGET_SYSLOG_OR_KMSG);
log_parse_environment();
log_open();
- if (replay("/") < 0)
+ if (!enough_ram()) {
+ log_info("Disabling readahead replay due to low memory.");
+ return 0;
+ }
+
+ if (replay(argc >= 2 ? argv[1] : "/") < 0)
return 1;
return 0;