async fn start_rebuilds(&self) {
        if let Some(nexuses) = self.nexus_bdevs.as_ref() {
            for nexus in nexuses {
                if let Some(nexus_instance) =
                    instances().iter().find(|n| n.name == nexus.name)
                {
                    let degraded_children: Vec<&NexusChild> = nexus_instance
                        .children
                        .iter()
                        .filter(|child| {
                            child.state()
                                == ChildState::Faulted(Reason::OutOfSync)
                        })
                        .collect::<Vec<_>>();

                    // Get a mutable reference to the nexus instance. We can't
                    // do this when we first get the nexus instance (above)
                    // because it would cause multiple mutable borrows.
                    // We use "expect" here because we have already checked that
                    // the nexus exists above so we don't expect this to fail.
                    let nexus_instance = instances()
                        .iter_mut()
                        .find(|n| n.name == nexus.name)
                        .expect("Failed to find nexus");

                    for child in degraded_children {
                        dbg!("Start rebuilding child {}", &child.name);
                        if nexus_instance
                            .start_rebuild(&child.name)
                            .await
                            .is_err()
                        {
                            error!("Failed to start rebuild for {}", child);
                        }
                    }
                }
            }
        }
    }
/// start rebuilding any child that is in the degraded state
start rebuilding any child that is in the degraded state
start rebuilding any child that is in the degraded state
async fn start_rebuilds(&self) {
        if let Some(nexuses) = self.nexus_bdevs.as_ref() {
            for nexus in nexuses {
                if let Some(nexus_instance) =
                    instances().iter().find(|n| n.name == nexus.name)
                {
                    let degraded_children: Vec<&NexusChild> = nexus_instance
                        .children
                        .iter()
                        .filter(|child| {
                            child.state()
                                == ChildState::Faulted(Reason::OutOfSync)
                        })
                        .collect::<Vec<_>>();
                    // Get a mutable reference to the nexus instance. We can't
                    // do this when we first get the nexus instance (above)
                    // because it would cause multiple mutable borrows.
                    // We use "expect" here because we have already checked that
                    // the nexus exists above so we don't expect this to fail.
                    let nexus_instance = instances()
                        .iter_mut()
                        .find(|n| n.name == nexus.name)
                        .expect("Failed to find nexus");
                    for child in degraded_children {
                        dbg!("Start rebuilding child {}", &child.name);
                        if nexus_instance
                            .start_rebuild(&child.name)
                            .await
                            .is_err()
                        {
                            error!("Failed to start rebuild for {}", child);
                        }
                    }
                }
            }
        }
    }
async fn start_rebuilds ( & self ) { if let Some ( nexuses ) = self . nexus_bdevs . as_ref ( ) { for nexus in nexuses { if let Some ( nexus_instance ) = instances ( ) . iter ( ) . find ( | n | n . name == nexus . name ) { let degraded_children : Vec < & NexusChild > = nexus_instance . children . iter ( ) . filter ( | child | { child . state ( ) == ChildState :: Faulted ( Reason :: OutOfSync ) } ) . collect :: < Vec < _ > > ( ) ; // Get a mutable reference to the nexus instance. We can't // do this when we first get the nexus instance (above) // because it would cause multiple mutable borrows. // We use "expect" here because we have already checked that // the nexus exists above so we don't expect this to fail. let nexus_instance = instances ( ) . iter_mut ( ) . find ( | n | n . name == nexus . name ) . expect ( " " ) ; for child in degraded_children { dbg ! ( " " child name ) ; if nexus_instance . start_rebuild ( & child . name ) . await . is_err ( ) { error ! ( " " child ) ; } } } } } }
start rebuilding any child that is in the degraded state
start rebuilding any child that is in the degraded state
&self