FreeBSD/contrib/subversion/subversion/libsvn_fs_fs/verify.c
/* Verify that for all phys-to-log index entries for revisions START to
 * START + COUNT-1 in FS match the actual pack / rev file contents.
 * If given, invoke CANCEL_FUNC with CANCEL_BATON at regular intervals.
 * Use POOL for allocations.
 *
 * Please note that we can only check on pack / rev file granularity and
 * must only be called for a single rev / pack file.
 */
Verify that for all phys-to-log index entries for revisions START to
START + COUNT-1 in FS match the actual pack / rev file contents.
If given, invoke CANCEL_FUNC with CANCEL_BATON at regular intervals.
Use POOL for allocations.

Please note that we can only check on pack / rev file granularity and
must only be called for a single rev / pack file.
Verify that for all phys - to - log index entries for revisions START to START + COUNT - 1 in FS match the actual pack / rev file contents . If given invoke CANCEL_FUNC with CANCEL_BATON at regular intervals . Use POOL for allocations . Please note that we can only check on pack / rev file granularity and must only be called for a single rev / pack file .
static svn_error_t *
compare_p2l_to_rev(svn_fs_t *fs,
                   svn_revnum_t start,
                   svn_revnum_t count,
                   svn_cancel_func_t cancel_func,
                   void *cancel_baton,
                   apr_pool_t *pool)
{
  fs_fs_data_t *ffd = fs->fsap_data;
  apr_pool_t *iterpool = svn_pool_create(pool);
  apr_off_t max_offset;
  apr_off_t offset = 0;
  svn_fs_fs__revision_file_t *rev_file;
  SVN_ERR(svn_fs_fs__open_pack_or_rev_file(&rev_file, fs, start, pool,
                                           iterpool));
  SVN_ERR(svn_fs_fs__auto_read_footer(rev_file));
  SVN_ERR(svn_fs_fs__p2l_get_max_offset(&max_offset, fs, rev_file, start,
                                        pool));
  if (rev_file->l2p_offset != max_offset)
    return svn_error_createf(SVN_ERR_FS_INDEX_INCONSISTENT, NULL,
                             _("File size of %s for revision r%ld does "
                               "not match p2l index size of %s"),
                             apr_off_t_toa(pool, rev_file->l2p_offset), start,
                             apr_off_t_toa(pool, max_offset));
  SVN_ERR(svn_io_file_aligned_seek(rev_file->file, ffd->block_size, NULL, 0,
                                   pool));
  for (offset = 0; offset < max_offset; )
    {
      apr_array_header_t *entries;
      int i;
      svn_pool_clear(iterpool);
      SVN_ERR(svn_fs_fs__p2l_index_lookup(&entries, fs, rev_file, start,
                                          offset, ffd->p2l_page_size,
                                          iterpool, iterpool));
      SVN_ERR(svn_io_file_aligned_seek(rev_file->file, ffd->block_size,
                                       NULL, offset, iterpool));
      for (i = 0; i < entries->nelts; ++i)
        {
          svn_fs_fs__p2l_entry_t *entry
            = &APR_ARRAY_IDX(entries, i, svn_fs_fs__p2l_entry_t);
          if (i == 0 && entry->offset < offset)
            continue;
          if (entry->size == 0)
            continue;
          if (entry->offset != offset)
            return svn_error_createf(SVN_ERR_FS_INDEX_INCONSISTENT,
                                     NULL,
                                     _("p2l index entry for revision r%ld"
                                       " is non-contiguous between offsets "
                                       " %s and %s"),
                                     start,
                                     apr_off_t_toa(pool, offset),
                                     apr_off_t_toa(pool, entry->offset));
          if (entry->type == SVN_FS_FS__ITEM_TYPE_UNUSED)
            {
              if (entry->offset != max_offset)
                SVN_ERR(read_all_nul(rev_file->file, entry->size, pool));
            }
          else
            {
              if (entry->size < STREAM_THRESHOLD)
                SVN_ERR(expected_buffered_checksum(rev_file->file, entry,
                                                   pool));
              else
                SVN_ERR(expected_streamed_checksum(rev_file->file, entry,
                                                   pool));
            }
          offset += entry->size;
        }
      if (cancel_func)
        SVN_ERR(cancel_func(cancel_baton));
    }
  svn_pool_destroy(iterpool);
  SVN_ERR(svn_fs_fs__close_revision_file(rev_file));
  return SVN_NO_ERROR;
}
static svn_error_t * compare_p2l_to_rev ( svn_fs_t * fs , svn_revnum_t start , svn_revnum_t count , svn_cancel_func_t cancel_func , void * cancel_baton , apr_pool_t * pool ) { fs_fs_data_t * ffd = fs -> fsap_data ; apr_pool_t * iterpool = svn_pool_create ( pool ) ; apr_off_t max_offset ; apr_off_t offset = 0 ; svn_fs_fs__revision_file_t * rev_file ; SVN_ERR ( svn_fs_fs__open_pack_or_rev_file ( & rev_file , fs , start , pool , iterpool ) ) ; SVN_ERR ( svn_fs_fs__auto_read_footer ( rev_file ) ) ; SVN_ERR ( svn_fs_fs__p2l_get_max_offset ( & max_offset , fs , rev_file , start , pool ) ) ; if ( rev_file -> l2p_offset != max_offset ) return svn_error_createf ( SVN_ERR_FS_INDEX_INCONSISTENT , NULL , _ ( " " " " ) , apr_off_t_toa ( pool , rev_file -> l2p_offset ) , start , apr_off_t_toa ( pool , max_offset ) ) ; SVN_ERR ( svn_io_file_aligned_seek ( rev_file -> file , ffd -> block_size , NULL , 0 , pool ) ) ; for ( offset = 0 ; offset < max_offset ; ) { apr_array_header_t * entries ; int i ; svn_pool_clear ( iterpool ) ; SVN_ERR ( svn_fs_fs__p2l_index_lookup ( & entries , fs , rev_file , start , offset , ffd -> p2l_page_size , iterpool , iterpool ) ) ; SVN_ERR ( svn_io_file_aligned_seek ( rev_file -> file , ffd -> block_size , NULL , offset , iterpool ) ) ; for ( i = 0 ; i < entries -> nelts ; ++ i ) { svn_fs_fs__p2l_entry_t * entry = & APR_ARRAY_IDX ( entries , i , svn_fs_fs__p2l_entry_t ) ; if ( i == 0 && entry -> offset < offset ) continue ; if ( entry -> size == 0 ) continue ; if ( entry -> offset != offset ) return svn_error_createf ( SVN_ERR_FS_INDEX_INCONSISTENT , NULL , _ ( " " " " " " ) , start , apr_off_t_toa ( pool , offset ) , apr_off_t_toa ( pool , entry -> offset ) ) ; if ( entry -> type == SVN_FS_FS__ITEM_TYPE_UNUSED ) { if ( entry -> offset != max_offset ) SVN_ERR ( read_all_nul ( rev_file -> file , entry -> size , pool ) ) ; } else { if ( entry -> size < STREAM_THRESHOLD ) SVN_ERR ( expected_buffered_checksum ( rev_file -> file , entry , pool ) ) ; else SVN_ERR ( expected_streamed_checksum ( rev_file -> file , entry , pool ) ) ; } offset += entry -> size ; } if ( cancel_func ) SVN_ERR ( cancel_func ( cancel_baton ) ) ; } svn_pool_destroy ( iterpool ) ; SVN_ERR ( svn_fs_fs__close_revision_file ( rev_file ) ) ; return SVN_NO_ERROR ; }
Verify that for all phys-to-log index entries for revisions START to
 START + COUNT-1 in FS match the actual pack / rev file contents.
Verify that for all phys - to - log index entries for revisions START to START + COUNT - 1 in FS match the actual pack / rev file contents .
/* open the pack / rev file that is covered by the p2l index */ /* check file size vs. range covered by index */ /* for all offsets in the file, get the P2L index entries and check
     them against the L2P index */ /* get all entries for the current block */ /* The above might have moved the file pointer.
       * Ensure we actually start reading at OFFSET.  */ /* process all entries (and later continue with the next block) */ /* skip bits we previously checked */ /* skip zero-sized entries */ /* p2l index must cover all rev / pack file offsets exactly once */ /* empty sections must contain NUL bytes only */ /* skip filler entry at the end of the p2l index */ /* advance offset */