pub(crate) fn refresh(&mut self) {
        let nexus = unsafe { Nexus::from_raw(self.device) };
        info!(
            "{}(thread:{:?}), refreshing IO channels",
            nexus.name,
            Mthread::current().unwrap().name(),
        );

        trace!(
            "{}: Current number of IO channels write: {} read: {}",
            nexus.name,
            self.writers.len(),
            self.readers.len(),
        );

        // clear the vector of channels and reset other internal values,
        // clearing the values will drop any existing handles in the
        // channel
        self.writers.clear();
        self.readers.clear();
        self.previous = 0;

        // iterate over all our children which are in the open state
        nexus
            .children
            .iter_mut()
            .filter(|c| c.state() == ChildState::Open)
            .for_each(|c| match (c.handle(), c.handle()) {
                (Ok(w), Ok(r)) => {
                    self.writers.push(w);
                    self.readers.push(r);
                }
                _ => {
                    c.set_state(ChildState::Faulted(Reason::CantOpen));
                    error!("failed to create handle for {}", c);
                }
            });

        // then add write-only children
        if !self.readers.is_empty() {
            nexus
                .children
                .iter_mut()
                .filter(|c| c.rebuilding())
                .for_each(|c| {
                    if let Ok(hdl) = c.handle() {
                        self.writers.push(hdl);
                    } else {
                        c.set_state(ChildState::Faulted(Reason::CantOpen));
                        error!("failed to create handle for {}", c);
                    }
                });
        }

        trace!(
            "{}: New number of IO channels write:{} read:{} out of {} children",
            nexus.name,
            self.writers.len(),
            self.readers.len(),
            nexus.children.len()
        );

        //trace!("{:?}", nexus.children);
    }
/// refreshing our channels simply means that we either have a child going
/// online or offline. We don't know which child has gone, or was added, so
/// we simply put back all the channels, and reopen the bdevs that are in
/// the online state.
refreshing our channels simply means that we either have a child going
online or offline. We don't know which child has gone, or was added, so
we simply put back all the channels, and reopen the bdevs that are in
the online state.
refreshing our channels simply means that we either have a child going online or offline . We don ' t know which child has gone or was added so we simply put back all the channels and reopen the bdevs that are in the online state .
pub(crate) fn refresh(&mut self) {
        let nexus = unsafe { Nexus::from_raw(self.device) };
        info!(
            "{}(thread:{:?}), refreshing IO channels",
            nexus.name,
            Mthread::current().unwrap().name(),
        );
        trace!(
            "{}: Current number of IO channels write: {} read: {}",
            nexus.name,
            self.writers.len(),
            self.readers.len(),
        );
        // clear the vector of channels and reset other internal values,
        // clearing the values will drop any existing handles in the
        // channel
        self.writers.clear();
        self.readers.clear();
        self.previous = 0;
        // iterate over all our children which are in the open state
        nexus
            .children
            .iter_mut()
            .filter(|c| c.state() == ChildState::Open)
            .for_each(|c| match (c.handle(), c.handle()) {
                (Ok(w), Ok(r)) => {
                    self.writers.push(w);
                    self.readers.push(r);
                }
                _ => {
                    c.set_state(ChildState::Faulted(Reason::CantOpen));
                    error!("failed to create handle for {}", c);
                }
            });
        // then add write-only children
        if !self.readers.is_empty() {
            nexus
                .children
                .iter_mut()
                .filter(|c| c.rebuilding())
                .for_each(|c| {
                    if let Ok(hdl) = c.handle() {
                        self.writers.push(hdl);
                    } else {
                        c.set_state(ChildState::Faulted(Reason::CantOpen));
                        error!("failed to create handle for {}", c);
                    }
                });
        }
        trace!(
            "{}: New number of IO channels write:{} read:{} out of {} children",
            nexus.name,
            self.writers.len(),
            self.readers.len(),
            nexus.children.len()
        );
        //trace!("{:?}", nexus.children);
    }
pub ( crate ) fn refresh ( & mut self ) { let nexus = unsafe { Nexus :: from_raw ( self . device ) } ; info ! ( " " nexus name Mthread current ( ) unwrap ( ) name ( ) ) ; trace ! ( " " nexus name self writers len ( ) self readers len ( ) ) ; // clear the vector of channels and reset other internal values, // clearing the values will drop any existing handles in the // channel self . writers . clear ( ) ; self . readers . clear ( ) ; self . previous = 0 ; // iterate over all our children which are in the open state nexus . children . iter_mut ( ) . filter ( | c | c . state ( ) == ChildState :: Open ) . for_each ( | c | match ( c . handle ( ) , c . handle ( ) ) { ( Ok ( w ) , Ok ( r ) ) => { self . writers . push ( w ) ; self . readers . push ( r ) ; } _ => { c . set_state ( ChildState :: Faulted ( Reason :: CantOpen ) ) ; error ! ( " " c ) ; } } ) ; // then add write-only children if ! self . readers . is_empty ( ) { nexus . children . iter_mut ( ) . filter ( | c | c . rebuilding ( ) ) . for_each ( | c | { if let Ok ( hdl ) = c . handle ( ) { self . writers . push ( hdl ) ; } else { c . set_state ( ChildState :: Faulted ( Reason :: CantOpen ) ) ; error ! ( " " c ) ; } } ) ; } trace ! ( " " nexus name self writers len ( ) self readers len ( ) nexus children len ( ) ) ; //trace!("{:?}", nexus.children); }
refreshing our channels simply means that we either have a child going
online or offline.
refreshing our channels simply means that we either have a child going online or offline .
&mut self