You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Daniel Shahaf <da...@elego.de> on 2011/09/07 16:19:19 UTC

Re: svn commit: r1166184 - /subversion/branches/fs-successor-ids/subversion/libsvn_fs_fs/fs_fs.c

This will assert with

% cat $REPOS/db/format
6
layout linear
%


stsp@apache.org wrote on Wed, Sep 07, 2011 at 13:53:59 -0000:
> Author: stsp
> Date: Wed Sep  7 13:53:59 2011
> New Revision: 1166184
> 
> URL: http://svn.apache.org/viewvc?rev=1166184&view=rev
> Log:
> On the fs-successor-ids branch, shard files within db/successors/ into
> directories, such that no more than MAX_FILES_PER_DIR files are created
> in a directory. This follows the layout specified in the 'format' file,
> just like the sibling directories of db/successors/ do.
> 
> * subversion/libsvn_fs_fs/fs_fs.c
>   (path_successor_ids_shard, path_successor_revisions_shard,
>    path_successor_node_revs_shard): New. Return the appropriate shard for
>     a given revision.
>   (path_successor_ids, path_successor_revisions,
>    path_successor_node_revs): Use above new helper function to compute paths.
>   (make_successor_ids_dirs): Create shards named '0'.
>   (update_successor_map): Create new shards as necessary.
> 
> Modified:
>     subversion/branches/fs-successor-ids/subversion/libsvn_fs_fs/fs_fs.c
> 
> Modified: subversion/branches/fs-successor-ids/subversion/libsvn_fs_fs/fs_fs.c
> URL: http://svn.apache.org/viewvc/subversion/branches/fs-successor-ids/subversion/libsvn_fs_fs/fs_fs.c?rev=1166184&r1=1166183&r2=1166184&view=diff
> ==============================================================================
> --- subversion/branches/fs-successor-ids/subversion/libsvn_fs_fs/fs_fs.c (original)
> +++ subversion/branches/fs-successor-ids/subversion/libsvn_fs_fs/fs_fs.c Wed Sep  7 13:53:59 2011
> @@ -253,26 +253,66 @@ path_rev(svn_fs_t *fs, svn_revnum_t rev,
>  }
>  
>  static const char *
> -path_successor_ids(svn_fs_t *fs, svn_revnum_t rev, apr_pool_t *pool)
> +path_successor_ids_shard(svn_fs_t *fs, svn_revnum_t rev, apr_pool_t *pool)
>  {
> -  long filenum = rev / FSFS_SUCCESSORS_MAX_REVS_PER_FILE;
> +  fs_fs_data_t *ffd = fs->fsap_data;
>  
> +  assert(ffd->max_files_per_dir);
>    return svn_dirent_join_many(pool, fs->path, PATH_SUCCESSORS_TOP_DIR,
>                                PATH_SUCCESSORS_IDS_DIR,
> -                              apr_psprintf(pool, "%ld", filenum), NULL);
> +                              apr_psprintf(pool, "%ld",
> +                                                 rev / ffd->max_files_per_dir),
> +                              NULL);
>  }
>  
>  static const char *
> -path_successor_revisions(svn_fs_t *fs, svn_revnum_t rev, apr_pool_t *pool)
> +path_successor_ids(svn_fs_t *fs, svn_revnum_t rev, apr_pool_t *pool)
>  {
>    long filenum = rev / FSFS_SUCCESSORS_MAX_REVS_PER_FILE;
>  
> +  return svn_dirent_join_many(pool, path_successor_ids_shard(fs, rev, pool),
> +                              apr_psprintf(pool, "%ld", filenum), NULL);
> +}
> +
> +static const char *
> +path_successor_revisions_shard(svn_fs_t *fs, svn_revnum_t rev,
> +                               apr_pool_t *pool)
> +{
> +  fs_fs_data_t *ffd = fs->fsap_data;
> +
> +  assert(ffd->max_files_per_dir);
>    return svn_dirent_join_many(pool, fs->path, PATH_SUCCESSORS_TOP_DIR,
>                                PATH_SUCCESSORS_REVISIONS_DIR,
> +                              apr_psprintf(pool, "%ld",
> +                                                 rev / ffd->max_files_per_dir),
> +                              NULL);
> +}
> +
> +static const char *
> +path_successor_revisions(svn_fs_t *fs, svn_revnum_t rev, apr_pool_t *pool)
> +{
> +  long filenum = rev / FSFS_SUCCESSORS_MAX_REVS_PER_FILE;
> +
> +  return svn_dirent_join_many(pool,
> +                              path_successor_revisions_shard(fs, rev, pool),
>                                apr_psprintf(pool, "%ld", filenum), NULL);
>  }
>  
>  static const char *
> +path_successor_node_revs_shard(svn_fs_t *fs, svn_revnum_t rev,
> +                               apr_pool_t *pool)
> +{
> +  fs_fs_data_t *ffd = fs->fsap_data;
> +
> +  assert(ffd->max_files_per_dir);
> +  return svn_dirent_join_many(pool, fs->path, PATH_SUCCESSORS_TOP_DIR,
> +                              PATH_SUCCESSORS_NODE_REVS_DIR,
> +                              apr_psprintf(pool, "%ld",
> +                                                 rev / ffd->max_files_per_dir),
> +                              NULL);
> +}
> +
> +static const char *
>  path_successor_node_revs(svn_fs_t *fs, const char *node_rev_id,
>                           apr_pool_t *pool)
>  {
> @@ -285,8 +325,8 @@ path_successor_node_revs(svn_fs_t *fs, c
>    rev = svn_fs_fs__id_rev(id);
>    filenum = rev / FSFS_SUCCESSORS_MAX_REVS_PER_FILE;
>  
> -  return svn_dirent_join_many(pool, fs->path, PATH_SUCCESSORS_TOP_DIR,
> -                              PATH_SUCCESSORS_NODE_REVS_DIR,
> +  return svn_dirent_join_many(pool,
> +                              path_successor_node_revs_shard(fs, rev, pool),
>                                apr_psprintf(pool, "%ld", filenum), NULL);
>  }
>  
> @@ -1282,19 +1322,21 @@ make_successor_ids_dirs(svn_fs_t *fs, ap
>  {
>    const char *top_dir = svn_dirent_join(fs->path, PATH_SUCCESSORS_TOP_DIR,
>                                          pool);
> -  const char *node_revs_dir = svn_dirent_join(top_dir,
> -                                              PATH_SUCCESSORS_NODE_REVS_DIR,
> -                                              pool);
> -  const char *revs_dir = svn_dirent_join(top_dir,
> -                                         PATH_SUCCESSORS_REVISIONS_DIR, pool);
> -  const char *data_dir = svn_dirent_join(top_dir, PATH_SUCCESSORS_IDS_DIR,
> -                                         pool);
> +  const char *node_revs_dir = svn_dirent_join_many(
> +                                pool, top_dir, PATH_SUCCESSORS_NODE_REVS_DIR,
> +                                "0", NULL, pool);
> +  const char *revisions_dir = svn_dirent_join_many(
> +                                pool, top_dir, PATH_SUCCESSORS_REVISIONS_DIR,
> +                                "0", NULL, pool);
> +  const char *ids_dir = svn_dirent_join_many(pool, top_dir,
> +                                             PATH_SUCCESSORS_IDS_DIR,
> +                                             "0", NULL, pool);
>    apr_file_t *file;
>    apr_uint64_t n;
>  
>    SVN_ERR(svn_io_make_dir_recursively(node_revs_dir, pool));
> -  SVN_ERR(svn_io_make_dir_recursively(revs_dir, pool));
> -  SVN_ERR(svn_io_make_dir_recursively(data_dir, pool));
> +  SVN_ERR(svn_io_make_dir_recursively(revisions_dir, pool));
> +  SVN_ERR(svn_io_make_dir_recursively(ids_dir, pool));
>  
>    /* Create empty successor-ID data for revision zero.
>     * No successors were created in this revision. */
> @@ -6227,6 +6269,47 @@ update_successor_map(svn_fs_t *fs,
>    SVN_ERR(update_successor_node_revs_files(&node_revs_tempfiles, fs,
>                                             new_rev, successor_ids, pool));
>  
> +  if (new_rev % FSFS_SUCCESSORS_MAX_REVS_PER_FILE == 0)
> +    {
> +      /* Create the shards for new successor files. We don't care if this
> +       * fails because the shards already existed for some reason. */
> +      svn_error_t *err;
> +      const char *new_dir = path_successor_ids_shard(fs, new_rev, pool);
> +      err = svn_io_dir_make(new_dir, APR_OS_DEFAULT, pool);
> +      if (err && !APR_STATUS_IS_EEXIST(err->apr_err))
> +        SVN_ERR(err);
> +      svn_error_clear(err);
> +      SVN_ERR(svn_fs_fs__dup_perms(new_dir,
> +                                   svn_dirent_join(fs->path,
> +                                                   PATH_SUCCESSORS_IDS_DIR,
> +                                                   pool),
> +                                   pool));
> +
> +      new_dir = path_successor_revisions_shard(fs, new_rev, pool);
> +      err = svn_io_dir_make(new_dir, APR_OS_DEFAULT, pool);
> +      if (err && !APR_STATUS_IS_EEXIST(err->apr_err))
> +        SVN_ERR(err);
> +      svn_error_clear(err);
> +      SVN_ERR(svn_fs_fs__dup_perms(new_dir,
> +                                   svn_dirent_join(
> +                                     fs->path,
> +                                     PATH_SUCCESSORS_REVISIONS_DIR,
> +                                     pool),
> +                                   pool));
> +
> +      new_dir = path_successor_node_revs_shard(fs, new_rev, pool);
> +      err = svn_io_dir_make(new_dir, APR_OS_DEFAULT, pool);
> +      if (err && !APR_STATUS_IS_EEXIST(err->apr_err))
> +        SVN_ERR(err);
> +      svn_error_clear(err);
> +      SVN_ERR(svn_fs_fs__dup_perms(new_dir,
> +                                   svn_dirent_join(
> +                                     fs->path,
> +                                     PATH_SUCCESSORS_NODE_REVS_DIR,
> +                                     pool),
> +                                   pool));
> +    }
> +
>    /* Move temporary files into place. */
>    if (new_rev > 1 && new_rev % FSFS_SUCCESSORS_MAX_REVS_PER_FILE != 0)
>      perms_reference = successor_ids_abspath;
> 
> 

Re: svn commit: r1166184 - /subversion/branches/fs-successor-ids/subversion/libsvn_fs_fs/fs_fs.c

Posted by Daniel Shahaf <da...@elego.de>.
Stefan Sperling wrote on Wed, Sep 07, 2011 at 16:46:21 +0200:
> On Wed, Sep 07, 2011 at 05:19:19PM +0300, Daniel Shahaf wrote:
> > This will assert with
> > 
> > % cat $REPOS/db/format
> > 6
> > layout linear
> > %
> 
> Good catch. The assert() is from code I copy-pasted. Will look into it.

You need to decide at what level to check the format number.  For
example, in make_successor_dirs() you check the format number in the
function itself; the other option is to assert() the format number in
the function and check it at the caller, and I believe that's what I did
last time I had to make that call.

Re: svn commit: r1166184 - /subversion/branches/fs-successor-ids/subversion/libsvn_fs_fs/fs_fs.c

Posted by Stefan Sperling <st...@elego.de>.
On Wed, Sep 07, 2011 at 05:19:19PM +0300, Daniel Shahaf wrote:
> This will assert with
> 
> % cat $REPOS/db/format
> 6
> layout linear
> %

Good catch. The assert() is from code I copy-pasted. Will look into it.