/// Prefetch filesystem and file data to improve performance.
///
/// To improve application filesystem access performance, the filesystem may prefetch file or
/// metadata in advance. There are ways to configure the file list to be prefetched.
/// 1. Static file prefetch list configured during image building, recorded in prefetch list
///    in Rafs v5 file system metadata.
///     Base on prefetch table which is persisted to bootstrap when building image.
/// 2. Dynamic file prefetch list configured by command line. The dynamic file prefetch list
///    has higher priority and the static file prefetch list will be ignored if there's dynamic
///    prefetch list. When a directory is specified for dynamic prefetch list, all sub directory
///    and files under the directory will be prefetched.
///
/// Each inode passed into should correspond to directory. And it already does the file type
/// check inside.
Prefetch filesystem and file data to improve performance.
To improve application filesystem access performance, the filesystem may prefetch file or
metadata in advance. There are ways to configure the file list to be prefetched.
1. Static file prefetch list configured during image building, recorded in prefetch list
in Rafs v5 file system metadata.
Base on prefetch table which is persisted to bootstrap when building image.
2. Dynamic file prefetch list configured by command line. The dynamic file prefetch list
has higher priority and the static file prefetch list will be ignored if there's dynamic
prefetch list. When a directory is specified for dynamic prefetch list, all sub directory
and files under the directory will be prefetched.

Each inode passed into should correspond to directory. And it already does the file type
check inside.
Prefetch filesystem and file data to improve performance . To improve application filesystem access performance the filesystem may prefetch file or metadata in advance . There are ways to configure the file list to be prefetched . 1 . Static file prefetch list configured during image building recorded in prefetch list in Rafs v5 file system metadata . Base on prefetch table which is persisted to bootstrap when building image . 2 . Dynamic file prefetch list configured by command line . The dynamic file prefetch list has higher priority and the static file prefetch list will be ignored if there ' s dynamic prefetch list . When a directory is specified for dynamic prefetch list all sub directory and files under the directory will be prefetched . Each inode passed into should correspond to directory . And it already does the file type check inside .
pub fn prefetch_files(
        &self,
        r: &mut RafsIoReader,
        files: Option<Vec<Inode>>,
        fetcher: &dyn Fn(&mut BlobIoVec),
    ) -> RafsResult<()> {
        // Try to prefetch files according to the list specified by the `--prefetch-files` option.
        if let Some(files) = files {
            // Avoid prefetching multiple times for hardlinks to the same file.
            let mut hardlinks: HashSet<u64> = HashSet::new();
            let mut head_desc = BlobIoVec {
                bi_size: 0,
                bi_flags: 0,
                bi_vec: Vec::new(),
            };
            for f_ino in files {
                self.prefetch_data(f_ino, &mut head_desc, &mut hardlinks, fetcher)
                    .map_err(|e| RafsError::Prefetch(e.to_string()))?;
            }
            // Flush the pending prefetch requests.
            fetcher(&mut head_desc);
            Ok(())
        } else if self.meta.is_v5() {
            self.prefetch_data_v5(r, fetcher).map(|_| ())
        } else {
            Err(RafsError::Prefetch(
                "Unknown filesystem version, prefetch disabled".to_string(),
            ))
        }
    }
pub fn prefetch_files ( & self , r : & mut RafsIoReader , files : Option < Vec < Inode > > , fetcher : & dyn Fn ( & mut BlobIoVec ) , ) -> RafsResult < ( ) > { // Try to prefetch files according to the list specified by the `--prefetch-files` option. if let Some ( files ) = files { // Avoid prefetching multiple times for hardlinks to the same file. let mut hardlinks : HashSet < u64 > = HashSet :: new ( ) ; let mut head_desc = BlobIoVec { bi_size : 0 , bi_flags : 0 , bi_vec : Vec :: new ( ) , } ; for f_ino in files { self . prefetch_data ( f_ino , & mut head_desc , & mut hardlinks , fetcher ) . map_err ( | e | RafsError :: Prefetch ( e . to_string ( ) ) ) ? ; } // Flush the pending prefetch requests. fetcher ( & mut head_desc ) ; Ok ( ( ) ) } else if self . meta . is_v5 ( ) { self . prefetch_data_v5 ( r , fetcher ) . map ( | _ | ( ) ) } else { Err ( RafsError :: Prefetch ( " " . to_string ( ) , ) ) } }
Prefetch filesystem and file data to improve performance.
Prefetch filesystem and file data to improve performance .
&self
r
&mut RafsIoReader
files
Option<Vec<Inode>>
fetcher
&dyn Fn(&mut BlobIoVec)