fn drop()

in rd-agent/src/main.rs [1037:1071]


    fn drop(&mut self) {
        if let Some(iosched) = self.sr_iosched.as_ref() {
            if let Err(e) = set_iosched(&self.scr_dev, iosched) {
                error!("cfg: Failed to restore iosched to {:?} ({:#})", iosched, &e);
            }
        }
        if let Some(wbt) = self.sr_wbt {
            let path = self.sr_wbt_path.as_ref().unwrap();
            info!("cfg: Restoring {:?} to {}", path, wbt);
            if let Err(e) = write_one_line(path, &format!("{}", wbt)) {
                error!("cfg: Failed to restore {:?} ({:#})", &path, &e);
            }
        }
        if let Some(swappiness) = self.sr_swappiness {
            info!("cfg: Restoring swappiness to {}", swappiness);
            if let Err(e) = write_one_line(SWAPPINESS_PATH, &format!("{}", swappiness)) {
                error!("cfg: Failed to restore swappiness ({:#})", &e);
            }
        }
        if let Some(enabled) = self.sr_zswap_enabled {
            info!("cfg: Restoring zswap enabled to {}", enabled);
            if let Err(e) = write_one_line(
                ZSWAP_ENABLED_PATH,
                &format!("{}", if enabled { "Y" } else { "N" }),
            ) {
                error!("cfg: Failed to restore zswap enabled ({:#})", &e);
            }
        }
        if let Some(svc) = &mut self.sr_oomd_sys_svc {
            info!("cfg: Restoring {:?}", &svc.name);
            if let Err(e) = svc.try_start() {
                error!("cfg: Failed to restore {:?} ({:#})", &svc.name, &e);
            }
        }
    }