chiark / gitweb /
journal: bump RLIMIT_NOFILE when journal files to 16K (if possible)
authorLennart Poettering <lennart@poettering.net>
Thu, 8 Jan 2015 02:17:50 +0000 (03:17 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 8 Jan 2015 02:20:45 +0000 (03:20 +0100)
When there are a lot of split out journal files, we might run out of fds
quicker then we want. Hence: bump RLIMIT_NOFILE to 16K if possible.

Do these even for journalctl. On Fedora the soft RLIMIT_NOFILE is at 1K,
the hard at 4K by default for normal user processes, this code hence
bumps this up for users to 4K.

https://bugzilla.redhat.com/show_bug.cgi?id=1179980

src/journal/journalctl.c
src/shared/util.h
src/systemctl/systemctl.c
units/systemd-journal-gatewayd.service.in
units/systemd-journal-upload.service.in
units/systemd-journald.service.in

index 62931f14c9bb71d7a886ff6bd66acbdde775b90a..db9576c4933f276b4fafb9303525b61756aac5da 100644 (file)
@@ -1722,6 +1722,11 @@ int main(int argc, char *argv[]) {
         signal(SIGWINCH, columns_lines_cache_reset);
         sigbus_install();
 
+        /* Increase max number of open files to 16K if we can, we
+         * might needs this when browsing journal files, which might
+         * be split up into many files. */
+        setrlimit_closest(RLIMIT_NOFILE, &RLIMIT_MAKE_CONST(16384));
+
         if (arg_action == ACTION_NEW_ID128) {
                 r = generate_new_id128();
                 goto finish;
index 31103e957f4aa104c613919c48997ef3db05fd48..3b3035a1c7beefa14dc5a482b244165742f2a677 100644 (file)
@@ -1074,3 +1074,5 @@ int same_fd(int a, int b);
 
 int chattr_fd(int fd, bool b, int mask);
 int chattr_path(const char *p, bool b, int mask);
+
+#define RLIMIT_MAKE_CONST(lim) ((struct rlimit) { lim, lim })
index 679541493a74abb5fd59d81b71d19bdbadf2cbbe..86b5ae0b039b4f61e1e80fa2a37430cc2915171d 100644 (file)
@@ -7409,6 +7409,11 @@ int main(int argc, char*argv[]) {
                 goto finish;
         }
 
+        /* Increase max number of open files to 16K if we can, we
+         * might needs this when browsing journal files, which might
+         * be split up into many files. */
+        setrlimit_closest(RLIMIT_NOFILE, &RLIMIT_MAKE_CONST(16384));
+
         if (!avoid_bus())
                 r = bus_open_transport_systemd(arg_transport, arg_host, arg_scope != UNIT_FILE_SYSTEM, &bus);
 
index 5bd8e4b34174edf3a025e7d48acd7e178ed82fca..987220e554208dbf6a0a2eaa4b06d6453a7f8899 100644 (file)
@@ -20,5 +20,9 @@ PrivateNetwork=yes
 ProtectSystem=full
 ProtectHome=yes
 
+# If there are many split upjournal files we need a lot of fds to
+# access them all and combine
+LimitNOFILE=16384
+
 [Install]
 Also=systemd-journal-gatewayd.socket
index 359ff10e259d4af338504d9f01966f125cb2b885..b2e3c769cce8db0fa333ec5ee5079f2b755eb94b 100644 (file)
@@ -17,5 +17,9 @@ PrivateTmp=yes
 PrivateDevices=yes
 WatchdogSec=20min
 
+# If there are many split up journal files we need a lot of fds to
+# access them all and combine
+LimitNOFILE=16384
+
 [Install]
 WantedBy=multi-user.target
index e3eea259593df6850eeacceb9d5694d9495c8c34..a3540c65d2e70085ecd4fa242f93ab176c1a58a9 100644 (file)
@@ -26,5 +26,7 @@ WatchdogSec=1min
 FileDescriptorStoreMax=1024
 
 # Increase the default a bit in order to allow many simultaneous
-# services being run since we keep one fd open per service.
+# services being run since we keep one fd open per service. Also, when
+# flushing journal files to disk, we might need a lot of fds when many
+# journal files are combined.
 LimitNOFILE=16384