FreeBSD/contrib/subversion/subversion/libsvn_fs_fs/index.c
/* Using the log-to-phys indexes in FS, find the absolute offset in the
 * rev file for (REVISION, ITEM_INDEX) and return it in *OFFSET.
 * Use SCRATCH_POOL for temporary allocations.
 */
Using the log-to-phys indexes in FS, find the absolute offset in the
rev file for (REVISION, ITEM_INDEX) and return it in *OFFSET.
Use SCRATCH_POOL for temporary allocations.
Using the log - to - phys indexes in FS find the absolute offset in the rev file for ( REVISION ITEM_INDEX ) and return it in * OFFSET . Use SCRATCH_POOL for temporary allocations .
static svn_error_t *
l2p_index_lookup(apr_off_t *offset,
                 svn_fs_t *fs,
                 svn_fs_fs__revision_file_t *rev_file,
                 svn_revnum_t revision,
                 apr_uint64_t item_index,
                 apr_pool_t *scratch_pool)
{
  fs_fs_data_t *ffd = fs->fsap_data;
  l2p_page_info_baton_t info_baton;
  l2p_entry_baton_t page_baton;
  l2p_page_t *page = NULL;
  svn_fs_fs__page_cache_key_t key = { 0 };
  svn_boolean_t is_cached = FALSE;
  void *dummy = NULL;
  info_baton.revision = revision;
  info_baton.item_index = item_index;
  SVN_ERR(get_l2p_page_info(&info_baton, rev_file, fs, scratch_pool));
  page_baton.revision = revision;
  page_baton.item_index = item_index;
  page_baton.page_offset = info_baton.page_offset;
  assert(revision <= APR_UINT32_MAX);
  key.revision = (apr_uint32_t)revision;
  key.is_packed = svn_fs_fs__is_packed_rev(fs, revision);
  key.page = info_baton.page_no;
  SVN_ERR(svn_cache__get_partial(&dummy, &is_cached,
                                 ffd->l2p_page_cache, &key,
                                 l2p_entry_access_func, &page_baton,
                                 scratch_pool));
  if (!is_cached)
    {
      apr_array_header_t *pages;
      svn_revnum_t prefetch_revision;
      svn_revnum_t last_revision
        = info_baton.first_revision
          + (key.is_packed ? ffd->max_files_per_dir : 1);
      svn_boolean_t end;
      apr_off_t max_offset
        = APR_ALIGN(info_baton.entry.offset + info_baton.entry.size,
                    ffd->block_size);
      apr_off_t min_offset = max_offset - ffd->block_size;
      SVN_ERR(get_l2p_page(&page, rev_file, fs, info_baton.first_revision,
                           &info_baton.entry, scratch_pool));
      SVN_ERR(svn_cache__set(ffd->l2p_page_cache, &key, page, scratch_pool));
      SVN_ERR(l2p_page_get_entry(&page_baton, page, page->offsets,
                                 scratch_pool));
      if (ffd->use_block_read)
        {
          apr_pool_t *iterpool = svn_pool_create(scratch_pool);
          pages = apr_array_make(scratch_pool, 16,
                                 sizeof(l2p_page_table_entry_t));
          end = FALSE;
          for (prefetch_revision = revision;
              prefetch_revision < last_revision && !end;
              ++prefetch_revision)
            {
              int excluded_page_no = prefetch_revision == revision
                                  ? info_baton.page_no
                                  : -1;
              svn_pool_clear(iterpool);
              SVN_ERR(prefetch_l2p_pages(&end, fs, rev_file,
                                        info_baton.first_revision,
                                        prefetch_revision, pages,
                                        excluded_page_no, min_offset,
                                        max_offset, iterpool));
            }
          end = FALSE;
          for (prefetch_revision = revision-1;
              prefetch_revision >= info_baton.first_revision && !end;
              --prefetch_revision)
            {
              svn_pool_clear(iterpool);
              SVN_ERR(prefetch_l2p_pages(&end, fs, rev_file,
                                        info_baton.first_revision,
                                        prefetch_revision, pages, -1,
                                        min_offset, max_offset, iterpool));
            }
          svn_pool_destroy(iterpool);
        }
    }
  *offset = page_baton.offset;
  return SVN_NO_ERROR;
}
static svn_error_t * l2p_index_lookup ( apr_off_t * offset , svn_fs_t * fs , svn_fs_fs__revision_file_t * rev_file , svn_revnum_t revision , apr_uint64_t item_index , apr_pool_t * scratch_pool ) { fs_fs_data_t * ffd = fs -> fsap_data ; l2p_page_info_baton_t info_baton ; l2p_entry_baton_t page_baton ; l2p_page_t * page = NULL ; svn_fs_fs__page_cache_key_t key = { 0 } ; svn_boolean_t is_cached = FALSE ; void * dummy = NULL ; info_baton . revision = revision ; info_baton . item_index = item_index ; SVN_ERR ( get_l2p_page_info ( & info_baton , rev_file , fs , scratch_pool ) ) ; page_baton . revision = revision ; page_baton . item_index = item_index ; page_baton . page_offset = info_baton . page_offset ; assert ( revision <= APR_UINT32_MAX ) ; key . revision = ( apr_uint32_t ) revision ; key . is_packed = svn_fs_fs__is_packed_rev ( fs , revision ) ; key . page = info_baton . page_no ; SVN_ERR ( svn_cache__get_partial ( & dummy , & is_cached , ffd -> l2p_page_cache , & key , l2p_entry_access_func , & page_baton , scratch_pool ) ) ; if ( ! is_cached ) { apr_array_header_t * pages ; svn_revnum_t prefetch_revision ; svn_revnum_t last_revision = info_baton . first_revision + ( key . is_packed ? ffd -> max_files_per_dir : 1 ) ; svn_boolean_t end ; apr_off_t max_offset = APR_ALIGN ( info_baton . entry . offset + info_baton . entry . size , ffd -> block_size ) ; apr_off_t min_offset = max_offset - ffd -> block_size ; SVN_ERR ( get_l2p_page ( & page , rev_file , fs , info_baton . first_revision , & info_baton . entry , scratch_pool ) ) ; SVN_ERR ( svn_cache__set ( ffd -> l2p_page_cache , & key , page , scratch_pool ) ) ; SVN_ERR ( l2p_page_get_entry ( & page_baton , page , page -> offsets , scratch_pool ) ) ; if ( ffd -> use_block_read ) { apr_pool_t * iterpool = svn_pool_create ( scratch_pool ) ; pages = apr_array_make ( scratch_pool , 16 , sizeof ( l2p_page_table_entry_t ) ) ; end = FALSE ; for ( prefetch_revision = revision ; prefetch_revision < last_revision && ! end ; ++ prefetch_revision ) { int excluded_page_no = prefetch_revision == revision ? info_baton . page_no : -1 ; svn_pool_clear ( iterpool ) ; SVN_ERR ( prefetch_l2p_pages ( & end , fs , rev_file , info_baton . first_revision , prefetch_revision , pages , excluded_page_no , min_offset , max_offset , iterpool ) ) ; } end = FALSE ; for ( prefetch_revision = revision - 1 ; prefetch_revision >= info_baton . first_revision && ! end ; -- prefetch_revision ) { svn_pool_clear ( iterpool ) ; SVN_ERR ( prefetch_l2p_pages ( & end , fs , rev_file , info_baton . first_revision , prefetch_revision , pages , -1 , min_offset , max_offset , iterpool ) ) ; } svn_pool_destroy ( iterpool ) ; } } * offset = page_baton . offset ; return SVN_NO_ERROR ; }
Using the log-to-phys indexes in FS, find the absolute offset in the
 rev file for (REVISION, ITEM_INDEX) and return it in *OFFSET.
Using the log - to - phys indexes in FS find the absolute offset in the rev file for ( REVISION ITEM_INDEX ) and return it in * OFFSET .
/* read index master data structure and extract the info required to
   * access the l2p index page for (REVISION,ITEM_INDEX)*/ /* try to find the page in the cache and get the OFFSET from it */ /* we need to read the info from disk (might already be in the
       * APR file buffer, though) */ /* read the relevant page */ /* cache the page and extract the result we need */ /* prefetch pages from following and preceding revisions */