Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "stratisd"
version = "3.9.2"
version = "3.10.0"
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
Expand Down
182 changes: 182 additions & 0 deletions src/dbus/blockdev/blockdev_3_10/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
// 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::{
self,
fdo::Error,
interface,
zvariant::{ObjectPath, OwnedObjectPath},
Connection,
};

use crate::dbus::blockdev::blockdev_3_0::{
devnode_prop, hardware_info_prop, init_time_prop, physical_path_prop, pool_prop, tier_prop,
total_physical_size_prop, user_info_prop,
};
use crate::{
dbus::{
blockdev::shared::{blockdev_prop, set_blockdev_prop},
manager::Manager,
},
engine::{DevUuid, Engine, Lockable, PoolUuid},
stratis::StratisResult,
};

use crate::dbus::blockdev::blockdev_3_3::{
new_physical_size_prop, send_user_info_signal_on_change, set_user_info_prop,
};

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

impl BlockdevR10 {
fn new(
engine: Arc<dyn Engine>,
connection: Arc<Connection>,
manager: Lockable<Arc<RwLock<Manager>>>,
parent_uuid: PoolUuid,
uuid: DevUuid,
) -> Self {
BlockdevR10 {
engine,
connection,
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,
Arc::clone(connection),
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::<BlockdevR10, _>(path)
.await?;
Ok(())
}
}

#[interface(name = "org.storage.stratis3.blockdev.r10", introspection_docs = false)]
impl BlockdevR10 {
#[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)]
async fn user_info(&self) -> Result<(bool, String), Error> {
blockdev_prop(&self.engine, self.parent_uuid, self.uuid, user_info_prop).await
}

#[zbus(property)]
async fn set_user_info(&self, value: (bool, String)) -> Result<(), zbus::Error> {
set_blockdev_prop(
&self.engine,
&self.connection,
&self.manager,
self.parent_uuid,
self.uuid,
value,
set_user_info_prop,
send_user_info_signal_on_change,
)
.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) -> String {
self.uuid.simple().to_string()
}

#[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
}

#[zbus(property)]
async fn new_physical_size(&self) -> Result<(bool, String), Error> {
blockdev_prop(
&self.engine,
self.parent_uuid,
self.uuid,
new_physical_size_prop,
)
.await
}
}
15 changes: 15 additions & 0 deletions src/dbus/blockdev/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use crate::{

mod blockdev_3_0;
mod blockdev_3_1;
mod blockdev_3_10;
mod blockdev_3_2;
mod blockdev_3_3;
mod blockdev_3_4;
Expand All @@ -31,6 +32,7 @@ mod shared;

pub use blockdev_3_0::BlockdevR0;
pub use blockdev_3_1::BlockdevR1;
pub use blockdev_3_10::BlockdevR10;
pub use blockdev_3_2::BlockdevR2;
pub use blockdev_3_3::BlockdevR3;
pub use blockdev_3_4::BlockdevR4;
Expand Down Expand Up @@ -173,6 +175,18 @@ pub async fn register_blockdev<'a>(
{
warn!("Failed to register interface blockdev.r9 for pool with UUID {pool_uuid}: {e}");
};
if let Err(e) = BlockdevR10::register(
engine.clone(),
connection,
manager,
path.clone(),
pool_uuid,
dev_uuid,
)
.await
{
warn!("Failed to register interface blockdev.r10 for pool with UUID {pool_uuid}: {e}");
};
manager.write().await.add_blockdev(&path, dev_uuid)?;
Ok(path)
}
Expand All @@ -192,6 +206,7 @@ pub async fn unregister_blockdev(
BlockdevR7::unregister(connection, path.clone()).await?;
BlockdevR8::unregister(connection, path.clone()).await?;
BlockdevR9::unregister(connection, path.clone()).await?;
BlockdevR10::unregister(connection, path.clone()).await?;

let mut lock = manager.write().await;
let uuid = lock
Expand Down
Loading
Loading