Modified: subversion/branches/authzperf/subversion/libsvn_fs_x/hotcopy.h URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs_x/hotcopy.h?rev=1649205&r1=1649204&r2=1649205&view=diff ============================================================================== --- subversion/branches/authzperf/subversion/libsvn_fs_x/hotcopy.h (original) +++ subversion/branches/authzperf/subversion/libsvn_fs_x/hotcopy.h Sat Jan 3 14:00:41 2015 @@ -36,11 +36,14 @@ svn_fs_x__hotcopy_prepare_target(svn_fs_ apr_pool_t *pool); /* Copy the fsfs filesystem SRC_FS into DST_FS. If INCREMENTAL is TRUE, do - * not re-copy data which already exists in DST_FS. Use POOL for temporary - * allocations. */ + * not re-copy data which already exists in DST_FS. Indicate progress via + * the optional NOTIFY_FUNC callback using NOTIFY_BATON. Use POOL for + * temporary allocations. */ svn_error_t * svn_fs_x__hotcopy(svn_fs_t *src_fs, svn_fs_t *dst_fs, svn_boolean_t incremental, + svn_fs_hotcopy_notify_t notify_func, + void *notify_baton, svn_cancel_func_t cancel_func, void *cancel_baton, apr_pool_t *pool);
Modified: subversion/branches/authzperf/subversion/libsvn_fs_x/id.c URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs_x/id.c?rev=1649205&r1=1649204&r2=1649205&view=diff ============================================================================== --- subversion/branches/authzperf/subversion/libsvn_fs_x/id.c (original) +++ subversion/branches/authzperf/subversion/libsvn_fs_x/id.c Sat Jan 3 14:00:41 2015 @@ -1,4 +1,4 @@ -/* id.c : operations on node-revision IDs +/* id.c : implements FSX-internal ID functions * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one @@ -21,32 +21,14 @@ */ #include <assert.h> -#include <string.h> -#include <stdlib.h> #include "id.h" #include "index.h" #include "util.h" -#include "../libsvn_fs/fs-loader.h" -#include "private/svn_temp_serializer.h" #include "private/svn_string_private.h" -typedef struct fs_x__id_t -{ - /* API visible part */ - svn_fs_id_t generic_id; - - /* private members */ - svn_fs_x__id_part_t node_id; - svn_fs_x__id_part_t copy_id; - svn_fs_x__id_part_t noderev_id; - - apr_pool_t *pool; /* pool that was used to allocate this struct */ -} fs_x__id_t; - - svn_boolean_t svn_fs_x__is_txn(svn_fs_x__change_set_t change_set) @@ -95,7 +77,7 @@ svn_fs_x__change_set_by_txn(apr_int64_t /* Parse the NUL-terminated ID part at DATA and write the result into *PART. * Return TRUE if no errors were detected. */ static svn_boolean_t -part_parse(svn_fs_x__id_part_t *part, +part_parse(svn_fs_x__id_t *part, const char *data) { part->number = svn__base36toui64(&data, data); @@ -119,7 +101,7 @@ part_parse(svn_fs_x__id_part_t *part, */ static char * part_unparse(char *p, - const svn_fs_x__id_part_t *part) + const svn_fs_x__id_t *part) { p += svn__ui64tobase36(p, part->number); if (part->change_set >= 0) @@ -141,150 +123,71 @@ part_unparse(char *p, /* Operations on ID parts */ svn_boolean_t -svn_fs_x__id_part_is_root(const svn_fs_x__id_part_t* part) +svn_fs_x__id_is_root(const svn_fs_x__id_t* part) { return part->change_set == 0 && part->number == 0; } svn_boolean_t -svn_fs_x__id_part_eq(const svn_fs_x__id_part_t *lhs, - const svn_fs_x__id_part_t *rhs) +svn_fs_x__id_eq(const svn_fs_x__id_t *lhs, + const svn_fs_x__id_t *rhs) { return lhs->change_set == rhs->change_set && lhs->number == rhs->number; } - - -/* Accessing ID Pieces. */ - -const svn_fs_x__id_part_t * -svn_fs_x__id_node_id(const svn_fs_id_t *fs_id) -{ - const fs_x__id_t *id = (const fs_x__id_t *)fs_id; - - return &id->node_id; -} - - -const svn_fs_x__id_part_t * -svn_fs_x__id_copy_id(const svn_fs_id_t *fs_id) -{ - const fs_x__id_t *id = (const fs_x__id_t *)fs_id; - - return &id->copy_id; -} - - -svn_fs_x__txn_id_t -svn_fs_x__id_txn_id(const svn_fs_id_t *fs_id) -{ - const fs_x__id_t *id = (const fs_x__id_t *)fs_id; +svn_error_t * +svn_fs_x__id_parse(svn_fs_x__id_t *part, + const char *data) +{ + if (!part_parse(part, data)) + return svn_error_createf(SVN_ERR_FS_MALFORMED_NODEREV_ID, NULL, + "Malformed ID string"); - return svn_fs_x__get_txn_id(id->noderev_id.change_set); -} - - -const svn_fs_x__id_part_t * -svn_fs_x__id_noderev_id(const svn_fs_id_t *fs_id) -{ - const fs_x__id_t *id = (const fs_x__id_t *)fs_id; - - return &id->noderev_id; -} - -svn_revnum_t -svn_fs_x__id_rev(const svn_fs_id_t *fs_id) -{ - const fs_x__id_t *id = (const fs_x__id_t *)fs_id; - - return svn_fs_x__get_revnum(id->noderev_id.change_set); -} - - -apr_uint64_t -svn_fs_x__id_item(const svn_fs_id_t *fs_id) -{ - const fs_x__id_t *id = (const fs_x__id_t *)fs_id; - - return id->noderev_id.number; -} - -svn_boolean_t -svn_fs_x__id_is_txn(const svn_fs_id_t *fs_id) -{ - const fs_x__id_t *id = (const fs_x__id_t *)fs_id; - - return svn_fs_x__is_txn(id->noderev_id.change_set); + return SVN_NO_ERROR; } svn_string_t * -svn_fs_x__id_unparse(const svn_fs_id_t *fs_id, +svn_fs_x__id_unparse(const svn_fs_x__id_t *id, apr_pool_t *pool) { - char string[6 * SVN_INT64_BUFFER_SIZE + 10]; - const fs_x__id_t *id = (const fs_x__id_t *)fs_id; - - char *p = part_unparse(string, &id->node_id); - *(p++) = '.'; - p = part_unparse(p, &id->copy_id); - *(p++) = '.'; - p = part_unparse(p, &id->noderev_id); + char string[2 * SVN_INT64_BUFFER_SIZE + 1]; + char *p = part_unparse(string, id); return svn_string_ncreate(string, p - string, pool); } - -/*** Comparing node IDs ***/ - -svn_boolean_t -svn_fs_x__id_eq(const svn_fs_id_t *a, - const svn_fs_id_t *b) +void +svn_fs_x__id_reset(svn_fs_x__id_t *part) { - const fs_x__id_t *id_a = (const fs_x__id_t *)a; - const fs_x__id_t *id_b = (const fs_x__id_t *)b; - - if (a == b) - return TRUE; - - return memcmp(&id_a->node_id, &id_b->node_id, - 3 * sizeof(svn_fs_x__id_part_t)) == 0; + part->change_set = SVN_FS_X__INVALID_CHANGE_SET; + part->number = 0; } - svn_boolean_t -svn_fs_x__id_check_related(const svn_fs_id_t *a, - const svn_fs_id_t *b) +svn_fs_x__id_used(const svn_fs_x__id_t *part) { - const fs_x__id_t *id_a = (const fs_x__id_t *)a; - const fs_x__id_t *id_b = (const fs_x__id_t *)b; - - if (a == b) - return TRUE; - - /* Items from different txns are unrelated. */ - if ( svn_fs_x__is_txn(id_a->noderev_id.change_set) - && svn_fs_x__is_txn(id_b->noderev_id.change_set) - && id_a->noderev_id.change_set != id_b->noderev_id.change_set) - return FALSE; - - /* related if they trace back to the same node creation */ - return svn_fs_x__id_part_eq(&id_a->node_id, &id_b->node_id); + return part->change_set != SVN_FS_X__INVALID_CHANGE_SET; } +void +svn_fs_x__init_txn_root(svn_fs_x__id_t *noderev_id, + svn_fs_x__txn_id_t txn_id) +{ + noderev_id->change_set = svn_fs_x__change_set_by_txn(txn_id); + noderev_id->number = SVN_FS_X__ITEM_INDEX_ROOT_NODE; +} -svn_fs_node_relation_t -svn_fs_x__id_compare(const svn_fs_id_t *a, - const svn_fs_id_t *b) +void +svn_fs_x__init_rev_root(svn_fs_x__id_t *noderev_id, + svn_revnum_t rev) { - if (svn_fs_x__id_eq(a, b)) - return svn_fs_node_same; - return (svn_fs_x__id_check_related(a, b) ? svn_fs_node_common_ancestor - : svn_fs_node_unrelated); + noderev_id->change_set = svn_fs_x__change_set_by_rev(rev); + noderev_id->number = SVN_FS_X__ITEM_INDEX_ROOT_NODE; } int -svn_fs_x__id_part_compare(const svn_fs_x__id_part_t *a, - const svn_fs_x__id_part_t *b) +svn_fs_x__id_compare(const svn_fs_x__id_t *a, + const svn_fs_x__id_t *b) { if (a->change_set < b->change_set) return -1; @@ -293,199 +196,3 @@ svn_fs_x__id_part_compare(const svn_fs_x return a->number < b->number ? -1 : a->number == b->number ? 0 : 1; } - - - -/* Creating ID's. */ - -static id_vtable_t id_vtable = { - svn_fs_x__id_unparse, - svn_fs_x__id_compare -}; - -svn_fs_id_t * -svn_fs_x__id_txn_create_root(svn_fs_x__txn_id_t txn_id, - apr_pool_t *pool) -{ - fs_x__id_t *id = apr_pcalloc(pool, sizeof(*id)); - - /* node ID and copy ID are "0" */ - - id->noderev_id.change_set = svn_fs_x__change_set_by_txn(txn_id); - id->noderev_id.number = SVN_FS_X__ITEM_INDEX_ROOT_NODE; - - id->generic_id.vtable = &id_vtable; - id->generic_id.fsap_data = id; - id->pool = pool; - - return (svn_fs_id_t *)id; -} - -svn_fs_id_t *svn_fs_x__id_create_root(const svn_revnum_t revision, - apr_pool_t *pool) -{ - fs_x__id_t *id = apr_pcalloc(pool, sizeof(*id)); - - /* node ID and copy ID are "0" */ - - id->noderev_id.change_set = svn_fs_x__change_set_by_rev(revision); - id->noderev_id.number = SVN_FS_X__ITEM_INDEX_ROOT_NODE; - - id->generic_id.vtable = &id_vtable; - id->generic_id.fsap_data = id; - id->pool = pool; - - return (svn_fs_id_t *)id; -} - -svn_fs_id_t * -svn_fs_x__id_txn_create(const svn_fs_x__id_part_t *node_id, - const svn_fs_x__id_part_t *copy_id, - svn_fs_x__txn_id_t txn_id, - apr_uint64_t item, - apr_pool_t *pool) -{ - fs_x__id_t *id = apr_pcalloc(pool, sizeof(*id)); - - id->node_id = *node_id; - id->copy_id = *copy_id; - - id->noderev_id.change_set = svn_fs_x__change_set_by_txn(txn_id); - id->noderev_id.number = item; - - id->generic_id.vtable = &id_vtable; - id->generic_id.fsap_data = id; - id->pool = pool; - - return (svn_fs_id_t *)id; -} - - -svn_fs_id_t * -svn_fs_x__id_create(const svn_fs_x__id_part_t *node_id, - const svn_fs_x__id_part_t *copy_id, - const svn_fs_x__id_part_t *noderev_id, - apr_pool_t *pool) -{ - fs_x__id_t *id = apr_pcalloc(pool, sizeof(*id)); - - id->node_id = *node_id; - id->copy_id = *copy_id; - id->noderev_id = *noderev_id; - - id->generic_id.vtable = &id_vtable; - id->generic_id.fsap_data = id; - id->pool = pool; - - return (svn_fs_id_t *)id; -} - - -svn_fs_id_t * -svn_fs_x__id_copy(const svn_fs_id_t *source, apr_pool_t *pool) -{ - const fs_x__id_t *id = (const fs_x__id_t *)source; - fs_x__id_t *new_id = apr_pmemdup(pool, id, sizeof(*id)); - - new_id->generic_id.fsap_data = new_id; - new_id->pool = pool; - - return (svn_fs_id_t *)new_id; -} - - -svn_fs_id_t * -svn_fs_x__id_parse(const char *data, - apr_size_t len, - apr_pool_t *pool) -{ - fs_x__id_t *id; - char *data_copy, *str; - - /* Dup the ID data into POOL. Our returned ID will have references - into this memory. */ - data_copy = apr_pstrmemdup(pool, data, len); - - /* Alloc a new svn_fs_id_t structure. */ - id = apr_pcalloc(pool, sizeof(*id)); - id->generic_id.vtable = &id_vtable; - id->generic_id.fsap_data = id; - id->pool = pool; - - /* Now, we basically just need to "split" this data on `.' - characters. We will use svn_cstring_tokenize, which will put - terminators where each of the '.'s used to be. Then our new - id field will reference string locations inside our duplicate - string.*/ - - /* Node Id */ - str = svn_cstring_tokenize(".", &data_copy); - if (str == NULL) - return NULL; - if (! part_parse(&id->node_id, str)) - return NULL; - - /* Copy Id */ - str = svn_cstring_tokenize(".", &data_copy); - if (str == NULL) - return NULL; - if (! part_parse(&id->copy_id, str)) - return NULL; - - /* NodeRev Id */ - str = svn_cstring_tokenize(".", &data_copy); - if (str == NULL) - return NULL; - - if (! part_parse(&id->noderev_id, str)) - return NULL; - - return (svn_fs_id_t *)id; -} - -/* (de-)serialization support */ - -/* Serialize an ID within the serialization CONTEXT. - */ -void -svn_fs_x__id_serialize(svn_temp_serializer__context_t *context, - const svn_fs_id_t * const *in) -{ - const fs_x__id_t *id = (const fs_x__id_t *)*in; - - /* nothing to do for NULL ids */ - if (id == NULL) - return; - - /* serialize the id data struct itself */ - svn_temp_serializer__add_leaf(context, - (const void * const *)in, - sizeof(fs_x__id_t)); -} - -/* Deserialize an ID inside the BUFFER. - */ -void -svn_fs_x__id_deserialize(void *buffer, - svn_fs_id_t **in_out, - apr_pool_t *pool) -{ - fs_x__id_t *id; - - /* The id maybe all what is in the whole buffer. - * Don't try to fixup the pointer in that case*/ - if (*in_out != buffer) - svn_temp_deserializer__resolve(buffer, (void**)in_out); - - id = (fs_x__id_t *)*in_out; - - /* no id, no sub-structure fixup necessary */ - if (id == NULL) - return; - - /* the stored vtable is bogus at best -> set the right one */ - id->generic_id.vtable = &id_vtable; - id->generic_id.fsap_data = id; - id->pool = pool; -} - Modified: subversion/branches/authzperf/subversion/libsvn_fs_x/id.h URL: http://svn.apache.org/viewvc/subversion/branches/authzperf/subversion/libsvn_fs_x/id.h?rev=1649205&r1=1649204&r2=1649205&view=diff ============================================================================== --- subversion/branches/authzperf/subversion/libsvn_fs_x/id.h (original) +++ subversion/branches/authzperf/subversion/libsvn_fs_x/id.h Sat Jan 3 14:00:41 2015 @@ -1,4 +1,4 @@ -/* id.h : interface to node ID functions, private to libsvn_fs_x +/* id.h : interface to FSX-internal ID functions * * ==================================================================== * Licensed to the Apache Software Foundation (ASF) under one @@ -57,135 +57,65 @@ svn_revnum_t svn_fs_x__get_revnum(svn_fs /* Return the transaction ID that corresponds to CHANGE_SET. Will SVN_FS_X__INVALID_TXN_ID for revisions. */ -apr_int64_t svn_fs_x__get_txn_id(svn_fs_x__change_set_t change_set); +svn_fs_x__txn_id_t svn_fs_x__get_txn_id(svn_fs_x__change_set_t change_set); /* Convert REVNUM into a change set number */ svn_fs_x__change_set_t svn_fs_x__change_set_by_rev(svn_revnum_t revnum); /* Convert TXN_ID into a change set number */ -svn_fs_x__change_set_t svn_fs_x__change_set_by_txn(apr_int64_t txn_id); +svn_fs_x__change_set_t svn_fs_x__change_set_by_txn(svn_fs_x__txn_id_t txn_id); -/* A rev node ID in FSX consists of a 3 of sub-IDs ("parts") that consist - * of a creation CHANGE_SET number and some revision-local counter value - * (NUMBER). +/* An ID in FSX consists of a creation CHANGE_SET number and some changeset- + * local counter value (NUMBER). */ -typedef struct svn_fs_x__id_part_t +typedef struct svn_fs_x__id_t { svn_fs_x__change_set_t change_set; apr_uint64_t number; -} svn_fs_x__id_part_t; +} svn_fs_x__id_t; /*** Operations on ID parts. ***/ /* Return TRUE, if both elements of the PART is 0, i.e. this is the default * value if e.g. no copies were made of this node. */ -svn_boolean_t svn_fs_x__id_part_is_root(const svn_fs_x__id_part_t *part); +svn_boolean_t svn_fs_x__id_is_root(const svn_fs_x__id_t *part); /* Return TRUE, if all element values of *LHS and *RHS match. */ -svn_boolean_t svn_fs_x__id_part_eq(const svn_fs_x__id_part_t *lhs, - const svn_fs_x__id_part_t *rhs); +svn_boolean_t svn_fs_x__id_eq(const svn_fs_x__id_t *lhs, + const svn_fs_x__id_t *rhs); - -/*** ID accessor functions. ***/ - -/* Get the "node id" portion of ID. */ -const svn_fs_x__id_part_t *svn_fs_x__id_node_id(const svn_fs_id_t *id); - -/* Get the "copy id" portion of ID. */ -const svn_fs_x__id_part_t *svn_fs_x__id_copy_id(const svn_fs_id_t *id); - -/* Get the "txn id" portion of ID, - * or SVN_FS_X__INVALID_TXN_ID if it is a permanent ID. */ -svn_fs_x__txn_id_t svn_fs_x__id_txn_id(const svn_fs_id_t *id); - -/* Get the "noderev id" portion of ID. */ -const svn_fs_x__id_part_t *svn_fs_x__id_noderev_id(const svn_fs_id_t *id); - -/* Get the "rev" portion of ID, or SVN_INVALID_REVNUM if it is a - transaction ID. */ -svn_revnum_t svn_fs_x__id_rev(const svn_fs_id_t *id); - -/* Access the "item" portion of the ID, or 0 if it is a transaction - ID. */ -apr_uint64_t svn_fs_x__id_item(const svn_fs_id_t *id); - -/* Return TRUE, if this is a transaction ID. */ -svn_boolean_t svn_fs_x__id_is_txn(const svn_fs_id_t *id); +/* Parse the NUL-terminated ID part at DATA and write the result into *PART. + */ +svn_error_t * +svn_fs_x__id_parse(svn_fs_x__id_t *part, + const char *data); /* Convert ID into string form, allocated in POOL. */ -svn_string_t *svn_fs_x__id_unparse(const svn_fs_id_t *id, - apr_pool_t *pool); - -/* Return true if A and B are equal. */ -svn_boolean_t svn_fs_x__id_eq(const svn_fs_id_t *a, - const svn_fs_id_t *b); - -/* Return true if A and B are related. */ -svn_boolean_t svn_fs_x__id_check_related(const svn_fs_id_t *a, - const svn_fs_id_t *b); - -/* Return the noderev relationship between A and B. */ -svn_fs_node_relation_t svn_fs_x__id_compare(const svn_fs_id_t *a, - const svn_fs_id_t *b); - -/* Return 0 if A and B are equal, 1 if A is "greater than" B, -1 otherwise. */ -int svn_fs_x__id_part_compare(const svn_fs_x__id_part_t *a, - const svn_fs_x__id_part_t *b); +svn_string_t * +svn_fs_x__id_unparse(const svn_fs_x__id_t*id, + apr_pool_t *pool); -/* Create the txn root ID for transaction TXN_ID. Allocate it in POOL. */ -svn_fs_id_t *svn_fs_x__id_txn_create_root(svn_fs_x__txn_id_t txnnum, - apr_pool_t *pool); - -/* Create the root ID for REVISION. Allocate it in POOL. */ -svn_fs_id_t *svn_fs_x__id_create_root(const svn_revnum_t revision, - apr_pool_t *pool); - -/* Create an ID within a transaction based on NODE_ID, COPY_ID, TXN_ID - and ITEM number, allocated in POOL. */ -svn_fs_id_t *svn_fs_x__id_txn_create(const svn_fs_x__id_part_t *node_id, - const svn_fs_x__id_part_t *copy_id, - svn_fs_x__txn_id_t txn_id, - apr_uint64_t item, - apr_pool_t *pool); - -/* Create a permanent ID based on NODE_ID, COPY_ID and NODEREV_ID, - allocated in POOL. */ -svn_fs_id_t *svn_fs_x__id_create(const svn_fs_x__id_part_t *node_id, - const svn_fs_x__id_part_t *copy_id, - const svn_fs_x__id_part_t *noderev_id, - apr_pool_t *pool); - -/* Return a copy of ID, allocated from POOL. */ -svn_fs_id_t *svn_fs_x__id_copy(const svn_fs_id_t *id, - apr_pool_t *pool); - -/* Return an ID resulting from parsing the string DATA (with length - LEN), or NULL if DATA is an invalid ID string. */ -svn_fs_id_t *svn_fs_x__id_parse(const char *data, - apr_size_t len, - apr_pool_t *pool); +/* Set *PART to "unused". */ +void svn_fs_x__id_reset(svn_fs_x__id_t *part); +/* Return TRUE if *PART is belongs to either a revision or transaction. */ +svn_boolean_t svn_fs_x__id_used(const svn_fs_x__id_t *part); -/* (de-)serialization support*/ - -struct svn_temp_serializer__context_t; +/* Return 0 if A and B are equal, 1 if A is "greater than" B, -1 otherwise. */ +int svn_fs_x__id_compare(const svn_fs_x__id_t *a, + const svn_fs_x__id_t *b); -/** - * Serialize an @a id within the serialization @a context. - */ +/* Set *NODEREV_ID to the root node ID of transaction TXN_ID. */ void -svn_fs_x__id_serialize(struct svn_temp_serializer__context_t *context, - const svn_fs_id_t * const *id); +svn_fs_x__init_txn_root(svn_fs_x__id_t *noderev_id, + svn_fs_x__txn_id_t txn_id); -/** - * Deserialize an @a id within the @a buffer and associate it with @a pool. - */ +/* Set *NODEREV_ID to the root node ID of revision REV. */ void -svn_fs_x__id_deserialize(void *buffer, - svn_fs_id_t **id, - apr_pool_t *pool); +svn_fs_x__init_rev_root(svn_fs_x__id_t *noderev_id, + svn_revnum_t rev); #ifdef __cplusplus }
