Author: stefan2
Date: Sat Mar 30 10:47:32 2013
New Revision: 1462727
URL: http://svn.apache.org/r1462727
Log:
On the fsfs-format7 branch: "flatten" representation_t by replacing
the svn_checksum_t* sub-structures with plain digests. That makes
representations and noderevs much easier to cache and copy.
Only in a few places do we have to construct proper svn_checksum_t
objects, most changes are simple adaptions and some are simplifications.
The code would be even nicer if we had access to lib_subr's private
MD5 and SHA1 interfaces.
* subversion/libsvn_fs_fs/fs.h
(representation_t): replace checksum objects with digests
* subversion/libsvn_fs_fs/cached_data.c
(rep_read_baton,
delta_read_baton): replace md5 checksum objects with digests
(rep_read_get_baton,
svn_fs_fs__get_file_delta_stream): update
(delta_read_md5_digest): simplify
(rep_read_contents): construct local checksum object from baton
* subversion/libsvn_fs_fs/fs_fs.c
(svn_fs_fs__file_checksum): update
(svn_fs_fs__rep_copy): simplify
* subversion/libsvn_fs_fs/low_level.c
(svn_fs_fs__parse_representation): update
(format_digest): replaces DISPLAY_MAYBE_NULL_CHECKSUM macro
(svn_fs_fs__unparse_representation): use the new function
* subversion/libsvn_fs_fs/rep-cache.c
(svn_fs_fs__walk_rep_reference,
svn_fs_fs__get_rep_reference): update
(svn_fs_fs__set_rep_reference): construct local checksum object
* subversion/libsvn_fs_fs/temp_serializer.c
(serialize_checksum,
deserialize_checksum): drop obsolete functions
(serialize_representation,
svn_fs_fs__noderev_deserialize): simplify
* subversion/libsvn_fs_fs/transaction.c
(store_sha1_rep_mapping,
digests_final,
write_final_rev): update
(get_shared_rep): update; construct temporary checksum object
* subversion/libsvn_fs_fs/util.h
(path_txn_sha1): take a digest instead of a checksum
* subversion/libsvn_fs_fs/util.c
(path_txn_sha1): construct temp. checksum object
* tools/server-side/svn-rep-sharing-stats.c
(value_t): make SHA1 checksum an embedded member
(record,
pretty_print): update
Modified:
subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c
subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs.h
subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs_fs.c
subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c
subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/rep-cache.c
subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.c
subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c
subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.c
subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.h
subversion/branches/fsfs-format7/tools/server-side/svn-rep-sharing-stats.c
Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c
URL:
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c?rev=1462727&r1=1462726&r2=1462727&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c
(original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/cached_data.c Sat
Mar 30 10:47:32 2013
@@ -914,7 +914,7 @@ struct rep_read_baton
length, and the amount we've read so far. Some of this
information is redundant with rs_list and src_state, but it's
convenient for the checksumming code to have it here. */
- svn_checksum_t *md5_checksum;
+ unsigned char md5_digest[APR_MD5_DIGESTSIZE];
svn_filesize_t len;
svn_filesize_t off;
@@ -1188,7 +1188,7 @@ rep_read_get_baton(struct rep_read_baton
b->buf = NULL;
b->md5_checksum_ctx = svn_checksum_ctx_create(svn_checksum_md5, pool);
b->checksum_finalized = FALSE;
- b->md5_checksum = svn_checksum_dup(rep->md5_checksum, pool);
+ memcpy(b->md5_digest, rep->md5_digest, sizeof(rep->md5_digest));
b->len = rep->expanded_size;
b->off = 0;
b->fulltext_cache_key = fulltext_cache_key;
@@ -1612,13 +1612,16 @@ rep_read_contents(void *baton,
if (rb->off == rb->len)
{
svn_checksum_t *md5_checksum;
+ svn_checksum_t expected;
+ expected.kind = svn_checksum_md5;
+ expected.digest = rb->md5_digest;
rb->checksum_finalized = TRUE;
SVN_ERR(svn_checksum_final(&md5_checksum, rb->md5_checksum_ctx,
rb->pool));
- if (!svn_checksum_match(md5_checksum, rb->md5_checksum))
+ if (!svn_checksum_match(md5_checksum, &expected))
return svn_error_create(SVN_ERR_FS_CORRUPT,
- svn_checksum_mismatch_err(rb->md5_checksum, md5_checksum,
+ svn_checksum_mismatch_err(&expected, md5_checksum,
rb->pool,
_("Checksum mismatch while reading representation")),
NULL);
@@ -1756,7 +1759,7 @@ svn_fs_fs__try_process_file_contents(svn
struct delta_read_baton
{
struct rep_state_t *rs;
- svn_checksum_t *checksum;
+ unsigned char md5_digest[APR_MD5_DIGESTSIZE];
};
/* This implements the svn_txdelta_next_window_fn_t interface. */
@@ -1781,11 +1784,7 @@ static const unsigned char *
delta_read_md5_digest(void *baton)
{
struct delta_read_baton *drb = baton;
-
- if (drb->checksum->kind == svn_checksum_md5)
- return drb->checksum->digest;
- else
- return NULL;
+ return drb->md5_digest;
}
svn_error_t *
@@ -1815,9 +1814,10 @@ svn_fs_fs__get_file_delta_stream(svn_txd
{
/* Create the delta read baton. */
struct delta_read_baton *drb = apr_pcalloc(pool, sizeof(*drb));
+
drb->rs = rep_state;
- drb->checksum = svn_checksum_dup(target->data_rep->md5_checksum,
- pool);
+ memcpy(drb->md5_digest, target->data_rep->md5_digest,
+ sizeof(drb->md5_digest));
*stream_p = svn_txdelta_stream_create(drb, delta_read_next_window,
delta_read_md5_digest, pool);
return SVN_NO_ERROR;
Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs.h
URL:
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs.h?rev=1462727&r1=1462726&r2=1462727&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs.h (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs.h Sat Mar 30
10:47:32 2013
@@ -26,6 +26,8 @@
#include <apr_pools.h>
#include <apr_hash.h>
#include <apr_network_io.h>
+#include <apr_md5.h>
+#include <apr_sha1.h>
#include "svn_fs.h"
#include "svn_config.h"
@@ -447,20 +449,20 @@ typedef struct transaction_t
* svn_fs_fs__rep_copy. */
typedef struct representation_t
{
- /* Checksums for the contents produced by this representation.
+ /* Checksums digests for the contents produced by this representation.
This checksum is for the contents the rep shows to consumers,
regardless of how the rep stores the data under the hood. It is
independent of the storage (fulltext, delta, whatever).
- If checksum is NULL, then for compatibility behave as though this
+ If has_sha1 is FALSE, then for compatibility behave as though this
checksum matches the expected checksum.
The md5 checksum is always filled, unless this is rep which was
retrieved from the rep-cache. The sha1 checksum is only computed on
- a write, for use with rep-sharing; it may be read from an existing
- representation, but otherwise it is NULL. */
- svn_checksum_t *md5_checksum;
- svn_checksum_t *sha1_checksum;
+ a write, for use with rep-sharing. */
+ svn_boolean_t has_sha1;
+ unsigned char sha1_digest[APR_SHA1_DIGESTSIZE];
+ unsigned char md5_digest[APR_MD5_DIGESTSIZE];
/* Revision where this representation is located. */
svn_revnum_t revision;
Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs_fs.c
URL:
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs_fs.c?rev=1462727&r1=1462726&r2=1462727&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/fs_fs.c Sat Mar 30
10:47:32 2013
@@ -845,24 +845,32 @@ svn_fs_fs__file_checksum(svn_checksum_t
svn_checksum_kind_t kind,
apr_pool_t *pool)
{
+ *checksum = NULL;
+
if (noderev->data_rep)
{
+ svn_checksum_t temp;
+ temp.kind = kind;
+
switch(kind)
{
case svn_checksum_md5:
- *checksum = svn_checksum_dup(noderev->data_rep->md5_checksum,
- pool);
+ temp.digest = noderev->data_rep->md5_digest;
break;
+
case svn_checksum_sha1:
- *checksum = svn_checksum_dup(noderev->data_rep->sha1_checksum,
- pool);
+ if (! noderev->data_rep->has_sha1)
+ return SVN_NO_ERROR;
+
+ temp.digest = noderev->data_rep->sha1_digest;
break;
+
default:
- *checksum = NULL;
+ return SVN_NO_ERROR;
}
+
+ *checksum = svn_checksum_dup(&temp, pool);
}
- else
- *checksum = NULL;
return SVN_NO_ERROR;
}
@@ -879,8 +887,6 @@ svn_fs_fs__rep_copy(representation_t *re
rep_new = apr_palloc(pool, sizeof(*rep_new));
memcpy(rep_new, rep, sizeof(*rep_new));
- rep_new->md5_checksum = svn_checksum_dup(rep->md5_checksum, pool);
- rep_new->sha1_checksum = svn_checksum_dup(rep->sha1_checksum, pool);
return rep_new;
}
Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c
URL:
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c?rev=1462727&r1=1462726&r2=1462727&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c
(original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/low_level.c Sat
Mar 30 10:47:32 2013
@@ -249,6 +249,7 @@ svn_fs_fs__parse_representation(represen
char *str;
apr_int64_t val;
char *string = text->data;
+ svn_checksum_t *checksum;
rep = apr_pcalloc(pool, sizeof(*rep));
*rep_p = rep;
@@ -300,8 +301,8 @@ svn_fs_fs__parse_representation(represen
return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
_("Malformed text representation offset line in
node-rev"));
- SVN_ERR(svn_checksum_parse_hex(&rep->md5_checksum, svn_checksum_md5, str,
- pool));
+ SVN_ERR(svn_checksum_parse_hex(&checksum, svn_checksum_md5, str, pool));
+ memcpy(rep->md5_digest, checksum->digest, sizeof(rep->md5_digest));
/* The remaining fields are only used for formats >= 4, so check that. */
str = svn_cstring_tokenize(" ", &string);
@@ -313,8 +314,9 @@ svn_fs_fs__parse_representation(represen
return svn_error_create(SVN_ERR_FS_CORRUPT, NULL,
_("Malformed text representation offset line in
node-rev"));
- SVN_ERR(svn_checksum_parse_hex(&rep->sha1_checksum, svn_checksum_sha1, str,
- pool));
+ SVN_ERR(svn_checksum_parse_hex(&checksum, svn_checksum_sha1, str, pool));
+ rep->has_sha1 = checksum != NULL;
+ memcpy(rep->sha1_digest, checksum->digest, sizeof(rep->sha1_digest));
/* Read the uniquifier. */
str = svn_cstring_tokenize("/", &string);
@@ -518,6 +520,25 @@ svn_fs_fs__read_noderev(node_revision_t
return SVN_NO_ERROR;
}
+/* Return a textual representation of the DIGEST of given KIND.
+ * If IS_NULL is TRUE, no digest is available.
+ * Use POOL for allocations.
+ */
+static const char *
+format_digest(const unsigned char *digest,
+ svn_checksum_kind_t kind,
+ svn_boolean_t is_null,
+ apr_pool_t *pool)
+{
+ svn_checksum_t checksum;
+ checksum.digest = digest;
+ checksum.kind = kind;
+
+ if (is_null)
+ return "(null)";
+
+ return svn_checksum_to_cstring_display(&checksum, pool);
+}
/* Return a formatted string, compatible with filesystem format FORMAT,
that represents the location of representation REP. If
@@ -535,18 +556,13 @@ svn_fs_fs__unparse_representation(repres
if (svn_fs_fs__id_txn_used(&rep->txn_id) && mutable_rep_truncated)
return svn_stringbuf_ncreate("-1", 2, pool);
-#define DISPLAY_MAYBE_NULL_CHECKSUM(checksum) \
- ((checksum != NULL) \
- ? svn_checksum_to_cstring_display((checksum), pool) \
- : "(null)")
-
- if (format < SVN_FS_FS__MIN_REP_SHARING_FORMAT || rep->sha1_checksum == NULL)
+ if (format < SVN_FS_FS__MIN_REP_SHARING_FORMAT || !rep->has_sha1)
return svn_stringbuf_createf
(pool, "%ld %" APR_OFF_T_FMT " %" SVN_FILESIZE_T_FMT
" %" SVN_FILESIZE_T_FMT " %s",
rep->revision, rep->item_index, rep->size,
rep->expanded_size,
- DISPLAY_MAYBE_NULL_CHECKSUM(rep->md5_checksum));
+ format_digest(rep->md5_digest, svn_checksum_md5, FALSE, pool));
svn__ui64tobase36(buffer, rep->uniquifier.number);
return svn_stringbuf_createf
@@ -554,8 +570,9 @@ svn_fs_fs__unparse_representation(repres
" %" SVN_FILESIZE_T_FMT " %s %s %s/%s",
rep->revision, rep->item_index, rep->size,
rep->expanded_size,
- DISPLAY_MAYBE_NULL_CHECKSUM(rep->md5_checksum),
- DISPLAY_MAYBE_NULL_CHECKSUM(rep->sha1_checksum),
+ format_digest(rep->md5_digest, svn_checksum_md5, FALSE, pool),
+ format_digest(rep->sha1_digest, svn_checksum_sha1,
+ !rep->has_sha1, pool),
svn_fs_fs__id_txn_unparse(&rep->uniquifier.txn_id, pool),
buffer);
Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/rep-cache.c
URL:
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/rep-cache.c?rev=1462727&r1=1462726&r2=1462727&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/rep-cache.c
(original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/rep-cache.c Sat
Mar 30 10:47:32 2013
@@ -178,6 +178,7 @@ svn_fs_fs__walk_rep_reference(svn_fs_t *
representation_t *rep;
const char *sha1_digest;
svn_error_t *err;
+ svn_checksum_t *checksum;
/* Clear ITERPOOL occasionally. */
if (iterations++ % 16 == 0)
@@ -195,11 +196,13 @@ svn_fs_fs__walk_rep_reference(svn_fs_t *
rep = apr_pcalloc(iterpool, sizeof(*rep));
svn_fs_fs__id_txn_reset(&rep->txn_id);
sha1_digest = svn_sqlite__column_text(stmt, 0, iterpool);
- err = svn_checksum_parse_hex(&rep->sha1_checksum,
- svn_checksum_sha1, sha1_digest,
- iterpool);
+ err = svn_checksum_parse_hex(&checksum, svn_checksum_sha1,
+ sha1_digest, iterpool);
if (err)
return svn_error_compose_create(err, svn_sqlite__reset(stmt));
+
+ rep->has_sha1 = TRUE;
+ memcpy(rep->sha1_digest, checksum->digest, sizeof(rep->sha1_digest));
rep->revision = svn_sqlite__column_revnum(stmt, 1);
rep->item_index = svn_sqlite__column_int64(stmt, 2);
rep->size = svn_sqlite__column_int64(stmt, 3);
@@ -252,7 +255,9 @@ svn_fs_fs__get_rep_reference(representat
{
*rep = apr_pcalloc(pool, sizeof(**rep));
svn_fs_fs__id_txn_reset(&(*rep)->txn_id);
- (*rep)->sha1_checksum = svn_checksum_dup(checksum, pool);
+ memcpy((*rep)->sha1_digest, checksum->digest,
+ sizeof((*rep)->sha1_digest));
+ (*rep)->has_sha1 = TRUE;
(*rep)->revision = svn_sqlite__column_revnum(stmt, 0);
(*rep)->item_index = svn_sqlite__column_int64(stmt, 1);
(*rep)->size = svn_sqlite__column_int64(stmt, 2);
@@ -278,20 +283,23 @@ svn_fs_fs__set_rep_reference(svn_fs_t *f
fs_fs_data_t *ffd = fs->fsap_data;
svn_sqlite__stmt_t *stmt;
svn_error_t *err;
+ svn_checksum_t checksum;
+ checksum.kind = svn_checksum_sha1;
+ checksum.digest = rep->sha1_digest;
SVN_ERR_ASSERT(ffd->rep_sharing_allowed);
if (! ffd->rep_cache_db)
SVN_ERR(svn_fs_fs__open_rep_cache(fs, pool));
/* We only allow SHA1 checksums in this table. */
- if (rep->sha1_checksum == NULL)
+ if (! rep->has_sha1)
return svn_error_create(SVN_ERR_BAD_CHECKSUM_KIND, NULL,
_("Only SHA1 checksums can be used as keys in the "
"rep_cache table.\n"));
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(rep->sha1_checksum, pool),
+ svn_checksum_to_cstring(&checksum, pool),
(apr_int64_t) rep->revision,
(apr_int64_t) rep->item_index,
(apr_int64_t) rep->size,
@@ -311,8 +319,7 @@ svn_fs_fs__set_rep_reference(svn_fs_t *f
should exist. If so, and the value is the same one we were
about to write, that's cool -- just do nothing. If, however,
the value is *different*, that's a red flag! */
- SVN_ERR(svn_fs_fs__get_rep_reference(&old_rep, fs, rep->sha1_checksum,
- pool));
+ SVN_ERR(svn_fs_fs__get_rep_reference(&old_rep, fs, &checksum, pool));
if (old_rep)
{
@@ -329,7 +336,7 @@ svn_fs_fs__set_rep_reference(svn_fs_t *f
APR_OFF_T_FMT, SVN_FILESIZE_T_FMT,
SVN_FILESIZE_T_FMT, APR_OFF_T_FMT,
SVN_FILESIZE_T_FMT, SVN_FILESIZE_T_FMT),
- svn_checksum_to_cstring_display(rep->sha1_checksum, pool),
+ svn_checksum_to_cstring_display(&checksum, pool),
fs->path, old_rep->revision, old_rep->item_index,
old_rep->size, old_rep->expanded_size, rep->revision,
rep->item_index, rep->size, rep->expanded_size);
Modified:
subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.c
URL:
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.c?rev=1462727&r1=1462726&r2=1462727&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.c
(original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/temp_serializer.c
Sat Mar 30 10:47:32 2013
@@ -127,43 +127,6 @@ deserialize_svn_string(void *buffer, svn
svn_temp_deserializer__resolve(*string, (void **)&(*string)->data);
}
-/* Utility function to serialize checkum CS within the given serialization
- * CONTEXT.
- */
-static void
-serialize_checksum(svn_temp_serializer__context_t *context,
- svn_checksum_t * const *cs)
-{
- const svn_checksum_t *checksum = *cs;
- if (checksum == NULL)
- return;
-
- svn_temp_serializer__push(context,
- (const void * const *)cs,
- sizeof(*checksum));
-
- /* The digest is arbitrary binary data.
- * Thus, we cannot use svn_temp_serializer__add_string. */
- svn_temp_serializer__add_leaf(context,
- (const void * const *)&checksum->digest,
- svn_checksum_size(checksum));
-
- /* return to the caller's nesting level */
- svn_temp_serializer__pop(context);
-}
-
-/* Utility function to deserialize the checksum CS inside the BUFFER.
- */
-static void
-deserialize_checksum(void *buffer, svn_checksum_t **cs)
-{
- svn_temp_deserializer__resolve(buffer, (void **)cs);
- if (*cs == NULL)
- return;
-
- svn_temp_deserializer__resolve(*cs, (void **)&(*cs)->digest);
-}
-
/* Utility function to serialize the REPRESENTATION within the given
* serialization CONTEXT.
*/
@@ -176,35 +139,9 @@ serialize_representation(svn_temp_serial
return;
/* serialize the representation struct itself */
- svn_temp_serializer__push(context,
- (const void * const *)representation,
- sizeof(*rep));
-
- /* serialize sub-structures */
- serialize_checksum(context, &rep->md5_checksum);
- serialize_checksum(context, &rep->sha1_checksum);
-
- /* return to the caller's nesting level */
- svn_temp_serializer__pop(context);
-}
-
-/* Utility function to deserialize the REPRESENTATIONS inside the BUFFER.
- */
-static void
-deserialize_representation(void *buffer,
- representation_t **representation)
-{
- representation_t *rep;
-
- /* fixup the reference to the representation itself */
- svn_temp_deserializer__resolve(buffer, (void **)representation);
- rep = *representation;
- if (rep == NULL)
- return;
-
- /* fixup of sub-structures */
- deserialize_checksum(rep, &rep->md5_checksum);
- deserialize_checksum(rep, &rep->sha1_checksum);
+ svn_temp_serializer__add_leaf(context,
+ (const void * const *)representation,
+ sizeof(*rep));
}
/* auxilliary structure representing the content of a directory hash */
@@ -406,8 +343,8 @@ svn_fs_fs__noderev_deserialize(void *buf
/* fixup of sub-structures */
svn_fs_fs__id_deserialize(noderev, (svn_fs_id_t **)&noderev->id);
svn_fs_fs__id_deserialize(noderev, (svn_fs_id_t **)&noderev->predecessor_id);
- deserialize_representation(noderev, &noderev->prop_rep);
- deserialize_representation(noderev, &noderev->data_rep);
+ svn_temp_deserializer__resolve(noderev, (void **)&noderev->prop_rep);
+ svn_temp_deserializer__resolve(noderev, (void **)&noderev->data_rep);
svn_temp_deserializer__resolve(noderev, (void **)&noderev->copyfrom_path);
svn_temp_deserializer__resolve(noderev, (void **)&noderev->copyroot_path);
Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c
URL:
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c?rev=1462727&r1=1462726&r2=1462727&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c
(original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/transaction.c Sat
Mar 30 10:47:32 2013
@@ -575,12 +575,12 @@ store_sha1_rep_mapping(svn_fs_t *fs,
* its SHA-1 is known, store the rep struct under its SHA1. */
if ( ffd->rep_sharing_allowed
&& noderev->data_rep
- && noderev->data_rep->sha1_checksum)
+ && noderev->data_rep->has_sha1)
{
apr_file_t *rep_file;
const char *file_name = path_txn_sha1(fs,
&noderev->data_rep->txn_id,
- noderev->data_rep->sha1_checksum,
+ noderev->data_rep->sha1_digest,
pool);
svn_stringbuf_t *rep_string
= svn_fs_fs__unparse_representation(noderev->data_rep,
@@ -2019,14 +2019,16 @@ get_shared_rep(representation_t **old_re
because it is cheepest. */
if (reps_hash)
*old_rep = apr_hash_get(reps_hash,
- rep->sha1_checksum->digest,
+ rep->sha1_digest,
APR_SHA1_DIGESTSIZE);
/* If we haven't found anything yet, try harder and consult our DB. */
if (*old_rep == NULL)
{
- err = svn_fs_fs__get_rep_reference(old_rep, fs, rep->sha1_checksum,
- pool);
+ svn_checksum_t checksum;
+ checksum.digest = rep->sha1_digest;
+ checksum.kind = svn_checksum_sha1;
+ err = svn_fs_fs__get_rep_reference(old_rep, fs, &checksum, pool);
/* ### Other error codes that we shouldn't mask out? */
if (err == SVN_NO_ERROR)
{
@@ -2064,7 +2066,7 @@ get_shared_rep(representation_t **old_re
{
svn_node_kind_t kind;
const char *file_name
- = path_txn_sha1(fs, &rep->txn_id, rep->sha1_checksum, pool);
+ = path_txn_sha1(fs, &rep->txn_id, rep->sha1_digest, pool);
/* in our txn, is there a rep file named with the wanted SHA1?
If so, read it and use that rep.
@@ -2082,7 +2084,7 @@ get_shared_rep(representation_t **old_re
if (*old_rep)
{
/* Use the old rep for this content. */
- (*old_rep)->md5_checksum = rep->md5_checksum;
+ memcpy((*old_rep)->md5_digest, rep->md5_digest, sizeof(rep->md5_digest));
(*old_rep)->uniquifier = rep->uniquifier;
}
@@ -2098,8 +2100,14 @@ digests_final(representation_t *rep,
const svn_checksum_ctx_t *sha1_ctx,
apr_pool_t *pool)
{
- SVN_ERR(svn_checksum_final(&rep->md5_checksum, md5_ctx, pool));
- SVN_ERR(svn_checksum_final(&rep->sha1_checksum, sha1_ctx, pool));
+ svn_checksum_t *checksum;
+
+ SVN_ERR(svn_checksum_final(&checksum, md5_ctx, pool));
+ memcpy(rep->md5_digest, checksum->digest, svn_checksum_size(checksum));
+ SVN_ERR(svn_checksum_final(&checksum, sha1_ctx, pool));
+ rep->has_sha1 = checksum != NULL;
+ if (rep->has_sha1)
+ memcpy(rep->sha1_digest, checksum->digest, svn_checksum_size(checksum));
return SVN_NO_ERROR;
}
@@ -2859,7 +2867,7 @@ write_final_rev(const svn_fs_id_t **new_
APR_ARRAY_PUSH(reps_to_cache, representation_t *) = copy;
apr_hash_set(reps_hash,
- copy->sha1_checksum->digest,
+ copy->sha1_digest,
APR_SHA1_DIGESTSIZE,
copy);
}
@@ -2867,11 +2875,11 @@ write_final_rev(const svn_fs_id_t **new_
/* don't serialize SHA1 for dirs to disk (waste of space) */
if (noderev->data_rep && noderev->kind == svn_node_dir)
- noderev->data_rep->sha1_checksum = NULL;
+ noderev->data_rep->has_sha1 = FALSE;
/* don't serialize SHA1 for props to disk (waste of space) */
if (noderev->prop_rep)
- noderev->prop_rep->sha1_checksum = NULL;
+ noderev->prop_rep->has_sha1 = FALSE;
/* Workaround issue #4031: is-fresh-txn-root in revision files. */
noderev->is_fresh_txn_root = FALSE;
Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.c
URL:
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.c?rev=1462727&r1=1462726&r2=1462727&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.c (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.c Sat Mar 30
10:47:32 2013
@@ -261,11 +261,15 @@ path_txn_dir(svn_fs_t *fs,
const char *
path_txn_sha1(svn_fs_t *fs,
const svn_fs_fs__id_part_t *txn_id,
- svn_checksum_t *sha1,
+ const unsigned char *sha1,
apr_pool_t *pool)
{
+ svn_checksum_t checksum;
+ checksum.digest = sha1;
+ checksum.kind = svn_checksum_sha1;
+
return svn_dirent_join(path_txn_dir(fs, txn_id, pool),
- svn_checksum_to_cstring(sha1, pool),
+ svn_checksum_to_cstring(&checksum, pool),
pool);
}
Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.h
URL:
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.h?rev=1462727&r1=1462726&r2=1462727&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.h (original)
+++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/util.h Sat Mar 30
10:47:32 2013
@@ -154,7 +154,7 @@ path_txn_dir(svn_fs_t *fs,
const char *
path_txn_sha1(svn_fs_t *fs,
const svn_fs_fs__id_part_t *txn_id,
- svn_checksum_t *sha1,
+ const unsigned char *sha1,
apr_pool_t *pool);
const char *
Modified:
subversion/branches/fsfs-format7/tools/server-side/svn-rep-sharing-stats.c
URL:
http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/tools/server-side/svn-rep-sharing-stats.c?rev=1462727&r1=1462726&r2=1462727&view=diff
==============================================================================
--- subversion/branches/fsfs-format7/tools/server-side/svn-rep-sharing-stats.c
(original)
+++ subversion/branches/fsfs-format7/tools/server-side/svn-rep-sharing-stats.c
Sat Mar 30 10:47:32 2013
@@ -181,7 +181,8 @@ struct key_t
/* What we need to know about a rep. */
struct value_t
{
- svn_checksum_t *sha1_checksum;
+ svn_checksum_t checksum;
+ unsigned char sha1_digest[APR_SHA1_DIGESTSIZE];
apr_uint64_t refcount;
};
@@ -199,7 +200,7 @@ static svn_error_t *record(apr_hash_t *r
* exist or doesn't have the checksum we are after. (The latter case
* often corresponds to node_rev->kind == svn_node_dir.)
*/
- if (records == NULL || rep == NULL || rep->sha1_checksum == NULL)
+ if (records == NULL || rep == NULL || !rep->has_sha1)
return SVN_NO_ERROR;
/* Construct the key.
@@ -213,18 +214,16 @@ static svn_error_t *record(apr_hash_t *r
/* Update or create the value. */
if ((value = apr_hash_get(records, key, sizeof(*key))))
{
- /* Paranoia. */
- SVN_ERR_ASSERT(value->sha1_checksum != NULL);
- SVN_ERR_ASSERT(svn_checksum_match(value->sha1_checksum,
- rep->sha1_checksum));
/* Real work. */
value->refcount++;
}
else
{
value = apr_palloc(result_pool, sizeof(*value));
- value->sha1_checksum = svn_checksum_dup(rep->sha1_checksum, result_pool);
+ value->checksum.digest = value->sha1_digest;
+ value->checksum.kind = svn_checksum_sha1;
value->refcount = 1;
+ memcpy(value->sha1_digest, rep->sha1_digest, sizeof(value->sha1_digest));
}
/* Store them. */
@@ -339,7 +338,7 @@ pretty_print(const char *name,
SVN_ERR(svn_cmdline_printf(scratch_pool, "%s %" APR_UINT64_T_FMT " %s\n",
name, value->refcount,
svn_checksum_to_cstring_display(
- value->sha1_checksum,
+ &value->checksum,
scratch_pool)));
}