[systemd-commits] 4 commits - src/journal

Lennart Poettering lennart at kemper.freedesktop.org
Wed Jul 18 07:24:04 PDT 2012


 src/journal/journal-file.c |   28 ++++++++++++++++++++++------
 src/journal/journald.c     |   10 ++++------
 2 files changed, 26 insertions(+), 12 deletions(-)

New commits:
commit 4a299a7ad547becb70e8271eaf8cdc27e8e6836a
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jul 18 16:23:26 2012 +0200

    journal: remove all of /run/log/journal when serializing, since the machine ID might deviate

diff --git a/src/journal/journald.c b/src/journal/journald.c
index 18db31c..3e75818 100644
--- a/src/journal/journald.c
+++ b/src/journal/journald.c
@@ -2147,11 +2147,8 @@ finish:
         journal_file_close(s->runtime_journal);
         s->runtime_journal = NULL;
 
-        if (r >= 0) {
-                char path[] = "/run/log/journal/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
-                sd_id128_to_string(machine, path + 17);
-                rm_rf(path, false, true, false);
-        }
+        if (r >= 0)
+                rm_rf("/run/log/journal", false, true, false);
 
         return r;
 }

commit 4ca86bbc25540acc322679b98c4f18a540c100ee
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jul 18 16:23:06 2012 +0200

    journal: don't complain if the syslog forwarder socket doesn't exist

diff --git a/src/journal/journald.c b/src/journal/journald.c
index 17aac88..18db31c 100644
--- a/src/journal/journald.c
+++ b/src/journal/journald.c
@@ -868,7 +868,8 @@ static void forward_syslog_iovec(Server *s, const struct iovec *iovec, unsigned
                         return;
         }
 
-        log_debug("Failed to forward syslog message: %m");
+        if (errno != ENOENT)
+                log_debug("Failed to forward syslog message: %m");
 }
 
 static void forward_syslog_raw(Server *s, int priority, const char *buffer, struct ucred *ucred, struct timeval *tv) {

commit 361f9cbc7e6c7d3ac41892f5a5aebd1ef4049b95
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jul 18 16:22:40 2012 +0200

    journal: when we suggest a rotation, explain why

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index b9ab009..9efa82c 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -2593,8 +2593,10 @@ bool journal_file_rotate_suggested(JournalFile *f) {
 
         /* If we gained new header fields we gained new features,
          * hence suggest a rotation */
-        if (le64toh(f->header->header_size) < sizeof(Header))
+        if (le64toh(f->header->header_size) < sizeof(Header)) {
+                log_debug("%s uses an outdated header, suggesting rotation.", f->path);
                 return true;
+        }
 
         /* Let's check if the hash tables grew over a certain fill
          * level (75%, borrowing this value from Java's hash table
@@ -2603,12 +2605,26 @@ bool journal_file_rotate_suggested(JournalFile *f) {
          * in newer versions. */
 
         if (JOURNAL_HEADER_CONTAINS(f->header, n_data))
-                if (le64toh(f->header->n_data) * 4ULL > (le64toh(f->header->data_hash_table_size) / sizeof(HashItem)) * 3ULL)
+                if (le64toh(f->header->n_data) * 4ULL > (le64toh(f->header->data_hash_table_size) / sizeof(HashItem)) * 3ULL) {
+                        log_debug("Data hash table of %s has a fill level at %.1f (%llu of %llu items, %llu file size, %llu bytes per hash table item), suggesting rotation.",
+                                  f->path,
+                                  100.0 * (double) le64toh(f->header->n_data) / ((double) (le64toh(f->header->data_hash_table_size) / sizeof(HashItem))),
+                                  (unsigned long long) le64toh(f->header->n_data),
+                                  (unsigned long long) (le64toh(f->header->data_hash_table_size) / sizeof(HashItem)),
+                                  (unsigned long long) (f->last_stat.st_size),
+                                  (unsigned long long) (f->last_stat.st_size / le64toh(f->header->n_data)));
                         return true;
+                }
 
         if (JOURNAL_HEADER_CONTAINS(f->header, n_fields))
-                if (le64toh(f->header->n_fields) * 4ULL > (le64toh(f->header->field_hash_table_size) / sizeof(HashItem)) * 3ULL)
+                if (le64toh(f->header->n_fields) * 4ULL > (le64toh(f->header->field_hash_table_size) / sizeof(HashItem)) * 3ULL) {
+                        log_debug("Field hash table of %s has a fill level at %.1f (%llu of %llu items), suggesting rotation.",
+                                  f->path,
+                                  100.0 * (double) le64toh(f->header->n_fields) / ((double) (le64toh(f->header->field_hash_table_size) / sizeof(HashItem))),
+                                  (unsigned long long) le64toh(f->header->n_fields),
+                                  (unsigned long long) (le64toh(f->header->field_hash_table_size) / sizeof(HashItem)));
                         return true;
+                }
 
         return false;
 }

commit dfabe643f3560dcf147f49ec11e95b95c718c3da
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jul 18 16:22:25 2012 +0200

    journal: estimate data hash table size a bit larger by default

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index d8ce495..b9ab009 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -510,16 +510,16 @@ static int journal_file_setup_data_hash_table(JournalFile *f) {
 
         assert(f);
 
-        /* We estimate that we need 1 hash table entry per 2K of
+        /* We estimate that we need 1 hash table entry per 768 of
            journal file and we want to make sure we never get beyond
            75% fill level. Calculate the hash table size for the
            maximum file size based on these metrics. */
 
-        s = (f->metrics.max_size * 4 / 2048 / 3) * sizeof(HashItem);
+        s = (f->metrics.max_size * 4 / 768 / 3) * sizeof(HashItem);
         if (s < DEFAULT_DATA_HASH_TABLE_SIZE)
                 s = DEFAULT_DATA_HASH_TABLE_SIZE;
 
-        log_info("Reserving %llu entries in hash table.", (unsigned long long) s);
+        log_info("Reserving %llu entries in hash table.", (unsigned long long) (s / sizeof(HashItem)));
 
         r = journal_file_append_object(f,
                                        OBJECT_DATA_HASH_TABLE,



More information about the systemd-commits mailing list