fn prefetch(&self, bios: &mut [RafsBio]) -> Result<usize> {
        let (mut tx, rx) = spmc::channel::<MergedBackendRequest>();
        for num in 0..self.prefetch_worker.threads_count {
            let backend = Arc::clone(&self.backend);
            let rx = rx.clone();
            let _thread = thread::Builder::new()
                .name(format!("prefetch_thread_{}", num))
                .spawn(move || {
                    while let Ok(mr) = rx.recv() {
                        let blob_offset = mr.blob_offset;
                        let blob_size = mr.blob_size;
                        let blob_id = &mr.blob_id;
                        trace!(
                            "Merged req id {} req offset {} size {}",
                            blob_id,
                            blob_offset,
                            blob_size
                        );
                        // Blob id must be unique.
                        // TODO: Currently, request length to backend may span a whole chunk,
                        // Do we need to split it into smaller pieces?
                        if backend
                            .prefetch_blob(blob_id, blob_offset as u32, blob_size)
                            .is_err()
                        {
                            error!(
                                "Readahead from {} for {} bytes failed",
                                blob_offset, blob_size
                            )
                        }
                    }
                    info!("Prefetch thread exits.")
                });
        }

        let mut bios = bios.to_vec();
        let merging_size = self.prefetch_worker.merging_size;
        let _thread = thread::Builder::new().spawn({
            move || {
                generate_merged_requests(bios.as_mut_slice(), &mut tx, merging_size);
            }
        });

        Ok(0)
    }
/// Prefetch works when blobcache is enabled
Prefetch works when blobcache is enabled
Prefetch works when blobcache is enabled
fn prefetch(&self, bios: &mut [RafsBio]) -> Result<usize> {
        let (mut tx, rx) = spmc::channel::<MergedBackendRequest>();
        for num in 0..self.prefetch_worker.threads_count {
            let backend = Arc::clone(&self.backend);
            let rx = rx.clone();
            let _thread = thread::Builder::new()
                .name(format!("prefetch_thread_{}", num))
                .spawn(move || {
                    while let Ok(mr) = rx.recv() {
                        let blob_offset = mr.blob_offset;
                        let blob_size = mr.blob_size;
                        let blob_id = &mr.blob_id;
                        trace!(
                            "Merged req id {} req offset {} size {}",
                            blob_id,
                            blob_offset,
                            blob_size
                        );
                        // Blob id must be unique.
                        // TODO: Currently, request length to backend may span a whole chunk,
                        // Do we need to split it into smaller pieces?
                        if backend
                            .prefetch_blob(blob_id, blob_offset as u32, blob_size)
                            .is_err()
                        {
                            error!(
                                "Readahead from {} for {} bytes failed",
                                blob_offset, blob_size
                            )
                        }
                    }
                    info!("Prefetch thread exits.")
                });
        }
        let mut bios = bios.to_vec();
        let merging_size = self.prefetch_worker.merging_size;
        let _thread = thread::Builder::new().spawn({
            move || {
                generate_merged_requests(bios.as_mut_slice(), &mut tx, merging_size);
            }
        });
        Ok(0)
    }
fn prefetch ( & self , bios : & mut [ RafsBio ] ) -> Result < usize > { let ( mut tx , rx ) = spmc :: channel :: < MergedBackendRequest > ( ) ; for num in 0 .. self . prefetch_worker . threads_count { let backend = Arc :: clone ( & self . backend ) ; let rx = rx . clone ( ) ; let _thread = thread :: Builder :: new ( ) . name ( format ! ( " " num ) ) . spawn ( move | | { while let Ok ( mr ) = rx . recv ( ) { let blob_offset = mr . blob_offset ; let blob_size = mr . blob_size ; let blob_id = & mr . blob_id ; trace ! ( " " blob_id blob_offset blob_size ) ; // Blob id must be unique. // TODO: Currently, request length to backend may span a whole chunk, // Do we need to split it into smaller pieces? if backend . prefetch_blob ( blob_id , blob_offset as u32 , blob_size ) . is_err ( ) { error ! ( " " blob_offset blob_size ) } } info ! ( " " ) } ) ; } let mut bios = bios . to_vec ( ) ; let merging_size = self . prefetch_worker . merging_size ; let _thread = thread :: Builder :: new ( ) . spawn ( { move | | { generate_merged_requests ( bios . as_mut_slice ( ) , & mut tx , merging_size ) ; } } ) ; Ok ( 0 ) }
Prefetch works when blobcache is enabled
Prefetch works when blobcache is enabled
&self
bios
&mut [RafsBio]
&self
bios
&mut [RafsBio]