Modified: subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/noderevs.c URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/noderevs.c?rev=1652409&r1=1652408&r2=1652409&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/noderevs.c (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/noderevs.c Fri Jan 16 14:01:35 2015 @@ -49,16 +49,6 @@ /* the noderev has copy-root path and revision */ #define NODEREV_HAS_CPATH 0x00040 -/* Our internal representation of an id - * (basically, strip off the txn_id and the fs-agnostic header) - */ -typedef struct binary_id_t -{ - svn_fs_x__id_part_t node_id; - svn_fs_x__id_part_t copy_id; - svn_fs_x__id_part_t noderev_id; -} binary_id_t; - /* Our internal representation of an representation. */ typedef struct binary_representation_t @@ -70,7 +60,7 @@ typedef struct binary_representation_t unsigned char md5_digest[APR_MD5_DIGESTSIZE]; /* Location of this representation. */ - svn_fs_x__id_part_t id; + svn_fs_x__id_t id; /* The size of the representation in bytes as seen in the revision file. */ @@ -81,7 +71,7 @@ typedef struct binary_representation_t svn_filesize_t expanded_size; } binary_representation_t; -/* Our internal representation of a node_revision_t. +/* Our internal representation of a svn_fs_x__noderev_t. * * We will store path strings in a string container and reference them * from here. Similarly, IDs and representations are being stored in @@ -93,9 +83,15 @@ typedef struct binary_noderev_t /* node type and presence indicators */ apr_uint32_t flags; - /* Index+1 of the node-id for this node-rev. */ + /* Index+1 of the noderev-id for this node-rev. */ int id; + /* Index+1 of the node-id for this node-rev. */ + int node_id; + + /* Index+1 of the copy-id for this node-rev. */ + int copy_id; + /* Index+1 of the predecessor node revision id, or 0 if there is no predecessor for this node revision */ int predecessor_id; @@ -156,19 +152,14 @@ struct svn_fs_x__noderevs_t apr_hash_t *ids_dict; /* During construction, maps a full binary_representation_t to an index - * into DATA_REPS. */ - apr_hash_t *data_reps_dict; - - /* During construction, maps a full binary_representation_t to an index - * into PROP_REPS. */ - apr_hash_t *prop_reps_dict; + * into REPS. */ + apr_hash_t *reps_dict; /* array of binary_id_t */ apr_array_header_t *ids; - /* arrays of binary_representation_t */ - apr_array_header_t *data_reps; - apr_array_header_t *prop_reps; + /* array of binary_representation_t */ + apr_array_header_t *reps; /* array of binary_noderev_t. */ apr_array_header_t *noderevs; @@ -176,24 +167,23 @@ struct svn_fs_x__noderevs_t svn_fs_x__noderevs_t * svn_fs_x__noderevs_create(int initial_count, - apr_pool_t* pool) + apr_pool_t* result_pool) { - svn_fs_x__noderevs_t *noderevs = apr_palloc(pool, sizeof(*noderevs)); + svn_fs_x__noderevs_t *noderevs + = apr_palloc(result_pool, sizeof(*noderevs)); - noderevs->builder = svn_fs_x__string_table_builder_create(pool); - noderevs->ids_dict = svn_hash__make(pool); - noderevs->data_reps_dict = svn_hash__make(pool); - noderevs->prop_reps_dict = svn_hash__make(pool); + noderevs->builder = svn_fs_x__string_table_builder_create(result_pool); + noderevs->ids_dict = svn_hash__make(result_pool); + noderevs->reps_dict = svn_hash__make(result_pool); noderevs->paths = NULL; noderevs->ids - = apr_array_make(pool, initial_count, sizeof(binary_id_t)); - noderevs->data_reps - = apr_array_make(pool, initial_count, sizeof(binary_representation_t)); - noderevs->prop_reps - = apr_array_make(pool, initial_count, sizeof(binary_representation_t)); + = apr_array_make(result_pool, 2 * initial_count, sizeof(svn_fs_x__id_t)); + noderevs->reps + = apr_array_make(result_pool, 2 * initial_count, + sizeof(binary_representation_t)); noderevs->noderevs - = apr_array_make(pool, initial_count, sizeof(binary_noderev_t)); + = apr_array_make(result_pool, initial_count, sizeof(binary_noderev_t)); return noderevs; } @@ -204,24 +194,19 @@ svn_fs_x__noderevs_create(int initial_co static int store_id(apr_array_header_t *ids, apr_hash_t *dict, - const svn_fs_id_t *id) + const svn_fs_x__id_t *id) { - binary_id_t bin_id = { { 0 } }; int idx; void *idx_void; - if (id == NULL) + if (!svn_fs_x__id_used(id)) return 0; - - bin_id.node_id = *svn_fs_x__id_node_id(id); - bin_id.copy_id = *svn_fs_x__id_copy_id(id); - bin_id.noderev_id = *svn_fs_x__id_noderev_id(id); - idx_void = apr_hash_get(dict, &bin_id, sizeof(bin_id)); + idx_void = apr_hash_get(dict, &id, sizeof(id)); idx = (int)(apr_uintptr_t)idx_void; if (idx == 0) { - APR_ARRAY_PUSH(ids, binary_id_t) = bin_id; + APR_ARRAY_PUSH(ids, svn_fs_x__id_t) = *id; idx = ids->nelts; apr_hash_set(dict, ids->elts + (idx-1) * ids->elt_size, ids->elt_size, (void*)(apr_uintptr_t)idx); @@ -236,7 +221,7 @@ store_id(apr_array_header_t *ids, static int store_representation(apr_array_header_t *reps, apr_hash_t *dict, - const representation_t *rep) + const svn_fs_x__representation_t *rep) { binary_representation_t binary_rep = { 0 }; int idx; @@ -267,7 +252,7 @@ store_representation(apr_array_header_t apr_size_t svn_fs_x__noderevs_add(svn_fs_x__noderevs_t *container, - node_revision_t *noderev) + svn_fs_x__noderev_t *noderev) { binary_noderev_t binary_noderev = { 0 }; @@ -278,9 +263,13 @@ svn_fs_x__noderevs_add(svn_fs_x__noderev | (int)noderev->kind; binary_noderev.id - = store_id(container->ids, container->ids_dict, noderev->id); + = store_id(container->ids, container->ids_dict, &noderev->noderev_id); + binary_noderev.node_id + = store_id(container->ids, container->ids_dict, &noderev->node_id); + binary_noderev.copy_id + = store_id(container->ids, container->ids_dict, &noderev->copy_id); binary_noderev.predecessor_id - = store_id(container->ids, container->ids_dict, noderev->predecessor_id); + = store_id(container->ids, container->ids_dict, &noderev->predecessor_id); if (noderev->copyfrom_path) { @@ -301,19 +290,18 @@ svn_fs_x__noderevs_add(svn_fs_x__noderev } binary_noderev.predecessor_count = noderev->predecessor_count; - binary_noderev.prop_rep = store_representation(container->prop_reps, - container->prop_reps_dict, + binary_noderev.prop_rep = store_representation(container->reps, + container->reps_dict, noderev->prop_rep); - if (noderev->data_rep) - binary_noderev.data_rep = store_representation(container->data_reps, - container->data_reps_dict, - noderev->data_rep); + binary_noderev.data_rep = store_representation(container->reps, + container->reps_dict, + noderev->data_rep); if (noderev->created_path) binary_noderev.created_path = svn_fs_x__string_table_builder_add(container->builder, - noderev->created_path, - 0); + noderev->created_path, + 0); binary_noderev.mergeinfo_count = noderev->mergeinfo_count; @@ -331,58 +319,48 @@ svn_fs_x__noderevs_estimate_size(const s /* string table code makes its own prediction, * noderevs should be < 16 bytes each, - * ids < 10 bytes each, + * id parts < 4 bytes each, * data representations < 40 bytes each, * property representations < 30 bytes each, * some static overhead should be assumed */ return svn_fs_x__string_table_builder_estimate_size(container->builder) + container->noderevs->nelts * 16 - + container->ids->nelts * 10 - + container->data_reps->nelts * 40 - + container->prop_reps->nelts * 30 + + container->ids->nelts * 4 + + container->reps->nelts * 40 + 100; } -/* Create an svn_fs_id_t in *ID, allocated in POOL based on the id stored - * at index IDX in IDS. +/* Set *ID to the ID part stored at index IDX in IDS. */ static svn_error_t * -get_id(const svn_fs_id_t **id, +get_id(svn_fs_x__id_t *id, const apr_array_header_t *ids, - int idx, - apr_pool_t *pool) + int idx) { - binary_id_t *binary_id; - /* handle NULL IDs */ if (idx == 0) { - *id = NULL; + svn_fs_x__id_reset(id); return SVN_NO_ERROR; } /* check for corrupted data */ if (idx < 0 || idx > ids->nelts) return svn_error_createf(SVN_ERR_FS_CONTAINER_INDEX, NULL, - _("Node revision ID index %d" - " exceeds container size %d"), + _("ID part index %d exceeds container size %d"), idx, ids->nelts); - /* create a svn_fs_id_t from stored info */ - binary_id = &APR_ARRAY_IDX(ids, idx - 1, binary_id_t); - *id = svn_fs_x__id_create(&binary_id->node_id, - &binary_id->copy_id, - &binary_id->noderev_id, - pool); + /* Return the requested ID. */ + *id = APR_ARRAY_IDX(ids, idx - 1, svn_fs_x__id_t); return SVN_NO_ERROR; } -/* Create a representation_t in *REP, allocated in POOL based on the +/* Create a svn_fs_x__representation_t in *REP, allocated in POOL based on the * representation stored at index IDX in REPS. */ static svn_error_t * -get_representation(representation_t **rep, +get_representation(svn_fs_x__representation_t **rep, const apr_array_header_t *reps, int idx, apr_pool_t *pool) @@ -420,14 +398,14 @@ get_representation(representation_t **re } svn_error_t * -svn_fs_x__noderevs_get(node_revision_t **noderev_p, +svn_fs_x__noderevs_get(svn_fs_x__noderev_t **noderev_p, const svn_fs_x__noderevs_t *container, apr_size_t idx, apr_pool_t *pool) { - node_revision_t *noderev; + svn_fs_x__noderev_t *noderev; binary_noderev_t *binary_noderev; - + /* CONTAINER must be in 'finalized' mode */ SVN_ERR_ASSERT(container->builder == NULL); SVN_ERR_ASSERT(container->paths); @@ -444,11 +422,15 @@ svn_fs_x__noderevs_get(node_revision_t * /* allocate result struct and fill it field by field */ noderev = apr_pcalloc(pool, sizeof(*noderev)); binary_noderev = &APR_ARRAY_IDX(container->noderevs, idx, binary_noderev_t); - + noderev->kind = (svn_node_kind_t)(binary_noderev->flags & NODEREV_KIND_MASK); - SVN_ERR(get_id(&noderev->id, container->ids, binary_noderev->id, pool)); + SVN_ERR(get_id(&noderev->noderev_id, container->ids, binary_noderev->id)); + SVN_ERR(get_id(&noderev->node_id, container->ids, + binary_noderev->node_id)); + SVN_ERR(get_id(&noderev->copy_id, container->ids, + binary_noderev->copy_id)); SVN_ERR(get_id(&noderev->predecessor_id, container->ids, - binary_noderev->predecessor_id, pool)); + binary_noderev->predecessor_id)); if (binary_noderev->flags & NODEREV_HAS_COPYFROM) { @@ -482,9 +464,9 @@ svn_fs_x__noderevs_get(node_revision_t * noderev->predecessor_count = binary_noderev->predecessor_count; - SVN_ERR(get_representation(&noderev->prop_rep, container->prop_reps, + SVN_ERR(get_representation(&noderev->prop_rep, container->reps, binary_noderev->prop_rep, pool)); - SVN_ERR(get_representation(&noderev->data_rep, container->data_reps, + SVN_ERR(get_representation(&noderev->data_rep, container->reps, binary_noderev->data_rep, pool)); if (binary_noderev->flags & NODEREV_HAS_CPATH) @@ -558,56 +540,50 @@ write_reps(svn_packed__int_stream_t *rep svn_error_t * svn_fs_x__write_noderevs_container(svn_stream_t *stream, const svn_fs_x__noderevs_t *container, - apr_pool_t *pool) + apr_pool_t *scratch_pool) { int i; string_table_t *paths = container->paths ? container->paths : svn_fs_x__string_table_create(container->builder, - pool); + scratch_pool); - 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 common top-level stream for all arrays. One sub-stream */ svn_packed__int_stream_t *structs_stream = svn_packed__create_int_stream(root, FALSE, FALSE); svn_packed__int_stream_t *ids_stream = svn_packed__create_int_substream(structs_stream, FALSE, FALSE); - svn_packed__int_stream_t *data_reps_stream - = create_rep_stream(structs_stream); - svn_packed__int_stream_t *prop_reps_stream + svn_packed__int_stream_t *reps_stream = create_rep_stream(structs_stream); svn_packed__int_stream_t *noderevs_stream = svn_packed__create_int_substream(structs_stream, FALSE, FALSE); svn_packed__byte_stream_t *digests_stream = svn_packed__create_bytes_stream(root); - /* structure the CHANGES_STREAM such we can extract much of the redundancy - * from the binary_change_t structs */ - for (i = 0; i < 3 * 2; ++i) + /* structure the IDS_STREAM such we can extract much of the redundancy + * from the svn_fs_x__ip_part_t structs */ + for (i = 0; i < 2; ++i) svn_packed__create_int_substream(ids_stream, TRUE, FALSE); + /* Same storing binary_noderev_t in the NODEREVS_STREAM */ svn_packed__create_int_substream(noderevs_stream, FALSE, FALSE); - for (i = 0; i < 11; ++i) + for (i = 0; i < 13; ++i) svn_packed__create_int_substream(noderevs_stream, TRUE, FALSE); /* serialize ids array */ for (i = 0; i < container->ids->nelts; ++i) { - binary_id_t *id = &APR_ARRAY_IDX(container->ids, i, binary_id_t); + svn_fs_x__id_t *id = &APR_ARRAY_IDX(container->ids, i, svn_fs_x__id_t); - svn_packed__add_int(ids_stream, id->node_id.change_set); - svn_packed__add_uint(ids_stream, id->node_id.number); - svn_packed__add_int(ids_stream, id->copy_id.change_set); - svn_packed__add_uint(ids_stream, id->copy_id.number); - svn_packed__add_int(ids_stream, id->noderev_id.change_set); - svn_packed__add_uint(ids_stream, id->noderev_id.number); + svn_packed__add_int(ids_stream, id->change_set); + svn_packed__add_uint(ids_stream, id->number); } /* serialize rep arrays */ - write_reps(data_reps_stream, digests_stream, container->data_reps); - write_reps(prop_reps_stream, digests_stream, container->prop_reps); + write_reps(reps_stream, digests_stream, container->reps); /* serialize noderevs array */ for (i = 0; i < container->noderevs->nelts; ++i) @@ -618,6 +594,8 @@ svn_fs_x__write_noderevs_container(svn_s svn_packed__add_uint(noderevs_stream, noderev->flags); svn_packed__add_uint(noderevs_stream, noderev->id); + svn_packed__add_uint(noderevs_stream, noderev->node_id); + svn_packed__add_uint(noderevs_stream, noderev->copy_id); svn_packed__add_uint(noderevs_stream, noderev->predecessor_id); svn_packed__add_uint(noderevs_stream, noderev->predecessor_count); @@ -634,15 +612,15 @@ svn_fs_x__write_noderevs_container(svn_s } /* write to disk */ - SVN_ERR(svn_fs_x__write_string_table(stream, paths, pool)); - SVN_ERR(svn_packed__data_write(stream, root, pool)); + SVN_ERR(svn_fs_x__write_string_table(stream, paths, scratch_pool)); + SVN_ERR(svn_packed__data_write(stream, root, scratch_pool)); return SVN_NO_ERROR; } -/* Allocate a representation_t array in POOL and return it in *REPS_P. - * Deserialize the data in REP_STREAM and DIGEST_STREAM and store the - * resulting representations into the *REPS_P. +/* Allocate a svn_fs_x__representation_t array in POOL and return it in + * REPS_P. Deserialize the data in REP_STREAM and DIGEST_STREAM and store + * the resulting representations into the *REPS_P. */ static svn_error_t * read_reps(apr_array_header_t **reps_p, @@ -719,8 +697,7 @@ svn_fs_x__read_noderevs_container(svn_fs svn_packed__data_root_t *root; svn_packed__int_stream_t *structs_stream; svn_packed__int_stream_t *ids_stream; - svn_packed__int_stream_t *data_reps_stream; - svn_packed__int_stream_t *prop_reps_stream; + svn_packed__int_stream_t *reps_stream; svn_packed__int_stream_t *noderevs_stream; svn_packed__byte_stream_t *digests_stream; @@ -732,34 +709,27 @@ svn_fs_x__read_noderevs_container(svn_fs /* get streams */ structs_stream = svn_packed__first_int_stream(root); ids_stream = svn_packed__first_int_substream(structs_stream); - data_reps_stream = svn_packed__next_int_stream(ids_stream); - prop_reps_stream = svn_packed__next_int_stream(data_reps_stream); - noderevs_stream = svn_packed__next_int_stream(prop_reps_stream); + reps_stream = svn_packed__next_int_stream(ids_stream); + noderevs_stream = svn_packed__next_int_stream(reps_stream); digests_stream = svn_packed__first_byte_stream(root); /* read ids array */ count = svn_packed__int_count(svn_packed__first_int_substream(ids_stream)); noderevs->ids - = apr_array_make(result_pool, (int)count, sizeof(binary_id_t)); + = apr_array_make(result_pool, (int)count, sizeof(svn_fs_x__id_t)); for (i = 0; i < count; ++i) { - binary_id_t id; + svn_fs_x__id_t id; - id.node_id.change_set = (svn_revnum_t)svn_packed__get_int(ids_stream); - id.node_id.number = svn_packed__get_uint(ids_stream); - id.copy_id.change_set = (svn_revnum_t)svn_packed__get_int(ids_stream); - id.copy_id.number = svn_packed__get_uint(ids_stream); - id.noderev_id.change_set = (svn_revnum_t)svn_packed__get_int(ids_stream); - id.noderev_id.number = svn_packed__get_uint(ids_stream); + id.change_set = (svn_revnum_t)svn_packed__get_int(ids_stream); + id.number = svn_packed__get_uint(ids_stream); - APR_ARRAY_PUSH(noderevs->ids, binary_id_t) = id; + APR_ARRAY_PUSH(noderevs->ids, svn_fs_x__id_t) = id; } /* read rep arrays */ - SVN_ERR(read_reps(&noderevs->data_reps, data_reps_stream, digests_stream, - result_pool)); - SVN_ERR(read_reps(&noderevs->prop_reps, prop_reps_stream, digests_stream, + SVN_ERR(read_reps(&noderevs->reps, reps_stream, digests_stream, result_pool)); /* read noderevs array */ @@ -774,6 +744,8 @@ svn_fs_x__read_noderevs_container(svn_fs noderev.flags = (apr_uint32_t)svn_packed__get_uint(noderevs_stream); noderev.id = (int)svn_packed__get_uint(noderevs_stream); + noderev.node_id = (int)svn_packed__get_uint(noderevs_stream); + noderev.copy_id = (int)svn_packed__get_uint(noderevs_stream); noderev.predecessor_id = (int)svn_packed__get_uint(noderevs_stream); noderev.predecessor_count = (int)svn_packed__get_uint(noderevs_stream); @@ -806,8 +778,7 @@ svn_fs_x__serialize_noderevs_container(v svn_stringbuf_t *serialized; apr_size_t size = noderevs->ids->elt_size * noderevs->ids->nelts - + noderevs->data_reps->elt_size * noderevs->data_reps->nelts - + noderevs->prop_reps->elt_size * noderevs->prop_reps->nelts + + noderevs->reps->elt_size * noderevs->reps->nelts + noderevs->noderevs->elt_size * noderevs->noderevs->nelts + 10 * noderevs->noderevs->elt_size + 100; @@ -819,8 +790,7 @@ svn_fs_x__serialize_noderevs_container(v /* serialize sub-structures */ svn_fs_x__serialize_string_table(context, &noderevs->paths); svn_fs_x__serialize_apr_array(context, &noderevs->ids); - svn_fs_x__serialize_apr_array(context, &noderevs->data_reps); - svn_fs_x__serialize_apr_array(context, &noderevs->prop_reps); + svn_fs_x__serialize_apr_array(context, &noderevs->reps); svn_fs_x__serialize_apr_array(context, &noderevs->noderevs); /* return the serialized result */ @@ -843,8 +813,7 @@ svn_fs_x__deserialize_noderevs_container /* de-serialize sub-structures */ svn_fs_x__deserialize_string_table(noderevs, &noderevs->paths); svn_fs_x__deserialize_apr_array(noderevs, &noderevs->ids, pool); - svn_fs_x__deserialize_apr_array(noderevs, &noderevs->data_reps, pool); - svn_fs_x__deserialize_apr_array(noderevs, &noderevs->prop_reps, pool); + svn_fs_x__deserialize_apr_array(noderevs, &noderevs->reps, pool); svn_fs_x__deserialize_apr_array(noderevs, &noderevs->noderevs, pool); /* done */ @@ -878,12 +847,11 @@ svn_fs_x__noderevs_get_func(void **out, void *baton, apr_pool_t *pool) { - node_revision_t *noderev; + svn_fs_x__noderev_t *noderev; binary_noderev_t *binary_noderev; - + apr_array_header_t ids; - apr_array_header_t data_reps; - apr_array_header_t prop_reps; + apr_array_header_t reps; apr_array_header_t noderevs; apr_uint32_t idx = *(apr_uint32_t *)baton; @@ -895,18 +863,19 @@ svn_fs_x__noderevs_get_func(void **out, (const void *const *)&container->paths); resolve_apr_array_header(&ids, container, &container->ids); - resolve_apr_array_header(&data_reps, container, &container->data_reps); - resolve_apr_array_header(&prop_reps, container, &container->prop_reps); + resolve_apr_array_header(&reps, container, &container->reps); resolve_apr_array_header(&noderevs, container, &container->noderevs); - + /* allocate result struct and fill it field by field */ noderev = apr_pcalloc(pool, sizeof(*noderev)); binary_noderev = &APR_ARRAY_IDX(&noderevs, idx, binary_noderev_t); - + noderev->kind = (svn_node_kind_t)(binary_noderev->flags & NODEREV_KIND_MASK); - SVN_ERR(get_id(&noderev->id, &ids, binary_noderev->id, pool)); + SVN_ERR(get_id(&noderev->noderev_id, &ids, binary_noderev->id)); + SVN_ERR(get_id(&noderev->node_id, &ids, binary_noderev->node_id)); + SVN_ERR(get_id(&noderev->copy_id, &ids, binary_noderev->copy_id)); SVN_ERR(get_id(&noderev->predecessor_id, &ids, - binary_noderev->predecessor_id, pool)); + binary_noderev->predecessor_id)); if (binary_noderev->flags & NODEREV_HAS_COPYFROM) { @@ -940,9 +909,9 @@ svn_fs_x__noderevs_get_func(void **out, noderev->predecessor_count = binary_noderev->predecessor_count; - SVN_ERR(get_representation(&noderev->prop_rep, &prop_reps, + SVN_ERR(get_representation(&noderev->prop_rep, &reps, binary_noderev->prop_rep, pool)); - SVN_ERR(get_representation(&noderev->data_rep, &data_reps, + SVN_ERR(get_representation(&noderev->data_rep, &reps, binary_noderev->data_rep, pool)); if (binary_noderev->flags & NODEREV_HAS_CPATH)
Modified: subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/noderevs.h URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/noderevs.h?rev=1652409&r1=1652408&r2=1652409&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/noderevs.h (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/noderevs.h Fri Jan 16 14:01:35 2015 @@ -33,7 +33,7 @@ * * In its serialized form, the svn_fs_x__noderevs_t container extracts * most of that redundancy and the run-time representation is also much - * smaller than sum of the respective node_revision_t objects. + * smaller than sum of the respective svn_fs_x__noderev_t objects. * * As with other containers, this one has two modes: 'construction', in * which you may add data to it, and 'getter' in which there is only r/o @@ -47,18 +47,19 @@ typedef struct svn_fs_x__noderevs_t svn_ /* Create and populate noderev containers. */ /* Create and return a new noderevs container with an initial capacity of - * INITIAL_COUNT node_revision_t objects. Allocate the result in POOL. + * INITIAL_COUNT svn_fs_x__noderev_t objects. + * Allocate the result in RESULT_POOL. */ svn_fs_x__noderevs_t * svn_fs_x__noderevs_create(int initial_count, - apr_pool_t *pool); + apr_pool_t *result_pool); /* Add NODEREV to the CONTAINER. Return the index that identifies the new * item in this container. */ apr_size_t svn_fs_x__noderevs_add(svn_fs_x__noderevs_t *container, - node_revision_t *noderev); + svn_fs_x__noderev_t *noderev); /* Return a rough estimate in bytes for the serialized representation * of CONTAINER. @@ -72,20 +73,20 @@ svn_fs_x__noderevs_estimate_size(const s * the result in POOL and return it in *NODEREV_P. */ svn_error_t * -svn_fs_x__noderevs_get(node_revision_t **noderev_p, +svn_fs_x__noderevs_get(svn_fs_x__noderev_t **noderev_p, const svn_fs_x__noderevs_t *container, apr_size_t idx, apr_pool_t *pool); /* I/O interface. */ -/* Write a serialized representation of CONTAINER to STREAM. Use POOL for - * temporary allocations. +/* Write a serialized representation of CONTAINER to STREAM. + * Use SCRATCH_POOL for temporary allocations. */ svn_error_t * svn_fs_x__write_noderevs_container(svn_stream_t *stream, - const svn_fs_x__noderevs_t *container, - apr_pool_t *pool); + const svn_fs_x__noderevs_t *container, + apr_pool_t *scratch_pool); /* Read a noderev container from its serialized representation in STREAM. * Allocate the result in RESULT_POOL and return it in *CONTAINER. Use @@ -116,7 +117,7 @@ svn_fs_x__deserialize_noderevs_container apr_pool_t *pool); /* Implements svn_cache__partial_getter_func_t for svn_fs_x__noderevs_t, - * setting *OUT to the node_revision_t selected by the apr_uint32_t index + * setting *OUT to the svn_fs_x__noderev_t selected by the apr_uint32_t index * passed in as *BATON. This function is similar to svn_fs_x__noderevs_get * but operates on the cache serialized representation of the container. */ Modified: subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/pack.c URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/pack.c?rev=1652409&r1=1652408&r2=1652409&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/pack.c (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/pack.c Fri Jan 16 14:01:35 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,7 +2224,7 @@ 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; } @@ -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; + 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,7 +2311,7 @@ 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 }; pb.fs = fs; @@ -2299,5 +2319,5 @@ svn_fs_x__pack(svn_fs_t *fs, 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/svn-auth-x509/subversion/libsvn_fs_x/pack.h URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/pack.h?rev=1652409&r1=1652408&r2=1652409&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/pack.h (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/pack.h Fri Jan 16 14:01:35 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/svn-auth-x509/subversion/libsvn_fs_x/recovery.c URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/recovery.c?rev=1652409&r1=1652408&r2=1652409&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/recovery.c (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/recovery.c Fri Jan 16 14:01:35 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) { @@ -114,28 +116,29 @@ struct recover_baton { write lock. This implements the svn_fs_x__with_write_lock() 'body' callback type. BATON is a 'struct recover_baton *'. */ 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; 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; /* 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,12 +179,12 @@ 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)); + 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_none) { svn_boolean_t missing = TRUE; - if (!svn_fs_x__packed_revprop_available(&missing, fs, max_rev, pool)) + if (!svn_fs_x__packed_revprop_available(&missing, fs, max_rev, scratch_pool)) { if (missing) { @@ -214,21 +217,21 @@ 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) + apr_pool_t *scratch_pool) { struct recover_baton b; @@ -239,5 +242,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/svn-auth-x509/subversion/libsvn_fs_x/recovery.h URL: http://svn.apache.org/viewvc/subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/recovery.h?rev=1652409&r1=1652408&r2=1652409&view=diff ============================================================================== --- subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/recovery.h (original) +++ subversion/branches/svn-auth-x509/subversion/libsvn_fs_x/recovery.h Fri Jan 16 14:01:35 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
