mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-10 01:17:44 +03:00
journal-vacuum: count size of all journal files
Currently, active journal files are excluded, which means that vacuuming may not remove anything even if *MaxUse= has been exceeded.
This commit is contained in:
parent
206760a4bc
commit
9ea46af4f2
@ -159,6 +159,8 @@ int journal_directory_vacuum(
|
||||
if (!S_ISREG(st.st_mode))
|
||||
continue;
|
||||
|
||||
size = 512UL * (uint64_t) st.st_blocks;
|
||||
|
||||
q = strlen(de->d_name);
|
||||
|
||||
if (endswith(de->d_name, ".journal")) {
|
||||
@ -168,6 +170,7 @@ int journal_directory_vacuum(
|
||||
|
||||
if (q < 1 + 32 + 1 + 16 + 1 + 16 + 8) {
|
||||
n_active_files++;
|
||||
sum += size;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -175,6 +178,7 @@ int journal_directory_vacuum(
|
||||
de->d_name[q-8-16-1-16-1] != '-' ||
|
||||
de->d_name[q-8-16-1-16-1-32-1] != '@') {
|
||||
n_active_files++;
|
||||
sum += size;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -187,11 +191,13 @@ int journal_directory_vacuum(
|
||||
de->d_name[q-8-16-1-16-1] = 0;
|
||||
if (sd_id128_from_string(de->d_name + q-8-16-1-16-1-32, &seqnum_id) < 0) {
|
||||
n_active_files++;
|
||||
sum += size;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (sscanf(de->d_name + q-8-16-1-16, "%16llx-%16llx.journal", &seqnum, &realtime) != 2) {
|
||||
n_active_files++;
|
||||
sum += size;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -207,12 +213,14 @@ int journal_directory_vacuum(
|
||||
|
||||
if (q < 1 + 16 + 1 + 16 + 8 + 1) {
|
||||
n_active_files++;
|
||||
sum += size;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (de->d_name[q-1-8-16-1] != '-' ||
|
||||
de->d_name[q-1-8-16-1-16-1] != '@') {
|
||||
n_active_files++;
|
||||
sum += size;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -224,6 +232,7 @@ int journal_directory_vacuum(
|
||||
|
||||
if (sscanf(de->d_name + q-1-8-16-1-16, "%16llx-%16llx.journal~", &realtime, &tmp) != 2) {
|
||||
n_active_files++;
|
||||
sum += size;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -234,8 +243,6 @@ int journal_directory_vacuum(
|
||||
continue;
|
||||
}
|
||||
|
||||
size = 512UL * (uint64_t) st.st_blocks;
|
||||
|
||||
r = journal_file_empty(dirfd(d), p);
|
||||
if (r < 0) {
|
||||
log_debug_errno(r, "Failed check if %s is empty, ignoring: %m", p);
|
||||
|
Loading…
Reference in New Issue
Block a user