summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd/0006-journal-Use-posix-fallocate-only-if-available.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0006-journal-Use-posix-fallocate-only-if-available.patch')
-rw-r--r--meta/recipes-core/systemd/systemd/0006-journal-Use-posix-fallocate-only-if-available.patch96
1 files changed, 0 insertions, 96 deletions
diff --git a/meta/recipes-core/systemd/systemd/0006-journal-Use-posix-fallocate-only-if-available.patch b/meta/recipes-core/systemd/systemd/0006-journal-Use-posix-fallocate-only-if-available.patch
deleted file mode 100644
index 631dd77465..0000000000
--- a/meta/recipes-core/systemd/systemd/0006-journal-Use-posix-fallocate-only-if-available.patch
+++ /dev/null
@@ -1,96 +0,0 @@
1From 34a61b6c9eed3fad360066fb63132ebc7e0aaaa6 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 20 Feb 2015 05:12:48 +0000
4Subject: [PATCH 06/11] journal: Use posix fallocate only if available
5
6Some architecture ports in uclibc did not support it in past
7
8Upstream-Status: Denied [no desire for uclibc support]
9
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
12---
13 src/journal/journal-file.c | 16 +++++++++++++++-
14 src/journal/journald-kmsg.c | 15 ++++++++++++++-
15 2 files changed, 29 insertions(+), 2 deletions(-)
16
17diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
18index 2845e05..9431171 100644
19--- a/src/journal/journal-file.c
20+++ b/src/journal/journal-file.c
21@@ -36,6 +36,8 @@
22 #include "compress.h"
23 #include "fsprg.h"
24
25+#include "config.h"
26+
27 #define DEFAULT_DATA_HASH_TABLE_SIZE (2047ULL*sizeof(HashItem))
28 #define DEFAULT_FIELD_HASH_TABLE_SIZE (333ULL*sizeof(HashItem))
29
30@@ -354,7 +356,7 @@ static int journal_file_fstat(JournalFile *f) {
31
32 static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size) {
33 uint64_t old_size, new_size;
34- int r;
35+ int r = 0;
36
37 assert(f);
38
39@@ -418,9 +420,21 @@ static int journal_file_allocate(JournalFile *f, uint64_t offset, uint64_t size)
40 /* Note that the glibc fallocate() fallback is very
41 inefficient, hence we try to minimize the allocation area
42 as we can. */
43+#ifdef HAVE_POSIX_FALLOCATE
44 r = posix_fallocate(f->fd, old_size, new_size - old_size);
45 if (r != 0)
46 return -r;
47+#else
48+ /* Write something every 512 bytes to make sure the block is allocated */
49+ uint64_t len = new_size - old_size;
50+ uint64_t offset = old_size;
51+ for (offset += (len-1) % 512; len > 0; offset += 512) {
52+ len -= 512;
53+ if (pwrite(f->fd, "", 1, offset) != 1)
54+ return -errno;
55+ }
56+
57+#endif /* HAVE_POSIX_FALLOCATE */
58
59 f->header->arena_size = htole64(new_size - le64toh(f->header->header_size));
60
61diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
62index c4216c4..a998ed5 100644
63--- a/src/journal/journald-kmsg.c
64+++ b/src/journal/journald-kmsg.c
65@@ -436,6 +436,7 @@ fail:
66 int server_open_kernel_seqnum(Server *s) {
67 _cleanup_close_ int fd;
68 uint64_t *p;
69+ int r = 0;
70
71 assert(s);
72
73@@ -449,7 +450,19 @@ int server_open_kernel_seqnum(Server *s) {
74 return 0;
75 }
76
77- if (posix_fallocate(fd, 0, sizeof(uint64_t)) < 0) {
78+#ifdef HAVE_POSIX_FALLOCATE
79+ r = posix_fallocate(fd, 0, sizeof(uint64_t));
80+#else
81+ /* Use good old method to write zeros into the journal file
82+ perhaps very inefficient yet working. */
83+ char *buf = alloca(sizeof(uint64_t));
84+ off_t oldpos = lseek(fd, 0, SEEK_CUR);
85+ bzero(buf, sizeof(uint64_t));
86+ lseek(fd, 0, SEEK_SET);
87+ r = write(fd, buf, sizeof(uint64_t));
88+ lseek(fd, oldpos, SEEK_SET);
89+#endif /* HAVE_POSIX_FALLOCATE */
90+ if (r < 0) {
91 log_error_errno(errno, "Failed to allocate sequential number file, ignoring: %m");
92 return 0;
93 }
94--
952.1.4
96