1
0
mirror of https://github.com/systemd/systemd synced 2026-04-10 17:15:03 +02:00

Compare commits

...

7 Commits

Author SHA1 Message Date
Luca Boccassi
58f62d7079
Merge pull request #21784 from DaanDeMeyer/issue-21675
journal: Hole punching improvements
2021-12-15 22:38:00 +00:00
Yu Watanabe
2b3a8e2830 network: route: update comment 2021-12-15 20:07:17 +00:00
Daan De Meyer
24040269ee journal: Stop reading in increments of block size during hole punching
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.
2021-12-15 18:24:29 +01:00
Daan De Meyer
d951ac5578 journal: Use 16kb buffer during hole punching
Let's use the same buffer size as used in as copy.h.
2021-12-15 18:22:17 +01:00
Daan De Meyer
cdbba44878 journal: Correctly advance offset when iterating hash table entries
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.
2021-12-15 18:21:19 +01:00
Daan De Meyer
a2799cc556 journal: Add a minimum hole size for hole punching
Let's not bother punching extremely small holes to avoid unnecessary
file fragmentation.
2021-12-15 18:17:22 +01:00
Yu Watanabe
bd47f33f16 NEWS: update networkd related entries 2021-12-16 02:12:03 +09:00
3 changed files with 19 additions and 16 deletions

7
NEWS
View File

@ -335,14 +335,15 @@ CHANGES WITH 250 in spe:
UseMTU= setting that may be used to control whether to apply the
announced MTU settings to the local interface.
* systemd-networkd now ships with another default .network files:
* systemd-networkd now ships with new default .network files:
80-container-vb.network which matches host-side network bridge device
created by systemd-nspawn's --network-bridge or --network-zone
switch, and 80-6rd-tunnel.network which matches automatically created
sit tunnel with 6rd prefix when the DHCP 6RD option is received.
* systemd-networkd and systemd-udevd now support IP over InfiniBand
interfaces.
interfaces. The Kind= setting in .netdev file accepts "ipoib". And
systemd.netdev files gained the [IPoIB] section.
* systemd-networkd's handling of Endpoint= resolution for WireGuard
interfaces has been improved.
@ -353,7 +354,7 @@ CHANGES WITH 250 in spe:
* systemd-networkd will now once again automatically generate persistent
MAC addresses for batadv and bridge interfaces. Users can disable this
by using MACAddress=none.
by using MACAddress=none in .netdev files.
* .link files gained a new WakeOnLanPassword= setting in the [Link]
section that allows to specify a WoL "SecureOn" password on hardware

View File

@ -15,6 +15,9 @@
#include "stat-util.h"
#include "sync-util.h"
#define PAYLOAD_BUFFER_SIZE (16U * 1024U)
#define MINIMUM_HOLE_SIZE (1U * 1024U * 1024U / 2U)
static int journald_file_truncate(JournalFile *f) {
uint64_t p;
int r;
@ -66,6 +69,9 @@ static int journald_file_entry_array_punch_hole(JournalFile *f, uint64_t p, uint
(journal_file_entry_array_n_items(&o) - n_unused) * sizeof(le64_t);
sz = p + le64toh(o.object.size) - offset;
if (sz < MINIMUM_HOLE_SIZE)
return 0;
if (fallocate(f->fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, offset, sz) < 0)
return log_debug_errno(errno, "Failed to punch hole in entry array of %s: %m", f->path);
@ -73,9 +79,9 @@ static int journald_file_entry_array_punch_hole(JournalFile *f, uint64_t p, uint
}
static int journald_file_punch_holes(JournalFile *f) {
HashItem items[4096 / sizeof(HashItem)];
HashItem items[PAYLOAD_BUFFER_SIZE / sizeof(HashItem)];
uint64_t p, sz;
size_t to_read;
ssize_t n;
int r;
r = journald_file_entry_array_punch_hole(
@ -85,16 +91,13 @@ static int journald_file_punch_holes(JournalFile *f) {
p = le64toh(f->header->data_hash_table_offset);
sz = le64toh(f->header->data_hash_table_size);
to_read = MIN((size_t) f->last_stat.st_blksize, sizeof(items));
for (uint64_t i = p; i < p + sz; i += sizeof(items)) {
ssize_t n_read;
for (uint64_t i = p; i < p + sz; i += n) {
n = pread(f->fd, items, MIN(sizeof(items), p + sz - i), i);
if (n < 0)
return n;
n_read = pread(f->fd, items, MIN(to_read, p + sz - i), i);
if (n_read < 0)
return n_read;
for (size_t j = 0; j < (size_t) n_read / sizeof(HashItem); j++) {
for (size_t j = 0; j < (size_t) n / sizeof(HashItem); j++) {
Object o;
for (uint64_t q = le64toh(items[j].head_hash_offset); q != 0;

View File

@ -854,9 +854,8 @@ static bool route_by_kernel(const Route *route) {
if (route->protocol == RTPROT_KERNEL)
return true;
/* Do not touch multicast route added by kernel. See issue #6088.
* TODO: Why the kernel adds this route with protocol RTPROT_BOOT?
* https://tools.ietf.org/html/rfc4862#section-5.4 may explain why. */
/* The kernels older than a826b04303a40d52439aa141035fca5654ccaccd (v5.11) create the IPv6
* multicast with RTPROT_BOOT. Do not touch it. */
if (route->protocol == RTPROT_BOOT &&
route->family == AF_INET6 &&
route->dst_prefixlen == 8 &&