/// Wrapper for create aio or uring bdev C function
Wrapper for create aio or uring bdev C function
Wrapper for create aio or uring bdev C function
pub fn create_base_bdev(
    file: &str,
    block_size: u32,
    io_if: PoolIoIf,
) -> Result<()> {
    let (mut do_uring, must_uring) = match io_if {
        PoolIoIf::PoolIoAuto => (true, false),
        PoolIoIf::PoolIoAio => (false, false),
        PoolIoIf::PoolIoUring => (true, true),
    };
    if do_uring && !uring_util::kernel_support() {
        if must_uring {
            return Err(Error::UringUnsupported);
        } else {
            warn!("Uring not supported by kernel, falling back to aio for bdev {}", file);
            do_uring = false;
        }
    }
    let bdev_type = if !do_uring {
        ("aio", "AIO")
    } else {
        ("uring", "Uring")
    };
    debug!("Creating {} bdev {} ...", bdev_type.0, file);
    let cstr_file = CString::new(file).unwrap();
    let rc = if !do_uring {
        unsafe {
            create_aio_bdev(cstr_file.as_ptr(), cstr_file.as_ptr(), block_size)
        }
    } else if unsafe {
        create_uring_bdev(cstr_file.as_ptr(), cstr_file.as_ptr(), block_size)
            .is_null()
    } {
        -1
    } else {
        0
    };
    if rc != 0 {
        Err(Error::BadBdev {
            bdev_if: bdev_type.1.to_string(),
            name: String::from(file),
        })
    } else {
        info!("{} bdev {} was created", bdev_type.0, file);
        Ok(())
    }
}
pub fn create_base_bdev ( file : & str , block_size : u32 , io_if : PoolIoIf , ) -> Result < ( ) > { let ( mut do_uring , must_uring ) = match io_if { PoolIoIf :: PoolIoAuto => ( true , false ) , PoolIoIf :: PoolIoAio => ( false , false ) , PoolIoIf :: PoolIoUring => ( true , true ) , } ; if do_uring && ! uring_util :: kernel_support ( ) { if must_uring { return Err ( Error :: UringUnsupported ) ; } else { warn ! ( " " file ) ; do_uring = false ; } } let bdev_type = if ! do_uring { ( " " , " " ) } else { ( " " , " " ) } ; debug ! ( " " bdev_type 0 file ) ; let cstr_file = CString :: new ( file ) . unwrap ( ) ; let rc = if ! do_uring { unsafe { create_aio_bdev ( cstr_file . as_ptr ( ) , cstr_file . as_ptr ( ) , block_size ) } } else if unsafe { create_uring_bdev ( cstr_file . as_ptr ( ) , cstr_file . as_ptr ( ) , block_size ) . is_null ( ) } { - 1 } else { 0 } ; if rc != 0 { Err ( Error :: BadBdev { bdev_if : bdev_type . 1 . to_string ( ) , name : String :: from ( file ) , } ) } else { info ! ( " " bdev_type 0 file ) ; Ok ( ( ) ) } }
Wrapper for create aio or uring bdev C function
Wrapper for create aio or uring bdev C function
file
&str
block_size
u32
io_if
PoolIoIf