Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/revprops.c URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/revprops.c?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/revprops.c (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/revprops.c Wed Jan 21 16:22:19 2015 @@ -61,7 +61,7 @@ svn_fs_x__upgrade_pack_revprops(svn_fs_t void *cancel_baton, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; const char *revprops_shard_path; const char *revprops_pack_file_dir; apr_int64_t shard; @@ -113,7 +113,7 @@ svn_fs_x__upgrade_cleanup_pack_revprops( void *cancel_baton, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; const char *revprops_shard_path; apr_int64_t shard; apr_int64_t first_unpacked_shard @@ -194,7 +194,7 @@ static svn_error_t * close_revprop_generation_file(svn_fs_t *fs, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; if (ffd->revprop_generation_file) { SVN_ERR(svn_io_file_close(ffd->revprop_generation_file, scratch_pool)); @@ -216,7 +216,7 @@ open_revprop_generation_file(svn_fs_t *f svn_boolean_t read_only, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; apr_int32_t flags = read_only ? APR_READ : (APR_READ | APR_WRITE); /* Close the current file handle if it has insufficient rights. */ @@ -299,7 +299,7 @@ read_revprop_generation_file(apr_int64_t svn_fs_t *fs, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; apr_pool_t *iterpool = svn_pool_create(scratch_pool); char buf[CHECKSUMMED_NUMBER_BUFFER_LEN]; apr_size_t len; @@ -354,7 +354,7 @@ write_revprop_generation_file(svn_fs_t * apr_int64_t current, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; svn_stringbuf_t *buffer; apr_off_t offset = 0; @@ -405,12 +405,12 @@ static void log_revprop_cache_init_warning(svn_fs_t *fs, svn_error_t *underlying_err, const char *message, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { svn_error_t *err = svn_error_createf( SVN_ERR_FS_REVPROP_CACHE_INIT_FAILURE, underlying_err, message, - svn_dirent_local_style(fs->path, pool)); + svn_dirent_local_style(fs->path, scratch_pool)); if (fs->warning) (fs->warning)(fs->warning_baton, err); @@ -424,7 +424,7 @@ static svn_boolean_t has_revprop_cache(svn_fs_t *fs, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; svn_error_t *error; /* is the cache (still) enabled? */ @@ -472,7 +472,7 @@ revprop_generation_fixup(void *void_bato apr_pool_t *scratch_pool) { revprop_generation_upgrade_t *baton = void_baton; - fs_x_data_t *ffd = baton->fs->fsap_data; + svn_fs_x__data_t *ffd = baton->fs->fsap_data; assert(ffd->has_write_lock); /* Make sure we don't operate on stale OS buffers. */ @@ -507,7 +507,7 @@ read_revprop_generation(apr_int64_t *gen apr_pool_t *scratch_pool) { apr_int64_t current = 0; - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; /* read the current revprop generation number */ SVN_ERR(read_revprop_generation_file(¤t, fs, scratch_pool)); @@ -562,7 +562,7 @@ begin_revprop_change(apr_int64_t *genera svn_fs_t *fs, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; SVN_ERR_ASSERT(ffd->has_write_lock); /* Close and re-open to make sure we read the latest data. */ @@ -589,7 +589,7 @@ end_revprop_change(svn_fs_t *fs, apr_int64_t generation, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; SVN_ERR_ASSERT(ffd->has_write_lock); SVN_ERR_ASSERT(generation % 2); @@ -660,8 +660,8 @@ typedef struct packed_revprops_t * our file system, the revprops belong to REVISION and the global revprop * GENERATION is used as well. * - * The returned hash will be allocated in POOL, SCRATCH_POOL is being used - * for temporary allocations. + * The returned hash will be allocated in RESULT_POOL, SCRATCH_POOL is + * being used for temporary allocations. */ static svn_error_t * parse_revprop(apr_hash_t **properties, @@ -669,17 +669,18 @@ parse_revprop(apr_hash_t **properties, svn_revnum_t revision, apr_int64_t generation, svn_string_t *content, - apr_pool_t *pool, + apr_pool_t *result_pool, apr_pool_t *scratch_pool) { svn_stream_t *stream = svn_stream_from_string(content, scratch_pool); - *properties = apr_hash_make(pool); + *properties = apr_hash_make(result_pool); - SVN_ERR(svn_hash_read2(*properties, stream, SVN_HASH_TERMINATOR, pool)); - if (has_revprop_cache(fs, pool)) + SVN_ERR(svn_hash_read2(*properties, stream, SVN_HASH_TERMINATOR, + result_pool)); + if (has_revprop_cache(fs, scratch_pool)) { - fs_x_data_t *ffd = fs->fsap_data; - pair_cache_key_t key = { 0 }; + svn_fs_x__data_t *ffd = fs->fsap_data; + svn_fs_x__pair_cache_key_t key = { 0 }; key.revision = revision; key.second = generation; @@ -747,15 +748,16 @@ get_min_filename_len(packed_revprops_t * } /* Given FS and REVPROPS->REVISION, fill the FILENAME, FOLDER and MANIFEST - * members. Use POOL for allocating results and SCRATCH_POOL for temporaries. + * members. Use RESULT_POOL for allocating results and SCRATCH_POOL for + * temporaries. */ static svn_error_t * get_revprop_packname(svn_fs_t *fs, packed_revprops_t *revprops, - apr_pool_t *pool, + apr_pool_t *result_pool, apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; svn_stringbuf_t *content = NULL; const char *manifest_file_path; int idx, rev_count; @@ -773,17 +775,19 @@ get_revprop_packname(svn_fs_t *fs, --rev_count; } - revprops->manifest = apr_array_make(pool, rev_count, sizeof(const char*)); + revprops->manifest = apr_array_make(result_pool, rev_count, + sizeof(const char*)); /* No line in the file can be less than this number of chars long. */ min_filename_len = get_min_filename_len(revprops); /* Read the content of the manifest file */ revprops->folder - = svn_fs_x__path_revprops_pack_shard(fs, revprops->revision, pool); - manifest_file_path = svn_dirent_join(revprops->folder, PATH_MANIFEST, pool); + = svn_fs_x__path_revprops_pack_shard(fs, revprops->revision, result_pool); + manifest_file_path = svn_dirent_join(revprops->folder, PATH_MANIFEST, + result_pool); - SVN_ERR(svn_fs_x__read_content(&content, manifest_file_path, pool)); + SVN_ERR(svn_fs_x__read_content(&content, manifest_file_path, result_pool)); /* There CONTENT must have a certain minimal size and there no * unterminated lines at the end of the file. Both guarantees also @@ -859,7 +863,7 @@ same_shard(svn_fs_t *fs, svn_revnum_t r1, svn_revnum_t r2) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; return (r1 / ffd->max_files_per_dir) == (r2 / ffd->max_files_per_dir); } @@ -876,7 +880,7 @@ static svn_error_t * parse_packed_revprops(svn_fs_t *fs, packed_revprops_t *revprops, svn_boolean_t read_all, - apr_pool_t *pool, + apr_pool_t *result_pool, apr_pool_t *scratch_pool) { svn_stream_t *stream; @@ -888,7 +892,7 @@ parse_packed_revprops(svn_fs_t *fs, /* decompress (even if the data is only "stored", there is still a * length header to remove) */ svn_stringbuf_t *compressed = revprops->packed_revprops; - svn_stringbuf_t *uncompressed = svn_stringbuf_create_empty(pool); + svn_stringbuf_t *uncompressed = svn_stringbuf_create_empty(result_pool); SVN_ERR(svn__decompress(compressed, uncompressed, APR_SIZE_MAX)); /* read first revision number and number of revisions in the pack */ @@ -926,7 +930,7 @@ parse_packed_revprops(svn_fs_t *fs, offset = header_end - uncompressed->data + 2; - revprops->packed_revprops = svn_stringbuf_create_empty(pool); + revprops->packed_revprops = svn_stringbuf_create_empty(result_pool); revprops->packed_revprops->data = uncompressed->data + offset; revprops->packed_revprops->len = (apr_size_t)(uncompressed->len - offset); revprops->packed_revprops->blocksize = (apr_size_t)(uncompressed->blocksize - offset); @@ -936,8 +940,10 @@ parse_packed_revprops(svn_fs_t *fs, if (read_all) { /* Init / construct REVPROPS members. */ - revprops->sizes = apr_array_make(pool, (int)count, sizeof(offset)); - revprops->offsets = apr_array_make(pool, (int)count, sizeof(offset)); + revprops->sizes = apr_array_make(result_pool, (int)count, + sizeof(offset)); + revprops->offsets = apr_array_make(result_pool, (int)count, + sizeof(offset)); } /* Now parse, revision by revision, the size and content of each @@ -964,7 +970,7 @@ parse_packed_revprops(svn_fs_t *fs, { SVN_ERR(parse_revprop(&revprops->properties, fs, revision, revprops->generation, &serialized, - pool, iterpool)); + result_pool, iterpool)); revprops->serialized_size = serialized.len; /* If we only wanted the revprops for REVISION then we are done. */ @@ -1078,7 +1084,7 @@ svn_fs_x__get_revision_proplist(apr_hash svn_boolean_t bypass_cache, apr_pool_t *pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; apr_int64_t generation = 0; /* not found, yet */ @@ -1091,7 +1097,7 @@ svn_fs_x__get_revision_proplist(apr_hash if (!bypass_cache && has_revprop_cache(fs, pool)) { svn_boolean_t is_cached; - pair_cache_key_t key = { 0 }; + svn_fs_x__pair_cache_key_t key = { 0 }; SVN_ERR(read_revprop_generation(&generation, fs, pool)); @@ -1176,7 +1182,7 @@ write_non_packed_revprop(const char **fi * Finally, delete all the temporary files given in FILES_TO_DELETE. * The latter may be NULL. * - * Use POOL for temporary allocations. + * Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * switch_to_new_revprop(svn_fs_t *fs, @@ -1185,26 +1191,26 @@ switch_to_new_revprop(svn_fs_t *fs, const char *perms_reference, apr_array_header_t *files_to_delete, svn_boolean_t bump_generation, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { apr_int64_t generation; /* Now, we may actually be replacing revprops. Make sure that all other threads and processes will know about this. */ if (bump_generation) - SVN_ERR(begin_revprop_change(&generation, fs, pool)); + SVN_ERR(begin_revprop_change(&generation, fs, scratch_pool)); SVN_ERR(svn_fs_x__move_into_place(tmp_path, final_path, perms_reference, - pool)); + scratch_pool)); /* Indicate that the update (if relevant) has been completed. */ if (bump_generation) - SVN_ERR(end_revprop_change(fs, generation, pool)); + SVN_ERR(end_revprop_change(fs, generation, scratch_pool)); /* Clean up temporary files, if necessary. */ if (files_to_delete) { - apr_pool_t *iterpool = svn_pool_create(pool); + apr_pool_t *iterpool = svn_pool_create(scratch_pool); int i; for (i = 0; i < files_to_delete->nelts; ++i) @@ -1229,16 +1235,16 @@ serialize_revprops_header(svn_stream_t * apr_array_header_t *sizes, int start, int end, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { - apr_pool_t *iterpool = svn_pool_create(pool); + apr_pool_t *iterpool = svn_pool_create(scratch_pool); int i; SVN_ERR_ASSERT(start < end); /* start revision and entry count */ - SVN_ERR(svn_stream_printf(stream, pool, "%ld\n", start_revision)); - SVN_ERR(svn_stream_printf(stream, pool, "%d\n", end - start)); + SVN_ERR(svn_stream_printf(stream, scratch_pool, "%ld\n", start_revision)); + SVN_ERR(svn_stream_printf(stream, scratch_pool, "%d\n", end - start)); /* the sizes array */ for (i = start; i < end; ++i) @@ -1268,7 +1274,7 @@ serialize_revprops_header(svn_stream_t * * taken in that case but only a subset of the old data will be copied. * * NEW_TOTAL_SIZE is a hint for pre-allocating buffers of appropriate size. - * POOL is used for temporary allocations. + * SCRATCH_POOL is used for temporary allocations. */ static svn_error_t * repack_revprops(svn_fs_t *fs, @@ -1279,22 +1285,23 @@ repack_revprops(svn_fs_t *fs, svn_stringbuf_t *new_serialized, apr_off_t new_total_size, svn_stream_t *file_stream, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; svn_stream_t *stream; int i; /* create data empty buffers and the stream object */ svn_stringbuf_t *uncompressed - = svn_stringbuf_create_ensure((apr_size_t)new_total_size, pool); + = svn_stringbuf_create_ensure((apr_size_t)new_total_size, scratch_pool); svn_stringbuf_t *compressed - = svn_stringbuf_create_empty(pool); - stream = svn_stream_from_stringbuf(uncompressed, pool); + = svn_stringbuf_create_empty(scratch_pool); + stream = svn_stream_from_stringbuf(uncompressed, scratch_pool); /* write the header*/ SVN_ERR(serialize_revprops_header(stream, revprops->start_revision + start, - revprops->sizes, start, end, pool)); + revprops->sizes, start, end, + scratch_pool)); /* append the serialized revprops */ for (i = start; i < end; ++i) @@ -1409,7 +1416,7 @@ write_packed_revprop(const char **final_ apr_hash_t *proplist, apr_pool_t *pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; packed_revprops_t *revprops; apr_int64_t generation = 0; svn_stream_t *stream; @@ -1548,12 +1555,12 @@ write_packed_revprop(const char **final_ } /* Set the revision property list of revision REV in filesystem FS to - PROPLIST. Use POOL for temporary allocations. */ + PROPLIST. Use SCRATCH_POOL for temporary allocations. */ svn_error_t * svn_fs_x__set_revision_proplist(svn_fs_t *fs, svn_revnum_t rev, apr_hash_t *proplist, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { svn_boolean_t is_packed; svn_boolean_t bump_generation = FALSE; @@ -1562,7 +1569,7 @@ svn_fs_x__set_revision_proplist(svn_fs_t const char *perms_reference; apr_array_header_t *files_to_delete = NULL; - SVN_ERR(svn_fs_x__ensure_revision_exists(rev, fs, pool)); + SVN_ERR(svn_fs_x__ensure_revision_exists(rev, fs, scratch_pool)); /* this info will not change while we hold the global FS write lock */ is_packed = svn_fs_x__is_packed_revprop(fs, rev); @@ -1577,55 +1584,59 @@ svn_fs_x__set_revision_proplist(svn_fs_t else { svn_node_kind_t kind; - SVN_ERR(svn_io_check_path(svn_fs_x__path_revprops(fs, rev, pool), - &kind, pool)); + SVN_ERR(svn_io_check_path(svn_fs_x__path_revprops(fs, rev, + scratch_pool), + &kind, scratch_pool)); bump_generation = kind != svn_node_none; } /* Serialize the new revprop data */ if (is_packed) SVN_ERR(write_packed_revprop(&final_path, &tmp_path, &files_to_delete, - fs, rev, proplist, pool)); + fs, rev, proplist, scratch_pool)); else SVN_ERR(write_non_packed_revprop(&final_path, &tmp_path, - fs, rev, proplist, pool)); + fs, rev, proplist, scratch_pool)); /* We use the rev file of this revision as the perms reference, * because when setting revprops for the first time, the revprop * file won't exist and therefore can't serve as its own reference. * (Whereas the rev file should already exist at this point.) */ - perms_reference = svn_fs_x__path_rev_absolute(fs, rev, pool); + perms_reference = svn_fs_x__path_rev_absolute(fs, rev, scratch_pool); /* Now, switch to the new revprop data. */ SVN_ERR(switch_to_new_revprop(fs, final_path, tmp_path, perms_reference, - files_to_delete, bump_generation, pool)); + files_to_delete, bump_generation, + scratch_pool)); return SVN_NO_ERROR; } /* Return TRUE, if for REVISION in FS, we can find the revprop pack file. - * Use POOL for temporary allocations. + * Use SCRATCH_POOL for temporary allocations. * Set *MISSING, if the reason is a missing manifest or pack file. */ svn_boolean_t svn_fs_x__packed_revprop_available(svn_boolean_t *missing, svn_fs_t *fs, svn_revnum_t revision, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; svn_stringbuf_t *content = NULL; /* try to read the manifest file */ - const char *folder = svn_fs_x__path_revprops_pack_shard(fs, revision, pool); - const char *manifest_path = svn_dirent_join(folder, PATH_MANIFEST, pool); + const char *folder = svn_fs_x__path_revprops_pack_shard(fs, revision, + scratch_pool); + const char *manifest_path = svn_dirent_join(folder, PATH_MANIFEST, + scratch_pool); svn_error_t *err = svn_fs_x__try_stringbuf_from_file(&content, missing, manifest_path, FALSE, - pool); + scratch_pool); /* if the manifest cannot be read, consider the pack files inaccessible * even if the file itself exists. */ @@ -1657,8 +1668,8 @@ svn_fs_x__packed_revprop_available(svn_b /* the respective pack file must exist (and be a file) */ svn_node_kind_t kind; err = svn_io_check_path(svn_dirent_join(folder, content->data, - pool), - &kind, pool); + scratch_pool), + &kind, scratch_pool); if (err) { svn_error_clear(err);
Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/revprops.h URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/revprops.h?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/revprops.h (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/revprops.h Wed Jan 21 16:22:19 2015 @@ -32,10 +32,12 @@ extern "C" { /* Auto-create / replace the revprop generation file in FS with its * initial contents. In any case, FS will not hold an open handle to * it after this function succeeds. + * + * Use SCRATCH_POOL for temporary allocations. */ svn_error_t * svn_fs_x__reset_revprop_generation_file(svn_fs_t *fs, - apr_pool_t *pool); + apr_pool_t *scratch_pool); /* In the filesystem FS, pack all revprop shards up to min_unpacked_rev. * @@ -86,23 +88,23 @@ svn_fs_x__get_revision_proplist(apr_hash apr_pool_t *pool); /* Set the revision property list of revision REV in filesystem FS to - PROPLIST. Use POOL for temporary allocations. */ + PROPLIST. Use SCRATCH_POOL for temporary allocations. */ svn_error_t * svn_fs_x__set_revision_proplist(svn_fs_t *fs, svn_revnum_t rev, apr_hash_t *proplist, - apr_pool_t *pool); + apr_pool_t *scratch_pool); /* Return TRUE, if for REVISION in FS, we can find the revprop pack file. - * Use POOL for temporary allocations. + * Use SCRATCH_POOL for temporary allocations. * Set *MISSING, if the reason is a missing manifest or pack file. */ svn_boolean_t svn_fs_x__packed_revprop_available(svn_boolean_t *missing, svn_fs_t *fs, svn_revnum_t revision, - apr_pool_t *pool); + apr_pool_t *scratch_pool); /****** Packing FSX shards *********/ Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/string_table.c URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/string_table.c?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/string_table.c (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/string_table.c Wed Jan 21 16:22:19 2015 @@ -121,11 +121,11 @@ add_table(string_table_builder_t *builde } string_table_builder_t * -svn_fs_x__string_table_builder_create(apr_pool_t *pool) +svn_fs_x__string_table_builder_create(apr_pool_t *result_pool) { - string_table_builder_t *result = apr_palloc(pool, sizeof(*result)); - result->pool = pool; - result->tables = apr_array_make(pool, 1, sizeof(builder_table_t *)); + string_table_builder_t *result = apr_palloc(result_pool, sizeof(*result)); + result->pool = result_pool; + result->tables = apr_array_make(result_pool, 1, sizeof(builder_table_t *)); add_table(result); @@ -585,11 +585,11 @@ svn_fs_x__string_table_get(const string_ svn_error_t * svn_fs_x__write_string_table(svn_stream_t *stream, const string_table_t *table, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { apr_size_t i, k; - svn_packed__data_root_t *root = svn_packed__data_create_root(pool); + svn_packed__data_root_t *root = svn_packed__data_create_root(scratch_pool); svn_packed__int_stream_t *table_sizes = svn_packed__create_int_stream(root, FALSE, FALSE); @@ -646,7 +646,7 @@ svn_fs_x__write_string_table(svn_stream_ /* write to target stream */ - SVN_ERR(svn_packed__data_write(stream, root, pool)); + SVN_ERR(svn_packed__data_write(stream, root, scratch_pool)); return SVN_NO_ERROR; } Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/string_table.h URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/string_table.h?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/string_table.h (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/string_table.h Wed Jan 21 16:22:19 2015 @@ -47,10 +47,10 @@ typedef struct string_table_builder_t st /* the string table */ typedef struct string_table_t string_table_t; -/* Returns a new string table builder object, allocated in POOL. +/* Returns a new string table builder object, allocated in RESULT_POOL. */ string_table_builder_t * -svn_fs_x__string_table_builder_create(apr_pool_t *pool); +svn_fs_x__string_table_builder_create(apr_pool_t *result_pool); /* Add an arbitrary NUL-terminated C-string STRING of the given length LEN * to BUILDER. Return the index of that string in the future string table. @@ -86,12 +86,12 @@ svn_fs_x__string_table_get(const string_ apr_pool_t *pool); /* Write a serialized representation of the string table TABLE to STREAM. - * Use POOL for temporary allocations. + * Use SCRATCH_POOL for temporary allocations. */ svn_error_t * svn_fs_x__write_string_table(svn_stream_t *stream, const string_table_t *table, - apr_pool_t *pool); + apr_pool_t *scratch_pool); /* Read the serialized string table representation from STREAM and return * the resulting runtime representation in *TABLE_P. Allocate it in Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/temp_serializer.c URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/temp_serializer.c?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/temp_serializer.c (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/temp_serializer.c Wed Jan 21 16:22:19 2015 @@ -134,9 +134,9 @@ deserialize_svn_string(void *buffer, svn */ static void serialize_representation(svn_temp_serializer__context_t *context, - representation_t * const *representation) + svn_fs_x__representation_t * const *representation) { - const representation_t * rep = *representation; + const svn_fs_x__representation_t * rep = *representation; if (rep == NULL) return; @@ -203,7 +203,7 @@ typedef struct dir_data_t apr_size_t len; /* reference to the entries */ - svn_fs_dirent_t **entries; + svn_fs_x__dirent_t **entries; /* size of the serialized entries and don't be too wasteful * (needed since the entries are no longer in sequence) */ @@ -216,17 +216,16 @@ typedef struct dir_data_t */ static void serialize_dir_entry(svn_temp_serializer__context_t *context, - svn_fs_dirent_t **entry_p, + svn_fs_x__dirent_t **entry_p, apr_uint32_t *length) { - svn_fs_dirent_t *entry = *entry_p; + svn_fs_x__dirent_t *entry = *entry_p; apr_size_t initial_length = svn_temp_serializer__get_length(context); svn_temp_serializer__push(context, (const void * const *)entry_p, - sizeof(svn_fs_dirent_t)); + sizeof(svn_fs_x__dirent_t)); - svn_fs_x__id_serialize(context, &entry->id); svn_temp_serializer__add_string(context, &entry->name); *length = (apr_uint32_t)( svn_temp_serializer__get_length(context) @@ -236,10 +235,13 @@ serialize_dir_entry(svn_temp_serializer_ } /* Utility function to serialize the ENTRIES into a new serialization - * context to be returned. Allocation will be made form POOL. + * context to be returned. + * + * Temporary allocation will be made form SCRATCH_POOL. */ static svn_temp_serializer__context_t * -serialize_dir(apr_array_header_t *entries, apr_pool_t *pool) +serialize_dir(apr_array_header_t *entries, + apr_pool_t *scratch_pool) { dir_data_t dir_data; int i = 0; @@ -248,25 +250,26 @@ serialize_dir(apr_array_header_t *entrie /* calculate sizes */ int count = entries->nelts; apr_size_t over_provision = 2 + count / 4; - apr_size_t entries_len = (count + over_provision) * sizeof(svn_fs_dirent_t*); + apr_size_t entries_len = (count + over_provision) + * sizeof(svn_fs_x__dirent_t*); apr_size_t lengths_len = (count + over_provision) * sizeof(apr_uint32_t); /* copy the hash entries to an auxiliary struct of known layout */ dir_data.count = count; dir_data.over_provision = over_provision; dir_data.operations = 0; - dir_data.entries = apr_palloc(pool, entries_len); - dir_data.lengths = apr_palloc(pool, lengths_len); + dir_data.entries = apr_palloc(scratch_pool, entries_len); + dir_data.lengths = apr_palloc(scratch_pool, lengths_len); for (i = 0; i < count; ++i) - dir_data.entries[i] = APR_ARRAY_IDX(entries, i, svn_fs_dirent_t *); + dir_data.entries[i] = APR_ARRAY_IDX(entries, i, svn_fs_x__dirent_t *); /* Serialize that aux. structure into a new one. Also, provide a good * estimate for the size of the buffer that we will need. */ context = svn_temp_serializer__init(&dir_data, sizeof(dir_data), 50 + count * 200 + entries_len, - pool); + scratch_pool); /* serialize entries references */ svn_temp_serializer__push(context, @@ -296,11 +299,11 @@ static apr_array_header_t * deserialize_dir(void *buffer, dir_data_t *dir_data, apr_pool_t *pool) { apr_array_header_t *result - = apr_array_make(pool, dir_data->count, sizeof(svn_fs_dirent_t *)); + = apr_array_make(pool, dir_data->count, sizeof(svn_fs_x__dirent_t *)); apr_size_t i; apr_size_t count; - svn_fs_dirent_t *entry; - svn_fs_dirent_t **entries; + svn_fs_x__dirent_t *entry; + svn_fs_x__dirent_t **entries; /* resolve the reference to the entries array */ svn_temp_deserializer__resolve(buffer, (void **)&dir_data->entries); @@ -314,10 +317,9 @@ deserialize_dir(void *buffer, dir_data_t /* pointer fixup */ svn_temp_deserializer__resolve(entry, (void **)&entry->name); - svn_fs_x__id_deserialize(entry, (svn_fs_id_t **)&entry->id, pool); /* add the entry to the hash */ - APR_ARRAY_PUSH(result, svn_fs_dirent_t *) = entry; + APR_ARRAY_PUSH(result, svn_fs_x__dirent_t *) = entry; } /* return the now complete hash */ @@ -326,9 +328,9 @@ deserialize_dir(void *buffer, dir_data_t void svn_fs_x__noderev_serialize(svn_temp_serializer__context_t *context, - node_revision_t * const *noderev_p) + svn_fs_x__noderev_t * const *noderev_p) { - const node_revision_t *noderev = *noderev_p; + const svn_fs_x__noderev_t *noderev = *noderev_p; if (noderev == NULL) return; @@ -338,8 +340,6 @@ svn_fs_x__noderev_serialize(svn_temp_ser sizeof(*noderev)); /* serialize sub-structures */ - svn_fs_x__id_serialize(context, &noderev->id); - svn_fs_x__id_serialize(context, &noderev->predecessor_id); serialize_representation(context, &noderev->prop_rep); serialize_representation(context, &noderev->data_rep); @@ -354,10 +354,10 @@ svn_fs_x__noderev_serialize(svn_temp_ser void svn_fs_x__noderev_deserialize(void *buffer, - node_revision_t **noderev_p, + svn_fs_x__noderev_t **noderev_p, apr_pool_t *pool) { - node_revision_t *noderev; + svn_fs_x__noderev_t *noderev; /* fixup the reference to the representation itself, * if this is part of a parent structure. */ @@ -369,10 +369,6 @@ svn_fs_x__noderev_deserialize(void *buff return; /* fixup of sub-structures */ - svn_fs_x__id_deserialize(noderev, (svn_fs_id_t **)&noderev->id, pool); - svn_fs_x__id_deserialize(noderev, - (svn_fs_id_t **)&noderev->predecessor_id, - pool); svn_temp_deserializer__resolve(noderev, (void **)&noderev->prop_rep); svn_temp_deserializer__resolve(noderev, (void **)&noderev->data_rep); @@ -646,48 +642,7 @@ svn_fs_x__deserialize_properties(void ** return SVN_NO_ERROR; } -svn_error_t * -svn_fs_x__serialize_id(void **data, - apr_size_t *data_len, - void *in, - apr_pool_t *pool) -{ - const svn_fs_id_t *id = in; - svn_stringbuf_t *serialized; - - /* create an (empty) serialization context with plenty of buffer space */ - svn_temp_serializer__context_t *context = - svn_temp_serializer__init(NULL, 0, 250, pool); - - /* serialize the id */ - svn_fs_x__id_serialize(context, &id); - - /* return serialized data */ - serialized = svn_temp_serializer__get(context); - *data = serialized->data; - *data_len = serialized->len; - - return SVN_NO_ERROR; -} - -svn_error_t * -svn_fs_x__deserialize_id(void **out, - void *data, - apr_size_t data_len, - apr_pool_t *pool) -{ - /* Copy the _full_ buffer as it also contains the sub-structures. */ - svn_fs_id_t *id = (svn_fs_id_t *)data; - - /* fixup of all pointers etc. */ - svn_fs_x__id_deserialize(id, &id, pool); - - /* done */ - *out = id; - return SVN_NO_ERROR; -} - -/** Caching node_revision_t objects. **/ +/** Caching svn_fs_x__noderev_t objects. **/ svn_error_t * svn_fs_x__serialize_node_revision(void **buffer, @@ -696,7 +651,7 @@ svn_fs_x__serialize_node_revision(void * apr_pool_t *pool) { svn_stringbuf_t *serialized; - node_revision_t *noderev = item; + svn_fs_x__noderev_t *noderev = item; /* create an (empty) serialization context with plenty of (initial) * buffer space. */ @@ -723,7 +678,7 @@ svn_fs_x__deserialize_node_revision(void apr_pool_t *pool) { /* Copy the _full_ buffer as it also contains the sub-structures. */ - node_revision_t *noderev = (node_revision_t *)buffer; + svn_fs_x__noderev_t *noderev = (svn_fs_x__noderev_t *)buffer; /* fixup of all pointers etc. */ svn_fs_x__noderev_deserialize(noderev, &noderev, pool); @@ -800,7 +755,7 @@ svn_fs_x__get_sharded_offset(void **out, * the number of valid entries in ENTRIES. */ static apr_size_t -find_entry(svn_fs_dirent_t **entries, +find_entry(svn_fs_x__dirent_t **entries, const char *name, apr_size_t count, svn_boolean_t *found) @@ -812,7 +767,7 @@ find_entry(svn_fs_dirent_t **entries, for (middle = upper / 2; lower < upper; middle = (upper + lower) / 2) { - const svn_fs_dirent_t *entry = + const svn_fs_x__dirent_t *entry = svn_temp_deserializer__ptr(entries, (const void *const *)&entries[middle]); const char* entry_name = svn_temp_deserializer__ptr(entry, (const void *const *)&entry->name); @@ -828,7 +783,7 @@ find_entry(svn_fs_dirent_t **entries, *found = FALSE; if (lower < count) { - const svn_fs_dirent_t *entry = + const svn_fs_x__dirent_t *entry = svn_temp_deserializer__ptr(entries, (const void *const *)&entries[lower]); const char* entry_name = svn_temp_deserializer__ptr(entry, (const void *const *)&entry->name); @@ -840,6 +795,23 @@ find_entry(svn_fs_dirent_t **entries, return lower; } +/* Utility function that returns TRUE if entry number IDX in ENTRIES has the + * name NAME. + */ +static svn_boolean_t +found_entry(const svn_fs_x__dirent_t * const *entries, + const char *name, + apr_size_t idx) +{ + /* check whether we actually found a match */ + const svn_fs_x__dirent_t *entry = + svn_temp_deserializer__ptr(entries, (const void *const *)&entries[idx]); + const char* entry_name = + svn_temp_deserializer__ptr(entry, (const void *const *)&entry->name); + + return strcmp(entry_name, name) == 0; +} + svn_error_t * svn_fs_x__extract_dir_entry(void **out, const void *data, @@ -848,28 +820,48 @@ svn_fs_x__extract_dir_entry(void **out, apr_pool_t *pool) { const dir_data_t *dir_data = data; - const char* name = baton; + svn_fs_x__ede_baton_t *b = baton; svn_boolean_t found; + apr_size_t pos; /* resolve the reference to the entries array */ - const svn_fs_dirent_t * const *entries = + const svn_fs_x__dirent_t * const *entries = svn_temp_deserializer__ptr(data, (const void *const *)&dir_data->entries); /* resolve the reference to the lengths array */ const apr_uint32_t *lengths = svn_temp_deserializer__ptr(data, (const void *const *)&dir_data->lengths); - /* binary search for the desired entry by name */ - apr_size_t pos = find_entry((svn_fs_dirent_t **)entries, - name, - dir_data->count, - &found); + /* Special case: Early out for empty directories. + That simplifies tests further down the road. */ + *out = NULL; + if (dir_data->count == 0) + return SVN_NO_ERROR; + + /* HINT _might_ be the position we hit last time. + If within valid range, check whether HINT+1 is a hit. */ + if ( b->hint < dir_data->count - 1 + && found_entry(entries, b->name, b->hint + 1)) + { + /* Got lucky. */ + pos = b->hint + 1; + found = TRUE; + } + else + { + /* Binary search for the desired entry by name. */ + pos = find_entry((svn_fs_x__dirent_t **)entries, b->name, + dir_data->count, &found); + } + + /* Remember the hit index - if we FOUND the entry. */ + if (found) + b->hint = pos; /* de-serialize that entry or return NULL, if no match has been found */ - *out = NULL; if (found) { - const svn_fs_dirent_t *source = + const svn_fs_x__dirent_t *source = svn_temp_deserializer__ptr(entries, (const void *const *)&entries[pos]); /* Entries have been serialized one-by-one, each time including all @@ -880,13 +872,11 @@ svn_fs_x__extract_dir_entry(void **out, apr_size_t size = lengths[pos]; /* copy & deserialize the entry */ - svn_fs_dirent_t *new_entry = apr_palloc(pool, size); + svn_fs_x__dirent_t *new_entry = apr_palloc(pool, size); memcpy(new_entry, source, size); svn_temp_deserializer__resolve(new_entry, (void **)&new_entry->name); - svn_fs_x__id_deserialize(new_entry, (svn_fs_id_t **)&new_entry->id, - pool); - *(svn_fs_dirent_t **)out = new_entry; + *(svn_fs_x__dirent_t **)out = new_entry; } return SVN_NO_ERROR; @@ -905,7 +895,7 @@ slowly_replace_dir_entry(void **data, dir_data_t *dir_data = (dir_data_t *)*data; apr_array_header_t *dir; int idx = -1; - svn_fs_dirent_t *entry; + svn_fs_x__dirent_t *entry; SVN_ERR(svn_fs_x__deserialize_dir_entries((void **)&dir, *data, @@ -919,7 +909,8 @@ slowly_replace_dir_entry(void **data, { /* Replace ENTRY with / insert the NEW_ENTRY */ if (entry) - APR_ARRAY_IDX(dir, idx, svn_fs_dirent_t *) = replace_baton->new_entry; + APR_ARRAY_IDX(dir, idx, svn_fs_x__dirent_t *) + = replace_baton->new_entry; else svn_sort__array_insert(dir, &replace_baton->new_entry, idx); } @@ -942,7 +933,7 @@ svn_fs_x__replace_dir_entry(void **data, replace_baton_t *replace_baton = (replace_baton_t *)baton; dir_data_t *dir_data = (dir_data_t *)*data; svn_boolean_t found; - svn_fs_dirent_t **entries; + svn_fs_x__dirent_t **entries; apr_uint32_t *lengths; apr_uint32_t length; apr_size_t pos; @@ -956,7 +947,7 @@ svn_fs_x__replace_dir_entry(void **data, return slowly_replace_dir_entry(data, data_len, baton, pool); /* resolve the reference to the entries array */ - entries = (svn_fs_dirent_t **) + entries = (svn_fs_x__dirent_t **) svn_temp_deserializer__ptr((const char *)dir_data, (const void *const *)&dir_data->entries); @@ -1073,9 +1064,9 @@ svn_fs_x__deserialize_rep_header(void ** */ static void serialize_change(svn_temp_serializer__context_t *context, - change_t * const *change_p) + svn_fs_x__change_t * const *change_p) { - const change_t * change = *change_p; + const svn_fs_x__change_t * change = *change_p; if (change == NULL) return; @@ -1085,10 +1076,8 @@ serialize_change(svn_temp_serializer__co sizeof(*change)); /* serialize sub-structures */ - svn_fs_x__id_serialize(context, &change->info.node_rev_id); - svn_temp_serializer__add_string(context, &change->path.data); - svn_temp_serializer__add_string(context, &change->info.copyfrom_path); + svn_temp_serializer__add_string(context, &change->copyfrom_path); /* return to the caller's nesting level */ svn_temp_serializer__pop(context); @@ -1099,10 +1088,10 @@ serialize_change(svn_temp_serializer__co */ static void deserialize_change(void *buffer, - change_t **change_p, + svn_fs_x__change_t **change_p, apr_pool_t *pool) { - change_t * change; + svn_fs_x__change_t * change; /* fix-up of the pointer to the struct in question */ svn_temp_deserializer__resolve(buffer, (void **)change_p); @@ -1112,15 +1101,11 @@ deserialize_change(void *buffer, return; /* fix-up of sub-structures */ - svn_fs_x__id_deserialize(change, - (svn_fs_id_t **)&change->info.node_rev_id, - pool); - svn_temp_deserializer__resolve(change, (void **)&change->path.data); - svn_temp_deserializer__resolve(change, (void **)&change->info.copyfrom_path); + svn_temp_deserializer__resolve(change, (void **)&change->copyfrom_path); } -/* Auxiliary structure representing the content of a change_t array. +/* Auxiliary structure representing the content of a svn_fs_x__change_t array. This structure is much easier to (de-)serialize than an APR array. */ typedef struct changes_data_t @@ -1129,7 +1114,7 @@ typedef struct changes_data_t int count; /* reference to the changes */ - change_t **changes; + svn_fs_x__change_t **changes; } changes_data_t; svn_error_t * @@ -1147,7 +1132,7 @@ svn_fs_x__serialize_changes(void **data, /* initialize our auxiliary data structure and link it to the * array elements */ changes.count = array->nelts; - changes.changes = (change_t **)array->elts; + changes.changes = (svn_fs_x__change_t **)array->elts; /* serialize it and all its elements */ context = svn_temp_serializer__init(&changes, @@ -1157,7 +1142,7 @@ svn_fs_x__serialize_changes(void **data, svn_temp_serializer__push(context, (const void * const *)&changes.changes, - changes.count * sizeof(change_t*)); + changes.count * sizeof(svn_fs_x__change_t*)); for (i = 0; i < changes.count; ++i) serialize_change(context, &changes.changes[i]); @@ -1181,7 +1166,8 @@ svn_fs_x__deserialize_changes(void **out { int i; changes_data_t *changes = (changes_data_t *)data; - apr_array_header_t *array = apr_array_make(pool, 0, sizeof(change_t *)); + apr_array_header_t *array = apr_array_make(pool, 0, + sizeof(svn_fs_x__change_t *)); /* de-serialize our auxiliary data structure */ svn_temp_deserializer__resolve(changes, (void**)&changes->changes); @@ -1189,7 +1175,7 @@ svn_fs_x__deserialize_changes(void **out /* de-serialize each entry and add it to the array */ for (i = 0; i < changes->count; ++i) deserialize_change(changes->changes, - (change_t **)&changes->changes[i], + (svn_fs_x__change_t **)&changes->changes[i], pool); /* Use the changes buffer as the array's data buffer Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/temp_serializer.h URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/temp_serializer.h?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/temp_serializer.h (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/temp_serializer.h Wed Jan 21 16:22:19 2015 @@ -23,6 +23,7 @@ #ifndef SVN_LIBSVN_FS__TEMP_SERIALIZER_H #define SVN_LIBSVN_FS__TEMP_SERIALIZER_H +#include "private/svn_temp_serializer.h" #include "fs.h" /** @@ -40,7 +41,7 @@ svn_fs_x__combine_number_and_string(apr_ */ void svn_fs_x__noderev_serialize(struct svn_temp_serializer__context_t *context, - node_revision_t * const *noderev_p); + svn_fs_x__noderev_t * const *noderev_p); /** * Deserialize a @a noderev_p within the @a buffer and associate it with @@ -48,7 +49,7 @@ svn_fs_x__noderev_serialize(struct svn_t */ void svn_fs_x__noderev_deserialize(void *buffer, - node_revision_t **noderev_p, + svn_fs_x__noderev_t **noderev_p, apr_pool_t *pool); /** @@ -146,25 +147,7 @@ svn_fs_x__deserialize_properties(void ** apr_pool_t *pool); /** - * Implements #svn_cache__serialize_func_t for #svn_fs_id_t - */ -svn_error_t * -svn_fs_x__serialize_id(void **data, - apr_size_t *data_len, - void *in, - apr_pool_t *pool); - -/** - * Implements #svn_cache__deserialize_func_t for #svn_fs_id_t - */ -svn_error_t * -svn_fs_x__deserialize_id(void **out, - void *data, - apr_size_t data_len, - apr_pool_t *pool); - -/** - * Implements #svn_cache__serialize_func_t for #node_revision_t + * Implements #svn_cache__serialize_func_t for #svn_fs_x__noderev_t */ svn_error_t * svn_fs_x__serialize_node_revision(void **buffer, @@ -173,7 +156,7 @@ svn_fs_x__serialize_node_revision(void * apr_pool_t *pool); /** - * Implements #svn_cache__deserialize_func_t for #node_revision_t + * Implements #svn_cache__deserialize_func_t for #svn_fs_x__noderev_t */ svn_error_t * svn_fs_x__deserialize_node_revision(void **item, @@ -211,9 +194,20 @@ svn_fs_x__get_sharded_offset(void **out, apr_pool_t *pool); /** + * Baton type to be used with svn_fs_x__extract_dir_entry. */ +typedef struct svn_fs_x__ede_baton_t +{ + /* Name of the directory entry to find. */ + const char *name; + + /* Lookup hint [in / out] */ + apr_size_t hint; +} svn_fs_x__ede_baton_t; + +/** * Implements #svn_cache__partial_getter_func_t for a single - * #svn_fs_dirent_t within a serialized directory contents hash, - * identified by its name (const char @a *baton). + * #svn_fs_x__dirent_t within a serialized directory contents hash, + * identified by its name (given in @a svn_fs_x__ede_baton_t @a *baton). */ svn_error_t * svn_fs_x__extract_dir_entry(void **out, @@ -234,12 +228,12 @@ typedef struct replace_baton_t const char *name; /** directory entry to insert instead */ - svn_fs_dirent_t *new_entry; + svn_fs_x__dirent_t *new_entry; } replace_baton_t; /** * Implements #svn_cache__partial_setter_func_t for a single - * #svn_fs_dirent_t within a serialized directory contents hash, + * #svn_fs_x__dirent_t within a serialized directory contents hash, * identified by its name in the #replace_baton_t in @a baton. */ svn_error_t * @@ -268,7 +262,7 @@ svn_fs_x__deserialize_rep_header(void ** /** * Implements #svn_cache__serialize_func_t for an #apr_array_header_t of - * #change_t *. + * #svn_fs_x__change_t *. */ svn_error_t * svn_fs_x__serialize_changes(void **data, @@ -278,7 +272,7 @@ svn_fs_x__serialize_changes(void **data, /** * Implements #svn_cache__deserialize_func_t for an #apr_array_header_t of - * #change_t *. + * #svn_fs_x__change_t *. */ svn_error_t * svn_fs_x__deserialize_changes(void **out,
