Author: philip
Date: Thu May 28 10:39:07 2015
New Revision: 1682199
URL: http://svn.apache.org/r1682199
Log:
Apply FSFS revprop flush change, r1680819, to FSX.
* subversion/libsvn_fs_x/revprops.c
(repack_stream_open): Rename the function ...
(repack_file_open): ...to this. Rework it to return files (apr_file_t)
instead of streams.
(repack_revprops): Work with a file instead of a stream. Flush any
unwritten data to disk before returning.
(write_non_packed_revprop): Flush any unwritten data to disk after
serializing the revision property list.
(write_packed_revprop): Cope with the changes in repack_file_open() and
repack_revprops() that now work with files. Flush the data to disk when
done writing to a temporary manifest file.
Modified:
subversion/trunk/subversion/libsvn_fs_x/revprops.c
Modified: subversion/trunk/subversion/libsvn_fs_x/revprops.c
URL:
http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_x/revprops.c?rev=1682199&r1=1682198&r2=1682199&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_x/revprops.c (original)
+++ subversion/trunk/subversion/libsvn_fs_x/revprops.c Thu May 28 10:39:07 2015
@@ -1178,20 +1178,26 @@ write_non_packed_revprop(const char **fi
apr_pool_t *result_pool,
apr_pool_t *scratch_pool)
{
+ apr_file_t *file;
svn_stream_t *stream;
*final_path = svn_fs_x__path_revprops(fs, rev, result_pool);
/* ### do we have a directory sitting around already? we really shouldn't
### have to get the dirname here. */
- SVN_ERR(svn_stream_open_unique(&stream, tmp_path,
- svn_dirent_dirname(*final_path,
- scratch_pool),
- svn_io_file_del_none,
- result_pool, scratch_pool));
+ SVN_ERR(svn_io_open_unique_file3(&file, tmp_path,
+ svn_dirent_dirname(*final_path,
+ scratch_pool),
+ svn_io_file_del_none,
+ scratch_pool, scratch_pool));
+ stream = svn_stream_from_aprfile2(file, TRUE, scratch_pool);
SVN_ERR(svn_hash_write2(proplist, stream, SVN_HASH_TERMINATOR,
scratch_pool));
SVN_ERR(svn_stream_close(stream));
+ /* Flush temporary file to disk and close it. */
+ SVN_ERR(svn_io_file_flush_to_disk(file, scratch_pool));
+ SVN_ERR(svn_io_file_close(file, scratch_pool));
+
return SVN_NO_ERROR;
}
@@ -1287,7 +1293,7 @@ serialize_revprops_header(svn_stream_t *
return SVN_NO_ERROR;
}
-/* Writes the a pack file to FILE_STREAM. It copies the serialized data
+/* Writes the a pack file to FILE. It copies the serialized data
* from REVPROPS for the indexes [START,END) except for index CHANGED_INDEX.
*
* The data for the latter is taken from NEW_SERIALIZED. Note, that
@@ -1305,7 +1311,7 @@ repack_revprops(svn_fs_t *fs,
int changed_index,
svn_stringbuf_t *new_serialized,
apr_off_t new_total_size,
- svn_stream_t *file_stream,
+ apr_file_t *file,
apr_pool_t *scratch_pool)
{
svn_fs_x__data_t *ffd = fs->fsap_data;
@@ -1354,9 +1360,11 @@ repack_revprops(svn_fs_t *fs,
? SVN_DELTA_COMPRESSION_LEVEL_DEFAULT
: SVN_DELTA_COMPRESSION_LEVEL_NONE));
- /* finally, write the content to the target stream and close it */
- SVN_ERR(svn_stream_write(file_stream, compressed->data, &compressed->len));
- SVN_ERR(svn_stream_close(file_stream));
+ /* 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, scratch_pool));
+ SVN_ERR(svn_io_file_flush_to_disk(file, scratch_pool));
+ SVN_ERR(svn_io_file_close(file, scratch_pool));
return SVN_NO_ERROR;
}
@@ -1364,27 +1372,26 @@ repack_revprops(svn_fs_t *fs,
/* Allocate a new pack file name for revisions
* [REVPROPS->START_REVISION + START, REVPROPS->START_REVISION + END - 1]
* of REVPROPS->MANIFEST. Add the name of old file to FILES_TO_DELETE,
- * auto-create that array if necessary. Return an open file stream to
- * the new file in *STREAM allocated in RESULT_POOL. Allocate the paths
- * in *FILES_TO_DELETE from the same pool that contains the array itself.
+ * auto-create that array if necessary. Return an open file *FILE that is
+ * allocated in RESULT_POOL. Allocate the paths in *FILES_TO_DELETE from
+ * the same pool that contains the array itself.
*
* Use SCRATCH_POOL for temporary allocations.
*/
static svn_error_t *
-repack_stream_open(svn_stream_t **stream,
- svn_fs_t *fs,
- packed_revprops_t *revprops,
- int start,
- int end,
- apr_array_header_t **files_to_delete,
- apr_pool_t *result_pool,
- apr_pool_t *scratch_pool)
+repack_file_open(apr_file_t **file,
+ svn_fs_t *fs,
+ packed_revprops_t *revprops,
+ int start,
+ int end,
+ apr_array_header_t **files_to_delete,
+ apr_pool_t *result_pool,
+ apr_pool_t *scratch_pool)
{
apr_int64_t tag;
const char *tag_string;
svn_string_t *new_filename;
int i;
- apr_file_t *file;
int manifest_offset
= (int)(revprops->start_revision - revprops->manifest_start);
@@ -1418,13 +1425,12 @@ repack_stream_open(svn_stream_t **stream
APR_ARRAY_IDX(revprops->manifest, i + manifest_offset, const char*)
= new_filename->data;
- /* create a file stream for the new file */
- SVN_ERR(svn_io_file_open(&file, svn_dirent_join(revprops->folder,
- new_filename->data,
- scratch_pool),
+ /* open the file */
+ SVN_ERR(svn_io_file_open(file, svn_dirent_join(revprops->folder,
+ new_filename->data,
+ scratch_pool),
APR_WRITE | APR_CREATE, APR_OS_DEFAULT,
result_pool));
- *stream = svn_stream_from_aprfile2(file, FALSE, result_pool);
return SVN_NO_ERROR;
}
@@ -1450,6 +1456,7 @@ write_packed_revprop(const char **final_
packed_revprops_t *revprops;
apr_int64_t generation = 0;
svn_stream_t *stream;
+ apr_file_t *file;
svn_stringbuf_t *serialized;
apr_off_t new_total_size;
int changed_index;
@@ -1487,12 +1494,12 @@ write_packed_revprop(const char **final_
*final_path = svn_dirent_join(revprops->folder, revprops->filename,
result_pool);
- SVN_ERR(svn_stream_open_unique(&stream, tmp_path, revprops->folder,
- svn_io_file_del_none, result_pool,
- scratch_pool));
+ SVN_ERR(svn_io_open_unique_file3(&file, tmp_path, revprops->folder,
+ svn_io_file_del_none, result_pool,
+ scratch_pool));
SVN_ERR(repack_revprops(fs, revprops, 0, revprops->sizes->nelts,
changed_index, serialized, new_total_size,
- stream, scratch_pool));
+ file, scratch_pool));
}
else
{
@@ -1544,54 +1551,57 @@ write_packed_revprop(const char **final_
/* write the new, split files */
if (left_count)
{
- SVN_ERR(repack_stream_open(&stream, fs, revprops, 0,
- left_count, files_to_delete,
- scratch_pool, scratch_pool));
+ SVN_ERR(repack_file_open(&file, fs, revprops, 0,
+ left_count, files_to_delete,
+ scratch_pool, scratch_pool));
SVN_ERR(repack_revprops(fs, revprops, 0, left_count,
changed_index, serialized, new_total_size,
- stream, scratch_pool));
+ file, scratch_pool));
}
if (left_count + right_count < revprops->sizes->nelts)
{
- SVN_ERR(repack_stream_open(&stream, fs, revprops, changed_index,
- changed_index + 1, files_to_delete,
- scratch_pool, scratch_pool));
+ SVN_ERR(repack_file_open(&file, fs, revprops, changed_index,
+ changed_index + 1, files_to_delete,
+ scratch_pool, scratch_pool));
SVN_ERR(repack_revprops(fs, revprops, changed_index,
changed_index + 1,
changed_index, serialized, new_total_size,
- stream, scratch_pool));
+ file, scratch_pool));
}
if (right_count)
{
- SVN_ERR(repack_stream_open(&stream, fs, revprops,
- revprops->sizes->nelts - right_count,
- revprops->sizes->nelts,
- files_to_delete, scratch_pool,
- scratch_pool));
+ SVN_ERR(repack_file_open(&file, fs, revprops,
+ revprops->sizes->nelts - right_count,
+ revprops->sizes->nelts,
+ files_to_delete, scratch_pool,
+ scratch_pool));
SVN_ERR(repack_revprops(fs, revprops,
revprops->sizes->nelts - right_count,
revprops->sizes->nelts, changed_index,
- serialized, new_total_size, stream,
+ serialized, new_total_size, file,
scratch_pool));
}
/* write the new manifest */
*final_path = svn_dirent_join(revprops->folder, PATH_MANIFEST,
result_pool);
- SVN_ERR(svn_stream_open_unique(&stream, tmp_path, revprops->folder,
- svn_io_file_del_none, result_pool,
- scratch_pool));
+ SVN_ERR(svn_io_open_unique_file3(&file, tmp_path, revprops->folder,
+ svn_io_file_del_none, result_pool,
+ scratch_pool));
for (i = 0; i < revprops->manifest->nelts; ++i)
{
const char *filename = APR_ARRAY_IDX(revprops->manifest, i,
const char*);
- SVN_ERR(svn_stream_printf(stream, scratch_pool, "%s\n", filename));
+ SVN_ERR(svn_io_file_write_full(file, filename, strlen(filename),
+ NULL, scratch_pool));
+ SVN_ERR(svn_io_file_putc('\n', file, scratch_pool));
}
- SVN_ERR(svn_stream_close(stream));
+ SVN_ERR(svn_io_file_flush_to_disk(file, scratch_pool));
+ SVN_ERR(svn_io_file_close(file, scratch_pool));
}
return SVN_NO_ERROR;