Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
d565f86
Prototype of Version with zbus
jbaublitz Oct 16, 2025
01f2314
Prototype of udev event handling and pool addition to the D-Bus
jbaublitz Oct 28, 2025
261729b
Prototype of signal handling with zbus
jbaublitz Oct 30, 2025
448b6f0
Prototype of adding filesystems
jbaublitz Oct 30, 2025
d786358
Add ManagerR0 interface
jbaublitz Nov 6, 2025
e5a0773
Add ManagerR1 interface
jbaublitz Nov 14, 2025
5d2a1ae
Add ManagerR2 interface
jbaublitz Nov 18, 2025
0ce1e4a
Add ManagerR3 interface
jbaublitz Nov 20, 2025
b60d6fa
Add ManagerR4 interface
jbaublitz Nov 20, 2025
b92a6a6
Add ManagerR5 interface
jbaublitz Nov 20, 2025
fd59160
Add ManagerR6 interface
jbaublitz Nov 20, 2025
07e0a44
Add ManagerR7 interface
jbaublitz Nov 20, 2025
1a79f60
Add ManagerR8 interface
jbaublitz Nov 20, 2025
200299c
Add ManagerR9 interface
jbaublitz Nov 21, 2025
369c1fd
Refactor error handling in signal dispatch to not return early
jbaublitz Nov 26, 2025
7da1f39
Refactor error handling in Manager registration
jbaublitz Nov 26, 2025
8881862
Add PoolR0 interface
jbaublitz Nov 21, 2025
e87b1a6
Add PoolR1 interface
jbaublitz Dec 16, 2025
e3fe211
Add PoolR2 interface
jbaublitz Dec 16, 2025
2d5ac67
Add PoolR3 interface
jbaublitz Dec 16, 2025
48a9680
Add PoolR4 interface
jbaublitz Dec 16, 2025
c3a4e59
Add PoolR5 interface
jbaublitz Dec 17, 2025
8bbc02b
Add PoolR6 interface
jbaublitz Dec 17, 2025
603c6c3
Add PoolR7 interface
jbaublitz Dec 18, 2025
4f22cf8
Add PoolR8 interface
jbaublitz Dec 18, 2025
d74e0e5
Add PoolR9 interface
jbaublitz Dec 18, 2025
6822d6f
Fix no alloc space signal code
jbaublitz Dec 18, 2025
8b49a6a
Fix snake case naming in Manager interfaces
jbaublitz Dec 18, 2025
44a4d6d
Add forgotten MetadataVersion property
jbaublitz Dec 18, 2025
4228a18
Fix deadlock in destroy_pool method
jbaublitz Dec 18, 2025
c9888ff
Fix deadlock in stop_pool method
jbaublitz Dec 18, 2025
8af143e
Fixes for stopped_pool and locked_pool property and start pool method
jbaublitz Dec 19, 2025
6b5ce0b
Avoid double free in zbus migration
jbaublitz Jan 5, 2026
2bff73c
Fix deadlocks in start and stop pool implementations
jbaublitz Jan 5, 2026
fcadb2c
Fix return values that crash D-Bus socket
jbaublitz Jan 6, 2026
5bba8b1
Implementation of blockdev interfaces
mulkieran Dec 11, 2025
8f6b817
Implementation of filesystem interfaces
mulkieran Dec 11, 2025
dcadd88
Implement Report interfaces
mulkieran Dec 17, 2025
5d3a606
Add blockdev registration to pool registration
mulkieran Dec 11, 2025
49e72fc
Register Report interfaces
mulkieran Dec 17, 2025
5ce44b1
Implement EngineStateReport method on Manager
mulkieran Dec 18, 2025
cc17102
Add blockdev object paths when devices added to pool
mulkieran Dec 22, 2025
cd107c7
Unregister blockdevs at the appropriate times
mulkieran Jan 6, 2026
57e6677
destroy_filesystems: return String types for filesystem UUIDs
mulkieran Jan 7, 2026
07eb2f0
set_name: return String types for filesystem UUIDs
mulkieran Jan 7, 2026
2ac3e9f
set_name: return String types for pool UUIDs
mulkieran Jan 7, 2026
44ff839
Send signal for updated origins on filesystem deletion
jbaublitz Jan 7, 2026
209c941
Add signal handling for SetName on filesystem interfaces
jbaublitz Jan 7, 2026
8557741
Add signal handling for blockdev physical size change on blockdev int…
jbaublitz Jan 7, 2026
86bcaf2
Add signal handling for background filesystem property change signals
jbaublitz Jan 7, 2026
d96361c
Remove legacy D-Bus API
jbaublitz Jan 7, 2026
38ee3b9
Add detail to UUID/object path table collision error messages
mulkieran Jan 8, 2026
1f9f9ee
Unregister filesystem object paths at the appropriate times
mulkieran Jan 8, 2026
ebbea2d
Convert size strings to Bytes for D-Bus
mulkieran Jan 8, 2026
08b418e
Add infrastructure for all_read_available and all_write_availlable
jbaublitz Jun 10, 2025
1e5d089
Add Engine interface for read_all_available and write_all_available
jbaublitz Jun 30, 2025
db6ed2c
Change timer checks to acquire only available pools for write locks
jbaublitz Aug 20, 2025
54bdde9
Add encryption support in V2 crypt handle
jbaublitz Jul 16, 2024
879bc17
Add Engine interface for encrypting pool
jbaublitz Jul 16, 2024
380f8cb
Add D-Bus interface for encrypting pool
jbaublitz Jul 16, 2024
160de2b
Unit test for online encryption
jbaublitz Jan 20, 2025
c66ffc5
Add reencryption support in both crypt handles
jbaublitz Sep 17, 2024
7c95626
Add Engine interface for reencrypting pool
jbaublitz Sep 17, 2024
3dd3491
Add D-Bus interface for reencrypting pool
jbaublitz Sep 17, 2024
b69fe95
Unit test for online reencryption
jbaublitz Feb 4, 2025
5f5b824
Add decryption support in V2 crypt handle
jbaublitz Jan 22, 2025
5dd0176
Add Engine interface for decrypting pool
jbaublitz Jan 30, 2025
d0d2098
Add D-Bus interface for decrypting pool
jbaublitz Feb 3, 2025
9e8e48b
Unit test for online decryption
jbaublitz Feb 12, 2025
9d89853
Perform rollback for setup operations in reencryption
jbaublitz Feb 24, 2025
d33767a
Add last reencrypted timestamp to engine
jbaublitz Apr 29, 2025
de85d69
Update timestamp on successful decryption and reencryption operations
jbaublitz May 1, 2025
7f90fd9
Add reencryption timestamp API to engine
jbaublitz May 1, 2025
7e3ba94
Add property to indicate when the pool was last reencrypted
jbaublitz May 6, 2025
b522174
Add change signal for last encrypted timestamp
jbaublitz May 6, 2025
256c016
Refactor reencryption to use a read lock during operation
jbaublitz Jul 28, 2025
4493269
Add upgrade and downgrade to lock and use in reencryption
jbaublitz Aug 7, 2025
49533c6
Refactor encryption to use a read lock during operation
jbaublitz Aug 7, 2025
7407077
Refactor decryption to use a read lock during operation
jbaublitz Aug 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
660 changes: 568 additions & 92 deletions Cargo.lock

