| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
|\
| |
| | |
A couple of follow-ups for #22721
|
| |
| |
| |
| | |
Fixes: #16274
|
| |
| |
| |
| |
| | |
Pointed out in: https://github.com/systemd/systemd/pull/22721#discussion_r826014227
Follow-up for: 5a1355d848a0f6564a04c6d8268e72bc93d173de
|
| |
| |
| |
| |
| |
| |
| |
| | |
Make sure we reset the JSON format flags if the format option is used
multiple times, e.g. `journalctl -o json-format -o export`.
Pointed out in: https://github.com/systemd/systemd/pull/22721#discussion_r826018985
Follow-up for: 5a1355d848a0f6564a04c6d8268e72bc93d173de
|
|/
|
|
|
|
|
| |
When restoring the COW flag for journals on BTRFS, the full journal contents
are copied into new files. But during these operations, the acls of the
previous files were lost and users were not able to access to their old
journal contents anymore.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
so it can be output as JSON as well.
```
$ build-san/journalctl --list-boots --file boot-test.journal
IDX BOOT ID FIRST ENTRY LAST ENTRY
-3 39d66eb1925f4d01b8464d502650a714 Sat 2022-03-05 15:20:33 CET Sat 2022-03-05 16:19:21 CET
-2 5dffeb08a27344d5ae9e2fc244bbcbc5 Fri 2022-03-11 17:23:57 CET Fri 2022-03-11 17:38:31 CET
-1 c8ebd52915b642c39eda4bf00f864f79 Fri 2022-03-11 17:38:41 CET Fri 2022-03-11 20:03:46 CET
0 00bcba97c7094fa88cc5d1cf2a389057 Sat 2022-03-12 20:39:08 CET Sat 2022-03-12 20:40:18 CET
$ build-san/journalctl --list-boots --file boot-test.journal -q
-3 39d66eb1925f4d01b8464d502650a714 Sat 2022-03-05 15:20:33 CET Sat 2022-03-05 16:19:21 CET
-2 5dffeb08a27344d5ae9e2fc244bbcbc5 Fri 2022-03-11 17:23:57 CET Fri 2022-03-11 17:38:31 CET
-1 c8ebd52915b642c39eda4bf00f864f79 Fri 2022-03-11 17:38:41 CET Fri 2022-03-11 20:03:46 CET
0 00bcba97c7094fa88cc5d1cf2a389057 Sat 2022-03-12 20:39:08 CET Sat 2022-03-12 20:40:18 CET
$ build-san/journalctl --list-boots --file boot-test.journal -o json-pretty
[
{
"index" : -3,
"boot_id" : "39d66eb1925f4d01b8464d502650a714",
"first_entry" : 1646490033438495,
"last_entry" : 1646493561047353
},
{
"index" : -2,
"boot_id" : "5dffeb08a27344d5ae9e2fc244bbcbc5",
"first_entry" : 1647015837289036,
"last_entry" : 1647016711595489
},
{
"index" : -1,
"boot_id" : "c8ebd52915b642c39eda4bf00f864f79",
"first_entry" : 1647016721056382,
"last_entry" : 1647025426397414
},
{
"index" : 0,
"boot_id" : "00bcba97c7094fa88cc5d1cf2a389057",
"first_entry" : 1647113948506002,
"last_entry" : 1647114018943637
}
]
```
Resolves: #14625
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
The approach to use '''…'''.split() instead of a list of strings was initially
used when converting from automake because it allowed identical blocks of lines
to be used for both, making the conversion easier.
But over the years we have been using normal lists more and more, especially
when there were just a few filenames listed. This converts the rest.
No functional change.
|
|
|
|
|
|
| |
Add dlopen_dw(), dlopen_elf() and dlopen_pcre2() to the dlopen test.
To enable adding dlopen_pcre2(), we move pcre2-dlopen.h/c from
src/journal to src/shared.
|
|
|
|
|
|
|
|
| |
Apparently the error code fallocate() returns if hole punching is not
supported is not too well defined (man page just says "an error is
returned"), hence let's accept the usual set of errors, and the
normalize it to EOPNOTSUPP, and generate a clear error message in this
case.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
We have the journal file open already, hence reference it via the fd
insted of the file name. After all, some other tool might have
renamed/deleted it already.
Let's not actually reuse the fd though, since we want a separate file
offset for the copying, hence just make it simply and reopen via
/proc/self/fd/.
Follow-up for d71ece3f0b85c7a3decc50143b68ac07fc5831ae
|
|
|
|
|
| |
JournalFile and JournaldFile are hard to distinguish from each other.
Let's use ManagedJournalFile instead to make the distinction more clear.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
as before
This partially undoes the effect of
ab6e257b3e4e5b95f3750ed019bed6e89989e41b.
Originally, we always used the mmap logic to determine the current end
of the file. ab6e257b3e4e5b95f3750ed019bed6e89989e41b changed this so
that we always used pread().
With this change we'll use pread() from the synchronization thread and
mmap otherwise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes a bunch of issues:
pread() returns ssize_t, and returns errors in 'errno', handle that
correctly.
More importantly: it might incompletely read data in case we hit
EOF. Check for that, and handle it.
Finally, rename the function to journal_file_read_object_header(), since
it really doesn't read full objects, but only their headers.
Follow-up for: 117e21121e857b4b7d81949542e8dd257265970a
|
|
|
|
|
| |
Instead of punching a hole in the final object if it's an entry array,
let's just truncate the file instead.
|
|
|
|
|
| |
Let's make sure the data stored in last_stat is up-to-date after
truncating the journal file.
|
|
|
|
|
|
|
|
| |
functions
This reduces the number of calls to journal_file_move_to_object() which are heavy.
All call sites have easy access to the data object so this change doesn't end up
complicating things.
|
|
|
|
|
|
|
|
| |
ELEMENTSOF(iovec) is not the correct value for the newly introduced parameter m
to function map_all_fields because it is the maximum number of elements in the
iovec array, including those reserved for N_IOVEC_META_FIELDS. The correct
value is the current number of already used elements in the array plus the
maximum number to use for fields decoded from the kernel audit message.
|
|
|
|
|
|
|
|
|
|
|
| |
Previously, the holes we punched earlier would get removed when
copying the file. Let's enable the new COPY_HOLES flag to make
sure this doesn't happen.
In my test, this drops a 800MB btrfs journal (without compression)
to 720 MB.
Fixes #22087
|
|\
| |
| | |
journal: Fixes for handling of corrupt entry objects
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| | |
Allowing -e to be used to view the last logs of a previous boot seems
like a useful feature so let's not discard -b options anymore when
followed by -e.
Fixes #22107
|
| |
| |
| |
| |
| |
| | |
Not having to provide the full path in the source tree is much
nicer and the produced lists can also be used anywhere in the source
tree.
|
|/
|
|
|
|
| |
Not having to provide the full path in the source tree is much
nicer and the produced lists can also be used anywhere in the source
tree.
|
| |
|
|
|
|
|
|
|
| |
The previous message was confusing errors. When we're rotating because
we've reached the file size limit, let's log a better message.
Fixes #22007.
|
| |
|
|\
| |
| | |
Make FOREACH_DIRENT and FOREACH_DIRENT_ALL declare the iterator variables
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The meson default for static_library() are:
build_by_default=true, install=false. We never interact with the
static libraries, and we only care about them as a stepping-stone towards
the installable executables or libraries. Thus let's only build them if
they are a dependency of something else we are building.
While at it, let's drop install:false, since this appears to be the default.
This change would have fixed the issue with lib_import_common failing
to build too: we wouldn't attempt to build it.
In practice this changes very little, because we generally only declare static
libraries where there's something in the default target that will make use of
them. But it seems to be a better pattern to set build_by_default to false.
|
| |
| |
| |
| | |
As in the previous commit, 'de' is used as the iterator variable name.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The variable is not useful outside of the loop (it'll always be null
after the loop is finished), so we can declare it inline in the loop.
This saves one variable declaration and reduces the chances that somebody
tries to use the variable outside of the loop.
For consistency, 'de' is used everywhere for the var name.
|
|\ \
| | |
| | | |
journal: Hole punching improvements
|
| | |
| | |
| | |
| | |
| | |
| | | |
Let's not try to be overly clever here. This code path is not overly
performance sensitive and we should avoid trying to outsmart the kernel
without proper benchmarking.
|
| | |
| | |
| | |
| | | |
Let's use the same buffer size as used in as copy.h.
|
| | |
| | |
| | |
| | |
| | |
| | | |
pread() is not guaranteed to completely fill up the given buffer with
data which we assumed until now. Instead, only increment the offset by
the number of bytes that were actually read.
|
| |/
| |
| |
| |
| | |
Let's not bother punching extremely small holes to avoid unnecessary
file fragmentation.
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The message that the "journal begins … ends …" has been always confusing to
users. (Before b91ae210e62 it was "logs begin … end …" which was arguably even
more confusing, but really the change in b91ae210e62 didn't substantially change
this.)
When the range shown is limited (by -e, -f, --since, or other options), it
doesn't really matter to the user what the oldest entries are, since they are
purposefully limiting the range. In fact, if we are showing the last few
entries with -e or -f, knowing that many months the oldest entries have is
completely useless.
And when such options are *not* used, the first entry generally corresponds to
the beginning of the range shown, and the last entry corresponds to the end of
that range. So again, it's not particularly useful, except when debugging
journalctl or such. Let's just treat it as a debug message.
Fixes #21491.
|
|
|
|
|
| |
Both of these take multiple seconds, best-case, to get the last few
entries, but do so instantly with -b
|
|
|
|
|
| |
As found by fossies codespell:
https://fossies.org/linux/test/systemd-main.bb916f3.211208.tar.gz/codespell.html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously the MMapCache* was optionally NULL, which open would
handle by creating a new MMapCache* for the occasion.
This produced some slightly circuitous refcount-handling code in
the function, as well as arguably creating opportunities for
weirdness where an MMapCache* was intended to be supplied but
happened to be NULL, which this magic would then paper over.
In any case, this was basically only being utilized by tests,
apparently just to avoid having to create an MMapCache. So
update the relevant tests to supply an MMapCache and make
journal_file_open() treat a NULL MMapCache* as fatal w/assert.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Preparatory commit; before JournalFile can stop hanging onto its
copy of MMapCache, all these users need to find another way.
Most of the time these callers already have the MMapCache onhand,
so it's no big deal for them to just supply it.
journal_file_rotate() in particular needed to change, and it
seemed wise to not use the mmap_cache_fd_cache() accessor on
f->cache_fd, instead requiring the caller supply the cache to
use. This was done with an eye towards a potential future where
the journal_file_archive() isolates the cache_fd to a private
cache, which the newly rotated-to file wouldn't be allowed to
use. It's no biggie for the existing callers to just provide the
appropriate surviving cache.
Basically the mmap_cache_fd_cache() accessor was added just for
journal-verify.c's (ab)use of the mmap-cache. Which, if the
ugly singleton MMapCache assumption ever goes away, can be
cleaned up to simply use a separate MMapCache for those search
arrays.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Disabling NOCOW when data has been written to a file doesn't work.
Instead, when we're done writing to a journal file (after archiving),
let's rewrite the file with COW enabled. This also takes care of
properly defragmenting the file.
With zstd compression level 3, journal files are compressed to 12%
of their original size with default journal settings.
As rewriting the file might take a while since we also do an fsync()
after the rewrite, this work is done in the offline thread to avoid
blocking the journald event loop.
|
|
|
|
|
|
|
|
|
|
| |
When we archive a path, we rename the file to indicate this. However,
until now, we didn't actually update the path member of the corresponding
JournalFile instance. Let's make sure we also update this to avoid
misuse of the old path later on.
This change also requires we save the previous path in journal_file_rotate()
since we need to open a new file at the previous path.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
With this change, the logic to write the final tag, emit the final
change notification and to offline the file moves from journal_file_close()
to journald_file_close(). Since all this logic is only executed when
the journal file is writable and all code that writes journal files
already uses journald_file_close() instead of journal_file_close(), this
change should not introduce any changes in behaviour.
Moving the offline related logic to journald-file.c allows us to use
code from src/shared in the offlining logic, more specifically, we can
use the file copying logic from copy.h to fix BTRFS filesystem compression
for journal files when archiving.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently, all the logic related to writing journal files lives in
journal-file.c which is part of libsystemd (sd-journal). Because it's
part of libsystemd, we can't depend on any code from src/shared.
To allow using code from src/shared when writing journal files, let's
gradually move the write related logic from journal-file.c to
journald-file.c in src/journal. This directory is not part of libsystemd
and as such can use code from src/shared.
We can safely remove any journal write related logic from libsystemd as
it's not used by any public APIs in libsystemd.
This commit introduces the new file along with the JournaldFile struct
which wraps an instance of JournalFile. The goal is to gradually move
more functions from journal-file.c and fields from JournalFile to
journald-file.c and JournaldFile respectively.
This commit also modifies all call sites that write journal files to
use JournaldFile instead of JournalFile. All sd-journal tests that
write journal files are moved to src/journal so they can make use of
journald-file.c.
Because the deferred closes logic is only used by journald, we move it
out of journal-file.c as well. In journal_file_open(), we would wait for
any remaining deferred closes for the file we're about to open to complete
before continuing if the file was not newly created. In journald_file_open(),
we call this logic unconditionally since it stands that if a file is newly
created, it can't have any outstanding deferred closes.
No changes in behavior are introduced aside from the earlier execution
of waiting for any deferred closes to complete when opening a new journal
file.
|
| |
|
|
|
|
|
| |
u64log2 was strangely named. We even have log2i and log2u right below
in that file.
|