pub async fn fault_child(
        &mut self,
        name: &str,
        reason: Reason,
    ) -> Result<(), Error> {
        trace!("{}: fault child request for {}", self.name, name);

        if self.child_count < 2 {
            return Err(Error::RemoveLastChild {
                name: self.name.clone(),
                child: name.to_owned(),
            });
        }

        let healthy_children = self
            .children
            .iter()
            .filter(|c| c.state() == ChildState::Open)
            .collect::<Vec<_>>();

        if healthy_children.len() == 1 && healthy_children[0].name == name {
            // the last healthy child cannot be faulted
            return Err(Error::FaultingLastHealthyChild {
                name: self.name.clone(),
                child: name.to_owned(),
            });
        }

        let cancelled_rebuilding_children =
            self.cancel_child_rebuild_jobs(name).await;

        let result = match self.children.iter_mut().find(|c| c.name == name) {
            Some(child) => {
                match child.state() {
                    ChildState::Faulted(_) => {}
                    _ => {
                        child.fault(reason).await;
                        NexusChild::save_state_change();
                        self.reconfigure(DREvent::ChildFault).await;
                    }
                }
                Ok(())
            }
            None => Err(Error::ChildNotFound {
                name: self.name.clone(),
                child: name.to_owned(),
            }),
        };

        // start rebuilding the children that previously had their rebuild jobs
        // cancelled, in spite of whether or not the child was correctly faulted
        self.start_rebuild_jobs(cancelled_rebuilding_children).await;
        result
    }
/// fault a child device and reconfigure the IO channels
fault a child device and reconfigure the IO channels
fault a child device and reconfigure the IO channels
pub async fn fault_child(
        &mut self,
        name: &str,
        reason: Reason,
    ) -> Result<(), Error> {
        trace!("{}: fault child request for {}", self.name, name);
        if self.child_count < 2 {
            return Err(Error::RemoveLastChild {
                name: self.name.clone(),
                child: name.to_owned(),
            });
        }
        let healthy_children = self
            .children
            .iter()
            .filter(|c| c.state() == ChildState::Open)
            .collect::<Vec<_>>();
        if healthy_children.len() == 1 && healthy_children[0].name == name {
            // the last healthy child cannot be faulted
            return Err(Error::FaultingLastHealthyChild {
                name: self.name.clone(),
                child: name.to_owned(),
            });
        }
        let cancelled_rebuilding_children =
            self.cancel_child_rebuild_jobs(name).await;
        let result = match self.children.iter_mut().find(|c| c.name == name) {
            Some(child) => {
                match child.state() {
                    ChildState::Faulted(_) => {}
                    _ => {
                        child.fault(reason).await;
                        NexusChild::save_state_change();
                        self.reconfigure(DREvent::ChildFault).await;
                    }
                }
                Ok(())
            }
            None => Err(Error::ChildNotFound {
                name: self.name.clone(),
                child: name.to_owned(),
            }),
        };
        // start rebuilding the children that previously had their rebuild jobs
        // cancelled, in spite of whether or not the child was correctly faulted
        self.start_rebuild_jobs(cancelled_rebuilding_children).await;
        result
    }
pub async fn fault_child ( & mut self , name : & str , reason : Reason , ) -> Result < ( ) , Error > { trace ! ( " " self name name ) ; if self . child_count < 2 { return Err ( Error :: RemoveLastChild { name : self . name . clone ( ) , child : name . to_owned ( ) , } ) ; } let healthy_children = self . children . iter ( ) . filter ( | c | c . state ( ) == ChildState :: Open ) . collect :: < Vec < _ > > ( ) ; if healthy_children . len ( ) == 1 && healthy_children [ 0 ] . name == name { // the last healthy child cannot be faulted return Err ( Error :: FaultingLastHealthyChild { name : self . name . clone ( ) , child : name . to_owned ( ) , } ) ; } let cancelled_rebuilding_children = self . cancel_child_rebuild_jobs ( name ) . await ; let result = match self . children . iter_mut ( ) . find ( | c | c . name == name ) { Some ( child ) => { match child . state ( ) { ChildState :: Faulted ( _ ) => { } _ => { child . fault ( reason ) . await ; NexusChild :: save_state_change ( ) ; self . reconfigure ( DREvent :: ChildFault ) . await ; } } Ok ( ( ) ) } None => Err ( Error :: ChildNotFound { name : self . name . clone ( ) , child : name . to_owned ( ) , } ) , } ; // start rebuilding the children that previously had their rebuild jobs // cancelled, in spite of whether or not the child was correctly faulted self . start_rebuild_jobs ( cancelled_rebuilding_children ) . await ; result }
fault a child device and reconfigure the IO channels
fault a child device and reconfigure the IO channels
&mut self
name
&str
reason
Reason