[systemd-commits] 2 commits - src/core src/journal

Lennart Poettering lennart at kemper.freedesktop.org
Wed Sep 19 00:58:42 PDT 2012


 src/core/automount.c     |    2 +-
 src/core/mount.c         |    2 +-
 src/journal/sd-journal.c |   44 +++++++++++++++++++++++++++++---------------
 3 files changed, 31 insertions(+), 17 deletions(-)

New commits:
commit 468b21de7c9327bb8747d36e6273ed7aed97052a
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Sep 19 09:56:00 2012 +0200

    journal: when comparing two entries from separate files make sure we reposition the mmap window
    
    The mmap cache doesn't guarantee that we can look at two files at the
    same time. Hence make sure to look at the entries to compare one
    after the other, instead of at the same time when comparing them, and
    reposition the window in between.

diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index b4d35ee..2fa8172 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -357,15 +357,27 @@ _public_ void sd_journal_flush_matches(sd_journal *j) {
         detach_location(j);
 }
 
-static int compare_order(JournalFile *af, Object *ao,
-                         JournalFile *bf, Object *bo) {
+static int compare_entry_order(JournalFile *af, Object *_ao,
+                         JournalFile *bf, uint64_t bp) {
 
         uint64_t a, b;
+        Object *ao, *bo;
+        int r;
 
         assert(af);
-        assert(ao);
         assert(bf);
-        assert(bo);
+        assert(_ao);
+
+        /* The mmap cache might invalidate the object from the first
+         * file if we look at the one from the second file. Hence
+         * temporarily copy the header of the first one, and look at
+         * that only. */
+        ao = alloca(offsetof(EntryObject, items));
+        memcpy(ao, _ao, offsetof(EntryObject, items));
+
+        r = journal_file_move_to_object(bf, OBJECT_ENTRY, bp, &bo);
+        if (r < 0)
+                return strcmp(af->path, bf->path);
 
         /* We operate on two different files here, hence we can access
          * two objects at the same time, which we normally can't.
@@ -808,18 +820,17 @@ static int next_beyond_location(sd_journal *j, JournalFile *f, direction_t direc
 }
 
 static int real_journal_next(sd_journal *j, direction_t direction) {
-        JournalFile *f, *new_current = NULL;
+        JournalFile *f, *new_file = NULL;
+        uint64_t new_offset = 0;
+        Object *o;
+        uint64_t p;
         Iterator i;
         int r;
-        uint64_t new_offset = 0;
-        Object *new_entry = NULL;
 
         if (!j)
                 return -EINVAL;
 
         HASHMAP_FOREACH(f, j->files, i) {
-                Object *o;
-                uint64_t p;
                 bool found;
 
                 r = next_beyond_location(j, f, direction, &o, &p);
@@ -829,12 +840,12 @@ static int real_journal_next(sd_journal *j, direction_t direction) {
                 } else if (r == 0)
                         continue;
 
-                if (!new_current)
+                if (!new_file)
                         found = true;
                 else {
                         int k;
 
-                        k = compare_order(f, o, new_current, new_entry);
+                        k = compare_entry_order(f, o, new_file, new_offset);
 
                         if (direction == DIRECTION_DOWN)
                                 found = k < 0;
@@ -843,16 +854,19 @@ static int real_journal_next(sd_journal *j, direction_t direction) {
                 }
 
                 if (found) {
-                        new_current = f;
-                        new_entry = o;
+                        new_file = f;
                         new_offset = p;
                 }
         }
 
-        if (!new_current)
+        if (!new_file)
                 return 0;
 
-        set_location(j, new_current, new_entry, new_offset);
+        r = journal_file_move_to_object(new_file, OBJECT_ENTRY, new_offset, &o);
+        if (r < 0)
+                return r;
+
+        set_location(j, new_file, o, new_offset);
 
         return 1;
 }

commit a99124d92f8a60215f5ea5ed95de9792c1fb3324
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Sep 19 09:55:56 2012 +0200

    mount: reword directory empty warning a bit

diff --git a/src/core/automount.c b/src/core/automount.c
index 11b6a6a..b1619a6 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -502,7 +502,7 @@ static void automount_enter_waiting(Automount *a) {
         mkdir_p_label(a->where, 0555);
 
         if (dir_is_empty(a->where) <= 0)
-                log_notice("%s: Directory %s to mount over is not empty, ignoring. (To see the over-mounted files, please manually mount the underlying file system to a secondary location.)", a->meta.id, a->where);
+                log_notice("%s: Directory %s to mount over is not empty, mounting anyway. (To see the over-mounted files, please manually mount the underlying file system to a secondary location.)", a->meta.id, a->where);
 
         if (pipe2(p, O_NONBLOCK|O_CLOEXEC) < 0) {
                 r = -errno;
diff --git a/src/core/mount.c b/src/core/mount.c
index 66ef0cd..7e3ccc1 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -960,7 +960,7 @@ static void mount_enter_mounting(Mount *m) {
         mkdir_p_label(m->where, m->directory_mode);
 
         if (dir_is_empty(m->where) <= 0)
-                log_notice("%s: Directory %s to mount over is not empty, ignoring. (To see the over-mounted files, please manually mount the underlying file system to a secondary location.)", m->meta.id, m->where);
+                log_notice("%s: Directory %s to mount over is not empty, mounting anyway. (To see the over-mounted files, please manually mount the underlying file system to a secondary location.)", m->meta.id, m->where);
 
         /* Create the source directory for bind-mounts if needed */
         p = get_mount_parameters_fragment(m);



More information about the systemd-commits mailing list