You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ko...@apache.org on 2016/04/01 14:12:15 UTC
svn commit: r1737356 - in /subversion/trunk/subversion/libsvn_fs_fs: fs_fs.c
pack.c revprops.c revprops.h util.c
Author: kotkov
Date: Fri Apr 1 12:12:15 2016
New Revision: 1737356
URL: http://svn.apache.org/viewvc?rev=1737356&view=rev
Log:
In FSFS, update all remaining calling sites so that they would respect the
new filesystem config option, SVN_FS_CONFIG_NO_FLUSH_TO_DISK.
* subversion/libsvn_fs_fs/util.c
(svn_fs_fs__write_min_unpacked_rev): Don't flush to disk if that's
allowed.
* subversion/libsvn_fs_fs/fs_fs.c
(svn_fs_fs__write_format, svn_fs_fs__set_uuid): Don't flush to disk
if that's allowed.
* subversion/libsvn_fs_fs/revprops.h
(svn_fs_fs__copy_revprops, svn_fs_fs__pack_revprops_shard): Accept new
`flush_to_disk' argument.
* subversion/libsvn_fs_fs/revprops.c
(svn_fs_fs__copy_revprops, svn_fs_fs__pack_revprops_shard): Make the
flush optional based on the new argument.
(svn_fs_fs__upgrade_pack_revprops, write_non_packed_revprop,
switch_to_new_revprop, repack_revprops, write_packed_revprop): Don't
flush to disk if that's allowed.
* subversion/libsvn_fs_fs/pack.c
(pack_context_t): Add `flush_to_disk' boolean field.
(initialize_pack_context): Accept new `flush_to_disk' argument and set
the new field in pack_context_t accordingly.
(close_pack_context): Make the flush optional based on the stored state
in the pack context.
(pack_rev_shard): Accept new `flush_to_disk' argument, propagate it ...
(pack_log_addressed): ...here...
(pack_phys_addressed): ...and here.
(pack_shard): Adjust call to pack_rev_shard() and don't flush to disk
if that's allowed.
(synced_pack_shard): Adjust call to svn_fs_fs__pack_revprops_shard().
Modified:
subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
subversion/trunk/subversion/libsvn_fs_fs/pack.c
subversion/trunk/subversion/libsvn_fs_fs/revprops.c
subversion/trunk/subversion/libsvn_fs_fs/revprops.h
subversion/trunk/subversion/libsvn_fs_fs/util.c
Modified: subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c?rev=1737356&r1=1737355&r2=1737356&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c Fri Apr 1 12:12:15 2016
@@ -624,7 +624,8 @@ svn_fs_fs__write_format(svn_fs_t *fs,
else
{
SVN_ERR(svn_io_write_atomic2(path, sb->data, sb->len,
- NULL /* copy_perms_path */, TRUE, pool));
+ NULL /* copy_perms_path */,
+ ffd->flush_to_disk, pool));
}
/* And set the perms to make it read only */
@@ -1868,7 +1869,7 @@ svn_fs_fs__set_uuid(svn_fs_t *fs,
file does not exist during repository creation. */
SVN_ERR(svn_io_write_atomic2(uuid_path, contents->data, contents->len,
svn_fs_fs__path_current(fs, pool) /* perms */,
- TRUE, pool));
+ ffd->flush_to_disk, pool));
fs->uuid = apr_pstrdup(fs->pool, uuid);
Modified: subversion/trunk/subversion/libsvn_fs_fs/pack.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/pack.c?rev=1737356&r1=1737355&r2=1737356&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/pack.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/pack.c Fri Apr 1 12:12:15 2016
@@ -233,6 +233,9 @@ typedef struct pack_context_t
/* pool used for temporary data structures that will be cleaned up when
* the next range of revisions is being processed */
apr_pool_t *info_pool;
+
+ /* ensure that all filesystem changes are written to disk. */
+ svn_boolean_t flush_to_disk;
} pack_context_t;
/* Create and initialize a new pack context for packing shard SHARD_REV in
@@ -240,7 +243,7 @@ typedef struct pack_context_t
* and return the structure in *CONTEXT.
*
* Limit the number of items being copied per iteration to MAX_ITEMS.
- * Set CANCEL_FUNC and CANCEL_BATON as well.
+ * Set FLUSH_TO_DISK, CANCEL_FUNC and CANCEL_BATON as well.
*/
static svn_error_t *
initialize_pack_context(pack_context_t *context,
@@ -249,6 +252,7 @@ initialize_pack_context(pack_context_t *
const char *shard_dir,
svn_revnum_t shard_rev,
int max_items,
+ svn_boolean_t flush_to_disk,
svn_cancel_func_t cancel_func,
void *cancel_baton,
apr_pool_t *pool)
@@ -325,6 +329,8 @@ initialize_pack_context(pack_context_t *
context->info_pool = svn_pool_create(pool);
context->paths = svn_prefix_tree__create(context->info_pool);
+ context->flush_to_disk = flush_to_disk;
+
return SVN_NO_ERROR;
}
@@ -385,7 +391,8 @@ close_pack_context(pack_context_t *conte
SVN_ERR(svn_io_remove_file2(proto_p2l_index_path, FALSE, pool));
/* Ensure that packed file is written to disk.*/
- SVN_ERR(svn_io_file_flush_to_disk(context->pack_file, pool));
+ if (context->flush_to_disk)
+ SVN_ERR(svn_io_file_flush_to_disk(context->pack_file, pool));
SVN_ERR(svn_io_file_close(context->pack_file, pool));
return SVN_NO_ERROR;
@@ -1510,8 +1517,9 @@ append_revision(pack_context_t *context,
*
* 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.
+ * the extra memory consumption to MAX_MEM bytes. If FLUSH_TO_DISK is
+ * non-zero, do not return until the data has actually been written on
+ * the disk. CANCEL_FUNC and CANCEL_BATON are what you think they are.
*/
static svn_error_t *
pack_log_addressed(svn_fs_t *fs,
@@ -1519,6 +1527,7 @@ pack_log_addressed(svn_fs_t *fs,
const char *shard_dir,
svn_revnum_t shard_rev,
apr_size_t max_mem,
+ svn_boolean_t flush_to_disk,
svn_cancel_func_t cancel_func,
void *cancel_baton,
apr_pool_t *pool)
@@ -1551,8 +1560,8 @@ pack_log_addressed(svn_fs_t *fs,
/* 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));
+ shard_rev, max_items, flush_to_disk,
+ cancel_func, cancel_baton, pool));
/* phase 1: determine the size of the revisions to pack */
SVN_ERR(svn_fs_fs__l2p_get_max_ids(&max_ids, fs, shard_rev,
@@ -1675,14 +1684,16 @@ svn_fs_fs__get_packed_offset(apr_off_t *
*
* Pack the revision shard starting at SHARD_REV containing exactly
* MAX_FILES_PER_DIR revisions from SHARD_PATH into the PACK_FILE_DIR,
- * using POOL for allocations. CANCEL_FUNC and CANCEL_BATON are what you
- * think they are.
+ * using POOL for allocations. If FLUSH_TO_DISK is non-zero, do not
+ * return until the data has actually been written on the disk.
+ * CANCEL_FUNC and CANCEL_BATON are what you think they are.
*/
static svn_error_t *
pack_phys_addressed(const char *pack_file_dir,
const char *shard_path,
svn_revnum_t start_rev,
int max_files_per_dir,
+ svn_boolean_t flush_to_disk,
svn_cancel_func_t cancel_func,
void *cancel_baton,
apr_pool_t *pool)
@@ -1744,14 +1755,16 @@ pack_phys_addressed(const char *pack_fil
SVN_ERR(svn_stream_close(manifest_stream));
/* Ensure that pack file is written to disk. */
- SVN_ERR(svn_io_file_flush_to_disk(manifest_file, pool));
+ if (flush_to_disk)
+ SVN_ERR(svn_io_file_flush_to_disk(manifest_file, pool));
SVN_ERR(svn_io_file_close(manifest_file, pool));
/* disallow write access to the manifest file */
SVN_ERR(svn_io_set_file_read_only(manifest_file_path, FALSE, iterpool));
/* Ensure that pack file is written to disk. */
- SVN_ERR(svn_io_file_flush_to_disk(pack_file, pool));
+ if (flush_to_disk)
+ SVN_ERR(svn_io_file_flush_to_disk(pack_file, pool));
SVN_ERR(svn_io_file_close(pack_file, pool));
svn_pool_destroy(iterpool);
@@ -1762,8 +1775,9 @@ pack_phys_addressed(const char *pack_fil
/* 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.
+ * memory needed to MAX_MEM bytes. If FLUSH_TO_DISK is non-zero, do
+ * not return until the data has actually been written on the disk.
+ * 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.
@@ -1777,6 +1791,7 @@ pack_rev_shard(svn_fs_t *fs,
apr_int64_t shard,
int max_files_per_dir,
apr_size_t max_mem,
+ svn_boolean_t flush_to_disk,
svn_cancel_func_t cancel_func,
void *cancel_baton,
apr_pool_t *pool)
@@ -1796,12 +1811,13 @@ pack_rev_shard(svn_fs_t *fs,
/* Index information files */
if (svn_fs_fs__use_log_addressing(fs))
- SVN_ERR(pack_log_addressed(fs, pack_file_dir, shard_path, shard_rev,
- max_mem, cancel_func, cancel_baton, pool));
+ SVN_ERR(pack_log_addressed(fs, pack_file_dir, shard_path,
+ shard_rev, max_mem, flush_to_disk,
+ cancel_func, cancel_baton, pool));
else
SVN_ERR(pack_phys_addressed(pack_file_dir, shard_path, shard_rev,
- max_files_per_dir, cancel_func,
- cancel_baton, pool));
+ max_files_per_dir, flush_to_disk,
+ cancel_func, cancel_baton, 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));
@@ -1867,6 +1883,7 @@ synced_pack_shard(void *baton,
ffd->compress_packed_revprops
? SVN__COMPRESSION_ZLIB_DEFAULT
: SVN__COMPRESSION_NONE,
+ ffd->flush_to_disk,
pb->cancel_func,
pb->cancel_baton,
pool));
@@ -1943,8 +1960,8 @@ pack_shard(struct pack_baton *baton,
/* pack the revision content */
SVN_ERR(pack_rev_shard(baton->fs, rev_pack_file_dir, baton->rev_shard_path,
baton->shard, ffd->max_files_per_dir,
- DEFAULT_MAX_MEM, baton->cancel_func,
- baton->cancel_baton, pool));
+ DEFAULT_MAX_MEM, ffd->flush_to_disk,
+ baton->cancel_func, baton->cancel_baton, pool));
/* For newer repo formats, we only acquired the pack lock so far.
Before modifying the repo state by switching over to the packed
Modified: subversion/trunk/subversion/libsvn_fs_fs/revprops.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/revprops.c?rev=1737356&r1=1737355&r2=1737356&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/revprops.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/revprops.c Fri Apr 1 12:12:15 2016
@@ -79,6 +79,7 @@ svn_fs_fs__upgrade_pack_revprops(svn_fs_
shard, ffd->max_files_per_dir,
(int)(0.9 * ffd->revprop_pack_size),
compression_level,
+ ffd->flush_to_disk,
cancel_func, cancel_baton,
iterpool));
if (notify_func)
@@ -738,6 +739,7 @@ write_non_packed_revprop(const char **fi
apr_hash_t *proplist,
apr_pool_t *pool)
{
+ fs_fs_data_t *ffd = fs->fsap_data;
apr_file_t *file;
svn_stream_t *stream;
*final_path = svn_fs_fs__path_revprops(fs, rev, pool);
@@ -752,7 +754,8 @@ write_non_packed_revprop(const char **fi
SVN_ERR(svn_stream_close(stream));
/* Flush temporary file to disk and close it. */
- SVN_ERR(svn_io_file_flush_to_disk(file, pool));
+ if (ffd->flush_to_disk)
+ SVN_ERR(svn_io_file_flush_to_disk(file, pool));
SVN_ERR(svn_io_file_close(file, pool));
return SVN_NO_ERROR;
@@ -775,8 +778,10 @@ switch_to_new_revprop(svn_fs_t *fs,
apr_array_header_t *files_to_delete,
apr_pool_t *pool)
{
+ fs_fs_data_t *ffd = fs->fsap_data;
+
SVN_ERR(svn_fs_fs__move_into_place(tmp_path, final_path, perms_reference,
- TRUE, pool));
+ ffd->flush_to_disk, pool));
/* Clean up temporary files, if necessary. */
if (files_to_delete)
@@ -904,7 +909,8 @@ repack_revprops(svn_fs_t *fs,
/* finally, write the content to the target file, flush and close it */
SVN_ERR(svn_io_file_write_full(file, compressed->data, compressed->len,
NULL, pool));
- SVN_ERR(svn_io_file_flush_to_disk(file, pool));
+ if (ffd->flush_to_disk)
+ SVN_ERR(svn_io_file_flush_to_disk(file, pool));
SVN_ERR(svn_io_file_close(file, pool));
return SVN_NO_ERROR;
@@ -1111,7 +1117,8 @@ write_packed_revprop(const char **final_
SVN_ERR(svn_stream_printf(stream, pool, "%s\n", filename));
}
SVN_ERR(svn_stream_close(stream));
- SVN_ERR(svn_io_file_flush_to_disk(file, pool));
+ if (ffd->flush_to_disk)
+ SVN_ERR(svn_io_file_flush_to_disk(file, pool));
SVN_ERR(svn_io_file_close(file, pool));
}
@@ -1246,6 +1253,7 @@ svn_fs_fs__copy_revprops(const char *pac
apr_array_header_t *sizes,
apr_size_t total_size,
int compression_level,
+ svn_boolean_t flush_to_disk,
svn_cancel_func_t cancel_func,
void *cancel_baton,
apr_pool_t *scratch_pool)
@@ -1302,7 +1310,8 @@ svn_fs_fs__copy_revprops(const char *pac
/* write the pack file content to disk */
SVN_ERR(svn_io_file_write_full(pack_file, compressed->data, compressed->len,
NULL, scratch_pool));
- SVN_ERR(svn_io_file_flush_to_disk(pack_file, scratch_pool));
+ if (flush_to_disk)
+ SVN_ERR(svn_io_file_flush_to_disk(pack_file, scratch_pool));
SVN_ERR(svn_io_file_close(pack_file, scratch_pool));
svn_pool_destroy(iterpool);
@@ -1317,6 +1326,7 @@ svn_fs_fs__pack_revprops_shard(const cha
int max_files_per_dir,
apr_int64_t max_pack_size,
int compression_level,
+ svn_boolean_t flush_to_disk,
svn_cancel_func_t cancel_func,
void *cancel_baton,
apr_pool_t *scratch_pool)
@@ -1388,8 +1398,9 @@ svn_fs_fs__pack_revprops_shard(const cha
SVN_ERR(svn_fs_fs__copy_revprops(pack_file_dir, pack_filename,
shard_path, start_rev, rev-1,
sizes, total_size,
- compression_level, cancel_func,
- cancel_baton, iterpool));
+ compression_level, flush_to_disk,
+ cancel_func, cancel_baton,
+ iterpool));
/* next pack file starts empty again */
apr_array_clear(sizes);
@@ -1415,12 +1426,13 @@ svn_fs_fs__pack_revprops_shard(const cha
SVN_ERR(svn_fs_fs__copy_revprops(pack_file_dir, pack_filename,
shard_path, start_rev, rev-1,
sizes, (apr_size_t)total_size,
- compression_level, cancel_func,
- cancel_baton, iterpool));
+ compression_level, flush_to_disk,
+ cancel_func, cancel_baton, iterpool));
/* flush the manifest file to disk and update permissions */
SVN_ERR(svn_stream_close(manifest_stream));
- SVN_ERR(svn_io_file_flush_to_disk(manifest_file, iterpool));
+ if (flush_to_disk)
+ SVN_ERR(svn_io_file_flush_to_disk(manifest_file, iterpool));
SVN_ERR(svn_io_file_close(manifest_file, iterpool));
SVN_ERR(svn_io_copy_perms(shard_path, pack_file_dir, iterpool));
Modified: subversion/trunk/subversion/libsvn_fs_fs/revprops.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/revprops.h?rev=1737356&r1=1737355&r2=1737356&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/revprops.h (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/revprops.h Fri Apr 1 12:12:15 2016
@@ -111,8 +111,9 @@ svn_fs_fs__packed_revprop_available(svn_
* a hint on which initial buffer size we should use to hold the pack file
* content.
*
- * CANCEL_FUNC and CANCEL_BATON are used as usual. Temporary allocations
- * are done in SCRATCH_POOL.
+ * If FLUSH_TO_DISK is non-zero, do not return until the data has actually
+ * been written on the disk. CANCEL_FUNC and CANCEL_BATON are used as usual.
+ * Temporary allocations are done in SCRATCH_POOL.
*/
svn_error_t *
svn_fs_fs__copy_revprops(const char *pack_file_dir,
@@ -123,6 +124,7 @@ svn_fs_fs__copy_revprops(const char *pac
apr_array_header_t *sizes,
apr_size_t total_size,
int compression_level,
+ svn_boolean_t flush_to_disk,
svn_cancel_func_t cancel_func,
void *cancel_baton,
apr_pool_t *scratch_pool);
@@ -134,8 +136,9 @@ svn_fs_fs__copy_revprops(const char *pac
* have no unpacked data anymore. Call upgrade_cleanup_pack_revprops after
* the bump.
*
- * NOTIFY_FUNC and NOTIFY_BATON as well as CANCEL_FUNC and CANCEL_BATON are
- * used in the usual way. Temporary allocations are done in SCRATCH_POOL.
+ * If FLUSH_TO_DISK is non-zero, do not return until the data has actually
+ * been written on the disk. CANCEL_FUNC and CANCEL_BATON areused in the
+ * usual way. Temporary allocations are done in SCRATCH_POOL.
*/
svn_error_t *
svn_fs_fs__pack_revprops_shard(const char *pack_file_dir,
@@ -144,6 +147,7 @@ svn_fs_fs__pack_revprops_shard(const cha
int max_files_per_dir,
apr_int64_t max_pack_size,
int compression_level,
+ svn_boolean_t flush_to_disk,
svn_cancel_func_t cancel_func,
void *cancel_baton,
apr_pool_t *scratch_pool);
Modified: subversion/trunk/subversion/libsvn_fs_fs/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/util.c?rev=1737356&r1=1737355&r2=1737356&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/util.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/util.c Fri Apr 1 12:12:15 2016
@@ -428,6 +428,7 @@ svn_fs_fs__write_min_unpacked_rev(svn_fs
svn_revnum_t revnum,
apr_pool_t *scratch_pool)
{
+ fs_fs_data_t *ffd = fs->fsap_data;
const char *final_path;
char buf[SVN_INT64_BUFFER_SIZE];
apr_size_t len = svn__i64toa(buf, revnum);
@@ -436,8 +437,8 @@ svn_fs_fs__write_min_unpacked_rev(svn_fs
final_path = svn_fs_fs__path_min_unpacked_rev(fs, scratch_pool);
SVN_ERR(svn_io_write_atomic2(final_path, buf, len + 1,
- final_path /* copy_perms */, TRUE,
- scratch_pool));
+ final_path /* copy_perms */,
+ ffd->flush_to_disk, scratch_pool));
return SVN_NO_ERROR;
}