diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-11-13 00:42:22 -0500 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-01-11 16:54:59 -0500 |
commit | 348ced909724a1331b85d57aede80a102a00e428 (patch) | |
tree | 1b58129221dcfee9d8e2679cf48f12882f565bc2 /src/journal/journal-vacuum.c | |
parent | b94801803417c23d099cb7e508754181ecd27f9c (diff) | |
download | systemd-348ced909724a1331b85d57aede80a102a00e428.tar.gz |
journald: do not free space when disk space runs low
Before, journald would remove journal files until both MaxUse= and
KeepFree= settings would be satisfied. The first one depends (if set
automatically) on the size of the file system and is constant. But
the second one depends on current use of the file system, and a spike
in disk usage would cause journald to delete journal files, trying to
reach usage which would leave 15% of the disk free. This behaviour is
surprising for the user who doesn't expect his logs to be purged when
disk usage goes above 85%, which on a large disk could be some
gigabytes from being full. In addition attempting to keep 15% free
provides an attack vector where filling the disk sufficiently disposes
of almost all logs.
Instead, obey KeepFree= only as a limit on adding additional files.
When replacing old files with new, ignore KeepFree=. This means that
if journal disk usage reached some high point that at some later point
start to violate the KeepFree= constraint, journald will not add files
to go above this point, but it will stay (slightly) below it. When
journald is restarted, it forgets the previous maximum usage value,
and sets the limit based on the current usage, so if disk remains to
be filled, journald might use one journal-file-size less on each
restart, if restarts happen just after rotation. This seems like a
reasonable compromise between implementation complexity and robustness.
Diffstat (limited to 'src/journal/journal-vacuum.c')
-rw-r--r-- | src/journal/journal-vacuum.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/journal/journal-vacuum.c b/src/journal/journal-vacuum.c index b2b47d69b2..c92c198245 100644 --- a/src/journal/journal-vacuum.c +++ b/src/journal/journal-vacuum.c @@ -150,7 +150,6 @@ static int journal_file_empty(int dir_fd, const char *name) { int journal_directory_vacuum( const char *directory, uint64_t max_use, - uint64_t min_free, usec_t max_retention_usec, usec_t *oldest_usec) { @@ -164,7 +163,7 @@ int journal_directory_vacuum( assert(directory); - if (max_use <= 0 && min_free <= 0 && max_retention_usec <= 0) + if (max_use <= 0 && max_retention_usec <= 0) return 0; if (max_retention_usec > 0) { @@ -309,8 +308,7 @@ int journal_directory_vacuum( } if ((max_retention_usec <= 0 || list[i].realtime >= retention_limit) && - (max_use <= 0 || sum <= max_use) && - (min_free <= 0 || (uint64_t) ss.f_bavail * (uint64_t) ss.f_bsize >= min_free)) + (max_use <= 0 || sum <= max_use)) break; if (unlinkat(dirfd(d), list[i].filename, 0) >= 0) { |