You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2015/05/18 05:57:43 UTC

svn commit: r1679926 - in /subversion/trunk/subversion/libsvn_fs_fs: cached_data.c temp_serializer.c temp_serializer.h

Author: stefan2
Date: Mon May 18 03:57:42 2015
New Revision: 1679926

URL: http://svn.apache.org/r1679926
Log:
Complete work on the fs-test 44 issue in FSFS:
Make the last accessor - single dir entry read - handle / check the in-txn
filesize.  No access function should ever return stale dir cache entries nor
try to update them.  They may or may not get eventually overwritten with
current data or mey just be dropped.

* subversion/libsvn_fs_fs/temp_serializer.h
  (extract_dir_entry_baton_t): Declare new parameter type.
  (svn_fs_fs__extract_dir_entry): Update docstring requiring that the caller
                                  now provides a baton of the new type.

* subversion/libsvn_fs_fs/temp_serializer.c
  (svn_fs_fs__extract_dir_entry): Update. Cause a NULL / "not found" return
                                  when the cached data is stale as indicated
                                  by the file size.

* subversion/libsvn_fs_fs/cached_data.c
  (svn_fs_fs__rep_contents_dir_entry): Pass the expected filesize alongside
                                       the wanted direntry name to the getter.

Modified:
    subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
    subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c
    subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.h

Modified: subversion/trunk/subversion/libsvn_fs_fs/cached_data.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/cached_data.c?rev=1679926&r1=1679925&r2=1679926&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/cached_data.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/cached_data.c Mon May 18 03:57:42 2015
@@ -2729,13 +2729,22 @@ svn_fs_fs__rep_contents_dir_entry(svn_fs
                                          scratch_pool);
   if (cache)
     {
+      extract_dir_entry_baton_t baton;
+
+      const char *filename;
+      svn_filesize_t filesize;
+      SVN_ERR(get_txn_dir_info(&filename, &filesize, fs, noderev,
+                               scratch_pool, scratch_pool));
+
       /* Cache lookup. */
+      baton.txn_filesize = filesize;
+      baton.name = name;
       SVN_ERR(svn_cache__get_partial((void **)dirent,
                                      &found,
                                      cache,
                                      key,
                                      svn_fs_fs__extract_dir_entry,
-                                     (void*)name,
+                                     &baton,
                                      result_pool));
     }
 

Modified: subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c?rev=1679926&r1=1679925&r2=1679926&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.c Mon May 18 03:57:42 2015
@@ -882,7 +882,7 @@ svn_fs_fs__extract_dir_entry(void **out,
                              apr_pool_t *pool)
 {
   const dir_data_t *dir_data = data;
-  const char* name = baton;
+  const extract_dir_entry_baton_t *entry_baton = baton;
   svn_boolean_t found;
 
   /* resolve the reference to the entries array */
@@ -895,13 +895,14 @@ svn_fs_fs__extract_dir_entry(void **out,
 
   /* binary search for the desired entry by name */
   apr_size_t pos = find_entry((svn_fs_dirent_t **)entries,
-                              name,
+                              entry_baton->name,
                               dir_data->count,
                               &found);
 
-  /* de-serialize that entry or return NULL, if no match has been found */
+  /* de-serialize that entry or return NULL, if no match has been found.
+   * Be sure to check that the directory contents is still up-to-date. */
   *out = NULL;
-  if (found)
+  if (found && dir_data->txn_filesize == entry_baton->txn_filesize)
     {
       const svn_fs_dirent_t *source =
           svn_temp_deserializer__ptr(entries, (const void *const *)&entries[pos]);

Modified: subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.h?rev=1679926&r1=1679925&r2=1679926&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.h (original)
+++ subversion/trunk/subversion/libsvn_fs_fs/temp_serializer.h Mon May 18 03:57:42 2015
@@ -233,9 +233,26 @@ svn_fs_fs__extract_dir_filesize(void **o
                                 apr_pool_t *pool);
 
 /**
+ * Describes the entry to be found in a directory: Identifies the entry
+ * by @a name and requires the directory file size to be @a filesize.
+ */
+typedef struct extract_dir_entry_baton_t
+{
+  /** name of the directory entry to return */
+  const char *name;
+
+  /** Current length of the in-txn in-disk representation of the directory.
+   * SVN_INVALID_FILESIZE if unknown. */
+  svn_filesize_t txn_filesize;
+} extract_dir_entry_baton_t;
+
+
+/**
  * Implements #svn_cache__partial_getter_func_t for a single
  * #svn_fs_dirent_t within a serialized directory contents hash,
- * identified by its name (const char @a *baton).
+ * identified by its name (in (extract_dir_entry_baton_t *) @a *baton).
+ * If the filesize specified in the baton does not match the cached
+ * value for this directory, @a *out will be NULL as well.
  */
 svn_error_t *
 svn_fs_fs__extract_dir_entry(void **out,