subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1686987 - in /subversion/branches/fsx-1.10/subversion/libsvn_fs_x: fs.h transaction.c util.c util.h
Date Tue, 23 Jun 2015 08:34:24 GMT
Author: stefan2
Date: Tue Jun 23 08:34:24 2015
New Revision: 1686987

URL: http://svn.apache.org/r1686987
Log:
On the fsx-1.10 branch:
Give specific names to the precursor / temporary files for 'current' and
'txn-current'.  This is the first step in preparing FSX for providing
transactional guarantees with a single fsync delay (batch run).

* subversion/libsvn_fs_x/fs.h
  (PATH_NEXT,
   PATH_TXN_NEXT): Define the new file name constants.

* subversion/libsvn_fs_x/util.h
  (svn_fs_x__path_next,
   svn_fs_x__path_txn_next): Declare path constructors for the new files.

* subversion/libsvn_fs_x/util.c
  (svn_fs_x__path_next,
   svn_fs_x__path_txn_next): Implement them.
  (svn_fs_x__write_current): Instead of a random temporary file use the
                             newly defined one.

* subversion/libsvn_fs_x/transaction.c
  (get_and_increment_txn_key_body): Same.

Modified:
    subversion/branches/fsx-1.10/subversion/libsvn_fs_x/fs.h
    subversion/branches/fsx-1.10/subversion/libsvn_fs_x/transaction.c
    subversion/branches/fsx-1.10/subversion/libsvn_fs_x/util.c
    subversion/branches/fsx-1.10/subversion/libsvn_fs_x/util.h

Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/fs.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/fs.h?rev=1686987&r1=1686986&r2=1686987&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/fs.h (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/fs.h Tue Jun 23 08:34:24 2015
@@ -53,12 +53,14 @@ extern "C" {
 #define PATH_FORMAT           "format"           /* Contains format number */
 #define PATH_UUID             "uuid"             /* Contains UUID */
 #define PATH_CURRENT          "current"          /* Youngest revision */
+#define PATH_NEXT             "next"             /* Revision begin written. */
 #define PATH_LOCK_FILE        "write-lock"       /* Revision lock file */
 #define PATH_PACK_LOCK_FILE   "pack-lock"        /* Pack lock file */
 #define PATH_REVS_DIR         "revs"             /* Directory of revisions */
 #define PATH_TXNS_DIR         "transactions"     /* Directory of transactions */
 #define PATH_TXN_PROTOS_DIR   "txn-protorevs"    /* Directory of proto-revs */
 #define PATH_TXN_CURRENT      "txn-current"      /* File with next txn key */
+#define PATH_TXN_NEXT         "txn-next"         /* Will become txn-current */
 #define PATH_TXN_CURRENT_LOCK "txn-current-lock" /* Lock for txn-current */
 #define PATH_LOCKS_DIR        "locks"            /* Directory of locks */
 #define PATH_MIN_UNPACKED_REV "min-unpacked-rev" /* Oldest revision which

Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/transaction.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/transaction.c?rev=1686987&r1=1686986&r2=1686987&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/transaction.c (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/transaction.c Tue Jun 23 08:34:24
2015
@@ -1193,7 +1193,9 @@ get_and_increment_txn_key_body(void *bat
   get_and_increment_txn_key_baton_t *cb = baton;
   const char *txn_current_filename = svn_fs_x__path_txn_current(cb->fs,
                                                                 scratch_pool);
-  const char *tmp_filename;
+  const char *tmp_filename = svn_fs_x__path_txn_next(cb->fs, scratch_pool);
+  apr_file_t *file;
+
   char new_id_str[SVN_INT64_BUFFER_SIZE];
 
   svn_stringbuf_t *buf;
@@ -1202,14 +1204,16 @@ get_and_increment_txn_key_body(void *bat
   /* remove trailing newlines */
   cb->txn_number = svn__base36toui64(NULL, buf->data);
 
-  /* Increment the key and add a trailing \n to the string so the
-     txn-current file has a newline in it. */
-  SVN_ERR(svn_io_write_unique(&tmp_filename,
-                              svn_dirent_dirname(txn_current_filename,
-                                                 scratch_pool),
-                              new_id_str,
-                              svn__ui64tobase36(new_id_str, cb->txn_number+1),
-                              svn_io_file_del_none, scratch_pool));
+  /* Increment the key. */
+  SVN_ERR(svn_io_file_open(&file, tmp_filename,
+                           APR_WRITE | APR_CREATE | APR_BUFFERED,
+                           APR_OS_DEFAULT, scratch_pool));
+  SVN_ERR(svn_io_file_write_full(file, new_id_str,
+                                 svn__ui64tobase36(new_id_str,
+                                                   cb->txn_number+1),
+                                 NULL, scratch_pool));
+  SVN_ERR(svn_io_file_close(file, scratch_pool));
+
   SVN_ERR(svn_fs_x__move_into_place(tmp_filename, txn_current_filename,
                                     txn_current_filename, scratch_pool));
 

Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/util.c
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/util.c?rev=1686987&r1=1686986&r2=1686987&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/util.c (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/util.c Tue Jun 23 08:34:24 2015
@@ -110,11 +110,24 @@ svn_fs_x__path_current(svn_fs_t *fs,
 }
 
 const char *
+svn_fs_x__path_next(svn_fs_t *fs,
+                       apr_pool_t *result_pool)
+{
+  return svn_dirent_join(fs->path, PATH_NEXT, result_pool);
+}
+
+const char *
 svn_fs_x__path_txn_current(svn_fs_t *fs,
                            apr_pool_t *result_pool)
 {
-  return svn_dirent_join(fs->path, PATH_TXN_CURRENT,
-                         result_pool);
+  return svn_dirent_join(fs->path, PATH_TXN_CURRENT, result_pool);
+}
+
+const char *
+svn_fs_x__path_txn_next(svn_fs_t *fs,
+                           apr_pool_t *result_pool)
+{
+  return svn_dirent_join(fs->path, PATH_TXN_NEXT, result_pool);
 }
 
 const char *
@@ -569,15 +582,20 @@ svn_fs_x__write_current(svn_fs_t *fs,
 {
   char *buf;
   const char *tmp_name, *name;
+  apr_file_t *file;
 
   /* Now we can just write out this line. */
   buf = apr_psprintf(scratch_pool, "%ld\n", rev);
 
   name = svn_fs_x__path_current(fs, scratch_pool);
-  SVN_ERR(svn_io_write_unique(&tmp_name,
-                              svn_dirent_dirname(name, scratch_pool),
-                              buf, strlen(buf),
-                              svn_io_file_del_none, scratch_pool));
+  tmp_name = svn_fs_x__path_next(fs, scratch_pool);
+
+  SVN_ERR(svn_io_file_open(&file, tmp_name,
+                           APR_WRITE | APR_CREATE | APR_BUFFERED,
+                           APR_OS_DEFAULT, scratch_pool));
+  SVN_ERR(svn_io_file_write_full(file, buf, strlen(buf), NULL,
+                                 scratch_pool));
+  SVN_ERR(svn_io_file_close(file, scratch_pool));
 
   return svn_fs_x__move_into_place(tmp_name, name, name, scratch_pool);
 }

Modified: subversion/branches/fsx-1.10/subversion/libsvn_fs_x/util.h
URL: http://svn.apache.org/viewvc/subversion/branches/fsx-1.10/subversion/libsvn_fs_x/util.h?rev=1686987&r1=1686986&r2=1686987&view=diff
==============================================================================
--- subversion/branches/fsx-1.10/subversion/libsvn_fs_x/util.h (original)
+++ subversion/branches/fsx-1.10/subversion/libsvn_fs_x/util.h Tue Jun 23 08:34:24 2015
@@ -102,6 +102,12 @@ const char *
 svn_fs_x__path_current(svn_fs_t *fs,
                        apr_pool_t *result_pool);
 
+/* Return the path to the 'next' file in FS.
+   Perform allocation in RESULT_POOL. */
+const char *
+svn_fs_x__path_next(svn_fs_t *fs,
+                    apr_pool_t *result_pool);
+
 /* Return the full path of the "uuid" file in FS.
  * The result will be allocated in RESULT_POOL.
  */
@@ -116,6 +122,13 @@ const char *
 svn_fs_x__path_txn_current(svn_fs_t *fs,
                            apr_pool_t *result_pool);
 
+/* Return the full path of the "txn-next" file in FS.
+ * The result will be allocated in RESULT_POOL.
+ */
+const char *
+svn_fs_x__path_txn_next(svn_fs_t *fs,
+                        apr_pool_t *result_pool);
+
 /* Return the full path of the "txn-current-lock" file in FS.
  * The result will be allocated in RESULT_POOL.
  */



Mime
View raw message