Large diffs are not rendered by default.

17 changes: 7 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ version = "1.2.3"
optional = true

[dependencies.chrono]
version = "0.4.20"
version = "0.4.31"
optional = true
default-features = false
features = ["clock", "std"]
Expand All @@ -100,14 +100,6 @@ optional = true
version = "0.34.4"
optional = true

[dependencies.dbus]
version = "0.9.0"
optional = true

[dependencies.dbus-tree]
version = "0.9.2"
optional = true

[dependencies.either]
version = "1.6.1"
optional = true
Expand Down Expand Up @@ -234,6 +226,11 @@ version = "1.0.0"
optional = true
features = ["serde", "v4"]

[dependencies.zbus]
version = "5.12.0"
optional = true
features = ["tokio"]

[build-dependencies]
pkg-config = "0.3.31"

Expand Down Expand Up @@ -287,7 +284,7 @@ engine = [
"dep:uuid"
]
default = ["dbus_enabled", "engine"]
dbus_enabled = ["dep:dbus", "dep:dbus-tree"]
dbus_enabled = ["dep:zbus"]
extras = ["dep:pretty-hex"]
min = ["dep:termios"]
systemd_compat = ["dep:bindgen"]
Expand Down
53 changes: 53 additions & 0 deletions src/dbus/blockdev/blockdev_3_0/methods.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

