public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/stratisd] f45: Update #4110 backport to today's state
@ 2026-10-28 17:09 Adam Williamson
0 siblings, 0 replies; only message in thread
From: Adam Williamson @ 2026-10-28 17:09 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/stratisd
Branch : f45
Commit : 733325d6c9c01cc6d28673947edc6682dee9215f
Author : Adam Williamson <adamwill@fedoraproject.org>
Date : 2026-10-28T10:08:45-07:00
Stats : +203/-6 in 5 file(s)
URL : https://src.fedoraproject.org/rpms/stratisd/c/733325d6c9c01cc6d28673947edc6682dee9215f?branch=f45
Log:
Update #4110 backport to today's state
---
diff --git a/0001-Add-infinite-timeout-to-systemd-ask-password.patch b/0001-Add-infinite-timeout-to-systemd-ask-password.patch
index 3b486e9..8792eba 100644
--- a/0001-Add-infinite-timeout-to-systemd-ask-password.patch
+++ b/0001-Add-infinite-timeout-to-systemd-ask-password.patch
@@ -1,7 +1,7 @@
-From bc7bbebee92af29db222f9679d4f87bc8e11c84b Mon Sep 17 00:00:00 2001
+From 8e169a21b62707f873239bdacc4b3f9c062eac33 Mon Sep 17 00:00:00 2001
From: John Baublitz <jbaublitz@redhat.com>
Date: Thu, 22 Oct 2026 23:20:00 -0400
-Subject: [PATCH 1/3] Add infinite timeout to systemd-ask-password
+Subject: [PATCH 1/4] Add infinite timeout to systemd-ask-password
---
dracut/50stratis/stratis-rootfs-setup | 2 +-
diff --git a/0002-Add-stratis-min-pool-all-devices-present-command.patch b/0002-Add-stratis-min-pool-all-devices-present-command.patch
index 8a15f87..a1c82a3 100644
--- a/0002-Add-stratis-min-pool-all-devices-present-command.patch
+++ b/0002-Add-stratis-min-pool-all-devices-present-command.patch
@@ -1,7 +1,7 @@
-From d7057148388a1e93ebcf05d1b8cd81d0b5e4b111 Mon Sep 17 00:00:00 2001
+From b5604bcd49e432b6d92dd33676c7e4c53815ebb9 Mon Sep 17 00:00:00 2001
From: John Baublitz <jbaublitz@redhat.com>
Date: Mon, 26 Oct 2026 13:54:02 -0400
-Subject: [PATCH 2/3] Add stratis-min pool all-devices-present command
+Subject: [PATCH 2/4] Add stratis-min pool all-devices-present command
Add a stratis-min command and stratisd-min JSON-RPC request that report
whether all devices recorded in a pool's metadata have been found. Pools
diff --git a/0003-Wait-for-all-pool-devices-in-dracut-and-systemd-setu.patch b/0003-Wait-for-all-pool-devices-in-dracut-and-systemd-setu.patch
index 6759dbd..2ede3cd 100644
--- a/0003-Wait-for-all-pool-devices-in-dracut-and-systemd-setu.patch
+++ b/0003-Wait-for-all-pool-devices-in-dracut-and-systemd-setu.patch
@@ -1,7 +1,7 @@
-From c1c35dd5b3ffc4ca3eb4eab2073327b7bdb47e5c Mon Sep 17 00:00:00 2001
+From 871024e487d4623a747cdceeaed71bd82bd68186 Mon Sep 17 00:00:00 2001
From: John Baublitz <jbaublitz@redhat.com>
Date: Mon, 26 Oct 2026 14:10:19 -0400
-Subject: [PATCH 3/3] Wait for all pool devices in dracut and systemd setup
+Subject: [PATCH 3/4] Wait for all pool devices in dracut and systemd setup
scripts
Use stratis-min pool all-devices-present instead of is-stopped when
diff --git a/0004-Start-udev-monitor-before-engine-device-enumeration.patch b/0004-Start-udev-monitor-before-engine-device-enumeration.patch
new file mode 100644
index 0000000..9a87969
--- /dev/null
+++ b/0004-Start-udev-monitor-before-engine-device-enumeration.patch
@@ -0,0 +1,196 @@
+From c0c51a5335d449606d42d23e84ae9d600cdaa82b Mon Sep 17 00:00:00 2001
+From: John Baublitz <jbaublitz@redhat.com>
+Date: Wed, 28 Oct 2026 10:32:45 -0400
+Subject: [PATCH 4/4] Start udev monitor before engine device enumeration
+
+Previously a device event could fall between engine enumeration and the
+start of udev monitoring and be missed. The udev thread is now started
+first and the engine waits for it to signal readiness before enumerating
+devices.
+
+Assisted-by: Claude Code/claude-sonnet-5-5
+---
+ src/engine/strat_engine/engine.rs | 25 +++++++++++++--
+ src/stratis/run.rs | 52 +++++++++++++++++++++----------
+ src/stratis/udev_monitor.rs | 8 +++++
+ 3 files changed, 66 insertions(+), 19 deletions(-)
+
+diff --git a/src/engine/strat_engine/engine.rs b/src/engine/strat_engine/engine.rs
+index cef4b402..48c2c61d 100644
+--- a/src/engine/strat_engine/engine.rs
++++ b/src/engine/strat_engine/engine.rs
+@@ -13,7 +13,7 @@ use async_trait::async_trait;
+ use futures::{executor::block_on, future::join_all};
+ use serde_json::Value;
+ use tokio::{
+- sync::{mpsc, RwLock},
++ sync::{mpsc, oneshot, RwLock},
+ task::{spawn_blocking, JoinHandle},
+ };
+
+@@ -82,10 +82,23 @@ impl StratEngine {
+ /// Returns an error if the kernel doesn't support required DM features.
+ /// Returns an error if there was an error reading device nodes.
+ /// Returns an error if the executables on which it depends can not be found.
+- pub fn initialize(sender: mpsc::UnboundedSender<KeyDescription>) -> StratisResult<StratEngine> {
++ /// Returns an error if the udev monitor failed to start.
++ ///
++ /// Blocks until `udev_ready` signals that the udev monitor is listening,
++ /// so that no device event can fall between device enumeration and the
++ /// start of monitoring. This must not be called from an async context
++ /// without `spawn_blocking`.
++ pub fn initialize_after_udev(
++ sender: mpsc::UnboundedSender<KeyDescription>,
++ udev_ready: oneshot::Receiver<()>,
++ ) -> StratisResult<StratEngine> {
+ let fs = MemoryFilesystem::new()?;
+ verify_executables()?;
+
++ udev_ready.blocking_recv().map_err(|_| {
++ StratisError::Msg("udev monitor failed to start; can not enumerate devices".to_string())
++ })?;
++
+ let mut liminal_devices = LiminalDevices::default();
+ let mut pools = Table::default();
+ for (pool_name, pool_uuid, pool) in liminal_devices.setup_pools(find_all()?) {
+@@ -101,6 +114,14 @@ impl StratEngine {
+ })
+ }
+
++ /// Setup a StratEngine without waiting on a udev monitor.
++ #[cfg(test)]
++ pub fn initialize(sender: mpsc::UnboundedSender<KeyDescription>) -> StratisResult<StratEngine> {
++ let (ready, udev_ready) = oneshot::channel();
++ let _ = ready.send(());
++ StratEngine::initialize_after_udev(sender, udev_ready)
++ }
++
+ #[cfg(test)]
+ pub(crate) async fn create_pool_legacy(
+ &self,
+diff --git a/src/stratis/run.rs b/src/stratis/run.rs
+index 07292ea3..1f345049 100644
+--- a/src/stratis/run.rs
++++ b/src/stratis/run.rs
+@@ -13,8 +13,9 @@ use tokio::{
+ runtime::Builder,
+ select, signal,
+ sync::{
+- broadcast::channel,
++ broadcast::{self, channel},
+ mpsc::{self, unbounded_channel},
++ oneshot,
+ },
+ task,
+ };
+@@ -93,13 +94,18 @@ pub fn run(sim: bool) -> StratisResult<()> {
+ })
+ .build()?;
+ runtime.block_on(async move {
+- async fn start_threads(engine: Arc<dyn Engine>, sim: bool, key_recv: Option<mpsc::UnboundedReceiver<KeyDescription>>) -> StratisResult<()> {
+- let (trigger, should_exit) = channel(1);
+- let (udev_sender, udev_receiver) = unbounded_channel::<UdevEngineEvent>();
++ async fn start_threads(
++ engine: Arc<dyn Engine>,
++ sim: bool,
++ key_recv: Option<mpsc::UnboundedReceiver<KeyDescription>>,
++ join_udev: task::JoinHandle<StratisResult<()>>,
++ udev_receiver: mpsc::UnboundedReceiver<UdevEngineEvent>,
++ trigger: broadcast::Sender<()>,
++ ) -> StratisResult<()> {
+ #[cfg(feature = "dbus_enabled")]
+ let (connection, udev, manager) = create_dbus_handler(Arc::clone(&engine), udev_receiver).await?;
+
+- let join_udev = udev_thread(udev_sender, should_exit);
++ let join_udev = async move { join_udev.await? };
+ #[cfg(feature = "dbus_enabled")]
+ let join_ipc = setup(
+ Arc::clone(&engine),
+@@ -180,23 +186,35 @@ pub fn run(sim: bool) -> StratisResult<()> {
+ }
+
+ info!("stratis daemon version {VERSION} started");
++
++ // The udev thread is started before the engine so that the udev monitor
++ // is listening before the engine enumerates devices; the engine blocks
++ // on udev_ready until then. Engine initialization otherwise runs in
++ // parallel with udev monitor setup. If engine initialization fails,
++ // returning drops trigger, which notifies the udev thread to exit.
++ let (trigger, should_exit) = channel(1);
++ let (udev_sender, udev_receiver) = unbounded_channel::<UdevEngineEvent>();
++ let (ready, udev_ready) = oneshot::channel();
++ let join_udev = task::spawn(udev_thread(udev_sender, ready, should_exit));
++
+ if sim {
+ info!("Using SimEngine");
+- start_threads(Arc::new(SimEngine::default()), sim, None).await
++ start_threads(Arc::new(SimEngine::default()), sim, None, join_udev, udev_receiver, trigger).await
+ } else {
+ info!("Using StratEngine");
+ let (sender, recv) = unbounded_channel();
+- start_threads(
+- Arc::new(match StratEngine::initialize(sender) {
+- Ok(engine) => engine,
+- Err(e) => {
+- error!("Failed to start up stratisd engine: {e}; exiting");
+- return Err(e);
+- }
+- }),
+- sim,
+- Some(recv),
+- ).await
++ let engine = match task::spawn_blocking(move || {
++ StratEngine::initialize_after_udev(sender, udev_ready)
++ })
++ .await?
++ {
++ Ok(engine) => engine,
++ Err(e) => {
++ error!("Failed to start up stratisd engine: {e}; exiting");
++ return Err(e);
++ }
++ };
++ start_threads(Arc::new(engine), sim, Some(recv), join_udev, udev_receiver, trigger).await
+ }
+ })?;
+ Ok(())
+diff --git a/src/stratis/udev_monitor.rs b/src/stratis/udev_monitor.rs
+index cd0eb9de..47c279f3 100644
+--- a/src/stratis/udev_monitor.rs
++++ b/src/stratis/udev_monitor.rs
+@@ -12,6 +12,7 @@ use tokio::{
+ sync::{
+ broadcast::{error::TryRecvError, Receiver},
+ mpsc::UnboundedSender,
++ oneshot,
+ },
+ task::spawn_blocking,
+ };
+@@ -23,17 +24,24 @@ use crate::{
+
+ // Poll for udev events.
+ // Check for exit condition and return if true.
++// Signals on ready once the monitor is listening. If setup fails, ready is
++// dropped without a signal so that the receiver observes the failure.
+ pub async fn udev_thread(
+ sender: UnboundedSender<UdevEngineEvent>,
++ ready: oneshot::Sender<()>,
+ mut should_exit: Receiver<()>,
+ ) -> StratisResult<()> {
+ spawn_blocking(move || {
+ let context = libudev::Context::new()?;
+ let mut udev = UdevMonitor::create(&context)?;
+
++ // The receiver is gone only if the engine already failed to start,
++ // in which case the error is reported there.
++ let _ = ready.send(());
+
+ loop {
+ let mut pollers = [PollFd::new(udev.as_fd(), PollFlags::POLLIN)];
++
+ match poll(&mut pollers, 100u8)? {
+ 0 => {
+ match should_exit.try_recv() {
+--
+2.56.0
+
diff --git a/stratisd.spec b/stratisd.spec
index 58540c3..aa01cc3 100644
--- a/stratisd.spec
+++ b/stratisd.spec
@@ -22,6 +22,7 @@ Patch: 0001-Add-infinite-timeout-to-systemd-ask-password.patch
# Wait for all pool devices before attempting decryption
Patch: 0002-Add-stratis-min-pool-all-devices-present-command.patch
Patch: 0003-Wait-for-all-pool-devices-in-dracut-and-systemd-setu.patch
+Patch: 0004-Start-udev-monitor-before-engine-device-enumeration.patch
%if 0%{?rhel}
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-28 17:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-28 17:09 [rpms/stratisd] f45: Update #4110 backport to today's state Adam Williamson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox