Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/pack.c URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/pack.c?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/pack.c (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/pack.c Wed Jan 21 16:22:19 2015 @@ -101,7 +101,7 @@ typedef struct path_order_t svn_prefix_string__t *path; /* node ID for this PATH in REVISION */ - svn_fs_x__id_part_t node_id; + svn_fs_x__id_t node_id; /* when this change happened */ svn_revnum_t revision; @@ -113,10 +113,10 @@ typedef struct path_order_t apr_int64_t expanded_size; /* item ID of the noderev linked to the change. May be (0, 0). */ - svn_fs_x__id_part_t noderev_id; + svn_fs_x__id_t noderev_id; /* item ID of the representation containing the new data. May be (0, 0). */ - svn_fs_x__id_part_t rep_id; + svn_fs_x__id_t rep_id; } path_order_t; /* Represents a reference from item FROM to item TO. FROM may be a noderev @@ -125,8 +125,8 @@ typedef struct path_order_t */ typedef struct reference_t { - svn_fs_x__id_part_t to; - svn_fs_x__id_part_t from; + svn_fs_x__id_t to; + svn_fs_x__id_t from; } reference_t; /* This structure keeps track of all the temporary data and status that @@ -251,7 +251,7 @@ initialize_pack_context(pack_context_t * void *cancel_baton, apr_pool_t *pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; const char *temp_dir; int max_revs = MIN(ffd->max_files_per_dir, max_items); @@ -326,24 +326,24 @@ initialize_pack_context(pack_context_t * } /* Clean up / free all revision range specific data and files in CONTEXT. - * Use POOL for temporary allocations. + * Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * reset_pack_context(pack_context_t *context, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { apr_array_clear(context->changes); - SVN_ERR(svn_io_file_trunc(context->changes_file, 0, pool)); + SVN_ERR(svn_io_file_trunc(context->changes_file, 0, scratch_pool)); apr_array_clear(context->file_props); - SVN_ERR(svn_io_file_trunc(context->file_props_file, 0, pool)); + SVN_ERR(svn_io_file_trunc(context->file_props_file, 0, scratch_pool)); apr_array_clear(context->dir_props); - SVN_ERR(svn_io_file_trunc(context->dir_props_file, 0, pool)); + SVN_ERR(svn_io_file_trunc(context->dir_props_file, 0, scratch_pool)); apr_array_clear(context->rev_offsets); apr_array_clear(context->path_order); apr_array_clear(context->references); apr_array_clear(context->reps); - SVN_ERR(svn_io_file_trunc(context->reps_file, 0, pool)); + SVN_ERR(svn_io_file_trunc(context->reps_file, 0, scratch_pool)); svn_pool_clear(context->info_pool); @@ -351,50 +351,52 @@ reset_pack_context(pack_context_t *conte } /* Call this after the last revision range. It will finalize all index files - * for CONTEXT and close any open files. Use POOL for temporary allocations. + * for CONTEXT and close any open files. + * Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * close_pack_context(pack_context_t *context, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { const char *proto_l2p_index_path; const char *proto_p2l_index_path; /* need the file names for the actual index creation call further down */ SVN_ERR(svn_io_file_name_get(&proto_l2p_index_path, - context->proto_l2p_index, pool)); + context->proto_l2p_index, scratch_pool)); SVN_ERR(svn_io_file_name_get(&proto_p2l_index_path, - context->proto_p2l_index, pool)); + context->proto_p2l_index, scratch_pool)); /* finalize proto index files */ - SVN_ERR(svn_io_file_close(context->proto_l2p_index, pool)); - SVN_ERR(svn_io_file_close(context->proto_p2l_index, pool)); + SVN_ERR(svn_io_file_close(context->proto_l2p_index, scratch_pool)); + SVN_ERR(svn_io_file_close(context->proto_p2l_index, scratch_pool)); /* Append the actual index data to the pack file. */ SVN_ERR(svn_fs_x__add_index_data(context->fs, context->pack_file, proto_l2p_index_path, proto_p2l_index_path, context->shard_rev, - pool)); + scratch_pool)); /* remove proto index files */ - SVN_ERR(svn_io_remove_file2(proto_l2p_index_path, FALSE, pool)); - SVN_ERR(svn_io_remove_file2(proto_p2l_index_path, FALSE, pool)); + SVN_ERR(svn_io_remove_file2(proto_l2p_index_path, FALSE, scratch_pool)); + SVN_ERR(svn_io_remove_file2(proto_p2l_index_path, FALSE, scratch_pool)); - SVN_ERR(svn_io_file_close(context->pack_file, pool)); + SVN_ERR(svn_io_file_close(context->pack_file, scratch_pool)); return SVN_NO_ERROR; } /* Efficiently copy SIZE bytes from SOURCE to DEST. Invoke the CANCEL_FUNC - * from CONTEXT at regular intervals. Use POOL for allocations. + * from CONTEXT at regular intervals. + * Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * copy_file_data(pack_context_t *context, apr_file_t *dest, apr_file_t *source, apr_off_t size, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { /* most non-representation items will be small. Minimize the buffer * and infrastructure overhead in that case. */ @@ -405,17 +407,17 @@ copy_file_data(pack_context_t *context, /* copy small data using a fixed-size buffer on stack */ char buffer[STACK_BUFFER_SIZE]; SVN_ERR(svn_io_file_read_full2(source, buffer, (apr_size_t)size, - NULL, NULL, pool)); + NULL, NULL, scratch_pool)); SVN_ERR(svn_io_file_write_full(dest, buffer, (apr_size_t)size, - NULL, pool)); + NULL, scratch_pool)); } else { /* use streaming copies for larger data blocks. That may require * the allocation of larger buffers and we should make sure that * this extra memory is released asap. */ - fs_x_data_t *ffd = context->fs->fsap_data; - apr_pool_t *copypool = svn_pool_create(pool); + svn_fs_x__data_t *ffd = context->fs->fsap_data; + apr_pool_t *copypool = svn_pool_create(scratch_pool); char *buffer = apr_palloc(copypool, ffd->block_size); while (size) @@ -425,9 +427,9 @@ copy_file_data(pack_context_t *context, SVN_ERR(context->cancel_func(context->cancel_baton)); SVN_ERR(svn_io_file_read_full2(source, buffer, to_copy, - NULL, NULL, pool)); + NULL, NULL, scratch_pool)); SVN_ERR(svn_io_file_write_full(dest, buffer, to_copy, - NULL, pool)); + NULL, scratch_pool)); size -= to_copy; } @@ -438,12 +440,13 @@ copy_file_data(pack_context_t *context, return SVN_NO_ERROR; } -/* Writes SIZE bytes, all 0, to DEST. Uses POOL for allocations. +/* Writes SIZE bytes, all 0, to DEST. + * Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * write_null_bytes(apr_file_t *dest, apr_off_t size, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { /* Have a collection of high-quality, easy to access NUL bytes handy. */ enum { BUFFER_SIZE = 1024 }; @@ -453,7 +456,8 @@ write_null_bytes(apr_file_t *dest, while (size) { apr_size_t to_write = MIN(size, BUFFER_SIZE); - SVN_ERR(svn_io_file_write_full(dest, buffer, to_write, NULL, pool)); + SVN_ERR(svn_io_file_write_full(dest, buffer, to_write, NULL, + scratch_pool)); size -= to_write; } @@ -463,7 +467,8 @@ write_null_bytes(apr_file_t *dest, /* Copy the "simple" item (changed paths list or property representation) * from the current position in REV_FILE to TEMP_FILE using CONTEXT. Add * a copy of ENTRY to ENTRIES but with an updated offset value that points - * to the copy destination in TEMP_FILE. Use POOL for allocations. + * to the copy destination in TEMP_FILE. + * Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * copy_item_to_temp(pack_context_t *context, @@ -471,16 +476,17 @@ copy_item_to_temp(pack_context_t *contex apr_file_t *temp_file, svn_fs_x__revision_file_t *rev_file, svn_fs_x__p2l_entry_t *entry, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { svn_fs_x__p2l_entry_t *new_entry = svn_fs_x__p2l_entry_dup(entry, context->info_pool); - new_entry->offset = 0; - SVN_ERR(svn_io_file_seek(temp_file, APR_CUR, &new_entry->offset, pool)); + + SVN_ERR(svn_fs_x__get_file_offset(&new_entry->offset, temp_file, + scratch_pool)); APR_ARRAY_PUSH(entries, svn_fs_x__p2l_entry_t *) = new_entry; SVN_ERR(copy_file_data(context, temp_file, rev_file->file, entry->size, - pool)); + scratch_pool)); return SVN_NO_ERROR; } @@ -530,7 +536,7 @@ add_item_rep_mapping(pack_context_t *con */ static svn_fs_x__p2l_entry_t * get_item(pack_context_t *context, - const svn_fs_x__id_part_t *id, + const svn_fs_x__id_t *id, svn_boolean_t reset) { svn_fs_x__p2l_entry_t *result = NULL; @@ -551,13 +557,14 @@ get_item(pack_context_t *context, /* Copy representation item identified by ENTRY from the current position * in REV_FILE into CONTEXT->REPS_FILE. Add all tracking into needed by - * our placement algorithm to CONTEXT. Use POOL for temporary allocations. + * our placement algorithm to CONTEXT. + * Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * copy_rep_to_temp(pack_context_t *context, svn_fs_x__revision_file_t *rev_file, svn_fs_x__p2l_entry_t *entry, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { svn_fs_x__rep_header_t *rep_header; apr_off_t source_offset = entry->offset; @@ -565,14 +572,13 @@ copy_rep_to_temp(pack_context_t *context /* create a copy of ENTRY, make it point to the copy destination and * store it in CONTEXT */ entry = svn_fs_x__p2l_entry_dup(entry, context->info_pool); - entry->offset = 0; - SVN_ERR(svn_io_file_seek(context->reps_file, APR_CUR, &entry->offset, - pool)); + SVN_ERR(svn_fs_x__get_file_offset(&entry->offset, context->reps_file, + scratch_pool)); add_item_rep_mapping(context, entry); /* read & parse the representation header */ - SVN_ERR(svn_fs_x__read_rep_header(&rep_header, rev_file->stream, pool, - pool)); + SVN_ERR(svn_fs_x__read_rep_header(&rep_header, rev_file->stream, + scratch_pool, scratch_pool)); /* if the representation is a delta against some other rep, link the two */ if ( rep_header->type == svn_fs_x__rep_delta @@ -588,9 +594,10 @@ copy_rep_to_temp(pack_context_t *context } /* copy the whole rep (including header!) to our temp file */ - SVN_ERR(svn_io_file_seek(rev_file->file, APR_SET, &source_offset, pool)); + SVN_ERR(svn_io_file_seek(rev_file->file, APR_SET, &source_offset, + scratch_pool)); SVN_ERR(copy_file_data(context, context->reps_file, rev_file->file, - entry->size, pool)); + entry->size, scratch_pool)); return SVN_NO_ERROR; } @@ -667,35 +674,37 @@ tweak_path_for_ordering(const char *orig /* Copy node revision item identified by ENTRY from the current position * in REV_FILE into CONTEXT->REPS_FILE. Add all tracking into needed by - * our placement algorithm to CONTEXT. Use POOL for temporary allocations. + * our placement algorithm to CONTEXT. + * Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * copy_node_to_temp(pack_context_t *context, svn_fs_x__revision_file_t *rev_file, svn_fs_x__p2l_entry_t *entry, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { path_order_t *path_order = apr_pcalloc(context->info_pool, sizeof(*path_order)); - node_revision_t *noderev; + svn_fs_x__noderev_t *noderev; const char *sort_path; apr_off_t source_offset = entry->offset; /* read & parse noderev */ - SVN_ERR(svn_fs_x__read_noderev(&noderev, rev_file->stream, pool, pool)); + SVN_ERR(svn_fs_x__read_noderev(&noderev, rev_file->stream, scratch_pool, + scratch_pool)); /* create a copy of ENTRY, make it point to the copy destination and * store it in CONTEXT */ entry = svn_fs_x__p2l_entry_dup(entry, context->info_pool); - entry->offset = 0; - SVN_ERR(svn_io_file_seek(context->reps_file, APR_CUR, - &entry->offset, pool)); + SVN_ERR(svn_fs_x__get_file_offset(&entry->offset, context->reps_file, + scratch_pool)); add_item_rep_mapping(context, entry); /* copy the noderev to our temp file */ - SVN_ERR(svn_io_file_seek(rev_file->file, APR_SET, &source_offset, pool)); + SVN_ERR(svn_io_file_seek(rev_file->file, APR_SET, &source_offset, + scratch_pool)); SVN_ERR(copy_file_data(context, context->reps_file, rev_file->file, - entry->size, pool)); + entry->size, scratch_pool)); /* if the node has a data representation, make that the node's "base". * This will (often) cause the noderev to be placed right in front of @@ -718,12 +727,12 @@ copy_node_to_temp(pack_context_t *contex /* Sort path is the key used for ordering noderevs and associated reps. * It will not be stored in the final pack file. */ - sort_path = tweak_path_for_ordering(noderev->created_path, pool); + sort_path = tweak_path_for_ordering(noderev->created_path, scratch_pool); path_order->path = svn_prefix_string__create(context->paths, sort_path); - path_order->node_id = *svn_fs_x__id_node_id(noderev->id); - path_order->revision = svn_fs_x__id_rev(noderev->id); + path_order->node_id = noderev->node_id; + path_order->revision = svn_fs_x__get_revnum(noderev->noderev_id.change_set); path_order->is_dir = noderev->kind == svn_node_dir; - path_order->noderev_id = *svn_fs_x__id_noderev_id(noderev->id); + path_order->noderev_id = noderev->noderev_id; APR_ARRAY_PUSH(context->path_order, path_order_t *) = path_order; return SVN_NO_ERROR; @@ -777,7 +786,7 @@ compare_path_order(const path_order_t * return diff; /* reverse order on node (i.e. latest first) */ - diff = svn_fs_x__id_part_compare(&rhs->node_id, &lhs->node_id); + diff = svn_fs_x__id_compare(&rhs->node_id, &lhs->node_id); if (diff) return diff; @@ -797,8 +806,8 @@ compare_references(const reference_t * c const reference_t * lhs = *lhs_p; const reference_t * rhs = *rhs_p; - int diff = svn_fs_x__id_part_compare(&lhs->to, &rhs->to); - return diff ? diff : svn_fs_x__id_part_compare(&lhs->from, &rhs->from); + int diff = svn_fs_x__id_compare(&lhs->to, &rhs->to); + return diff ? diff : svn_fs_x__id_compare(&lhs->from, &rhs->from); } /* Order the data collected in CONTEXT such that we can place them in the @@ -819,20 +828,20 @@ sort_reps(pack_context_t *context) static apr_ssize_t get_block_left(pack_context_t *context) { - fs_x_data_t *ffd = context->fs->fsap_data; + svn_fs_x__data_t *ffd = context->fs->fsap_data; return ffd->block_size - (context->pack_offset % ffd->block_size); } /* To prevent items from overlapping a block boundary, we will usually * put them into the next block and top up the old one with NUL bytes. * Pad CONTEXT's pack file to the end of the current block, if that padding - * is short enough. Use POOL for allocations. + * is short enough. Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * auto_pad_block(pack_context_t *context, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = context->fs->fsap_data; + svn_fs_x__data_t *ffd = context->fs->fsap_data; /* This is the maximum number of bytes "wasted" that way per block. * Larger items will cross the block boundaries. */ @@ -855,9 +864,9 @@ auto_pad_block(pack_context_t *context, null_entry.item_count = 0; null_entry.items = NULL; - SVN_ERR(write_null_bytes(context->pack_file, padding, pool)); + SVN_ERR(write_null_bytes(context->pack_file, padding, scratch_pool)); SVN_ERR(svn_fs_x__p2l_proto_index_add_entry - (context->proto_p2l_index, &null_entry, pool)); + (context->proto_p2l_index, &null_entry, scratch_pool)); context->pack_offset += padding; } @@ -881,7 +890,7 @@ find_first_reference(pack_context_t *con reference_t *reference = APR_ARRAY_IDX(context->references, current, reference_t *); - if (svn_fs_x__id_part_compare(&reference->to, item->items) < 0) + if (svn_fs_x__id_compare(&reference->to, item->items) < 0) lower = current + 1; else upper = current - 1; @@ -902,7 +911,7 @@ is_reference_match(pack_context_t *conte return FALSE; reference = APR_ARRAY_IDX(context->references, idx, reference_t *); - return svn_fs_x__id_part_eq(&reference->to, item->items); + return svn_fs_x__id_eq(&reference->to, item->items); } /* Starting at IDX in CONTEXT->PATH_ORDER, select all representations and @@ -939,8 +948,7 @@ select_reps(pack_context_t *context, path_order_t *current_path = APR_ARRAY_IDX(path_order, idx, path_order_t *); - if (!svn_fs_x__id_part_eq(&start_path->node_id, - ¤t_path->node_id)) + if (!svn_fs_x__id_eq(&start_path->node_id, ¤t_path->node_id)) break; APR_ARRAY_IDX(path_order, idx, path_order_t *) = NULL; @@ -1039,7 +1047,7 @@ write_nodes_container(pack_context_t *co container_entry->type = SVN_FS_X__ITEM_TYPE_NODEREVS_CONT; container_entry->item_count = items->nelts; container_entry->items = apr_palloc(context->info_pool, - sizeof(svn_fs_x__id_part_t) * container_entry->item_count); + sizeof(svn_fs_x__id_t) * container_entry->item_count); for (i = 0; i < items->nelts; ++i) container_entry->items[i] @@ -1094,7 +1102,7 @@ store_nodes(pack_context_t *context, apr_size_t pack_savings = 0; for (i = 0; i < node_parts->nelts; ++i) { - node_revision_t *noderev; + svn_fs_x__noderev_t *noderev; svn_fs_x__p2l_entry_t *entry = APR_ARRAY_IDX(node_parts, i, svn_fs_x__p2l_entry_t *); @@ -1161,14 +1169,14 @@ store_nodes(pack_context_t *context, /* Finalize CONTAINER and write it to CONTEXT's pack file. * Append an P2L entry containing the given SUB_ITEMS to NEW_ENTRIES. - * Use POOL for temporary allocations. + * Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * write_reps_container(pack_context_t *context, svn_fs_x__reps_builder_t *container, apr_array_header_t *sub_items, apr_array_header_t *new_entries, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { apr_off_t offset = 0; svn_fs_x__p2l_entry_t container_entry; @@ -1177,42 +1185,44 @@ write_reps_container(pack_context_t *con = svn_checksum__wrap_write_stream_fnv1a_32x4 (&container_entry.fnv1_checksum, svn_stream_from_aprfile2(context->pack_file, - TRUE, pool), - pool); + TRUE, scratch_pool), + scratch_pool); - SVN_ERR(svn_fs_x__write_reps_container(pack_stream, container, pool)); + SVN_ERR(svn_fs_x__write_reps_container(pack_stream, container, + scratch_pool)); SVN_ERR(svn_stream_close(pack_stream)); - SVN_ERR(svn_io_file_seek(context->pack_file, APR_CUR, &offset, pool)); + SVN_ERR(svn_io_file_seek(context->pack_file, APR_CUR, &offset, + scratch_pool)); container_entry.offset = context->pack_offset; container_entry.size = offset - container_entry.offset; container_entry.type = SVN_FS_X__ITEM_TYPE_REPS_CONT; container_entry.item_count = sub_items->nelts; - container_entry.items = (svn_fs_x__id_part_t *)sub_items->elts; + container_entry.items = (svn_fs_x__id_t *)sub_items->elts; context->pack_offset = offset; APR_ARRAY_PUSH(new_entries, svn_fs_x__p2l_entry_t *) = svn_fs_x__p2l_entry_dup(&container_entry, context->info_pool); SVN_ERR(svn_fs_x__p2l_proto_index_add_entry - (context->proto_p2l_index, &container_entry, pool)); + (context->proto_p2l_index, &container_entry, scratch_pool)); return SVN_NO_ERROR; } /* Read the (property) representations identified by svn_fs_x__p2l_entry_t * elements in ENTRIES from TEMP_FILE, aggregate them and write them into - * CONTEXT->PACK_FILE. Use POOL for temporary allocations. + * CONTEXT->PACK_FILE. Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * write_reps_containers(pack_context_t *context, apr_array_header_t *entries, apr_file_t *temp_file, apr_array_header_t *new_entries, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { - apr_pool_t *iterpool = svn_pool_create(pool); - apr_pool_t *container_pool = svn_pool_create(pool); + apr_pool_t *iterpool = svn_pool_create(scratch_pool); + apr_pool_t *container_pool = svn_pool_create(scratch_pool); int i; apr_ssize_t block_left = get_block_left(context); @@ -1220,15 +1230,16 @@ write_reps_containers(pack_context_t *co svn_fs_x__reps_builder_t *container = svn_fs_x__reps_builder_create(context->fs, container_pool); apr_array_header_t *sub_items - = apr_array_make(pool, 64, sizeof(svn_fs_x__id_part_t)); + = apr_array_make(scratch_pool, 64, sizeof(svn_fs_x__id_t)); svn_fs_x__revision_file_t *file; - SVN_ERR(svn_fs_x__wrap_temp_rev_file(&file, context->fs, temp_file, pool)); + SVN_ERR(svn_fs_x__wrap_temp_rev_file(&file, context->fs, temp_file, + scratch_pool)); /* copy all items in strict order */ for (i = entries->nelts-1; i >= 0; --i) { - representation_t representation = { 0 }; + svn_fs_x__representation_t representation = { 0 }; svn_stringbuf_t *contents; svn_stream_t *stream; apr_size_t list_index; @@ -1286,7 +1297,7 @@ write_reps_containers(pack_context_t *co SVN_ERR_ASSERT(list_index == sub_items->nelts); block_left -= entry->size; - APR_ARRAY_PUSH(sub_items, svn_fs_x__id_part_t) = entry->items[0]; + APR_ARRAY_PUSH(sub_items, svn_fs_x__id_t) = entry->items[0]; svn_pool_clear(iterpool); } @@ -1328,17 +1339,17 @@ should_flush_nodes_container(pack_contex /* Read the contents of the first COUNT non-NULL, non-empty items in ITEMS * from TEMP_FILE and write them to CONTEXT->PACK_FILE. - * Use POOL for allocations. + * Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * store_items(pack_context_t *context, apr_file_t *temp_file, apr_array_header_t *items, int count, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { int i; - apr_pool_t *iterpool = svn_pool_create(pool); + apr_pool_t *iterpool = svn_pool_create(scratch_pool); /* copy all items in strict order */ for (i = 0; i < count; ++i) @@ -1375,26 +1386,26 @@ store_items(pack_context_t *context, /* Copy (append) the items identified by svn_fs_x__p2l_entry_t * elements * in ENTRIES strictly in order from TEMP_FILE into CONTEXT->PACK_FILE. - * Use POOL for temporary allocations. + * Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * copy_reps_from_temp(pack_context_t *context, apr_file_t *temp_file, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = context->fs->fsap_data; + svn_fs_x__data_t *ffd = context->fs->fsap_data; - apr_pool_t *iterpool = svn_pool_create(pool); - apr_pool_t *container_pool = svn_pool_create(pool); + apr_pool_t *iterpool = svn_pool_create(scratch_pool); + apr_pool_t *container_pool = svn_pool_create(scratch_pool); apr_array_header_t *path_order = context->path_order; apr_array_header_t *reps = context->reps; - apr_array_header_t *selected = apr_array_make(pool, 16, + apr_array_header_t *selected = apr_array_make(scratch_pool, 16, path_order->elt_size); - apr_array_header_t *node_parts = apr_array_make(pool, 16, + apr_array_header_t *node_parts = apr_array_make(scratch_pool, 16, reps->elt_size); - apr_array_header_t *rep_parts = apr_array_make(pool, 16, + apr_array_header_t *rep_parts = apr_array_make(scratch_pool, 16, reps->elt_size); - apr_array_header_t *nodes_in_container = apr_array_make(pool, 16, + apr_array_header_t *nodes_in_container = apr_array_make(scratch_pool, 16, reps->elt_size); int i, k; int initial_reps_count = reps->nelts; @@ -1450,7 +1461,8 @@ copy_reps_from_temp(pack_context_t *cont iterpool)); /* copy all items in strict order */ - SVN_ERR(store_items(context, temp_file, reps, initial_reps_count, pool)); + SVN_ERR(store_items(context, temp_file, reps, initial_reps_count, + scratch_pool)); /* vaccum ENTRIES array: eliminate NULL entries */ for (i = 0, k = 0; i < reps->nelts; ++i) @@ -1473,14 +1485,14 @@ copy_reps_from_temp(pack_context_t *cont /* Finalize CONTAINER and write it to CONTEXT's pack file. * Append an P2L entry containing the given SUB_ITEMS to NEW_ENTRIES. - * Use POOL for temporary allocations. + * Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * write_changes_container(pack_context_t *context, svn_fs_x__changes_t *container, apr_array_header_t *sub_items, apr_array_header_t *new_entries, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { apr_off_t offset = 0; svn_fs_x__p2l_entry_t container_entry; @@ -1489,43 +1501,44 @@ write_changes_container(pack_context_t * = svn_checksum__wrap_write_stream_fnv1a_32x4 (&container_entry.fnv1_checksum, svn_stream_from_aprfile2(context->pack_file, - TRUE, pool), - pool); + TRUE, scratch_pool), + scratch_pool); SVN_ERR(svn_fs_x__write_changes_container(pack_stream, container, - pool)); + scratch_pool)); SVN_ERR(svn_stream_close(pack_stream)); - SVN_ERR(svn_io_file_seek(context->pack_file, APR_CUR, &offset, pool)); + SVN_ERR(svn_io_file_seek(context->pack_file, APR_CUR, &offset, + scratch_pool)); container_entry.offset = context->pack_offset; container_entry.size = offset - container_entry.offset; container_entry.type = SVN_FS_X__ITEM_TYPE_CHANGES_CONT; container_entry.item_count = sub_items->nelts; - container_entry.items = (svn_fs_x__id_part_t *)sub_items->elts; + container_entry.items = (svn_fs_x__id_t *)sub_items->elts; context->pack_offset = offset; APR_ARRAY_PUSH(new_entries, svn_fs_x__p2l_entry_t *) = svn_fs_x__p2l_entry_dup(&container_entry, context->info_pool); SVN_ERR(svn_fs_x__p2l_proto_index_add_entry - (context->proto_p2l_index, &container_entry, pool)); + (context->proto_p2l_index, &container_entry, scratch_pool)); return SVN_NO_ERROR; } /* Read the change lists identified by svn_fs_x__p2l_entry_t * elements * in ENTRIES strictly in from TEMP_FILE, aggregate them and write them - * into CONTEXT->PACK_FILE. Use POOL for temporary allocations. + * into CONTEXT->PACK_FILE. Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * write_changes_containers(pack_context_t *context, apr_array_header_t *entries, apr_file_t *temp_file, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { - apr_pool_t *iterpool = svn_pool_create(pool); - apr_pool_t *container_pool = svn_pool_create(pool); + apr_pool_t *iterpool = svn_pool_create(scratch_pool); + apr_pool_t *container_pool = svn_pool_create(scratch_pool); int i; apr_ssize_t block_left = get_block_left(context); @@ -1534,11 +1547,11 @@ write_changes_containers(pack_context_t svn_fs_x__changes_t *container = svn_fs_x__changes_create(1000, container_pool); apr_array_header_t *sub_items - = apr_array_make(pool, 64, sizeof(svn_fs_x__id_part_t)); + = apr_array_make(scratch_pool, 64, sizeof(svn_fs_x__id_t)); apr_array_header_t *new_entries = apr_array_make(context->info_pool, 16, entries->elt_size); svn_stream_t *temp_stream - = svn_stream_from_aprfile2(temp_file, TRUE, pool); + = svn_stream_from_aprfile2(temp_file, TRUE, scratch_pool); /* copy all items in strict order */ for (i = entries->nelts-1; i >= 0; --i) @@ -1594,13 +1607,14 @@ write_changes_containers(pack_context_t * the container */ SVN_ERR(svn_io_file_seek(temp_file, APR_SET, &entry->offset, iterpool)); - SVN_ERR(svn_fs_x__read_changes(&changes, temp_stream, pool, iterpool)); + SVN_ERR(svn_fs_x__read_changes(&changes, temp_stream, scratch_pool, + iterpool)); SVN_ERR(svn_fs_x__changes_append_list(&list_index, container, changes)); SVN_ERR_ASSERT(list_index == sub_items->nelts); block_left -= estimated_size; estimated_addition += estimated_size; - APR_ARRAY_PUSH(sub_items, svn_fs_x__id_part_t) = entry->items[0]; + APR_ARRAY_PUSH(sub_items, svn_fs_x__id_t) = entry->items[0]; svn_pool_clear(iterpool); } @@ -1618,19 +1632,19 @@ write_changes_containers(pack_context_t /* Read the (property) representations identified by svn_fs_x__p2l_entry_t * elements in ENTRIES from TEMP_FILE, aggregate them and write them into - * CONTEXT->PACK_FILE. Use POOL for temporary allocations. + * CONTEXT->PACK_FILE. Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * write_property_containers(pack_context_t *context, apr_array_header_t *entries, apr_file_t *temp_file, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { apr_array_header_t *new_entries = apr_array_make(context->info_pool, 16, entries->elt_size); SVN_ERR(write_reps_containers(context, entries, temp_file, new_entries, - pool)); + scratch_pool)); *entries = *new_entries; @@ -1692,15 +1706,15 @@ write_l2p_index(pack_context_t *context, } /* Pack the current revision range of CONTEXT, i.e. this covers phases 2 - * to 4. Use POOL for allocations. + * to 4. Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * pack_range(pack_context_t *context, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = context->fs->fsap_data; - apr_pool_t *revpool = svn_pool_create(pool); - apr_pool_t *iterpool = svn_pool_create(pool); + svn_fs_x__data_t *ffd = context->fs->fsap_data; + apr_pool_t *revpool = svn_pool_create(scratch_pool); + apr_pool_t *iterpool = svn_pool_create(scratch_pool); /* Phase 2: Copy items into various buckets and build tracking info */ svn_revnum_t revision; @@ -1818,15 +1832,15 @@ pack_range(pack_context_t *context, /* Append CONTEXT->START_REV to the context's pack file with no re-ordering. * This function will only be used for very large revisions (>>100k changes). - * Use POOL for temporary allocations. + * Use SCRATCH_POOL for temporary allocations. */ static svn_error_t * append_revision(pack_context_t *context, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = context->fs->fsap_data; + svn_fs_x__data_t *ffd = context->fs->fsap_data; apr_off_t offset = 0; - apr_pool_t *iterpool = svn_pool_create(pool); + apr_pool_t *iterpool = svn_pool_create(scratch_pool); svn_fs_x__revision_file_t *rev_file; apr_finfo_t finfo; @@ -1834,19 +1848,19 @@ append_revision(pack_context_t *context, const char *path = svn_dirent_join(context->shard_dir, apr_psprintf(iterpool, "%ld", context->start_rev), - pool); - SVN_ERR(svn_io_stat(&finfo, path, APR_FINFO_SIZE, pool)); + scratch_pool); + SVN_ERR(svn_io_stat(&finfo, path, APR_FINFO_SIZE, scratch_pool)); /* Copy all the bits from the rev file to the end of the pack file. */ SVN_ERR(svn_fs_x__open_pack_or_rev_file(&rev_file, context->fs, - context->start_rev, pool, + context->start_rev, scratch_pool, iterpool)); SVN_ERR(copy_file_data(context, context->pack_file, rev_file->file, finfo.size, iterpool)); /* mark the start of a new revision */ SVN_ERR(svn_fs_x__l2p_proto_index_add_revision(context->proto_l2p_index, - pool)); + scratch_pool)); /* read the phys-to-log index file until we covered the whole rev file. * That index contains enough info to build both target indexes from it. */ @@ -1899,9 +1913,9 @@ append_revision(pack_context_t *context, /* Format 7 packing logic. * * Pack the revision shard starting at SHARD_REV in filesystem FS from - * SHARD_DIR into the PACK_FILE_DIR, using POOL for allocations. Limit - * the extra memory consumption to MAX_MEM bytes. CANCEL_FUNC and - * CANCEL_BATON are what you think they are. + * SHARD_DIR into the PACK_FILE_DIR, using SCRATCH_POOL for temporary + * allocations. Limit the extra memory consumption to MAX_MEM bytes. + * CANCEL_FUNC and CANCEL_BATON are what you think they are. */ static svn_error_t * pack_log_addressed(svn_fs_t *fs, @@ -1911,7 +1925,7 @@ pack_log_addressed(svn_fs_t *fs, apr_size_t max_mem, svn_cancel_func_t cancel_func, void *cancel_baton, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { enum { @@ -1931,17 +1945,17 @@ pack_log_addressed(svn_fs_t *fs, pack_context_t context = { 0 }; int i; apr_size_t item_count = 0; - apr_pool_t *iterpool = svn_pool_create(pool); + apr_pool_t *iterpool = svn_pool_create(scratch_pool); /* set up a pack context */ SVN_ERR(initialize_pack_context(&context, fs, pack_file_dir, shard_dir, shard_rev, max_items, cancel_func, - cancel_baton, pool)); + cancel_baton, scratch_pool)); /* phase 1: determine the size of the revisions to pack */ SVN_ERR(svn_fs_x__l2p_get_max_ids(&max_ids, fs, shard_rev, context.shard_end_rev - shard_rev, - pool, pool)); + scratch_pool, scratch_pool)); /* pack revisions in ranges that don't exceed MAX_MEM */ for (i = 0; i < max_ids->nelts; ++i) @@ -1989,14 +2003,14 @@ pack_log_addressed(svn_fs_t *fs, } /* Given REV in FS, set *REV_OFFSET to REV's offset in the packed file. - Use POOL for temporary allocations. */ + Use SCRATCH_POOL for temporary allocations. */ svn_error_t * svn_fs_x__get_packed_offset(apr_off_t *rev_offset, svn_fs_t *fs, svn_revnum_t rev, - 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 *manifest_stream; svn_boolean_t is_cached; svn_revnum_t shard; @@ -2014,20 +2028,22 @@ svn_fs_x__get_packed_offset(apr_off_t *r SVN_ERR(svn_cache__get_partial((void **) rev_offset, &is_cached, ffd->packed_offset_cache, &shard, svn_fs_x__get_sharded_offset, &shard_pos, - pool)); + scratch_pool)); if (is_cached) return SVN_NO_ERROR; /* Open the manifest file. */ SVN_ERR(svn_stream_open_readonly(&manifest_stream, - svn_fs_x__path_rev_packed(fs, rev, PATH_MANIFEST, pool), - pool, pool)); + svn_fs_x__path_rev_packed(fs, rev, PATH_MANIFEST, + scratch_pool), + scratch_pool, scratch_pool)); /* While we're here, let's just read the entire manifest file into an array, so we can cache the entire thing. */ - iterpool = svn_pool_create(pool); - manifest = apr_array_make(pool, ffd->max_files_per_dir, sizeof(apr_off_t)); + iterpool = svn_pool_create(scratch_pool); + manifest = apr_array_make(scratch_pool, ffd->max_files_per_dir, + sizeof(apr_off_t)); while (1) { svn_boolean_t eof; @@ -2048,14 +2064,15 @@ svn_fs_x__get_packed_offset(apr_off_t *r /* Close up shop and cache the array. */ SVN_ERR(svn_stream_close(manifest_stream)); - return svn_cache__set(ffd->packed_offset_cache, &shard, manifest, pool); + return svn_cache__set(ffd->packed_offset_cache, &shard, manifest, + scratch_pool); } /* In filesystem FS, pack the revision SHARD containing exactly * MAX_FILES_PER_DIR revisions from SHARD_PATH into the PACK_FILE_DIR, - * using POOL for allocations. Try to limit the amount of temporary - * memory needed to MAX_MEM bytes. CANCEL_FUNC and CANCEL_BATON are what - * you think they are. + * using SCRATCH_POOL for temporary allocations. Try to limit the amount of + * temporary memory needed to MAX_MEM bytes. CANCEL_FUNC and CANCEL_BATON + * are what you think they are. * * If for some reason we detect a partial packing already performed, we * remove the pack file and start again. @@ -2071,36 +2088,37 @@ pack_rev_shard(svn_fs_t *fs, apr_size_t max_mem, svn_cancel_func_t cancel_func, void *cancel_baton, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { const char *pack_file_path; svn_revnum_t shard_rev = (svn_revnum_t) (shard * max_files_per_dir); /* Some useful paths. */ - pack_file_path = svn_dirent_join(pack_file_dir, PATH_PACKED, pool); + pack_file_path = svn_dirent_join(pack_file_dir, PATH_PACKED, scratch_pool); /* Remove any existing pack file for this shard, since it is incomplete. */ SVN_ERR(svn_io_remove_dir2(pack_file_dir, TRUE, cancel_func, cancel_baton, - pool)); + scratch_pool)); /* Create the new directory and pack file. */ - SVN_ERR(svn_io_dir_make(pack_file_dir, APR_OS_DEFAULT, pool)); + SVN_ERR(svn_io_dir_make(pack_file_dir, APR_OS_DEFAULT, scratch_pool)); /* Index information files */ SVN_ERR(pack_log_addressed(fs, pack_file_dir, shard_path, shard_rev, - max_mem, cancel_func, cancel_baton, pool)); + max_mem, cancel_func, cancel_baton, + scratch_pool)); - SVN_ERR(svn_io_copy_perms(shard_path, pack_file_dir, pool)); - SVN_ERR(svn_io_set_file_read_only(pack_file_path, FALSE, pool)); + SVN_ERR(svn_io_copy_perms(shard_path, pack_file_dir, scratch_pool)); + SVN_ERR(svn_io_set_file_read_only(pack_file_path, FALSE, scratch_pool)); return SVN_NO_ERROR; } /* In the file system at FS_PATH, pack the SHARD in REVS_DIR and - * REVPROPS_DIR containing exactly MAX_FILES_PER_DIR revisions, using POOL - * for allocations. REVPROPS_DIR will be NULL if revprop packing is not - * supported. COMPRESSION_LEVEL and MAX_PACK_SIZE will be ignored in that - * case. + * REVPROPS_DIR containing exactly MAX_FILES_PER_DIR revisions, using + * SCRATCH_POOL temporary for allocations. REVPROPS_DIR will be NULL if + * revprop packing is not supported. COMPRESSION_LEVEL and MAX_PACK_SIZE + * will be ignored in that case. * * CANCEL_FUNC and CANCEL_BATON are what you think they are; similarly * NOTIFY_FUNC and NOTIFY_BATON. @@ -2120,43 +2138,43 @@ pack_shard(const char *revs_dir, void *notify_baton, svn_cancel_func_t cancel_func, void *cancel_baton, - 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; const char *rev_shard_path, *rev_pack_file_dir; const char *revprops_shard_path, *revprops_pack_file_dir; /* Notify caller we're starting to pack this shard. */ if (notify_func) SVN_ERR(notify_func(notify_baton, shard, svn_fs_pack_notify_start, - pool)); + scratch_pool)); /* Some useful paths. */ rev_pack_file_dir = svn_dirent_join(revs_dir, - apr_psprintf(pool, + apr_psprintf(scratch_pool, "%" APR_INT64_T_FMT PATH_EXT_PACKED_SHARD, shard), - pool); + scratch_pool); rev_shard_path = svn_dirent_join(revs_dir, - apr_psprintf(pool, "%" APR_INT64_T_FMT, shard), - pool); + apr_psprintf(scratch_pool, "%" APR_INT64_T_FMT, shard), + scratch_pool); /* pack the revision content */ SVN_ERR(pack_rev_shard(fs, rev_pack_file_dir, rev_shard_path, shard, max_files_per_dir, DEFAULT_MAX_MEM, - cancel_func, cancel_baton, pool)); + cancel_func, cancel_baton, scratch_pool)); /* if enabled, pack the revprops in an equivalent way */ if (revsprops_dir) { revprops_pack_file_dir = svn_dirent_join(revsprops_dir, - apr_psprintf(pool, + apr_psprintf(scratch_pool, "%" APR_INT64_T_FMT PATH_EXT_PACKED_SHARD, shard), - pool); + scratch_pool); revprops_shard_path = svn_dirent_join(revsprops_dir, - apr_psprintf(pool, "%" APR_INT64_T_FMT, shard), - pool); + apr_psprintf(scratch_pool, "%" APR_INT64_T_FMT, shard), + scratch_pool); SVN_ERR(svn_fs_x__pack_revprops_shard(revprops_pack_file_dir, revprops_shard_path, @@ -2164,20 +2182,20 @@ pack_shard(const char *revs_dir, (int)(0.9 * max_pack_size), compression_level, cancel_func, cancel_baton, - pool)); + scratch_pool)); } /* Update the min-unpacked-rev file to reflect our newly packed shard. */ SVN_ERR(svn_fs_x__write_min_unpacked_rev(fs, (svn_revnum_t)((shard + 1) * max_files_per_dir), - pool)); + scratch_pool)); ffd->min_unpacked_rev = (svn_revnum_t)((shard + 1) * max_files_per_dir); /* Finally, remove the existing shard directories. * For revprops, clean up older obsolete shards as well as they might * have been left over from an interrupted FS upgrade. */ SVN_ERR(svn_io_remove_dir2(rev_shard_path, TRUE, - cancel_func, cancel_baton, pool)); + cancel_func, cancel_baton, scratch_pool)); if (revsprops_dir) { svn_node_kind_t kind = svn_node_dir; @@ -2188,15 +2206,17 @@ pack_shard(const char *revs_dir, to_cleanup, max_files_per_dir, cancel_func, cancel_baton, - pool)); + scratch_pool)); /* If the previous shard exists, clean it up as well. Don't try to clean up shard 0 as it we can't tell quickly whether it actually needs cleaning up. */ revprops_shard_path = svn_dirent_join(revsprops_dir, - apr_psprintf(pool, "%" APR_INT64_T_FMT, --to_cleanup), - pool); - SVN_ERR(svn_io_check_path(revprops_shard_path, &kind, pool)); + apr_psprintf(scratch_pool, + "%" APR_INT64_T_FMT, + --to_cleanup), + scratch_pool); + SVN_ERR(svn_io_check_path(revprops_shard_path, &kind, scratch_pool)); } while (kind == svn_node_dir && to_cleanup > 0); } @@ -2204,24 +2224,24 @@ pack_shard(const char *revs_dir, /* Notify caller we're starting to pack this shard. */ if (notify_func) SVN_ERR(notify_func(notify_baton, shard, svn_fs_pack_notify_end, - pool)); + scratch_pool)); return SVN_NO_ERROR; } -struct pack_baton +typedef struct pack_baton_t { svn_fs_t *fs; svn_fs_pack_notify_t notify_func; void *notify_baton; svn_cancel_func_t cancel_func; void *cancel_baton; -}; +} pack_baton_t; /* The work-horse for svn_fs_x__pack, called with the FS write lock. This implements the svn_fs_x__with_write_lock() 'body' callback - type. BATON is a 'struct pack_baton *'. + type. BATON is a 'pack_baton_t *'. WARNING: if you add a call to this function, please note: The code currently assumes that any piece of code running with @@ -2235,10 +2255,10 @@ struct pack_baton */ static svn_error_t * pack_body(void *baton, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { - struct pack_baton *pb = baton; - fs_x_data_t *ffd = pb->fs->fsap_data; + pack_baton_t *pb = baton; + svn_fs_x__data_t *ffd = pb->fs->fsap_data; apr_int64_t completed_shards; apr_int64_t i; svn_revnum_t youngest; @@ -2248,20 +2268,20 @@ pack_body(void *baton, /* If we aren't using sharding, we can't do any packing, so quit. */ SVN_ERR(svn_fs_x__read_min_unpacked_rev(&ffd->min_unpacked_rev, pb->fs, - pool)); + scratch_pool)); - SVN_ERR(svn_fs_x__youngest_rev(&youngest, pb->fs, pool)); + SVN_ERR(svn_fs_x__youngest_rev(&youngest, pb->fs, scratch_pool)); completed_shards = (youngest + 1) / ffd->max_files_per_dir; /* See if we've already completed all possible shards thus far. */ if (ffd->min_unpacked_rev == (completed_shards * ffd->max_files_per_dir)) return SVN_NO_ERROR; - rev_data_path = svn_dirent_join(pb->fs->path, PATH_REVS_DIR, pool); + rev_data_path = svn_dirent_join(pb->fs->path, PATH_REVS_DIR, scratch_pool); revprops_data_path = svn_dirent_join(pb->fs->path, PATH_REVPROPS_DIR, - pool); + scratch_pool); - iterpool = svn_pool_create(pool); + iterpool = svn_pool_create(scratch_pool); for (i = ffd->min_unpacked_rev / ffd->max_files_per_dir; i < completed_shards; i++) @@ -2291,13 +2311,13 @@ svn_fs_x__pack(svn_fs_t *fs, void *notify_baton, svn_cancel_func_t cancel_func, void *cancel_baton, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { - struct pack_baton pb = { 0 }; + pack_baton_t pb = { 0 }; pb.fs = fs; pb.notify_func = notify_func; pb.notify_baton = notify_baton; pb.cancel_func = cancel_func; pb.cancel_baton = cancel_baton; - return svn_fs_x__with_pack_lock(fs, pack_body, &pb, pool); + return svn_fs_x__with_pack_lock(fs, pack_body, &pb, scratch_pool); }
Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/pack.h URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/pack.h?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/pack.h (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/pack.h Wed Jan 21 16:22:19 2015 @@ -28,6 +28,7 @@ /* Possibly pack the repository at PATH. This just take full shards, and combines all the revision files into a single one, with a manifest header. Use optional CANCEL_FUNC/CANCEL_BATON for cancellation support. + Use SCRATCH_POOL for temporary allocations. Existing filesystem references need not change. */ svn_error_t * @@ -36,18 +37,18 @@ svn_fs_x__pack(svn_fs_t *fs, void *notify_baton, svn_cancel_func_t cancel_func, void *cancel_baton, - apr_pool_t *pool); + apr_pool_t *scratch_pool); /** - * For the packed revision @a rev in @a fs, determine the offset within - * the revision pack file and return it in @a rev_offset. Use @a pool for - * allocations. + * For the packed revision REV in FS, determine the offset within the + * revision pack file and return it in REV_OFFSET. + * Use SCRATCH_POOL for temporary allocations. */ svn_error_t * svn_fs_x__get_packed_offset(apr_off_t *rev_offset, svn_fs_t *fs, svn_revnum_t rev, - apr_pool_t *pool); + apr_pool_t *scratch_pool); /* Return the svn_dir_entry_t* objects of DIRECTORY in an APR array * allocated in POOL with entries added in storage (on-disk) order. Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/recovery.c URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/recovery.c?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/recovery.c (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/recovery.c Wed Jan 21 16:22:19 2015 @@ -39,9 +39,11 @@ #include "svn_private_config.h" /* Part of the recovery procedure. Return the largest revision *REV in - filesystem FS. Use POOL for temporary allocation. */ + filesystem FS. Use SCRATCH_POOL for temporary allocation. */ static svn_error_t * -recover_get_largest_revision(svn_fs_t *fs, svn_revnum_t *rev, apr_pool_t *pool) +recover_get_largest_revision(svn_fs_t *fs, + svn_revnum_t *rev, + apr_pool_t *scratch_pool) { /* Discovering the largest revision in the filesystem would be an expensive operation if we did a readdir() or searched linearly, @@ -50,7 +52,7 @@ recover_get_largest_revision(svn_fs_t *f apr_pool_t *iterpool; svn_revnum_t left, right = 1; - iterpool = svn_pool_create(pool); + iterpool = svn_pool_create(scratch_pool); /* Keep doubling right, until we find a revision that doesn't exist. */ while (1) { @@ -104,38 +106,40 @@ recover_get_largest_revision(svn_fs_t *f } /* Baton used for recover_body below. */ -struct recover_baton { +typedef struct recover_baton_t { svn_fs_t *fs; svn_cancel_func_t cancel_func; void *cancel_baton; -}; +} recover_baton_t; /* The work-horse for svn_fs_x__recover, called with the FS write lock. This implements the svn_fs_x__with_write_lock() - 'body' callback type. BATON is a 'struct recover_baton *'. */ + 'body' callback type. BATON is a 'recover_baton_t *'. */ static svn_error_t * -recover_body(void *baton, apr_pool_t *pool) +recover_body(void *baton, + apr_pool_t *scratch_pool) { - struct recover_baton *b = baton; + recover_baton_t *b = baton; svn_fs_t *fs = b->fs; - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; svn_revnum_t max_rev; svn_revnum_t youngest_rev; - svn_node_kind_t youngest_revprops_kind; + svn_boolean_t revprop_missing = TRUE; + svn_boolean_t revprop_accessible = FALSE; /* Lose potentially corrupted data in temp files */ - SVN_ERR(svn_fs_x__reset_revprop_generation_file(fs, pool)); + SVN_ERR(svn_fs_x__reset_revprop_generation_file(fs, scratch_pool)); /* The admin may have created a plain copy of this repo before attempting to recover it (hotcopy may or may not work with corrupted repos). Bump the instance ID. */ - SVN_ERR(svn_fs_x__set_uuid(fs, fs->uuid, NULL, pool)); + SVN_ERR(svn_fs_x__set_uuid(fs, fs->uuid, NULL, scratch_pool)); /* We need to know the largest revision in the filesystem. */ - SVN_ERR(recover_get_largest_revision(fs, &max_rev, pool)); + SVN_ERR(recover_get_largest_revision(fs, &max_rev, scratch_pool)); /* Get the expected youngest revision */ - SVN_ERR(svn_fs_x__youngest_rev(&youngest_rev, fs, pool)); + SVN_ERR(svn_fs_x__youngest_rev(&youngest_rev, fs, scratch_pool)); /* Policy note: @@ -176,35 +180,49 @@ recover_body(void *baton, apr_pool_t *po /* Before setting current, verify that there is a revprops file for the youngest revision. (Issue #2992) */ - SVN_ERR(svn_io_check_path(svn_fs_x__path_revprops(fs, max_rev, pool), - &youngest_revprops_kind, pool)); - if (youngest_revprops_kind == svn_node_none) - { - svn_boolean_t missing = TRUE; - if (!svn_fs_x__packed_revprop_available(&missing, fs, max_rev, pool)) - { - if (missing) - { - return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL, - _("Revision %ld has a revs file but no " - "revprops file"), - max_rev); - } - else - { - return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL, - _("Revision %ld has a revs file but the " - "revprops file is inaccessible"), - max_rev); - } - } - } - else if (youngest_revprops_kind != svn_node_file) - { - return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL, - _("Revision %ld has a non-file where its " - "revprops file should be"), - max_rev); + if (svn_fs_x__is_packed_revprop(fs, max_rev)) + { + revprop_accessible + = svn_fs_x__packed_revprop_available(&revprop_missing, fs, max_rev, + scratch_pool); + } + else + { + svn_node_kind_t youngest_revprops_kind; + SVN_ERR(svn_io_check_path(svn_fs_x__path_revprops(fs, max_rev, + scratch_pool), + &youngest_revprops_kind, scratch_pool)); + + if (youngest_revprops_kind == svn_node_file) + { + revprop_missing = FALSE; + revprop_accessible = TRUE; + } + else if (youngest_revprops_kind != svn_node_none) + { + return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL, + _("Revision %ld has a non-file where its " + "revprops file should be"), + max_rev); + } + } + + if (!revprop_accessible) + { + if (revprop_missing) + { + return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL, + _("Revision %ld has a revs file but no " + "revprops file"), + max_rev); + } + else + { + return svn_error_createf(SVN_ERR_FS_CORRUPT, NULL, + _("Revision %ld has a revs file but the " + "revprops file is inaccessible"), + max_rev); + } } /* Prune younger-than-(newfound-youngest) revisions from the rep @@ -214,23 +232,25 @@ recover_body(void *baton, apr_pool_t *po { svn_boolean_t rep_cache_exists; - SVN_ERR(svn_fs_x__exists_rep_cache(&rep_cache_exists, fs, pool)); + SVN_ERR(svn_fs_x__exists_rep_cache(&rep_cache_exists, fs, + scratch_pool)); if (rep_cache_exists) - SVN_ERR(svn_fs_x__del_rep_reference(fs, max_rev, pool)); + SVN_ERR(svn_fs_x__del_rep_reference(fs, max_rev, scratch_pool)); } /* Now store the discovered youngest revision, and the next IDs if relevant, in a new 'current' file. */ - return svn_fs_x__write_current(fs, max_rev, pool); + return svn_fs_x__write_current(fs, max_rev, scratch_pool); } /* This implements the fs_library_vtable_t.recover() API. */ svn_error_t * svn_fs_x__recover(svn_fs_t *fs, - svn_cancel_func_t cancel_func, void *cancel_baton, - apr_pool_t *pool) + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool) { - struct recover_baton b; + recover_baton_t b; /* We have no way to take out an exclusive lock in FSX, so we're restricted as to the types of recovery we can do. Luckily, @@ -239,5 +259,5 @@ svn_fs_x__recover(svn_fs_t *fs, b.fs = fs; b.cancel_func = cancel_func; b.cancel_baton = cancel_baton; - return svn_fs_x__with_all_locks(fs, recover_body, &b, pool); + return svn_fs_x__with_all_locks(fs, recover_body, &b, scratch_pool); } Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/recovery.h URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/recovery.h?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/recovery.h (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/recovery.h Wed Jan 21 16:22:19 2015 @@ -27,10 +27,11 @@ /* Recover the fsx associated with filesystem FS. Use optional CANCEL_FUNC/CANCEL_BATON for cancellation support. - Use POOL for temporary allocations. */ -svn_error_t *svn_fs_x__recover(svn_fs_t *fs, - svn_cancel_func_t cancel_func, - void *cancel_baton, - apr_pool_t *pool); + Use SCRATCH_POOL for temporary allocations. */ +svn_error_t * +svn_fs_x__recover(svn_fs_t *fs, + svn_cancel_func_t cancel_func, + void *cancel_baton, + apr_pool_t *scratch_pool); #endif Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/rep-cache.c URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/rep-cache.c?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/rep-cache.c (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/rep-cache.c Wed Jan 21 16:22:19 2015 @@ -27,6 +27,7 @@ #include "fs_x.h" #include "fs.h" #include "rep-cache.h" +#include "util.h" #include "../libsvn_fs/fs-loader.h" #include "svn_path.h" @@ -58,17 +59,17 @@ path_rep_cache_db(const char *fs_path, */ static svn_error_t * open_rep_cache(void *baton, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { svn_fs_t *fs = baton; - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; svn_sqlite__db_t *sdb; const char *db_path; int version; /* Open (or create) the sqlite database. It will be automatically closed when fs->pool is destroyed. */ - db_path = path_rep_cache_db(fs->path, pool); + db_path = path_rep_cache_db(fs->path, scratch_pool); #ifndef WIN32 { /* We want to extend the permissions that apply to the repository @@ -76,11 +77,11 @@ open_rep_cache(void *baton, to umask. */ svn_boolean_t exists; - SVN_ERR(svn_fs_x__exists_rep_cache(&exists, fs, pool)); + SVN_ERR(svn_fs_x__exists_rep_cache(&exists, fs, scratch_pool)); if (!exists) { - const char *current = svn_fs_x__path_current(fs, pool); - svn_error_t *err = svn_io_file_create_empty(db_path, pool); + const char *current = svn_fs_x__path_current(fs, scratch_pool); + svn_error_t *err = svn_io_file_create_empty(db_path, scratch_pool); if (err && !APR_STATUS_IS_EEXIST(err->apr_err)) /* A real error. */ @@ -90,16 +91,16 @@ open_rep_cache(void *baton, svn_error_clear(err); else /* We created the file. */ - SVN_ERR(svn_io_copy_perms(current, db_path, pool)); + SVN_ERR(svn_io_copy_perms(current, db_path, scratch_pool)); } } #endif SVN_ERR(svn_sqlite__open(&sdb, db_path, svn_sqlite__mode_rwcreate, statements, 0, NULL, 0, - fs->pool, pool)); + fs->pool, scratch_pool)); - SVN_ERR(svn_sqlite__read_schema_version(&version, sdb, pool)); + SVN_ERR(svn_sqlite__read_schema_version(&version, sdb, scratch_pool)); if (version < REP_CACHE_SCHEMA_FORMAT) { /* Must be 0 -- an uninitialized (no schema) database. Create @@ -116,22 +117,23 @@ open_rep_cache(void *baton, svn_error_t * svn_fs_x__open_rep_cache(svn_fs_t *fs, - 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_error_t *err = svn_atomic__init_once(&ffd->rep_cache_db_opened, - open_rep_cache, fs, pool); + open_rep_cache, fs, scratch_pool); return svn_error_quick_wrap(err, _("Couldn't open rep-cache database")); } svn_error_t * svn_fs_x__exists_rep_cache(svn_boolean_t *exists, - svn_fs_t *fs, apr_pool_t *pool) + svn_fs_t *fs, + apr_pool_t *scratch_pool) { svn_node_kind_t kind; - SVN_ERR(svn_io_check_path(path_rep_cache_db(fs->path, pool), - &kind, pool)); + SVN_ERR(svn_io_check_path(path_rep_cache_db(fs->path, scratch_pool), + &kind, scratch_pool)); *exists = (kind != svn_node_none); return SVN_NO_ERROR; @@ -141,24 +143,24 @@ svn_error_t * svn_fs_x__walk_rep_reference(svn_fs_t *fs, svn_revnum_t start, svn_revnum_t end, - svn_error_t *(*walker)(representation_t *, + svn_error_t *(*walker)(svn_fs_x__representation_t *, void *, svn_fs_t *, apr_pool_t *), void *walker_baton, svn_cancel_func_t cancel_func, void *cancel_baton, - 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_sqlite__stmt_t *stmt; svn_boolean_t have_row; int iterations = 0; - apr_pool_t *iterpool = svn_pool_create(pool); + apr_pool_t *iterpool = svn_pool_create(scratch_pool); if (! ffd->rep_cache_db) - SVN_ERR(svn_fs_x__open_rep_cache(fs, pool)); + SVN_ERR(svn_fs_x__open_rep_cache(fs, scratch_pool)); /* Check global invariants. */ if (start == 0) @@ -183,7 +185,7 @@ svn_fs_x__walk_rep_reference(svn_fs_t *f SVN_ERR(svn_sqlite__step(&have_row, stmt)); while (have_row) { - representation_t *rep; + svn_fs_x__representation_t *rep; const char *sha1_digest; svn_error_t *err; svn_checksum_t *checksum; @@ -200,7 +202,7 @@ svn_fs_x__walk_rep_reference(svn_fs_t *f return svn_error_compose_create(err, svn_sqlite__reset(stmt)); } - /* Construct a representation_t. */ + /* Construct a svn_fs_x__representation_t. */ rep = apr_pcalloc(iterpool, sizeof(*rep)); sha1_digest = svn_sqlite__column_text(stmt, 0, iterpool); err = svn_checksum_parse_hex(&checksum, svn_checksum_sha1, @@ -234,18 +236,19 @@ svn_fs_x__walk_rep_reference(svn_fs_t *f If you extend this function, check the callsite to see if you have to make it not-ignore additional error codes. */ svn_error_t * -svn_fs_x__get_rep_reference(representation_t **rep, +svn_fs_x__get_rep_reference(svn_fs_x__representation_t **rep, svn_fs_t *fs, svn_checksum_t *checksum, - 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_sqlite__stmt_t *stmt; svn_boolean_t have_row; SVN_ERR_ASSERT(ffd->rep_sharing_allowed); if (! ffd->rep_cache_db) - SVN_ERR(svn_fs_x__open_rep_cache(fs, pool)); + SVN_ERR(svn_fs_x__open_rep_cache(fs, scratch_pool)); /* We only allow SHA1 checksums in this table. */ if (checksum->kind != svn_checksum_sha1) @@ -255,12 +258,12 @@ svn_fs_x__get_rep_reference(representati SVN_ERR(svn_sqlite__get_statement(&stmt, ffd->rep_cache_db, STMT_GET_REP)); SVN_ERR(svn_sqlite__bindf(stmt, "s", - svn_checksum_to_cstring(checksum, pool))); + svn_checksum_to_cstring(checksum, scratch_pool))); SVN_ERR(svn_sqlite__step(&have_row, stmt)); if (have_row) { - *rep = apr_pcalloc(pool, sizeof(**rep)); + *rep = apr_pcalloc(result_pool, sizeof(**rep)); memcpy((*rep)->sha1_digest, checksum->digest, sizeof((*rep)->sha1_digest)); (*rep)->has_sha1 = TRUE; @@ -278,12 +281,12 @@ svn_fs_x__get_rep_reference(representati { /* Check that REP refers to a revision that exists in FS. */ svn_revnum_t revision = svn_fs_x__get_revnum((*rep)->id.change_set); - svn_error_t *err = svn_fs_x__ensure_revision_exists(revision, fs, pool); + svn_error_t *err = svn_fs_x__ensure_revision_exists(revision, fs, + scratch_pool); if (err) return svn_error_createf(SVN_ERR_FS_CORRUPT, err, - "Checksum '%s' in rep-cache is beyond HEAD", - svn_checksum_to_cstring_display(checksum, - pool)); + "Checksum '%s' in rep-cache is beyond HEAD", + svn_checksum_to_cstring_display(checksum, scratch_pool)); } return SVN_NO_ERROR; @@ -291,10 +294,10 @@ svn_fs_x__get_rep_reference(representati svn_error_t * svn_fs_x__set_rep_reference(svn_fs_t *fs, - representation_t *rep, - apr_pool_t *pool) + svn_fs_x__representation_t *rep, + apr_pool_t *scratch_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; svn_sqlite__stmt_t *stmt; svn_error_t *err; svn_checksum_t checksum; @@ -303,7 +306,7 @@ svn_fs_x__set_rep_reference(svn_fs_t *fs SVN_ERR_ASSERT(ffd->rep_sharing_allowed); if (! ffd->rep_cache_db) - SVN_ERR(svn_fs_x__open_rep_cache(fs, pool)); + SVN_ERR(svn_fs_x__open_rep_cache(fs, scratch_pool)); /* We only allow SHA1 checksums in this table. */ if (! rep->has_sha1) @@ -313,7 +316,7 @@ svn_fs_x__set_rep_reference(svn_fs_t *fs SVN_ERR(svn_sqlite__get_statement(&stmt, ffd->rep_cache_db, STMT_SET_REP)); SVN_ERR(svn_sqlite__bindf(stmt, "siiii", - svn_checksum_to_cstring(&checksum, pool), + svn_checksum_to_cstring(&checksum, scratch_pool), (apr_int64_t) rep->id.change_set, (apr_int64_t) rep->id.number, (apr_int64_t) rep->size, @@ -322,7 +325,7 @@ svn_fs_x__set_rep_reference(svn_fs_t *fs err = svn_sqlite__insert(NULL, stmt); if (err) { - representation_t *old_rep; + svn_fs_x__representation_t *old_rep; if (err->apr_err != SVN_ERR_SQLITE_CONSTRAINT) return svn_error_trace(err); @@ -332,7 +335,8 @@ svn_fs_x__set_rep_reference(svn_fs_t *fs /* Constraint failed so the mapping for SHA1_CHECKSUM->REP should exist. If so that's cool -- just do nothing. If not, that's a red flag! */ - SVN_ERR(svn_fs_x__get_rep_reference(&old_rep, fs, &checksum, pool)); + SVN_ERR(svn_fs_x__get_rep_reference(&old_rep, fs, &checksum, + scratch_pool, scratch_pool)); if (!old_rep) { @@ -349,13 +353,13 @@ svn_fs_x__set_rep_reference(svn_fs_t *fs svn_error_t * svn_fs_x__del_rep_reference(svn_fs_t *fs, svn_revnum_t youngest, - 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_sqlite__stmt_t *stmt; if (! ffd->rep_cache_db) - SVN_ERR(svn_fs_x__open_rep_cache(fs, pool)); + SVN_ERR(svn_fs_x__open_rep_cache(fs, scratch_pool)); SVN_ERR(svn_sqlite__get_statement(&stmt, ffd->rep_cache_db, STMT_DEL_REPS_YOUNGER_THAN_REV)); @@ -367,12 +371,12 @@ svn_fs_x__del_rep_reference(svn_fs_t *fs svn_error_t * svn_fs_x__lock_rep_cache(svn_fs_t *fs, - 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; if (! ffd->rep_cache_db) - SVN_ERR(svn_fs_x__open_rep_cache(fs, pool)); + SVN_ERR(svn_fs_x__open_rep_cache(fs, scratch_pool)); SVN_ERR(svn_sqlite__exec_statements(ffd->rep_cache_db, STMT_LOCK_REP)); Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/rep-cache.h URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/rep-cache.h?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/rep-cache.h (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/rep-cache.h Wed Jan 21 16:22:19 2015 @@ -35,63 +35,64 @@ extern "C" { #define REP_CACHE_DB_NAME "rep-cache.db" /* Open and create, if needed, the rep cache database associated with FS. - Use POOL for temporary allocations. */ + Use SCRATCH_POOL for temporary allocations. */ svn_error_t * svn_fs_x__open_rep_cache(svn_fs_t *fs, - apr_pool_t *pool); + apr_pool_t *scratch_pool); /* Set *EXISTS to TRUE iff the rep-cache DB file exists. */ svn_error_t * svn_fs_x__exists_rep_cache(svn_boolean_t *exists, svn_fs_t *fs, - apr_pool_t *pool); + apr_pool_t *scratch_pool); /* Iterate all representations currently in FS's cache. */ svn_error_t * svn_fs_x__walk_rep_reference(svn_fs_t *fs, svn_revnum_t start, svn_revnum_t end, - svn_error_t *(*walker)(representation_t *rep, + svn_error_t *(*walker)(svn_fs_x__representation_t *rep, void *walker_baton, svn_fs_t *fs, apr_pool_t *scratch_pool), void *walker_baton, svn_cancel_func_t cancel_func, void *cancel_baton, - apr_pool_t *pool); + apr_pool_t *scratch_pool); /* Return the representation REP in FS which has fulltext CHECKSUM. - REP is allocated in POOL. If the rep cache database has not been - opened, just set *REP to NULL. Returns SVN_ERR_FS_CORRUPT if - a reference beyond HEAD is detected. */ + REP is allocated in RESULT_POOL. If the rep cache database has not been + opened, just set *REP to NULL. Returns SVN_ERR_FS_CORRUPT if a reference + beyond HEAD is detected. Uses SCRATCH_POOL for temporary allocations. */ svn_error_t * -svn_fs_x__get_rep_reference(representation_t **rep, +svn_fs_x__get_rep_reference(svn_fs_x__representation_t **rep, svn_fs_t *fs, svn_checksum_t *checksum, - apr_pool_t *pool); + apr_pool_t *result_pool, + apr_pool_t *scratch_pool); /* Set the representation REP in FS, using REP->CHECKSUM. - Use POOL for temporary allocations. Returns SVN_ERR_FS_CORRUPT if - an existing reference beyond HEAD is detected. + Use SCRATCH_POOL for temporary allocations. Returns SVN_ERR_FS_CORRUPT + if an existing reference beyond HEAD is detected. If the rep cache database has not been opened, this may be a no op. */ svn_error_t * svn_fs_x__set_rep_reference(svn_fs_t *fs, - representation_t *rep, - apr_pool_t *pool); + svn_fs_x__representation_t *rep, + apr_pool_t *scratch_pool); /* Delete from the cache all reps corresponding to revisions younger than YOUNGEST. */ svn_error_t * svn_fs_x__del_rep_reference(svn_fs_t *fs, svn_revnum_t youngest, - apr_pool_t *pool); + apr_pool_t *scratch_pool); /* Start a transaction to take an SQLite reserved lock that prevents other writes. */ svn_error_t * svn_fs_x__lock_rep_cache(svn_fs_t *fs, - apr_pool_t *pool); + apr_pool_t *scratch_pool); #ifdef __cplusplus } Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/reps.c URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/reps.c?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/reps.c (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/reps.c Wed Jan 21 16:22:19 2015 @@ -302,38 +302,40 @@ hash_to_index(hash_t *hash, hash_key_t a return (adler32 * 0xd1f3da69) >> hash->shift; } -/* Allocate and initialized SIZE buckets in POOL. Assign them to HASH. +/* Allocate and initialized SIZE buckets in RESULT_POOL. + * Assign them to HASH. */ static void allocate_hash_members(hash_t *hash, apr_size_t size, - apr_pool_t *pool) + apr_pool_t *result_pool) { apr_size_t i; - hash->pool = pool; + hash->pool = result_pool; hash->size = size; - hash->prefixes = apr_pcalloc(pool, size); - hash->last_matches = apr_pcalloc(pool, sizeof(*hash->last_matches) * size); - hash->offsets = apr_palloc(pool, sizeof(*hash->offsets) * size); + hash->prefixes = apr_pcalloc(result_pool, size); + hash->last_matches = apr_pcalloc(result_pool, + sizeof(*hash->last_matches) * size); + hash->offsets = apr_palloc(result_pool, sizeof(*hash->offsets) * size); for (i = 0; i < size; ++i) hash->offsets[i] = NO_OFFSET; } /* Initialize the HASH data structure with 2**TWOPOWER buckets allocated - * in POOL. + * in RESULT_POOL. */ static void init_hash(hash_t *hash, apr_size_t twoPower, - apr_pool_t *pool) + apr_pool_t *result_pool) { hash->used = 0; hash->shift = sizeof(hash_key_t) * 8 - twoPower; - allocate_hash_members(hash, 1 << twoPower, pool); + allocate_hash_members(hash, 1 << twoPower, result_pool); } /* Make HASH have at least MIN_SIZE buckets but at least double the number @@ -384,24 +386,26 @@ grow_hash(hash_t *hash, svn_fs_x__reps_builder_t * svn_fs_x__reps_builder_create(svn_fs_t *fs, - apr_pool_t *pool) + apr_pool_t *result_pool) { - svn_fs_x__reps_builder_t *result = apr_pcalloc(pool, sizeof(*result)); + svn_fs_x__reps_builder_t *result = apr_pcalloc(result_pool, + sizeof(*result)); result->fs = fs; - result->text = svn_stringbuf_create_empty(pool); - init_hash(&result->hash, 4, pool); + result->text = svn_stringbuf_create_empty(result_pool); + init_hash(&result->hash, 4, result_pool); - result->bases = apr_array_make(pool, 0, sizeof(base_t)); - result->reps = apr_array_make(pool, 0, sizeof(rep_t)); - result->instructions = apr_array_make(pool, 0, sizeof(instruction_t)); + result->bases = apr_array_make(result_pool, 0, sizeof(base_t)); + result->reps = apr_array_make(result_pool, 0, sizeof(rep_t)); + result->instructions = apr_array_make(result_pool, 0, + sizeof(instruction_t)); return result; } svn_error_t * svn_fs_x__reps_add_base(svn_fs_x__reps_builder_t *builder, - representation_t *rep, + svn_fs_x__representation_t *rep, int priority, apr_pool_t *scratch_pool) { @@ -689,10 +693,10 @@ svn_fs_x__extractor_drive(svn_stringbuf_ svn_error_t * svn_fs_x__write_reps_container(svn_stream_t *stream, const svn_fs_x__reps_builder_t *builder, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { int i; - 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); /* one top-level stream for each array */ svn_packed__int_stream_t *bases_stream @@ -755,7 +759,7 @@ svn_fs_x__write_reps_container(svn_strea svn_packed__add_uint(misc_stream, 0); /* write to 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/reps.h URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/reps.h?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/reps.h (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/reps.h Wed Jan 21 16:22:19 2015 @@ -71,11 +71,11 @@ typedef struct svn_fs_x__reps_baton_t /* Create and populate noderev containers. */ -/* Create and return a new builder object, allocated in POOL. +/* Create and return a new builder object, allocated in RESULT_POOL. */ svn_fs_x__reps_builder_t * svn_fs_x__reps_builder_create(svn_fs_t *fs, - apr_pool_t *pool); + apr_pool_t *result_pool); /* To BUILDER, add reference to the fulltext currently stored in * representation REP. Substrings matching with any of the base reps @@ -91,7 +91,7 @@ svn_fs_x__reps_builder_create(svn_fs_t * */ svn_error_t * svn_fs_x__reps_add_base(svn_fs_x__reps_builder_t *builder, - representation_t *rep, + svn_fs_x__representation_t *rep, int priority, apr_pool_t *scratch_pool); @@ -141,12 +141,12 @@ svn_fs_x__extractor_drive(svn_stringbuf_ /* I/O interface. */ /* Write a serialized representation of the final container described by - * BUILDER to STREAM. Use POOL for temporary allocations. + * BUILDER to STREAM. Use SCRATCH_POOL for temporary allocations. */ svn_error_t * svn_fs_x__write_reps_container(svn_stream_t *stream, const svn_fs_x__reps_builder_t *builder, - apr_pool_t *pool); + apr_pool_t *scratch_pool); /* Read a representations container from its serialized representation in * STREAM. Allocate the result in RESULT_POOL and return it in *CONTAINER. Modified: subversion/branches/pin-externals/subversion/libsvn_fs_x/rev_file.c URL: http://svn.apache.org/viewvc/subversion/branches/pin-externals/subversion/libsvn_fs_x/rev_file.c?rev=1653578&r1=1653577&r2=1653578&view=diff ============================================================================== --- subversion/branches/pin-externals/subversion/libsvn_fs_x/rev_file.c (original) +++ subversion/branches/pin-externals/subversion/libsvn_fs_x/rev_file.c Wed Jan 21 16:22:19 2015 @@ -37,7 +37,7 @@ static svn_fs_x__revision_file_t * create_revision_file(svn_fs_t *fs, apr_pool_t *result_pool) { - fs_x_data_t *ffd = fs->fsap_data; + svn_fs_x__data_t *ffd = fs->fsap_data; svn_fs_x__revision_file_t *file = apr_palloc(result_pool, sizeof(*file)); file->is_packed = FALSE;
