subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@apache.org
Subject svn commit: r1618151 - /subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c
Date Fri, 15 Aug 2014 11:17:23 GMT
Author: stefan2
Date: Fri Aug 15 11:17:22 2014
New Revision: 1618151

URL: http://svn.apache.org/r1618151
Log:
Follow-up to r1618138:  Correct UUID / ID handling during FS upgrade.

* subversion/libsvn_fs_fs/fs_fs.c
  (read_uuid): Factored out from ...
  (svn_fs_fs__open): ... this.
  (upgrade_body): Actually read the UUID before trying to rewrite it.
                  Always update the instance ID upon upgrade.

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/fs_fs.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=1618151&r1=1618150&r2=1618151&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/fs_fs.c Fri Aug 15 11:17:22 2014
@@ -1004,39 +1004,31 @@ read_global_config(svn_fs_t *fs)
   return SVN_NO_ERROR;
 }
 
-svn_error_t *
-svn_fs_fs__open(svn_fs_t *fs, const char *path, apr_pool_t *pool)
+/* Read FS's UUID file and store the data in the FS struct. */
+static svn_error_t *
+read_uuid(svn_fs_t *fs,
+          apr_pool_t *scratch_pool)
 {
   fs_fs_data_t *ffd = fs->fsap_data;
   apr_file_t *uuid_file;
-  int format, max_files_per_dir;
-  svn_revnum_t min_log_addressing_rev;
   char buf[APR_UUID_FORMATTED_LENGTH + 2];
   apr_size_t limit;
 
-  fs->path = apr_pstrdup(fs->pool, path);
-
-  /* Read the FS format number. */
-  SVN_ERR(read_format(&format, &max_files_per_dir, &min_log_addressing_rev,
-                      path_format(fs, pool), pool));
-
-  /* Now we've got a format number no matter what. */
-  ffd->format = format;
-  ffd->max_files_per_dir = max_files_per_dir;
-  ffd->min_log_addressing_rev = min_log_addressing_rev;
-
-  /* Read in and cache the repository uuid. */
-  SVN_ERR(svn_io_file_open(&uuid_file, path_uuid(fs, pool),
-                           APR_READ | APR_BUFFERED, APR_OS_DEFAULT, pool));
+  /* Read the repository uuid. */
+  SVN_ERR(svn_io_file_open(&uuid_file, path_uuid(fs, scratch_pool),
+                           APR_READ | APR_BUFFERED, APR_OS_DEFAULT,
+                           scratch_pool));
 
   limit = sizeof(buf);
-  SVN_ERR(svn_io_read_length_line(uuid_file, buf, &limit, pool));
+  SVN_ERR(svn_io_read_length_line(uuid_file, buf, &limit, scratch_pool));
   fs->uuid = apr_pstrdup(fs->pool, buf);
 
-  if (format >= SVN_FS_FS__MIN_INSTANCE_ID_FORMAT)
+  /* Read the instance ID. */
+  if (ffd->format >= SVN_FS_FS__MIN_INSTANCE_ID_FORMAT)
     {
       limit = sizeof(buf);
-      SVN_ERR(svn_io_read_length_line(uuid_file, buf, &limit, pool));
+      SVN_ERR(svn_io_read_length_line(uuid_file, buf, &limit,
+                                      scratch_pool));
       ffd->instance_id = apr_pstrdup(fs->pool, buf);
     }
   else
@@ -1044,7 +1036,31 @@ svn_fs_fs__open(svn_fs_t *fs, const char
       ffd->instance_id = fs->uuid;
     }
 
-  SVN_ERR(svn_io_file_close(uuid_file, pool));
+  SVN_ERR(svn_io_file_close(uuid_file, scratch_pool));
+
+  return SVN_NO_ERROR;
+}
+
+svn_error_t *
+svn_fs_fs__open(svn_fs_t *fs, const char *path, apr_pool_t *pool)
+{
+  fs_fs_data_t *ffd = fs->fsap_data;
+  int format, max_files_per_dir;
+  svn_revnum_t min_log_addressing_rev;
+
+  fs->path = apr_pstrdup(fs->pool, path);
+
+  /* Read the FS format number. */
+  SVN_ERR(read_format(&format, &max_files_per_dir, &min_log_addressing_rev,
+                      path_format(fs, pool), pool));
+
+  /* Now we've got a format number no matter what. */
+  ffd->format = format;
+  ffd->max_files_per_dir = max_files_per_dir;
+  ffd->min_log_addressing_rev = min_log_addressing_rev;
+
+  /* Read in and cache the repository uuid. */
+  SVN_ERR(read_uuid(fs, pool));
 
   /* Read the min unpacked revision. */
   if (ffd->format >= SVN_FS_FS__MIN_PACKED_FORMAT)
@@ -1175,16 +1191,20 @@ upgrade_body(void *baton, apr_pool_t *po
         * max_files_per_dir;
     }
 
+  /* We will need the UUID info shortly ...
+     Read it before the format bump as the UUID file still uses the old
+     format. */
+  SVN_ERR(read_uuid(fs, pool));
+
   /* Update the format info in the FS struct.  Upgrade steps further
      down will use the format from FS to create missing info. */
   ffd->format = SVN_FS_FS__FORMAT_NUMBER;
   ffd->max_files_per_dir = max_files_per_dir;
   ffd->min_log_addressing_rev = min_log_addressing_rev;
 
-  /* Come up with a new instance ID in case our filesystem did not
-     have one it before.  Keep the UUID. */
-  if (format < SVN_FS_FS__MIN_INSTANCE_ID_FORMAT)
-    SVN_ERR(svn_fs_fs__set_uuid(fs, fs->uuid, NULL, pool));
+  /* Always add / bump the instance ID such that no form of caching
+     accidentally uses outdated information.  Keep the UUID. */
+  SVN_ERR(svn_fs_fs__set_uuid(fs, fs->uuid, NULL, pool));
 
   /* Bump the format file. */
   SVN_ERR(svn_fs_fs__write_format(fs, TRUE, pool));



Mime
View raw message