pub(crate) fn gc_pages(
        &self,
        mut leftmost_chain: Vec<PageId>,
    ) -> Result<(), ()> {
        let guard = pin();

        while let Some(mut pid) = leftmost_chain.pop() {
            loop {
                let get_cursor = self
                    .context
                    .pagecache
                    .get(pid, &guard)
                    .map_err(|e| e.danger_cast())?;

                let (node, key) = match get_cursor {
                    PageGet::Materialized(node, key) => {
                        (node, key)
                    }
                    PageGet::Free(_) => {
                        error!("encountered Free node while GC'ing tree");
                        break;
                    }
                    broken => {
                        return Err(Error::ReportableBug(format!(
                            "got non-base node while GC'ing tree: {:?}",
                            broken
                        )))
                    }
                };

                let ret = self.context.pagecache.free(
                    pid,
                    key.clone(),
                    &guard,
                );

                match ret {
                    Ok(_) => {
                        let next_pid =
                            node.unwrap_base().next.unwrap_or(0);
                        if next_pid == 0 {
                            break;
                        }
                        assert_ne!(pid, next_pid);
                        pid = next_pid;
                    }
                    Err(Error::CasFailed(_k)) => continue,
                    Err(other) => return Err(other.danger_cast()),
                }
            }
        }

        Ok(())
    }
// Remove all pages for this tree from the underlying
// PageCache. This will leave orphans behind if
// the tree crashes during gc.
Remove all pages for this tree from the underlying
PageCache. This will leave orphans behind if
the tree crashes during gc.
Remove all pages for this tree from the underlying PageCache . This will leave orphans behind if the tree crashes during gc .
pub(crate) fn gc_pages(
        &self,
        mut leftmost_chain: Vec<PageId>,
    ) -> Result<(), ()> {
        let guard = pin();
        while let Some(mut pid) = leftmost_chain.pop() {
            loop {
                let get_cursor = self
                    .context
                    .pagecache
                    .get(pid, &guard)
                    .map_err(|e| e.danger_cast())?;
                let (node, key) = match get_cursor {
                    PageGet::Materialized(node, key) => {
                        (node, key)
                    }
                    PageGet::Free(_) => {
                        error!("encountered Free node while GC'ing tree");
                        break;
                    }
                    broken => {
                        return Err(Error::ReportableBug(format!(
                            "got non-base node while GC'ing tree: {:?}",
                            broken
                        )))
                    }
                };
                let ret = self.context.pagecache.free(
                    pid,
                    key.clone(),
                    &guard,
                );
                match ret {
                    Ok(_) => {
                        let next_pid =
                            node.unwrap_base().next.unwrap_or(0);
                        if next_pid == 0 {
                            break;
                        }
                        assert_ne!(pid, next_pid);
                        pid = next_pid;
                    }
                    Err(Error::CasFailed(_k)) => continue,
                    Err(other) => return Err(other.danger_cast()),
                }
            }
        }
        Ok(())
    }
pub ( crate ) fn gc_pages ( & self , mut leftmost_chain : Vec < PageId > , ) -> Result < ( ) , ( ) > { let guard = pin ( ) ; while let Some ( mut pid ) = leftmost_chain . pop ( ) { loop { let get_cursor = self . context . pagecache . get ( pid , & guard ) . map_err ( | e | e . danger_cast ( ) ) ? ; let ( node , key ) = match get_cursor { PageGet :: Materialized ( node , key ) => { ( node , key ) } PageGet :: Free ( _ ) => { error ! ( " " ) ; break ; } broken => { return Err ( Error :: ReportableBug ( format ! ( " " broken ) ) ) } } ; let ret = self . context . pagecache . free ( pid , key . clone ( ) , & guard , ) ; match ret { Ok ( _ ) => { let next_pid = node . unwrap_base ( ) . next . unwrap_or ( 0 ) ; if next_pid == 0 { break ; } assert_ne ! ( pid next_pid ) ; pid = next_pid ; } Err ( Error :: CasFailed ( _k ) ) => continue , Err ( other ) => return Err ( other . danger_cast ( ) ) , } } } Ok ( ( ) ) }
Remove all pages for this tree from the underlying
PageCache.
Remove all pages for this tree from the underlying PageCache .
&self
leftmost_chain
Vec<PageId>
&self
leftmost_chain
Vec<PageId>