pub(crate) fn rafsv5_alloc_bio_vecs<I: RafsInode + RafsV5InodeChunkOps + RafsV5InodeOps>(
    inode: &I,
    offset: u64,
    size: usize,
    user_io: bool,
) -> Result<Vec<BlobIoVec>> {
    let end = offset
        .checked_add(size as u64)
        .ok_or_else(|| einval!("invalid read size"))?;
    let (index_start, index_end) = calculate_bio_chunk_index(
        offset,
        end,
        inode.get_chunk_size() as u64,
        inode.get_child_count(),
        inode.has_hole(),
    );
    trace!(
        "alloc bio desc offset {} size {} i_size {} index_start {} index_end {} i_child_count {}",
        offset,
        size,
        inode.size(),
        index_start,
        index_end,
        inode.get_child_count()
    );
    if size == 0 || index_start >= inode.get_chunk_count() {
        return Ok(vec![]);
    }

    let mut descs = Vec::with_capacity(4);
    let mut desc = BlobIoVec::new();
    let chunk = inode.get_chunk_info_v5(index_start)?;
    let blob = inode.get_blob_by_index(chunk.blob_index())?;
    if !add_chunk_to_bio_desc(&mut desc, offset, end, chunk, blob, user_io) {
        return Err(einval!("failed to create blob io vector"));
    }
    for idx in index_start + 1..index_end {
        let chunk = inode.get_chunk_info_v5(idx)?;
        let blob = inode.get_blob_by_index(chunk.blob_index())?;
        if blob.blob_index() != desc.bi_vec[0].blob.blob_index() {
            descs.push(desc);
            desc = BlobIoVec::new();
        }
        if !add_chunk_to_bio_desc(&mut desc, offset, end, chunk, blob, user_io) {
            return Err(einval!("failed to create blob io vector"));
        }
    }
    descs.push(desc);

    Ok(descs)
}
/// Allocate a group of `BlobIoVec` to handle blob io to range `offset..ofset + size`.
///
/// The range `offset..ofset + size` may be backed by multiple blobs, so a group of `BlobIoVec` will
/// be returned on success, each one covers a continuous range on a single blob.
Allocate a group of `BlobIoVec` to handle blob io to range `offset..ofset + size`.
The range `offset..ofset + size` may be backed by multiple blobs, so a group of `BlobIoVec` will
be returned on success, each one covers a continuous range on a single blob.
Allocate a group of ` BlobIoVec ` to handle blob io to range ` offset .. ofset + size ` . The range ` offset .. ofset + size ` may be backed by multiple blobs so a group of ` BlobIoVec ` will be returned on success each one covers a continuous range on a single blob .
pub(crate) fn rafsv5_alloc_bio_vecs<I: RafsInode + RafsV5InodeChunkOps + RafsV5InodeOps>(
    inode: &I,
    offset: u64,
    size: usize,
    user_io: bool,
) -> Result<Vec<BlobIoVec>> {
    let end = offset
        .checked_add(size as u64)
        .ok_or_else(|| einval!("invalid read size"))?;
    let (index_start, index_end) = calculate_bio_chunk_index(
        offset,
        end,
        inode.get_chunk_size() as u64,
        inode.get_child_count(),
        inode.has_hole(),
    );
    trace!(
        "alloc bio desc offset {} size {} i_size {} index_start {} index_end {} i_child_count {}",
        offset,
        size,
        inode.size(),
        index_start,
        index_end,
        inode.get_child_count()
    );
    if size == 0 || index_start >= inode.get_chunk_count() {
        return Ok(vec![]);
    }
    let mut descs = Vec::with_capacity(4);
    let mut desc = BlobIoVec::new();
    let chunk = inode.get_chunk_info_v5(index_start)?;
    let blob = inode.get_blob_by_index(chunk.blob_index())?;
    if !add_chunk_to_bio_desc(&mut desc, offset, end, chunk, blob, user_io) {
        return Err(einval!("failed to create blob io vector"));
    }
    for idx in index_start + 1..index_end {
        let chunk = inode.get_chunk_info_v5(idx)?;
        let blob = inode.get_blob_by_index(chunk.blob_index())?;
        if blob.blob_index() != desc.bi_vec[0].blob.blob_index() {
            descs.push(desc);
            desc = BlobIoVec::new();
        }
        if !add_chunk_to_bio_desc(&mut desc, offset, end, chunk, blob, user_io) {
            return Err(einval!("failed to create blob io vector"));
        }
    }
    descs.push(desc);
    Ok(descs)
}
pub ( crate ) fn rafsv5_alloc_bio_vecs < I : RafsInode + RafsV5InodeChunkOps + RafsV5InodeOps > ( inode : & I , offset : u64 , size : usize , user_io : bool , ) -> Result < Vec < BlobIoVec > > { let end = offset . checked_add ( size as u64 ) . ok_or_else ( | | einval ! ( " " ) ) ? ; let ( index_start , index_end ) = calculate_bio_chunk_index ( offset , end , inode . get_chunk_size ( ) as u64 , inode . get_child_count ( ) , inode . has_hole ( ) , ) ; trace ! ( " " offset size inode size ( ) index_start index_end inode get_child_count ( ) ) ; if size == 0 || index_start >= inode . get_chunk_count ( ) { return Ok ( vec ! [ ] ) ; } let mut descs = Vec :: with_capacity ( 4 ) ; let mut desc = BlobIoVec :: new ( ) ; let chunk = inode . get_chunk_info_v5 ( index_start ) ? ; let blob = inode . get_blob_by_index ( chunk . blob_index ( ) ) ? ; if ! add_chunk_to_bio_desc ( & mut desc , offset , end , chunk , blob , user_io ) { return Err ( einval ! ( " " ) ) ; } for idx in index_start + 1 .. index_end { let chunk = inode . get_chunk_info_v5 ( idx ) ? ; let blob = inode . get_blob_by_index ( chunk . blob_index ( ) ) ? ; if blob . blob_index ( ) != desc . bi_vec [ 0 ] . blob . blob_index ( ) { descs . push ( desc ) ; desc = BlobIoVec :: new ( ) ; } if ! add_chunk_to_bio_desc ( & mut desc , offset , end , chunk , blob , user_io ) { return Err ( einval ! ( " " ) ) ; } } descs . push ( desc ) ; Ok ( descs ) }
Allocate a group of `BlobIoVec` to handle blob io to range `offset..ofset + size`.
Allocate a group of ` BlobIoVec ` to handle blob io to range ` offset .. ofset + size ` .
inode
&I
offset
u64
size
usize
user_io
bool
inode
&I
offset
u64
size
usize
user_io
bool