]> git.ipfire.org Git - thirdparty/systemd.git/commit
mmap-cache: bind prot(ection) to MMapFileDescriptor
authorVito Caputo <vcaputo@pengaru.com>
Thu, 3 Dec 2020 06:11:23 +0000 (22:11 -0800)
committerLennart Poettering <lennart@poettering.net>
Thu, 10 Dec 2020 12:03:31 +0000 (13:03 +0100)
commit104fc4be11e4429edcb81d39c2299433b71c54f6
tree1fa7d8103f23762abe304d292f74bff7f43fc8e4
parentcca2da15c83fa633e265065b5b201e1938a43f46
mmap-cache: bind prot(ection) to MMapFileDescriptor

There are no mmap_cache_get() users that actually deviate prot
from the JournalFile's f->prot.

So there's no point in making this a separate parameter to
mmap_cache_get(), nor is there any need to store it in
JournalFile's f->prot.

Instead just pass it to mmap_cache_add_fd() at MMapFileDescriptor
creation, storing it in there for the mmap() callers, which
already receive MMapFileDescriptor *.

For functions receiving both an MMapFileDescriptor * and prot,
the prot argument has been simply removed and call sites updated.

Formalizing this fd:prot binding at the public API also enables
discarding the prot check in window_matches(), which is a hot
function on long window lists, so a minor CPU efficiency gain
should be had there as seen with the past removal of the fd
check.  Unnoticable for uncached journals, but maybe a little
runtime improvement when cached in specific circumstances.

window_matches_fd() has also been simplified to treat the
MMapFileDescrptor * as equivalent to its fd and prot.
src/journal/journal-file.c
src/journal/journal-file.h
src/journal/journal-verify.c
src/journal/mmap-cache.c
src/journal/mmap-cache.h
src/journal/test-mmap-cache.c