2015-03-27 09:39:40 +01:00
|
|
|
From: werner@suse.de
|
|
|
|
Upstream: marked as openSUSE-specific fix originally, but may well
|
|
|
|
worth be to be sent upstream.
|
|
|
|
|
|
|
|
Original description:
|
|
|
|
(none)
|
|
|
|
|
|
|
|
Augmented description [jengelh@inai.de]:
|
|
|
|
Disable COW on journal files, as that is naturally leading to a lot
|
|
|
|
of unwanted fragmentation on btrfs.
|
|
|
|
No word on compression…
|
|
|
|
---
|
|
|
|
src/journal/journald-server.c | 34 ++++++++++++++++++++++++++++++++++
|
|
|
|
1 file changed, 34 insertions(+)
|
|
|
|
|
2016-02-03 10:19:12 +01:00
|
|
|
Index: systemd-227/src/journal/journald-server.c
|
2015-03-27 09:39:40 +01:00
|
|
|
===================================================================
|
2016-02-03 10:19:12 +01:00
|
|
|
--- systemd-227.orig/src/journal/journald-server.c
|
|
|
|
+++ systemd-227/src/journal/journald-server.c
|
|
|
|
@@ -24,6 +24,7 @@
|
|
|
|
#include <selinux/selinux.h>
|
|
|
|
#endif
|
2013-12-15 10:09:48 +01:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
+#include <linux/fs.h>
|
2015-12-27 01:53:14 +01:00
|
|
|
#include <sys/mman.h>
|
2016-02-03 10:19:12 +01:00
|
|
|
#include <sys/signalfd.h>
|
|
|
|
#include <sys/statvfs.h>
|
|
|
|
@@ -861,6 +862,39 @@ void server_driver_message(Server *s, sd
|
|
|
|
dispatch_message_real(s, iovec, n, ELEMENTSOF(iovec), &ucred, NULL, NULL, 0, NULL, LOG_INFO, 0);
|
2015-03-27 09:39:40 +01:00
|
|
|
}
|
2013-12-15 10:09:48 +01:00
|
|
|
|
2015-03-27 09:39:40 +01:00
|
|
|
+/*
|
|
|
|
+ * On journaling and/or compressing file systems, avoid doubling the efforts
|
|
|
|
+ * for the system, that is, set NOCOW and NOCOMP inode flags. Check for every
|
|
|
|
+ * single flag, as otherwise, some of the file systems may return EOPNOTSUPP on
|
2016-02-03 10:19:12 +01:00
|
|
|
+ * a single unkown flag (like Btrfs does).
|
2015-03-27 09:39:40 +01:00
|
|
|
+ *
|
|
|
|
+ * …but src/journal/journal-file.c already sets NOCOW too…⸘
|
|
|
|
+ */
|
|
|
|
+static void disable_cow(const char *dir, const Server *serv)
|
|
|
|
+{
|
|
|
|
+ unsigned long flags;
|
|
|
|
+ int fd = open(dir, O_DIRECTORY);
|
2015-03-09 09:20:20 +01:00
|
|
|
+
|
2015-03-27 09:39:40 +01:00
|
|
|
+ if (fd < 0)
|
|
|
|
+ return;
|
|
|
|
+ if (ioctl(fd, FS_IOC_GETFLAGS, &flags) == 0) {
|
|
|
|
+ unsigned long old = flags;
|
|
|
|
+ if (!(flags & FS_NOATIME_FL) &&
|
|
|
|
+ ioctl(fd, FS_IOC_SETFLAGS, flags | FS_NOATIME_FL) == 0)
|
|
|
|
+ flags |= FS_NOATIME_FL;
|
|
|
|
+ if (!(flags & FS_NOCOW_FL) &&
|
|
|
|
+ ioctl(fd, FS_IOC_SETFLAGS, flags | FS_NOCOW_FL) == 0)
|
|
|
|
+ flags |= FS_NOCOW_FL;
|
|
|
|
+ if (!(flags & FS_NOCOMP_FL) && serv->compress) {
|
|
|
|
+ flags &= ~FS_COMPR_FL;
|
|
|
|
+ flags |= FS_NOCOMP_FL;
|
2015-03-09 09:20:20 +01:00
|
|
|
+ }
|
2015-03-27 09:39:40 +01:00
|
|
|
+ if (old != flags)
|
|
|
|
+ ioctl(fd, FS_IOC_SETFLAGS, flags);
|
|
|
|
+ }
|
|
|
|
+ close(fd);
|
|
|
|
+}
|
2016-02-03 10:19:12 +01:00
|
|
|
+
|
|
|
|
void server_dispatch_message(
|
|
|
|
Server *s,
|
|
|
|
struct iovec *iovec, unsigned n, unsigned m,
|
|
|
|
@@ -948,6 +982,7 @@ static int system_journal_open(Server *s
|
2015-03-27 09:39:40 +01:00
|
|
|
|
2016-02-03 10:19:12 +01:00
|
|
|
fn = strjoina("/var/log/journal/", SERVER_MACHINE_ID(s));
|
2015-03-27 09:39:40 +01:00
|
|
|
(void) mkdir(fn, 0755);
|
|
|
|
+ disable_cow(fn, s);
|
2013-12-15 10:09:48 +01:00
|
|
|
|
2015-03-27 09:39:40 +01:00
|
|
|
fn = strjoina(fn, "/system.journal");
|
2013-12-15 10:09:48 +01:00
|
|
|
r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, s->compress, s->seal, &s->system_metrics, s->mmap, NULL, &s->system_journal);
|