summaryrefslogtreecommitdiff
path: root/src/journal/journald.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-08-14 22:02:24 +0200
committerLennart Poettering <lennart@poettering.net>2012-08-16 17:10:56 +0200
commit16e9f408fa9a9626059bdd6c89dc175e06b9e976 (patch)
tree89a6730a2f044626c9ca67d278dd6ac6a844aec3 /src/journal/journald.c
parent405053fafa88022c68e7adf04c91a56c1cde7dd8 (diff)
journal: implement generic sharable mmap caching logic
instead of having one simple per-file cache implement an more comprehensive one that works for multiple files and can actually maintain multiple maps per file and per object type.
Diffstat (limited to 'src/journal/journald.c')
-rw-r--r--src/journal/journald.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/journal/journald.c b/src/journal/journald.c
index 8c41d9bab..145663bf5 100644
--- a/src/journal/journald.c
+++ b/src/journal/journald.c
@@ -315,7 +315,7 @@ static JournalFile* find_journal(Server *s, uid_t uid) {
journal_file_close(f);
}
- r = journal_file_open_reliably(p, O_RDWR|O_CREAT, 0640, s->compress, false, &s->system_metrics, s->system_journal, &f);
+ r = journal_file_open_reliably(p, O_RDWR|O_CREAT, 0640, s->compress, false, &s->system_metrics, s->mmap, s->system_journal, &f);
free(p);
if (r < 0)
@@ -2006,7 +2006,7 @@ static int system_journal_open(Server *s) {
if (!fn)
return -ENOMEM;
- r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, s->compress, true, &s->system_metrics, NULL, &s->system_journal);
+ r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, s->compress, true, &s->system_metrics, s->mmap, NULL, &s->system_journal);
free(fn);
if (r >= 0)
@@ -2033,7 +2033,7 @@ static int system_journal_open(Server *s) {
* if it already exists, so that we can flush
* it into the system journal */
- r = journal_file_open(fn, O_RDWR, 0640, s->compress, false, &s->runtime_metrics, NULL, &s->runtime_journal);
+ r = journal_file_open(fn, O_RDWR, 0640, s->compress, false, &s->runtime_metrics, s->mmap, NULL, &s->runtime_journal);
free(fn);
if (r < 0) {
@@ -2049,7 +2049,7 @@ static int system_journal_open(Server *s) {
* it if necessary. */
(void) mkdir_parents(fn, 0755);
- r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, s->compress, false, &s->runtime_metrics, NULL, &s->runtime_journal);
+ r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, s->compress, false, &s->runtime_metrics, s->mmap, NULL, &s->runtime_journal);
free(fn);
if (r < 0) {
@@ -2793,6 +2793,10 @@ static int server_init(Server *s) {
if (!s->user_journals)
return log_oom();
+ s->mmap = mmap_cache_new(_OBJECT_TYPE_MAX, USER_JOURNALS_MAX + 2);
+ if (!s->mmap)
+ return log_oom();
+
s->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
if (s->epoll_fd < 0) {
log_error("Failed to create epoll object: %m");
@@ -2919,6 +2923,9 @@ static void server_done(Server *s) {
free(s->buffer);
free(s->tty_path);
+
+ if (s->mmap)
+ mmap_cache_unref(s->mmap);
}
int main(int argc, char *argv[]) {