use std::sync::Arc;

use crate::{
dbus::{consts::OK_STRING, types::DbusErrorEnum, util::tuple_to_option},
engine::{DevUuid, Engine, PoolIdentifier, PoolUuid, RenameAction},
stratis::StratisError,
};

pub async fn set_user_info_method(
engine: &Arc<dyn Engine>,
uuid: PoolUuid,
bd_uuid: DevUuid,
new_id_spec: (bool, &str),
) -> ((bool, DevUuid), u16, String) {
let default_return = (false, DevUuid::nil());

match engine
.get_mut_pool(PoolIdentifier::Uuid(uuid))
.await
.ok_or_else(|| StratisError::Msg(format!("No pool associated with uuid {uuid}")))
{
Err(err) => (default_return, DbusErrorEnum::ERROR as u16, err.to_string()),
Ok(mut guard) => {
let (pool_name, _, pool) = guard.as_mut_tuple();
match handle_action!(pool.set_blockdev_user_info(
&pool_name,
bd_uuid,
tuple_to_option(new_id_spec)
)) {
Ok(RenameAction::NoSource) => (
default_return,
DbusErrorEnum::ERROR as u16,
format!("pool doesn't know about block device {bd_uuid}"),
),
Ok(RenameAction::Renamed(_)) => (
(true, bd_uuid),
DbusErrorEnum::OK as u16,
OK_STRING.to_string(),
),
Ok(RenameAction::Identity) => (
default_return,
DbusErrorEnum::OK as u16,
OK_STRING.to_string(),
),
Err(err) => (default_return, DbusErrorEnum::ERROR as u16, err.to_string()),
}
}
}
}
149 changes: 149 additions & 0 deletions src/dbus/blockdev/blockdev_3_0/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

use std::sync::Arc;

use tokio::sync::RwLock;
use zbus::{
fdo::Error,
interface,
zvariant::{ObjectPath, OwnedObjectPath},
Connection,
};

use crate::{
dbus::{blockdev::shared::blockdev_prop, manager::Manager},
engine::{DevUuid, Engine, Lockable, PoolUuid},
stratis::StratisResult,
};

mod methods;
mod props;

pub use methods::set_user_info_method;
pub use props::{
devnode_prop, hardware_info_prop, init_time_prop, physical_path_prop, pool_prop, tier_prop,
total_physical_size_prop, user_info_prop,
};

pub struct BlockdevR0 {
engine: Arc<dyn Engine>,
manager: Lockable<Arc<RwLock<Manager>>>,
parent_uuid: PoolUuid,
uuid: DevUuid,
}

impl BlockdevR0 {
fn new(
engine: Arc<dyn Engine>,
manager: Lockable<Arc<RwLock<Manager>>>,
parent_uuid: PoolUuid,
uuid: DevUuid,
) -> Self {
BlockdevR0 {
engine,
manager,
parent_uuid,
uuid,
}
}

pub async fn register(
engine: Arc<dyn Engine>,
connection: &Arc<Connection>,
manager: &Lockable<Arc<RwLock<Manager>>>,
path: ObjectPath<'_>,
parent_uuid: PoolUuid,
uuid: DevUuid,
) -> StratisResult<()> {
let blockdev = Self::new(engine, manager.clone(), parent_uuid, uuid);

connection.object_server().at(path, blockdev).await?;
Ok(())
}

pub async fn unregister(
connection: &Arc<Connection>,
path: ObjectPath<'_>,
) -> StratisResult<()> {
connection
.object_server()
.remove::<BlockdevR0, _>(path)
.await?;
Ok(())
}
}

