44
55use std:: sync:: Arc ;
66
7- use zbus :: { fdo :: Error , interface , zvariant :: ObjectPath , Connection } ;
8-
9- use crate :: {
10- dbus :: blockdev :: shared :: blockdev_prop ,
11- engine :: { DevUuid , Engine , PoolUuid } ,
12- stratis :: StratisResult ,
7+ use tokio :: sync :: RwLock ;
8+ use zbus :: {
9+ fdo :: Error ,
10+ interface ,
11+ zvariant :: { ObjectPath , OwnedObjectPath } ,
12+ Connection ,
1313} ;
1414
1515use crate :: dbus:: blockdev:: blockdev_3_0:: {
1616 devnode_prop, hardware_info_prop, init_time_prop, physical_path_prop, pool_prop, tier_prop,
1717 total_physical_size_prop, user_info_prop,
1818} ;
19+ use crate :: {
20+ dbus:: { blockdev:: shared:: blockdev_prop, manager:: Manager } ,
21+ engine:: { DevUuid , Engine , Lockable , PoolUuid } ,
22+ stratis:: StratisResult ,
23+ } ;
1924
2025use crate :: dbus:: blockdev:: blockdev_3_3:: new_physical_size_prop;
2126
2227pub struct BlockdevR4 {
2328 engine : Arc < dyn Engine > ,
29+ manager : Lockable < Arc < RwLock < Manager > > > ,
2430 parent_uuid : PoolUuid ,
2531 uuid : DevUuid ,
2632}
2733
2834impl BlockdevR4 {
29- fn new ( engine : Arc < dyn Engine > , parent_uuid : PoolUuid , uuid : DevUuid ) -> Self {
35+ fn new (
36+ engine : Arc < dyn Engine > ,
37+ manager : Lockable < Arc < RwLock < Manager > > > ,
38+ parent_uuid : PoolUuid ,
39+ uuid : DevUuid ,
40+ ) -> Self {
3041 BlockdevR4 {
3142 engine,
43+ manager,
3244 parent_uuid,
3345 uuid,
3446 }
@@ -37,11 +49,12 @@ impl BlockdevR4 {
3749 pub async fn register (
3850 engine : Arc < dyn Engine > ,
3951 connection : & Arc < Connection > ,
52+ manager : & Lockable < Arc < RwLock < Manager > > > ,
4053 path : ObjectPath < ' _ > ,
4154 parent_uuid : PoolUuid ,
4255 uuid : DevUuid ,
4356 ) -> StratisResult < ( ) > {
44- let blockdev = Self :: new ( engine, parent_uuid, uuid) ;
57+ let blockdev = Self :: new ( engine, manager . clone ( ) , parent_uuid, uuid) ;
4558
4659 connection. object_server ( ) . at ( path, blockdev) . await ?;
4760 Ok ( ( ) )
@@ -98,8 +111,8 @@ impl BlockdevR4 {
98111
99112 #[ zbus( property( emits_changed_signal = "const" ) ) ]
100113 #[ allow( non_snake_case) ]
101- async fn Pool ( & self ) -> Result < ObjectPath < ' _ > , Error > {
102- blockdev_prop ( & self . engine , self . parent_uuid , self . uuid , pool_prop ) . await
114+ async fn Pool ( & self ) -> Result < OwnedObjectPath , Error > {
115+ pool_prop ( self . manager . read ( ) . await , self . parent_uuid )
103116 }
104117
105118 #[ zbus( property( emits_changed_signal = "const" ) ) ]
0 commit comments