systemd/0039-journal-when-appending-to-journal-file-allocate-larg.patch
Stephan Kulow 8591266f0f Accepting request 222383 from Base:System
- Add several upstream bugfix patches which are missed:
  * 0018-core-do-not-add-what-to-RequiresMountsFor-for-networ.patch
  * 0026-udevadm.xml-document-resolve-names-option-for-test.patch
  * 0030-Fix-for-SIGSEGV-in-systemd-bootchart-on-short-living.patch
  * 0032-rules-don-t-limit-some-of-the-rules-to-the-add-actio.patch
  * 0031-man-document-the-b-special-boot-option.patch
  * 0033-tmpfiles-log-unaccessible-FUSE-mount-points-only-as-.patch
  * 0034-systemd-python-fix-booted-and-add-two-functions-to-d.patch
  * 0035-activate-mention-E-in-the-help-text.patch
  * 0036-activate-fix-crash-when-s-is-passed.patch
  * 0037-tmpfiles-adjust-excludes-for-the-new-per-service-pri.patch
  * 0038-core-socket-fix-SO_REUSEPORT.patch
  * 0039-journal-when-appending-to-journal-file-allocate-larg.patch
  * 0040-journal-optimize-bisection-logic-a-bit-by-caching-th.patch
  * 0041-journal-fix-iteration-when-we-go-backwards-from-the-.patch
  * 0042-journal-allow-journal_file_copy_entry-to-work-on-non.patch
  * 0043-journal-simplify-pre-allocation-logic.patch
  * 0044-journald-mention-how-long-we-needed-to-flush-to-var-.patch
  * 0046-util.c-check-if-return-value-from-ttyname_r-is-0-ins.patch
  * 0047-docs-remove-unneeded-the-s-in-gudev-docs.patch
  * 0048-man-explicitly-say-when-multiple-units-can-be-specif.patch
  * 0049-systemd-treat-reload-failure-as-failure.patch
- Add patch 0001-Don-t-snprintf-a-potentially-NULL-pointer.patch
  to avoid potential NULL pointer
- Reorder patches to reflect udev/systemd usage

- don't build bash-completions for bootstrap package

- add more requires to this-is-only-for-build-envs to avoid 
  problems in kiwi configs

OBS-URL: https://build.opensuse.org/request/show/222383
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd?expand=0&rev=176
2014-02-15 16:19:18 +00:00

81 lines
2.8 KiB
Diff

From a676e66535e12458ea6d366a653f8dd60f982504 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 26 Nov 2013 18:39:42 +0100
Subject: [PATCH] journal: when appending to journal file, allocate larger
blocks at once
---
src/journal/journal-file.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git src/journal/journal-file.c src/journal/journal-file.c
index bc72fca..d606ada 100644
--- src/journal/journal-file.c
+++ src/journal/journal-file.c
@@ -68,6 +68,9 @@
/* How many entries to keep in the entry array chain cache at max */
#define CHAIN_CACHE_MAX 20
+/* How much to increase the journal file size at once each time we allocate something new. */
+#define FILE_SIZE_INCREASE (8ULL*1024ULL*1024ULL) /* 8MB */
+
int journal_file_set_online(JournalFile *f) {
assert(f);
@@ -218,8 +221,7 @@ static int journal_file_refresh_header(JournalFile *f) {
journal_file_set_online(f);
/* Sync the online state to disk */
- msync(f->header, PAGE_ALIGN(sizeof(Header)), MS_SYNC);
- fdatasync(f->fd);
+ fsync(f->fd);
return 0;
}
@@ -313,7 +315,7 @@ static int journal_file_verify_header(JournalFile *f) {
}
static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) {
- uint64_t old_size, new_size;
+ uint64_t old_size, new_size, file_size;
int r;
assert(f);
@@ -333,12 +335,10 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size)
if (new_size <= old_size)
return 0;
- if (f->metrics.max_size > 0 &&
- new_size > f->metrics.max_size)
+ if (f->metrics.max_size > 0 && new_size > f->metrics.max_size)
return -E2BIG;
- if (new_size > f->metrics.min_size &&
- f->metrics.keep_free > 0) {
+ if (new_size > f->metrics.min_size && f->metrics.keep_free > 0) {
struct statvfs svfs;
if (fstatvfs(f->fd, &svfs) >= 0) {
@@ -363,8 +363,16 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size)
if (r != 0)
return -r;
- if (fstat(f->fd, &f->last_stat) < 0)
- return -errno;
+ /* Increase the file size a bit further than this, so that we
+ * we can create larger memory maps to cache */
+ file_size = ((new_size+FILE_SIZE_INCREASE-1) / FILE_SIZE_INCREASE) * FILE_SIZE_INCREASE;
+ if (file_size > (uint64_t) f->last_stat.st_size) {
+ if (file_size > new_size)
+ ftruncate(f->fd, file_size);
+
+ if (fstat(f->fd, &f->last_stat) < 0)
+ return -errno;
+ }
f->header->arena_size = htole64(new_size - le64toh(f->header->header_size));
--
1.7.9.2