#[interface(name = "org.storage.stratis3.blockdev.r0", introspection_docs = false)]
impl BlockdevR0 {
#[zbus(out_args("changed", "return_code", "return_string"))]
async fn set_user_info(&self, id: (bool, &str)) -> ((bool, DevUuid), u16, String) {
set_user_info_method(&self.engine, self.parent_uuid, self.uuid, id).await
}

#[zbus(property(emits_changed_signal = "const"))]
async fn devnode(&self) -> Result<String, Error> {
blockdev_prop(&self.engine, self.parent_uuid, self.uuid, devnode_prop).await
}

#[zbus(property(emits_changed_signal = "const"))]
async fn hardware_info(&self) -> Result<(bool, String), Error> {
blockdev_prop(
&self.engine,
self.parent_uuid,
self.uuid,
hardware_info_prop,
)
.await
}

#[zbus(property(emits_changed_signal = "false"))]
async fn user_info(&self) -> Result<(bool, String), Error> {
blockdev_prop(&self.engine, self.parent_uuid, self.uuid, user_info_prop).await
}

#[zbus(property(emits_changed_signal = "const"))]
async fn initialization_time(&self) -> Result<u64, Error> {
blockdev_prop(&self.engine, self.parent_uuid, self.uuid, init_time_prop)
.await
.and_then(|r| r)
}

#[zbus(property(emits_changed_signal = "const"))]
async fn pool(&self) -> Result<OwnedObjectPath, Error> {
pool_prop(self.manager.read().await, self.parent_uuid)
}

#[zbus(property(emits_changed_signal = "const"))]
fn uuid(&self) -> DevUuid {
self.uuid
}

#[zbus(property(emits_changed_signal = "false"))]
async fn tier(&self) -> Result<u16, Error> {
blockdev_prop(&self.engine, self.parent_uuid, self.uuid, tier_prop).await
}

#[zbus(property(emits_changed_signal = "const"))]
async fn physical_path(&self) -> Result<String, Error> {
blockdev_prop(
&self.engine,
self.parent_uuid,
self.uuid,
physical_path_prop,
)
.await
}

#[zbus(property)]
async fn total_physical_size(&self) -> Result<String, Error> {
blockdev_prop(
&self.engine,
self.parent_uuid,
self.uuid,
total_physical_size_prop,
)
.await
}
}
53 changes: 53 additions & 0 deletions src/dbus/blockdev/blockdev_3_0/props.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

use tokio::sync::OwnedRwLockReadGuard;
use zbus::{fdo::Error, zvariant::OwnedObjectPath};

use crate::{
dbus::{util::option_to_tuple, Manager},
engine::{BlockDev, BlockDevTier, DevUuid, PoolUuid, SharedGuard},
};

pub fn devnode_prop(_: BlockDevTier, _: DevUuid, dev: &dyn BlockDev) -> String {
dev.metadata_path().display().to_string()
}

pub fn hardware_info_prop(_: BlockDevTier, _: DevUuid, dev: &dyn BlockDev) -> (bool, String) {
option_to_tuple(dev.hardware_info().map(|s| s.to_owned()), String::new())
}

pub fn init_time_prop(_: BlockDevTier, _: DevUuid, dev: &dyn BlockDev) -> Result<u64, Error> {
u64::try_from(dev.initialization_time().timestamp()).map_err(|e| Error::Failed(e.to_string()))
}

pub fn physical_path_prop(_: BlockDevTier, _: DevUuid, dev: &dyn BlockDev) -> String {
dev.devnode().display().to_string()
}

pub fn pool_prop(
guard: SharedGuard<OwnedRwLockReadGuard<Manager>>,
pool_uuid: PoolUuid,
) -> Result<OwnedObjectPath, Error> {
guard
.pool_get_path(&pool_uuid)
.ok_or_else(|| {
Error::Failed(format!(
"No object path associated with pool UUID {pool_uuid}"
))
})
.cloned()
}

pub fn total_physical_size_prop(_: BlockDevTier, _: DevUuid, dev: &dyn BlockDev) -> String {
(*dev.size().bytes()).to_string()
}

pub fn tier_prop(tier: BlockDevTier, _: DevUuid, _: &dyn BlockDev) -> u16 {
tier as u16
}

pub fn user_info_prop(_: BlockDevTier, _: DevUuid, dev: &dyn BlockDev) -> (bool, String) {
option_to_tuple(dev.user_info().map(|s| s.to_owned()), String::new())
}
Loading
Loading