/// Create a pool on base bdev
Create a pool on base bdev
Create a pool on base bdev
pub async fn create<'a>(name: &'a str, disk: &'a str) -> Result<Pool> {
        let base_bdev = match Bdev::lookup_by_name(disk) {
            Some(bdev) => bdev,
            None => {
                return Err(Error::UnknownBdev {
                    name: String::from(disk),
                })
            }
        };
        let pool_name = CString::new(name).unwrap();
        let (sender, receiver) = oneshot::channel::<i32>();
        let rc = unsafe {
            vbdev_lvs_create(
                base_bdev.as_ptr(),
                pool_name.as_ptr(),
                0,
                // We used to clear a pool with UNMAP but that takes awfully
                // long time on large SSDs (~ can take an hour). Clearing the
                // pool is not necessary. Clearing the lvol must be done, but
                // lvols tend to be small so there the overhead is acceptable.
                LVS_CLEAR_WITH_NONE,
                Some(pool_done_cb),
                cb_arg(sender),
            )
        };
        // TODO: free sender
        if rc < 0 {
            return Err(Error::BadCreate {
                name: String::from(name),
            });
        }
        let lvs_errno = receiver.await.expect("Cancellation is not supported");
        if lvs_errno != 0 {
            return Err(Error::FailedCreate {
                name: String::from(name),
                errno: lvs_errno,
            });
        }
        match Pool::lookup(&name) {
            Some(pool) => {
                info!("The pool {} has been created", name);
                Ok(pool)
            }
            None => Err(Error::PoolGone {
                name: String::from(name),
            }),
        }
    }
pub async fn create < ' a > ( name : & ' a str , disk : & ' a str ) -> Result < Pool > { let base_bdev = match Bdev :: lookup_by_name ( disk ) { Some ( bdev ) => bdev , None => { return Err ( Error :: UnknownBdev { name : String :: from ( disk ) , } ) } } ; let pool_name = CString :: new ( name ) . unwrap ( ) ; let ( sender , receiver ) = oneshot :: channel :: < i32 > ( ) ; let rc = unsafe { vbdev_lvs_create ( base_bdev . as_ptr ( ) , pool_name . as_ptr ( ) , 0 , // We used to clear a pool with UNMAP but that takes awfully // long time on large SSDs (~ can take an hour). Clearing the // pool is not necessary. Clearing the lvol must be done, but // lvols tend to be small so there the overhead is acceptable. LVS_CLEAR_WITH_NONE , Some ( pool_done_cb ) , cb_arg ( sender ) , ) } ; // TODO: free sender if rc < 0 { return Err ( Error :: BadCreate { name : String :: from ( name ) , } ) ; } let lvs_errno = receiver . await . expect ( " " ) ; if lvs_errno != 0 { return Err ( Error :: FailedCreate { name : String :: from ( name ) , errno : lvs_errno , } ) ; } match Pool :: lookup ( & name ) { Some ( pool ) => { info ! ( " " name ) ; Ok ( pool ) } None => Err ( Error :: PoolGone { name : String :: from ( name ) , } ) , } }
Create a pool on base bdev
Create a pool on base bdev
name
&'a str
disk
&'a str