chiark / gitweb /
journal: decrease default mmap window size to allow a bigger number of journals to...
[elogind.git] / src / journal / journal-file.c
index a784a3391b9271cdfc7b612957e9570ec1146ec7..be92c9044708f67c89caa78c19f7c3762f6f87a4 100644 (file)
 #define DEFAULT_DATA_HASH_TABLE_SIZE (2047ULL*16ULL)
 #define DEFAULT_FIELD_HASH_TABLE_SIZE (2047ULL*16ULL)
 
-#define DEFAULT_WINDOW_SIZE (128ULL*1024ULL*1024ULL)
+#define DEFAULT_WINDOW_SIZE (8ULL*1024ULL*1024ULL)
 
 #define COMPRESSION_SIZE_THRESHOLD (512ULL)
 
 /* This is the minimum journal file size */
-#define JOURNAL_FILE_SIZE_MIN (64ULL*1024ULL)
+#define JOURNAL_FILE_SIZE_MIN (64ULL*1024ULL)                  /* 64 KiB */
 
 /* These are the lower and upper bounds if we deduce the max_use value
  * from the file system size */
@@ -162,7 +162,7 @@ static int journal_file_verify_header(JournalFile *f) {
                 return -ENODATA;
 
         if (f->writable) {
-                uint32_t state;
+                uint8_t state;
                 sd_id128_t machine_id;
                 int r;
 
@@ -793,8 +793,8 @@ static uint64_t journal_file_entry_array_n_items(Object *o) {
 }
 
 static int link_entry_into_array(JournalFile *f,
-                                 uint64_t *first,
-                                 uint64_t *idx,
+                                 le64_t *first,
+                                 le64_t *idx,
                                  uint64_t p) {
         int r;
         uint64_t n = 0, ap = 0, q, i, a, hidx;
@@ -857,9 +857,9 @@ static int link_entry_into_array(JournalFile *f,
 }
 
 static int link_entry_into_array_plus_one(JournalFile *f,
-                                          uint64_t *extra,
-                                          uint64_t *first,
-                                          uint64_t *idx,
+                                          le64_t *extra,
+                                          le64_t *first,
+                                          le64_t *idx,
                                           uint64_t p) {
 
         int r;
@@ -873,7 +873,7 @@ static int link_entry_into_array_plus_one(JournalFile *f,
         if (*idx == 0)
                 *extra = htole64(p);
         else {
-                uint64_t i;
+                le64_t i;
 
                 i = htole64(le64toh(*idx) - 1);
                 r = link_entry_into_array(f, first, &i, p);
@@ -1866,7 +1866,7 @@ int journal_file_rotate(JournalFile **f) {
         if (r < 0)
                 return -errno;
 
-        old_file->header->state = le32toh(STATE_ARCHIVED);
+        old_file->header->state = STATE_ARCHIVED;
 
         r = journal_file_open(old_file->path, old_file->flags, old_file->mode, old_file, &new_file);
         journal_file_close(old_file);
@@ -1887,7 +1887,10 @@ int journal_file_open_reliably(
         char *p;
 
         r = journal_file_open(fname, flags, mode, template, ret);
-        if (r != -EBADMSG)
+        if (r != -EBADMSG && /* corrupted */
+            r != -ENODATA && /* truncated */
+            r != -EHOSTDOWN && /* other machine */
+            r != -EPROTONOSUPPORT) /* incompatible feature */
                 return r;
 
         if ((flags & O_ACCMODE) == O_RDONLY)
@@ -2068,7 +2071,7 @@ int journal_directory_vacuum(const char *directory, uint64_t max_use, uint64_t m
                 }
 
                 list[n_list].filename = p;
-                list[n_list].usage = (uint64_t) st.st_blksize * (uint64_t) st.st_blocks;
+                list[n_list].usage = 512UL * (uint64_t) st.st_blocks;
                 list[n_list].seqnum = seqnum;
                 list[n_list].realtime = realtime;
                 list[n_list].seqnum_id = seqnum_id;
@@ -2094,7 +2097,7 @@ int journal_directory_vacuum(const char *directory, uint64_t max_use, uint64_t m
                         break;
 
                 if (unlinkat(dirfd(d), list[i].filename, 0) >= 0) {
-                        log_debug("Deleted archived journal %s/%s.", directory, list[i].filename);
+                        log_info("Deleted archived journal %s/%s.", directory, list[i].filename);
                         sum -= list[i].usage;
                 } else if (errno != ENOENT)
                         log_warning("Failed to delete %s/%s: %m", directory, list[i].filename);
@@ -2141,7 +2144,8 @@ int journal_file_copy_entry(JournalFile *from, JournalFile *to, Object *o, uint6
         items = alloca(sizeof(EntryItem) * n);
 
         for (i = 0; i < n; i++) {
-                uint64_t le_hash, l, h;
+                uint64_t l, h;
+                le64_t le_hash;
                 size_t t;
                 void *data;
                 Object *u;
@@ -2262,9 +2266,9 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
                         m->keep_free = DEFAULT_KEEP_FREE;
         }
 
-        log_debug("Fixed max_use=%s max_size=%s min_size=%s keep_free=%s",
-                  format_bytes(a, sizeof(a), m->max_use),
-                  format_bytes(b, sizeof(b), m->max_size),
-                  format_bytes(c, sizeof(c), m->min_size),
-                  format_bytes(d, sizeof(d), m->keep_free));
+        log_info("Fixed max_use=%s max_size=%s min_size=%s keep_free=%s",
+                 format_bytes(a, sizeof(a), m->max_use),
+                 format_bytes(b, sizeof(b), m->max_size),
+                 format_bytes(c, sizeof(c), m->min_size),
+                 format_bytes(d, sizeof(d), m->keep_free));
 }