chiark / gitweb /
readahead-replay: delay ready notification until we queued first read
authorLennart Poettering <lennart@poettering.net>
Sat, 25 Sep 2010 11:47:31 +0000 (13:47 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 25 Sep 2010 11:47:31 +0000 (13:47 +0200)
src/readahead-collect.c
src/readahead-replay.c

index fe35da7004ff73374555b67d2c9c20c81ff506e4..6b9fb4650b78e2fe60499c7fe0d7f183966b2ada 100644 (file)
@@ -54,6 +54,7 @@
  *
  * - detect ssd/lvm/... on btrfs
  * - read ahead directories
  *
  * - detect ssd/lvm/... on btrfs
  * - read ahead directories
+ * - sd_readahead_cancel
  */
 
 static int btrfs_defrag(int fd) {
  */
 
 static int btrfs_defrag(int fd) {
index 58d9468c43010d04d17ed9120608f907ff4ec5db..c01f73e6a99d011f0232ac77fc43a63244237041 100644 (file)
@@ -114,7 +114,7 @@ static int replay(const char *root) {
         char line[LINE_MAX];
         int r = 0;
         char *pack_fn = NULL, c;
         char line[LINE_MAX];
         int r = 0;
         char *pack_fn = NULL, c;
-        bool on_ssd;
+        bool on_ssd, ready = false;
         int prio;
 
         assert(root);
         int prio;
 
         assert(root);
@@ -168,9 +168,7 @@ static int replay(const char *root) {
         if (ioprio_set(IOPRIO_WHO_PROCESS, getpid(), prio) < 0)
                 log_warning("Failed to set IDLE IO priority class: %m");
 
         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...");
 
 
         log_debug("Replaying...");
 
@@ -181,8 +179,18 @@ static int replay(const char *root) {
                         r = k;
                         goto finish;
                 }
                         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;
         if (ferror(pack)) {
                 log_error("Failed to read pack file.");
                 r = -EIO;