@@ -34,8 +34,9 @@ use crate::{
3434 pool:: { v1, v2, AnyPool } ,
3535 } ,
3636 structures:: {
37- AllLockReadGuard , AllLockWriteGuard , AllOrSomeLock , Lockable , SomeLockReadGuard ,
38- SomeLockWriteGuard , Table ,
37+ AllLockReadAvailableGuard , AllLockReadGuard , AllLockWriteAvailableGuard ,
38+ AllLockWriteGuard , AllOrSomeLock , Lockable , SomeLockReadGuard , SomeLockWriteGuard ,
39+ Table ,
3940 } ,
4041 types:: {
4142 CreateAction , DeleteAction , DevUuid , FilesystemUuid , InputEncryptionInfo ,
@@ -202,10 +203,20 @@ impl StratEngine {
202203 self . pools . read_all ( ) . await
203204 }
204205
206+ pub async fn available_pools ( & self ) -> Option < AllLockReadAvailableGuard < PoolUuid , AnyPool > > {
207+ self . pools . read_all_available ( ) . await
208+ }
209+
205210 pub async fn pools_mut ( & self ) -> AllLockWriteGuard < PoolUuid , AnyPool > {
206211 self . pools . write_all ( ) . await
207212 }
208213
214+ pub async fn available_pools_mut (
215+ & self ,
216+ ) -> Option < AllLockWriteAvailableGuard < PoolUuid , AnyPool > > {
217+ self . pools . write_all_available ( ) . await
218+ }
219+
209220 fn spawn_pool_check_handling (
210221 joins : & mut PoolJoinHandles ,
211222 mut guard : SomeLockWriteGuard < PoolUuid , AnyPool > ,
@@ -720,10 +731,18 @@ impl Engine for StratEngine {
720731 self . pools ( ) . await . into_dyn ( )
721732 }
722733
734+ async fn available_pools ( & self ) -> Option < AllLockReadAvailableGuard < PoolUuid , dyn Pool > > {
735+ self . available_pools ( ) . await . map ( |l| l. into_dyn ( ) )
736+ }
737+
723738 async fn pools_mut ( & self ) -> AllLockWriteGuard < PoolUuid , dyn Pool > {
724739 self . pools_mut ( ) . await . into_dyn ( )
725740 }
726741
742+ async fn available_pools_mut ( & self ) -> Option < AllLockWriteAvailableGuard < PoolUuid , dyn Pool > > {
743+ self . available_pools_mut ( ) . await . map ( |l| l. into_dyn ( ) )
744+ }
745+
727746 async fn get_events ( & self ) -> StratisResult < HashSet < PoolUuid > > {
728747 let device_list: HashMap < _ , _ > = get_dm ( )
729748 . list_devices ( ) ?
0 commit comments