diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-09-30 05:03:13 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-11-04 03:47:55 +0100 |
commit | a1b8d21fab0708d055aeb63e17f83c2df501c185 (patch) | |
tree | 858a2d1597a5481ed5be8b90bdfe2a5fe864f352 /src/libsystemd/sd-journal/sd-journal.c | |
parent | mmap-cache: introduce window_matches_by_addr() (diff) | |
download | systemd-a1b8d21fab0708d055aeb63e17f83c2df501c185.tar.xz systemd-a1b8d21fab0708d055aeb63e17f83c2df501c185.zip |
sd-journal: introduce journal_file_pin_object()
Previously, OBJECT_UNUSED was used for 'pinning' the mmap cache for an
object. But, OBJECT_UNUSED is also used for reading object when type
cannot be determined before read, e.g. when reading the tail object.
Let's introduce another category for pinning mmap cache, and use it when
we want to temporary pin an object.
Diffstat (limited to '')
-rw-r--r-- | src/libsystemd/sd-journal/sd-journal.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c index c61573f860..73a65da750 100644 --- a/src/libsystemd/sd-journal/sd-journal.c +++ b/src/libsystemd/sd-journal/sd-journal.c @@ -3190,20 +3190,14 @@ _public_ int sd_journal_enumerate_unique( continue; } - /* We do not use OBJECT_DATA context here, but OBJECT_UNUSED - * instead, so that we can look at this data object at the same - * time as one on another file */ - r = journal_file_move_to_object(j->unique_file, OBJECT_UNUSED, j->unique_offset, &o); + r = journal_file_move_to_object(j->unique_file, OBJECT_DATA, j->unique_offset, &o); if (r < 0) return r; - /* Let's do the type check by hand, since we used 0 context above. */ - if (o->object.type != OBJECT_DATA) - return log_debug_errno(SYNTHETIC_ERRNO(EBADMSG), - "%s:offset " OFSfmt ": object has type %d, expected %d", - j->unique_file->path, - j->unique_offset, - o->object.type, OBJECT_DATA); + /* Let's pin the data object, so we can look at it at the same time as one on another file. */ + r = journal_file_pin_object(j->unique_file, o); + if (r < 0) + return r; r = journal_file_data_payload(j->unique_file, o, j->unique_offset, NULL, 0, j->data_threshold, &odata, &ol); |