1
0
mirror of https://github.com/systemd/systemd synced 2025-10-03 18:54:45 +02:00

Compare commits

...

11 Commits

Author SHA1 Message Date
Luca Boccassi
24b27a0000 cg: get attribute for requested controller in cg_is_empty
This was changed SYSTEMD_CGROUP_CONTROLLER instead of the provided
parameter, which broke sd-cgls. Change it back.

Fixes https://github.com/systemd/systemd/issues/38426

Follow-up for c3f900770d0cff0cdf89751b614397b5e226194a
2025-08-01 08:02:57 +09:00
Luca Boccassi
cb88cf9760
udev/node: fix issue in removing device node symlink (#38419)
Fixes #37823.
2025-07-31 23:20:05 +01:00
Luca Boccassi
8cc1748ddc journald: add debug logs around offlining/archiving/rotating/varlink operations
It is not easy to understand what happens to a journal file
even with debug logs enabled. Add more dbg messages around operations
started by users to make it possible to follow the flow of operations.
2025-08-01 05:42:51 +09:00
Luca Boccassi
090b23e051 test: run test-journal-append binary with info level logging
It is ran thousands of times so the logs are overwhelming otherwise
2025-08-01 05:42:51 +09:00
RocketDev
6428c0f480 hwdb: disable Asus ROG keyboards sending poweroff
Asus ROG keyboards seems to send power off key code when keyboard wake
up. Reserve the key codes could suppress this problem.

Devices added: ROG Falchion & ROG Scope

Based on the work by Jon Nettleton:
https://gist.github.com/jnettlet/afb20a048b8720f3b4eb8506d8b05643
2025-08-01 05:41:45 +09:00
Yu Watanabe
c574e32fb9 hwdb: several cleanups
- drop trailing spaces,
- replace tabs with spaces,
- align comments.
2025-08-01 05:41:45 +09:00
Yu Watanabe
fdb8600575 TEST-64-UDEV-STORAGE: add stress tests for creating/removing device node symlinks
For issue #37823.
2025-08-01 04:09:40 +09:00
Yu Watanabe
35e4cfa83d TEST-64-UDEV-STORAGE: several cleanups
- drop unused variables,
- adjust number of partitions, interations, and timeout,
- clear partitions on each test case finished,
- check if unnecessary devlinks are removed,
- several coding style cleanups.
2025-08-01 04:09:40 +09:00
Yu Watanabe
453cbbe47b TEST-64-UDEV-STORAGE: several fixlets for check_device_units()
To suppress the following warnings in case check_device_unit() failed e.g.
when the device is already removed:
```
sed: couldn't write 130 items to stdout: Broken pipe
awk: write failure (Broken pipe)
awk: close failed on file "/dev/stdout" (Broken pipe)
```
2025-08-01 04:07:01 +09:00
Yu Watanabe
453e1375d0 udev/node: check the target device node of devlink on removal
If the removal of the devlink is requested due to this is a 'remove' event,
it is trivial that the devlink will not be owned by this device anymore.
Let's read the devlink and if it points to our device node, then we need
to update the devlink. If it points to another device node, then it is already
owned by another device, hence we should not touch it and keep it as is.

Fixes #37823.
2025-08-01 02:21:04 +09:00
Yu Watanabe
239c9a2e5f udev/node: split out link_search_and_update() and reduce indentation
No functional change, just refactoring and preparation for later change.
2025-08-01 02:10:10 +09:00
11 changed files with 328 additions and 158 deletions

View File

@ -155,8 +155,8 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pnAspireA317-33:*
# Acer Aspire One AO532h
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pnAO532h:*
KEYBOARD_KEY_84=bluetooth
KEYBOARD_KEY_ce=unknown # Brightness Up, also emitted by acpi-video, ignore
KEYBOARD_KEY_ef=unknown # Brightness Down, also emitted by acpi-video, ignore
KEYBOARD_KEY_ce=unknown # Brightness Up, also emitted by acpi-video, ignore
KEYBOARD_KEY_ef=unknown # Brightness Down, also emitted by acpi-video, ignore
# Acer Aspire One AOD270 (Atom N2600) and its Packard Bell Dot SC rebrand
evdev:name:Acer WMI hotkeys:dmi:bvn*:bvr*:bd*:svnAcer*:pnAOD270*:*
@ -165,8 +165,8 @@ evdev:name:Acer WMI hotkeys:dmi:*:svnPackardBell:pndots:*:rvnPackardBell:rnSJE01
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pnAOD270*:*
evdev:atkbd:dmi:*:svnPackardBell:pndots:*:rvnPackardBell:rnSJE01_CT:*
KEYBOARD_KEY_ce=unknown # Brightness Up, also emitted by acpi-video, ignore
KEYBOARD_KEY_ef=unknown # Brightness Down, also emitted by acpi-video, ignore
KEYBOARD_KEY_ce=unknown # Brightness Up, also emitted by acpi-video, ignore
KEYBOARD_KEY_ef=unknown # Brightness Down, also emitted by acpi-video, ignore
# Predator PT314-52s
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pnPredator*PT314-52s:pvr*
@ -243,7 +243,7 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pnNitro*AN*515-58:pvr*
# Nitro ANV15-51
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pnNitro*ANV*15-51:pvr*
KEYBOARD_KEY_66=micmute # Microphone mute button
KEYBOARD_KEY_f5=prog1 # NitroSense button
KEYBOARD_KEY_f5=prog1 # NitroSense button
###########################################################
# Alienware
@ -285,6 +285,21 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnASUS:pn*:*
KEYBOARD_KEY_ee=volumedown
KEYBOARD_KEY_ef=mute
# Asus ROG series
# Prevents the keyboard from sending POWER and SLEEP key presses
# when the keyboard goes to sleep.
evdev:input:b*v0B05p*e0111*
KEYBOARD_KEY_10081=reserved
KEYBOARD_KEY_10082=reserved
KEYBOARD_KEY_70070=reserved
KEYBOARD_KEY_70071=reserved
KEYBOARD_KEY_70072=reserved
KEYBOARD_KEY_70073=reserved
KEYBOARD_KEY_70074=reserved
KEYBOARD_KEY_70075=reserved
KEYBOARD_KEY_70076=reserved
KEYBOARD_KEY_70077=reserved
# Asus TF103C misses the home button in its PNP0C40 GPIO resources
# causing the volume-button mappings to be off by one, correct this
evdev:name:gpio-keys:phys:gpio-keys/input0:ev:3:dmi:*:svnASUSTeKCOMPUTERINC.:pnTF103C*:*
@ -304,10 +319,10 @@ evdev:name:gpio-keys:phys:gpio-keys/input0:ev:100003:dmi:*:svnASUSTeKCOMPUTERINC
# All four of these buttons generate a multi-scancode sequence
# consisting of Left_Meta, Right_Ctrl and another scancode.
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAYANEO:pnKUN:pvr*
KEYBOARD_KEY_18=f15 # LC (next to the left shoulder button)
KEYBOARD_KEY_20=f16 # RC (next to the right shoulder button)
KEYBOARD_KEY_28=f17 # Ayaneo (lower-right corner of screen)
KEYBOARD_KEY_30=f18 # Touchpad Mode (top-right corner of screen)
KEYBOARD_KEY_18=f15 # LC (next to the left shoulder button)
KEYBOARD_KEY_20=f16 # RC (next to the right shoulder button)
KEYBOARD_KEY_28=f17 # Ayaneo (lower-right corner of screen)
KEYBOARD_KEY_30=f18 # Touchpad Mode (top-right corner of screen)
# Most AYANEO devices expose an AT Translated Set 2 Keyboard
# for either three or four additional buttons not available
@ -316,10 +331,10 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAYANEO:pnKUN:pvr*
# depend on the model, but the final scancode is always the
# same.
evdev:name:AT Translated Set 2 keyboard:dmi:*:svnAYANEO:*
KEYBOARD_KEY_66=f15 # LC (All models)
KEYBOARD_KEY_67=f16 # RC (All models)
KEYBOARD_KEY_68=f17 # Ayaneo (All models)
KEYBOARD_KEY_69=f18 # Touchpad Mode (Kun only)
KEYBOARD_KEY_66=f15 # LC (All models)
KEYBOARD_KEY_67=f16 # RC (All models)
KEYBOARD_KEY_68=f17 # Ayaneo (All models)
KEYBOARD_KEY_69=f18 # Touchpad Mode (Kun only)
###########################################################
# BenQ
@ -433,10 +448,10 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnDell*:pnInspiron*1210:*
# Dell Inspiron 11 3168
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnDell*:pnInspiron11-3168:pvr*
KEYBOARD_KEY_c7=!home # Fn-LeftArrow
KEYBOARD_KEY_cf=!end # Fn-RightArrow
KEYBOARD_KEY_c9=!pageup # Fn-UpArrow
KEYBOARD_KEY_d1=!pagedown # Fn-DownArrow
KEYBOARD_KEY_c7=!home # Fn-LeftArrow
KEYBOARD_KEY_cf=!end # Fn-RightArrow
KEYBOARD_KEY_c9=!pageup # Fn-UpArrow
KEYBOARD_KEY_d1=!pagedown # Fn-DownArrow
# Dell Inspiron 1520 and Latitude 2110
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnDell*:pnInspiron*1520:*
@ -505,7 +520,7 @@ evdev:name:Dell Privacy Driver:dmi:bvn*:bvr*:bd*:svnDell*:pnPrecision*:*
# Dell Professional Sound Bar AE515
evdev:input:b0003v413CpA506*
KEYBOARD_KEY_b002f=micmute # Mic mute toggle
KEYBOARD_KEY_b002f=micmute # Mic mute toggle
###########################################################
# Everex
@ -704,10 +719,10 @@ evdev:name:Intel HID events:dmi:bvn*:bvr*:bd*:svnHP*:pnHPENVYx3602-in-1*:*
# HP Elite x2 1013 G3
evdev:atkbd:dmi:bvn*:bvr*:svnHP*:pnHPElitex21013G3:*
KEYBOARD_KEY_f8=unknown # rfkill is also reported by HP Wireless hotkeys
KEYBOARD_KEY_f8=unknown # rfkill is also reported by HP Wireless hotkeys
KEYBOARD_KEY_64=calendar
KEYBOARD_KEY_81=micmute # Microphone mute button
KEYBOARD_KEY_ee=switchvideomode # Switch display outputs
KEYBOARD_KEY_81=micmute # Microphone mute button
KEYBOARD_KEY_ee=switchvideomode # Switch display outputs
KEYBOARD_KEY_92=brightnessdown
KEYBOARD_KEY_97=brightnessup
@ -742,14 +757,14 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnHewlett-Packard*:pn*2570p*:*
evdev:atkbd:dmi:bvncoreboot:bvr*:bd*:svnHewlett-Packard*:pn*EliteBook2170p:*
evdev:atkbd:dmi:bvncoreboot:bvr*:bd*:svnHP*:pn*EliteBook2170p:*
KEYBOARD_KEY_66=backspace
KEYBOARD_KEY_be=battery # Fn+F2
KEYBOARD_KEY_d7=switchvideomode # Fn+F4
KEYBOARD_KEY_a3=mute # Fn+F5
KEYBOARD_KEY_a1=volumedown # Fn+F6
KEYBOARD_KEY_a2=volumeup # Fn+F7
KEYBOARD_KEY_a4=brightnessdown # Fn+F9
KEYBOARD_KEY_c3=brightnessup # Fn+F10
KEYBOARD_KEY_e3=wlan # Fn+F12
KEYBOARD_KEY_be=battery # Fn+F2
KEYBOARD_KEY_d7=switchvideomode # Fn+F4
KEYBOARD_KEY_a3=mute # Fn+F5
KEYBOARD_KEY_a1=volumedown # Fn+F6
KEYBOARD_KEY_a2=volumeup # Fn+F7
KEYBOARD_KEY_a4=brightnessdown # Fn+F9
KEYBOARD_KEY_c3=brightnessup # Fn+F10
KEYBOARD_KEY_e3=wlan # Fn+F12
# Elitebook 2760p
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnHewlett-Packard*:pn*2760p*:*
@ -1127,8 +1142,8 @@ evdev:atkbd:dmi:bvn*:bvr*:svnLENOVO:pn21KH*:pvrThinkBook16G6IRL:*
KEYBOARD_KEY_b0=!volumeup
evdev:atkbd:dmi:*:svnLENOVO:*:pvrLenovoYoga300-11IBR:*
KEYBOARD_KEY_62=unknown # Touchpad on, also emitted by "Ideapad extra buttons", ignore
KEYBOARD_KEY_63=unknown # Touchpad off, also emitted by "Ideapad extra buttons", ignore
KEYBOARD_KEY_62=unknown # Touchpad on, also emitted by "Ideapad extra buttons", ignore
KEYBOARD_KEY_63=unknown # Touchpad off, also emitted by "Ideapad extra buttons", ignore
# Lenovo Y50-70
evdev:atkbd:dmi:bvn*:bvr*:svnLENOVO*:pn*20378*:pvr*
@ -1274,10 +1289,10 @@ evdev:input:b0003v046Dp0056*
evdev:input:b0003v046Dp0057*
KEYBOARD_KEY_c1041=battery # Battery icon (Fn + F1)
#KEYBOARD_KEY_c101d=scrolldown # Button below scrollwheel (see note above)
#KEYBOARD_KEY_c101e=scrollup # Button above scrollwheel (see note above)
#KEYBOARD_KEY_c1022=scrollleft # Left click on scroll-wheel (see note above)
#KEYBOARD_KEY_c1024=scrollright # Right click on scroll-wheel (see note above)
#KEYBOARD_KEY_c101d=scrolldown # Button below scrollwheel (see note above)
#KEYBOARD_KEY_c101e=scrollup # Button above scrollwheel (see note above)
#KEYBOARD_KEY_c1022=scrollleft # Left click on scroll-wheel (see note above)
#KEYBOARD_KEY_c1024=scrollright # Right click on scroll-wheel (see note above)
# MX3200 keyboard (27 MHz, modelnumber Y-RAV80)
evdev:input:b0003v046Dp005C*
@ -1802,7 +1817,7 @@ evdev:input:b0003v258Ap001E*
###########################################################
evdev:atkbd:dmi:bvn*:bvr*:bd*:svn*:pn*:pvr*:rvnQuanta:rn30B7:rvr65.2B:*
KEYBOARD_KEY_88=media # "quick play
KEYBOARD_KEY_88=media # quick play
###########################################################
# Redmi
@ -1842,17 +1857,17 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svn[sS][aA][mM][sS][uU][nN][gG]*:pn*200E[45]*:*
evdev:atkbd:dmi:bvn*:bvr*:bd*:svn[sS][aA][mM][sS][uU][nN][gG]*:pn*356V[45]*:pvr*
evdev:atkbd:dmi:bvn*:bvr*:bd*:svn[sS][aA][mM][sS][uU][nN][gG]*:pn*355V[45]*:pvr*
KEYBOARD_KEY_ce=!prog1 # Fn+F1 launch control setting
KEYBOARD_KEY_89=!brightnessdown # Fn+F2 brightness down
KEYBOARD_KEY_88=!brightnessup # Fn+F3 brightness up
KEYBOARD_KEY_82=!switchvideomode # Fn+F4 display toggle
KEYBOARD_KEY_f7=!touchpad_on # Fn+F5 touchpad on
KEYBOARD_KEY_f9=!touchpad_off # Fn+F5 touchpad off
KEYBOARD_KEY_a0=!mute # Fn+F6 mute
KEYBOARD_KEY_ae=!volumedown # Fn+F7 volume down
KEYBOARD_KEY_b0=!volumeup # Fn+F8 volume up
KEYBOARD_KEY_b3=!prog2 # Fn+F11 toggle fan/cool mode
KEYBOARD_KEY_d5=!wlan # Fn+F12 toggle wifi
KEYBOARD_KEY_ce=!prog1 # Fn+F1 launch control setting
KEYBOARD_KEY_89=!brightnessdown # Fn+F2 brightness down
KEYBOARD_KEY_88=!brightnessup # Fn+F3 brightness up
KEYBOARD_KEY_82=!switchvideomode # Fn+F4 display toggle
KEYBOARD_KEY_f7=!touchpad_on # Fn+F5 touchpad on
KEYBOARD_KEY_f9=!touchpad_off # Fn+F5 touchpad off
KEYBOARD_KEY_a0=!mute # Fn+F6 mute
KEYBOARD_KEY_ae=!volumedown # Fn+F7 volume down
KEYBOARD_KEY_b0=!volumeup # Fn+F8 volume up
KEYBOARD_KEY_b3=!prog2 # Fn+F11 toggle fan/cool mode
KEYBOARD_KEY_d5=!wlan # Fn+F12 toggle wifi
# Series 5
evdev:atkbd:dmi:bvn*:bvr*:bd*:svn[sS][aA][mM][sS][uU][nN][gG]*:pn*530U*:*
@ -2290,8 +2305,8 @@ evdev:name:SIPODEV USB Composite Device:dmi:bvn*:bvr*:svnPositivoTecnologiaSA:pn
# Positivo (K116J)
evdev:name:AT Translated Set 2 keyboard:dmi:bvn*:svnPositivo*:pn*:pvr*:rvnPositivo*:rnK116J*
KEYBOARD_KEY_69=www
KEYBOARD_KEY_6e=search
KEYBOARD_KEY_69=www
KEYBOARD_KEY_6e=search
###########################################################
# Multilaser
@ -2332,7 +2347,7 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnDIXONSP:pnDIXON*:*
# The layout must be an xkb compatible layout (defined with XKB_FIXED_LAYOUT),
# with an accompanying variant (defined with XKB_FIXED_VARIANT) if necessary.
# Yubico Yubico Yubikey II"
# Yubico Yubico Yubikey II
evdev:input:b0003v1050p0010*
# Yubico Yubikey NEO OTP+CCID
evdev:input:b0003v1050p0111*

View File

@ -157,7 +157,7 @@ sensor:modalias:acpi:INVN6500*:dmi:*svnASUSTeK*:pnT200TA:*
# Asus Transformer Mini T103HAF
sensor:modalias:platform:HID-SENSOR-200073*:dmi:*svn*ASUSTeK*:pnT103HAF:*
ACCEL_MOUNT_MATRIX=0, -1, 0; 1, 0, 0; 0, 0, -1
ACCEL_MOUNT_MATRIX=0, -1, 0; 1, 0, 0; 0, 0, -1
sensor:modalias:acpi:INVN6500*:dmi:*svnASUSTeK*:*pnTP201SA:*
sensor:modalias:acpi:INVN6500*:dmi:*svnASUSTeK*:pn*E205SA:*
@ -524,7 +524,7 @@ sensor:modalias:acpi:KIOX000A*:dmi:*:svnEVE*:pnEveV:*
# Exo
#########################################
# EXO Wings 2in1 w1125
# EXO Wings 2in1 w1125
sensor:modalias:acpi:SMO8500*:dmi:*:svnEXO*:pnWings:*
ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, 1, 0; 0, 0, 1
@ -654,7 +654,7 @@ sensor:modalias:acpi:SMO8840*:dmi:*:svnHUAWEI:pnBOHK-WAX9X:*
sensor:modalias:acpi:KIOX000A*:dmi:bvnAmericanMegatrendsInc.:*:svnTobefilledbyO.E.M.:pnTW891:pvrTobefilledbyO.E.M.:rvnTobefilledbyO.E.M.:rnTW891:rvr1.0:cvnToBeFilledByO.E.M.:ct3:cvrToBeFilledByO.E.M.:*
ACCEL_MOUNT_MATRIX=0, 1, 0; 1, 0, 0; 0, 0, 1
# I.T.Works TW701 7" windows tablet, same hw as Trekstor ST70416-6
# I.T.Works TW701 7 inch windows tablet, same hw as Trekstor ST70416-6
sensor:modalias:acpi:BMA250*:dmi:*:bvritWORKS.G.WI71C.JGBMRB*:*:svnInsyde:pni71c:*
ACCEL_MOUNT_MATRIX=0, 1, 0; 1, 0, 0; 0, 0, 1
@ -908,7 +908,7 @@ sensor:modalias:acpi:KIOX010A*:dmi:*:svnCompletElectroServSA:pnMY8312:*
# Nuvision (TMax)
#########################################
# Nuvision/TMAX 8" Windows signature edition. TM800W560L
# Nuvision/TMAX 8 inch Windows signature edition. TM800W560L
sensor:modalias:acpi:KIOX000A*:dmi:*:svnTMAX:pnTM800W560L:*
ACCEL_MOUNT_MATRIX=1, 0, 0; 0, -1, 0; 0, 0, 1

View File

@ -773,7 +773,7 @@ int cg_is_empty(const char *controller, const char *path) {
if (empty_or_root(path))
return false;
r = cg_get_keyed_attribute(SYSTEMD_CGROUP_CONTROLLER, path, "cgroup.events", STRV_MAKE("populated"), &t);
r = cg_get_keyed_attribute(controller, path, "cgroup.events", STRV_MAKE("populated"), &t);
if (r == -ENOENT)
return true;
if (r < 0)

View File

@ -553,11 +553,14 @@ static int manager_do_rotate(
int r;
assert(f);
assert(m);
if (!*f)
return -EINVAL;
log_debug("Rotating journal file %s.", (*f)->path);
r = journal_file_rotate(f, m->mmap, manager_get_file_flags(m, seal), m->config.compress.threshold_bytes, m->deferred_closes);
if (r < 0) {
if (*f)

View File

@ -22,6 +22,8 @@ void sync_req_varlink_reply(SyncReq *req) {
if (req->offline)
manager_full_sync(req->manager, /* wait = */ true);
log_debug("Client request to sync journal (%s offlining) completed.", req->offline ? "with" : "without");
/* Disconnect the SyncReq from the Varlink connection object, and free it */
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = TAKE_PTR(req->link);
sd_varlink_set_userdata(vl, req->manager); /* reinstall manager object */
@ -96,6 +98,7 @@ static int vl_method_rotate(sd_varlink *link, sd_json_variant *parameters, sd_va
log_info("Received client request to rotate journal, rotating.");
manager_full_rotate(m);
log_debug("Client request to rotate journal completed.");
return sd_varlink_reply(link, NULL);
}
@ -119,6 +122,7 @@ static int vl_method_flush_to_var(sd_varlink *link, sd_json_variant *parameters,
log_info("Received client request to flush runtime journal.");
manager_full_flush(m);
log_debug("Client request to flush runtime journal completed.");
return sd_varlink_reply(link, NULL);
}
@ -142,6 +146,7 @@ static int vl_method_relinquish_var(sd_varlink *link, sd_json_variant *parameter
log_info("Received client request to relinquish %s access.", m->system_storage.path);
manager_relinquish_var(m);
log_debug("Client request to relinquish %s access completed.", m->system_storage.path);
return sd_varlink_reply(link, NULL);
}

View File

@ -197,10 +197,14 @@ int journal_file_set_offline_thread_join(JournalFile *f) {
if (f->offline_state == OFFLINE_JOINED)
return 0;
log_debug("Joining journal offlining thread for %s.", f->path);
r = pthread_join(f->offline_thread, NULL);
if (r)
return -r;
log_debug("Journal offlining thread for %s joined.", f->path);
f->offline_state = OFFLINE_JOINED;
if (mmap_cache_fd_got_sigbus(f->cache_fd))

View File

@ -12,7 +12,9 @@
#include "fd-util.h"
#include "journal-authenticate.h"
#include "journal-file-util.h"
#include "journal-internal.h"
#include "log.h"
#include "log-ratelimit.h"
#include "set.h"
#include "string-util.h"
@ -318,12 +320,25 @@ int journal_file_set_offline(JournalFile *f, bool wait) {
target_state = f->archive ? STATE_ARCHIVED : STATE_OFFLINE;
log_ratelimit_full(LOG_DEBUG,
JOURNAL_LOG_RATELIMIT,
"Journal file %s is %s transitioning to %s.",
f->path,
wait ? "synchronously" : "asynchronously",
f->archive ? "archived" : "offline");
/* An offlining journal is implicitly online and may modify f->header->state,
* we must also join any potentially lingering offline thread when already in
* the desired offline state.
*/
if (!journal_file_is_offlining(f) && f->header->state == target_state)
if (!journal_file_is_offlining(f) && f->header->state == target_state) {
log_ratelimit_full(LOG_DEBUG,
JOURNAL_LOG_RATELIMIT,
"Journal file %s is already %s, waiting for offlining thread.",
f->path,
f->archive ? "archived" : "offline");
return journal_file_set_offline_thread_join(f);
}
/* Restart an in-flight offline thread and wait if needed, or join a lingering done one. */
restarted = journal_file_set_offline_try_restart(f);
@ -336,6 +351,12 @@ int journal_file_set_offline(JournalFile *f, bool wait) {
if (restarted)
return 0;
log_ratelimit_full(LOG_DEBUG,
JOURNAL_LOG_RATELIMIT,
"Starting new %s offlining operation for journal file %s.",
wait ? "synchronous" : "asynchronous",
f->path);
/* Initiate a new offline. */
f->offline_state = OFFLINE_SYNCING;

View File

@ -103,6 +103,8 @@ TEST(cg_create) {
ASSERT_OK_POSITIVE(cg_is_empty(SYSTEMD_CGROUP_CONTROLLER, test_a));
ASSERT_OK_ZERO(cg_is_empty(SYSTEMD_CGROUP_CONTROLLER, test_b));
ASSERT_OK_POSITIVE(cg_is_empty(NULL, test_a));
ASSERT_OK_POSITIVE(cg_is_empty(NULL, test_b));
ASSERT_OK_ZERO(cg_kill_recursive(test_a, 0, 0, NULL, NULL, NULL));
ASSERT_OK_POSITIVE(cg_kill_recursive(test_b, 0, 0, NULL, NULL, NULL));

View File

@ -213,6 +213,24 @@ static int stack_directory_find_prioritized_devnode(sd_device *dev, int dirfd, b
return !!*ret;
}
static int link_search_and_update(sd_device *dev, const char *slink, int dirfd, bool add) {
int r;
assert(dev);
assert(slink);
assert(dirfd >= 0);
_cleanup_free_ char *devnode = NULL;
r = stack_directory_find_prioritized_devnode(dev, dirfd, add, &devnode);
if (r < 0)
return log_device_debug_errno(dev, r, "Failed to determine device node with the highest priority for '%s': %m", slink);
if (r > 0)
return node_create_symlink(dev, devnode, slink);
log_device_debug(dev, "No reference left for '%s', removing", slink);
return node_remove_symlink(dev, slink);
}
static int stack_directory_update(sd_device *dev, int fd, bool add) {
const char *id;
int r;
@ -420,7 +438,7 @@ static int link_update(sd_device *dev, const char *slink, bool add) {
_cleanup_(release_lock_file) LockFile lockfile = LOCK_FILE_INIT; /* #3 */
_cleanup_(rmdir_and_freep) char *dirpath = NULL; /* #2 */
_cleanup_close_ int dirfd = -EBADF; /* #1 */
_cleanup_free_ char *current_id = NULL, *devnode = NULL;
_cleanup_free_ char *current_id = NULL;
int r, current_prio;
assert(dev);
@ -430,72 +448,104 @@ static int link_update(sd_device *dev, const char *slink, bool add) {
if (r < 0)
return r;
r = node_get_current(slink, dirfd, &current_id, add ? &current_prio : NULL);
if (r < 0 && !ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(r))
return log_device_debug_errno(dev, r, "Failed to get the current device node priority for '%s': %m", slink);
if (add) {
r = node_get_current(slink, dirfd, &current_id, &current_prio);
if (r < 0 && !ERRNO_IS_DEVICE_ABSENT_OR_EMPTY(r))
return log_device_debug_errno(dev, r, "Failed to get the current device node priority for '%s': %m", slink);
}
r = stack_directory_update(dev, dirfd, add);
if (r < 0)
return log_device_debug_errno(dev, r, "Failed to update stack directory for '%s': %m", slink);
if (current_id) {
const char *id;
if (!add) {
_cleanup_free_ char *target = NULL;
r = sd_device_get_device_id(dev, &id);
if (r < 0)
return log_device_debug_errno(dev, r, "Failed to get device id: %m");
/* Especially on 'remove' event, the device ID obtained by node_get_current() may not be
* reliable, as the device node and/or device number may be reused. Hence, let's read the
* devlink here and if it points to our device node, then we need to update the devlink. If
* it points to another device node, then it is already owned by another device, hence we
* should not touch it and keep it as is. */
if (add) {
int prio;
r = readlink_malloc(slink, &target);
if (r < 0) {
if (r != -ENOENT)
log_device_debug_errno(dev, r, "Failed to read symbolic link '%s', ignoring: %m", slink);
r = device_get_devlink_priority(dev, &prio);
if (r < 0)
return log_device_debug_errno(dev, r, "Failed to get devlink priority: %m");
if (streq(current_id, id)) {
if (current_prio <= prio)
/* The devlink is ours and already exists, and the new priority is
* equal or higher than the previous. Hence, it is not necessary to
* recreate it. */
return 0;
/* The devlink priority is downgraded. Another device may have a higher
* priority now. Let's find the device node with the highest priority. */
} else {
if (current_prio > prio)
/* The devlink with a higher priority already exists and is owned by
* another device. Hence, it is not necessary to recreate it. */
return 0;
/* This device has the equal or a higher priority than the current. Let's
* create the devlink to our device node. */
return node_create_symlink(dev, /* devnode = */ NULL, slink);
}
} else {
if (!streq(current_id, id))
/* The devlink already exists and is owned by another device. Hence, it is
* not necessary to recreate it. */
return 0;
/* The current devlink is ours, and the target device will be removed. Hence, we need
* to search the device that has the highest priority. and update the devlink. */
/* The devlink does not exist. Let's find the most suitable owner, and create the
* devlink. This is typically not necessary and does nothing, but for safety in the
* case that the devlink is removed manually. */
return link_search_and_update(dev, slink, dirfd, add);
}
} else {
const char *node;
r = sd_device_get_devname(dev, &node);
if (r < 0)
return log_device_debug_errno(dev, r, "Failed to get device node: %m");
if (streq(node, target)) /* owned by us, needs to update. */
return link_search_and_update(dev, slink, dirfd, add);
/* The devlink does not point to our device node. For extra safety, let's validate the
* current devlink, in case that the devlink is manually modified by user. */
if (!path_startswith(target, "/dev/")) {
log_device_debug(dev, "Symbolic link '%s' points to '%s' which is outside of '/dev/', updating it.", slink, target);
return link_search_and_update(dev, slink, dirfd, add);
}
struct stat st;
if (lstat(target, &st) < 0) {
if (errno != ENOENT)
log_device_debug_errno(dev, errno, "Failed to stat '%s', ignoring: %m", target);
/* The current target device is also already removed? Let's update. */
return link_search_and_update(dev, slink, dirfd, add);
}
if (!IN_SET(st.st_mode & S_IFMT, S_IFBLK, S_IFCHR)) {
log_device_debug(dev, "Symbolic link '%s' points to '%s' which is not a device node, updating it.", slink, target);
return link_search_and_update(dev, slink, dirfd, add);
}
return 0; /* the devlink is owned by another device, and we should keep it as is. */
}
if (!current_id)
/* The requested devlink does not exist, or the target device does not exist and the devlink
* points to a non-existing device. Let's search the device that has the highest priority,
* and update the devlink. */
;
return link_search_and_update(dev, slink, dirfd, add);
const char *id;
r = sd_device_get_device_id(dev, &id);
if (r < 0)
return log_device_debug_errno(dev, r, "Failed to get device id: %m");
int prio;
r = device_get_devlink_priority(dev, &prio);
if (r < 0)
return log_device_debug_errno(dev, r, "Failed to get devlink priority: %m");
if (streq(current_id, id)) {
if (current_prio <= prio)
/* The devlink is ours and already exists, and the new priority is equal or higher
* than the previous. Hence, it is not necessary to recreate it. */
return 0;
/* The devlink priority is downgraded. Another device may have a higher priority now. Let's
* find the device node with the highest priority. */
return link_search_and_update(dev, slink, dirfd, add);
}
r = stack_directory_find_prioritized_devnode(dev, dirfd, add, &devnode);
if (r < 0)
return log_device_debug_errno(dev, r, "Failed to determine device node with the highest priority for '%s': %m", slink);
if (r > 0)
return node_create_symlink(dev, devnode, slink);
if (current_prio > prio)
/* The devlink with a higher priority already exists and is owned by another device. Hence,
* it is not necessary to recreate it. */
return 0;
log_device_debug(dev, "No reference left for '%s', removing", slink);
return node_remove_symlink(dev, slink);
/* This device has the equal or a higher priority than the current. Let's create the devlink to our
* device node. */
return node_create_symlink(dev, /* devnode = */ NULL, slink);
}
static int device_get_devpath_by_devnum(sd_device *dev, char **ret) {

View File

@ -12,35 +12,35 @@ TEST_JOURNAL_APPEND=/usr/lib/systemd/tests/unit-tests/manual/test-journal-append
[[ -x "$TEST_JOURNAL_APPEND" ]]
# Corrupt the first ~1024 bytes, this should be pretty quick
"$TEST_JOURNAL_APPEND" --sequential --start-offset=0 --iterations=350 --iteration-step=3
SYSTEMD_LOG_LEVEL=info "$TEST_JOURNAL_APPEND" --sequential --start-offset=0 --iterations=350 --iteration-step=3
# Skip most of the test when running without acceleration, as it's excruciatingly slow
# (this shouldn't be an issue, as it should run in nspawn as well)
if ! [[ "$(systemd-detect-virt -v)" == "qemu" ]]; then
# Corrupt the beginning of every 1K block between 1K - 32K
for ((i = 1024; i <= (32 * 1024); i += 1024)); do
"$TEST_JOURNAL_APPEND" --sequential --start-offset="$i" --iterations=5 --iteration-step=13
SYSTEMD_LOG_LEVEL=info "$TEST_JOURNAL_APPEND" --sequential --start-offset="$i" --iterations=5 --iteration-step=13
done
# Corrupt the beginning of every 16K block between 32K - 128K
for ((i = (32 * 1024); i <= (256 * 1024); i += (16 * 1024))); do
"$TEST_JOURNAL_APPEND" --sequential --start-offset="$i" --iterations=5 --iteration-step=13
SYSTEMD_LOG_LEVEL=info "$TEST_JOURNAL_APPEND" --sequential --start-offset="$i" --iterations=5 --iteration-step=13
done
# Corrupt the beginning of every 128K block between 128K - 1M
for ((i = (128 * 1024); i <= (1 * 1024 * 1024); i += (128 * 1024))); do
"$TEST_JOURNAL_APPEND" --sequential --start-offset="$i" --iterations=5 --iteration-step=13
SYSTEMD_LOG_LEVEL=info "$TEST_JOURNAL_APPEND" --sequential --start-offset="$i" --iterations=5 --iteration-step=13
done
# And finally the beginning of every 1M block between 1M and 8M
for ((i = (1 * 1024 * 1024); i < (8 * 1024 * 1024); i += (1 * 1024 * 1024))); do
"$TEST_JOURNAL_APPEND" --sequential --start-offset="$i" --iterations=5 --iteration-step=13
SYSTEMD_LOG_LEVEL=info "$TEST_JOURNAL_APPEND" --sequential --start-offset="$i" --iterations=5 --iteration-step=13
done
if [[ "$(nproc)" -ge 2 ]]; then
# Try to corrupt random bytes throughout the journal
"$TEST_JOURNAL_APPEND" --iterations=25
SYSTEMD_LOG_LEVEL=info "$TEST_JOURNAL_APPEND" --iterations=25
fi
else
"$TEST_JOURNAL_APPEND" --iterations=10
SYSTEMD_LOG_LEVEL=info "$TEST_JOURNAL_APPEND" --iterations=10
fi

View File

@ -117,7 +117,7 @@ check_device_unit() {(
fi
done
read -r -a links < <(udevadm info "$syspath" | sed -ne '/SYSTEMD_ALIAS=/ { s/^E: SYSTEMD_ALIAS=//; p }' 2>/dev/null)
read -r -a links < <(udevadm info -q property --property SYSTEMD_ALIAS --value "$syspath" 2>/dev/null)
for link in "${links[@]}"; do
if [[ "$link" == "$path" ]]; then # SYSTEMD_ALIAS= are absolute
return 0
@ -131,7 +131,7 @@ check_device_unit() {(
check_device_units() {(
set +x
local log_level path paths
local log_level path paths unit units
log_level="${1?}"
shift
@ -143,12 +143,13 @@ check_device_units() {(
fi
done
while read -r unit _; do
read -r -a units < <(systemctl list-units --all --type=device --no-legend dev-* | awk '$1 !~ /dev-tty.+/ && $4 == "plugged" { print $1 }' | sed -e 's/\.device$//')
for unit in "${units[@]}"; do
path=$(systemd-escape --path --unescape "$unit")
if ! check_device_unit "$log_level" "$path"; then
return 1
fi
done < <(systemctl list-units --all --type=device --no-legend dev-* | awk '$1 !~ /dev-tty.+/ && $4 == "plugged" { print $1 }' | sed -e 's/\.device$//')
done
return 0
)}
@ -380,9 +381,8 @@ EOF
}
testcase_simultaneous_events_1() {
local disk expected i iterations key link num_part part partscript rule target timeout
local -a devices symlinks
local -A running
local disk expected i iterations link num_part part partscript rule target timeout
local -a devices symlinks running
if [[ -v ASAN_OPTIONS || "$(systemd-detect-virt -v)" == "qemu" ]]; then
num_part=2
@ -437,18 +437,20 @@ EOF
# On unpatched udev versions the delete-recreate cycle may trigger a race
# leading to dead symlinks in /dev/disk/
for ((i = 1; i <= iterations; i++)); do
running=()
for disk in {0..9}; do
if ((disk % 2 == i % 2)); then
udevadm lock --timeout=30 --device="${devices[$disk]}" sfdisk -q --delete "${devices[$disk]}" &
else
udevadm lock --timeout=30 --device="${devices[$disk]}" sfdisk -q -X gpt "${devices[$disk]}" <"$partscript" &
fi
running[$disk]=$!
# shellcheck disable=SC2190
running+=( "$!" )
done
for key in "${!running[@]}"; do
wait "${running[$key]}"
unset "running[$key]"
for j in "${running[@]}"; do
wait "$j"
done
if ((i % 10 <= 1)); then
@ -472,28 +474,36 @@ EOF
done
helper_check_device_units
rm -f "$rule" "$partscript"
# Cleanup and check if unnecessary devlinks are removed.
for disk in {0..9}; do
udevadm lock --timeout="$timeout" --device="${devices[$disk]}" sfdisk -q --delete "${devices[$disk]}" || :
done
udevadm settle --timeout="$timeout"
for ((part = 1; part <= num_part; part++)); do
udevadm wait --timeout=10 --removed "/dev/disk/by-partlabel/test${part}"
done
rm -f "$rule" "$partscript"
udevadm control --reload
}
testcase_simultaneous_events_2() {
local disk expected i iterations key link num_part part script_dir target timeout
local -a devices symlinks
local -A running
local disk i iterations link num_part part script_dir target timeout
local -a devices running
script_dir="$(mktemp --directory "/tmp/test-udev-storage.script.XXXXXXXXXX")"
# shellcheck disable=SC2064
trap "rm -rf '$script_dir'" RETURN
if [[ -v ASAN_OPTIONS || "$(systemd-detect-virt -v)" == "qemu" ]]; then
num_part=20
iterations=1
timeout=2400
else
num_part=100
iterations=3
num_part=10
iterations=2
timeout=300
else
num_part=40
iterations=5
timeout=200
fi
for disk in {0..9}; do
@ -513,37 +523,97 @@ $(for ((part = 1; part <= num_part; part++)); do printf 'name="testlabel-%d", si
EOF
done
ls -l /dev/disk/by-partlabel
echo "## $iterations iterations start: $(date '+%H:%M:%S.%N')"
for ((i = 1; i <= iterations; i++)); do
running=()
for disk in "${devices[@]}"; do
udevadm lock --timeout=30 --device="$disk" \
bash -c "for ((i = 1; i <= $iterations; i++)); do sfdisk -q --delete $disk; sfdisk -q -X gpt $disk <$script_dir/partscript-\$i; done" &
for disk in {0..9}; do
udevadm lock --timeout="$timeout" --device="${devices[$disk]}" sfdisk -q --delete "${devices[$disk]}" &
running[$disk]=$!
done
for key in "${!running[@]}"; do
wait "${running[$key]}"
unset "running[$key]"
done
for disk in {0..9}; do
udevadm lock --timeout="$timeout" --device="${devices[$disk]}" sfdisk -q -X gpt "${devices[$disk]}" <"$script_dir/partscript-$i" &
running[$disk]=$!
done
for key in "${!running[@]}"; do
wait "${running[$key]}"
unset "running[$key]"
done
udevadm wait --settle --timeout="$timeout" "${devices[@]}" "/dev/disk/by-partlabel/testlabel-$i"
# shellcheck disable=SC2190
running+=( "$!" )
done
for i in "${running[@]}"; do
wait "$i"
done
udevadm settle --timeout="$timeout"
echo "## $iterations iterations end: $(date '+%H:%M:%S.%N')"
ls -l /dev/disk/by-partlabel
# Check if unnecessary devlinks are removed.
for ((i = 1; i < iterations; i++)); do
udevadm wait --timeout=10 --removed "/dev/disk/by-partlabel/testlabel-$i"
done
helper_check_device_units
# Cleanup
for disk in "${devices[@]}"; do
udevadm lock --timeout=30 --device="$disk" sfdisk -q --delete "$disk"
done
udevadm settle --timeout="$timeout"
udevadm wait --timeout=10 --removed "/dev/disk/by-partlabel/testlabel-$iterations"
}
testcase_simultaneous_events_3() {
local device i iterations link num_part part script_dir target timeout
# for issue #37823
script_dir="$(mktemp --directory "/tmp/test-udev-storage.script.XXXXXXXXXX")"
# shellcheck disable=SC2064
trap "rm -rf '$script_dir'" RETURN
num_part=5
iterations=30
if [[ -v ASAN_OPTIONS || "$(systemd-detect-virt -v)" == "qemu" ]]; then
timeout=120
else
timeout=60
fi
link="/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_deadbeeftest0"
device="$(readlink -f "$link")"
if [[ ! -b "$device" ]]; then
echo "ERROR: failed to find the test SCSI block device $link"
return 1
fi
for ((i = 1; i <= iterations; i++)); do
cat >"$script_dir/partscript-$i" <<EOF
$(for ((part = 1; part <= num_part; part++)); do printf 'name="test3-%d", size=1M\n' "$i"; done)
EOF
done
ls -l /dev/disk/by-partlabel/
echo "## $iterations iterations start: $(date '+%H:%M:%S.%N')"
udevadm lock --timeout="$timeout" --device="$device" \
bash -c "for ((i = 1; i <= $iterations; i++)); do sfdisk -q -X gpt $device <$script_dir/partscript-\$i; done"
udevadm settle --timeout="$timeout"
echo "## $iterations iterations end: $(date '+%H:%M:%S.%N')"
ls -l /dev/disk/by-partlabel/
# Check devlinks
for ((i = 1; i < iterations; i++)); do
udevadm wait --settle --timeout=10 --removed "/dev/disk/by-partlabel/test3-$i"
done
udevadm wait --settle --timeout=10 "/dev/disk/by-partlabel/test3-$iterations"
# Cleanup and check if the last devlink is removed
udevadm lock --timeout="$timeout" --device="$device" sfdisk -q --delete "$device"
udevadm wait --settle --timeout="$timeout" --removed "/dev/disk/by-partlabel/test3-$iterations"
}
testcase_simultaneous_events() {
testcase_simultaneous_events_1
testcase_simultaneous_events_2
testcase_simultaneous_events_3
}
testcase_lvm_basic() {