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 2021/02/25 16:30:08 UTC

svn commit: r1886923 - in /subversion/trunk/subversion/libsvn_wc: wc_db.c wc_db.h workqueue.c

Author: kotkov
Date: Thu Feb 25 16:30:08 2021
New Revision: 1886923

URL: http://svn.apache.org/viewvc?rev=1886923&view=rev
Log:
OP_FILE_INSTALL: use the timestamp and size from the working file writer,
instead performing a stat on the already installed file.

This avoids the difference in how we use the working file writer on various
calling sites.  Also, the new approach uses the optimizations provided by the
install stream to obtain the info, and may retrieve it by the open file handle.

* subversion/libsvn_wc/wc_db.h
  (struct svn_wc__db_fileinfo_t): New.  We'll use this structure to pass
   only timestamp and size values, instead of the full svn_io_dirent2_t when
   recording the file info.

* subversion/libsvn_wc/workqueue.c
  (work_item_baton_t): Now maps the paths to svn_wc__db_fileinfo_t objects.
  (get_and_record_fileinfo): Convert this utility function into...
  (wq_record_fileinfo): ...this function that only records the file info
   and does not return an error.
  (run_file_install): Obtain and record the timestamp and size values from
   the working file writer, if necessary.
  (run_record_fileinfo): Update the calling site of get_and_record_fileinfo().
   Call svn_io_stat_dirent2() with the same parameters as before and call the
   new wq_record_fileinfo() utility if necessary.   

* subversion/libsvn_wc/wc_db.c
  (wq_record): The `record_map` now maps to the svn_wc__db_fileinfo_t values.
   Update the call to db_record_fileinfo().

Modified:
    subversion/trunk/subversion/libsvn_wc/wc_db.c
    subversion/trunk/subversion/libsvn_wc/wc_db.h
    subversion/trunk/subversion/libsvn_wc/workqueue.c

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.c?rev=1886923&r1=1886922&r2=1886923&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.c (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.c Thu Feb 25 16:30:08 2021
@@ -13597,7 +13597,7 @@ wq_record(svn_wc__db_wcroot_t *wcroot,
        hi = apr_hash_next(hi))
     {
       const char *local_abspath = apr_hash_this_key(hi);
-      const svn_io_dirent2_t *dirent = apr_hash_this_val(hi);
+      const svn_wc__db_fileinfo_t *info = apr_hash_this_val(hi);
       const char *local_relpath = svn_dirent_skip_ancestor(wcroot->abspath,
                                                            local_abspath);
 
@@ -13607,7 +13607,7 @@ wq_record(svn_wc__db_wcroot_t *wcroot,
         continue;
 
       SVN_ERR(db_record_fileinfo(wcroot, local_relpath,
-                                 dirent->filesize, dirent->mtime,
+                                 info->size, info->mtime,
                                  iterpool));
     }
 

Modified: subversion/trunk/subversion/libsvn_wc/wc_db.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/wc_db.h?rev=1886923&r1=1886922&r2=1886923&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/wc_db.h (original)
+++ subversion/trunk/subversion/libsvn_wc/wc_db.h Thu Feb 25 16:30:08 2021
@@ -202,6 +202,15 @@ typedef struct svn_wc__db_lock_t {
   apr_time_t date;
 } svn_wc__db_lock_t;
 
+/* Structure holding the size and timestamp values for a file.  */
+typedef struct svn_wc__db_fileinfo_t {
+  /* The time the file was last modified. */
+  apr_time_t mtime;
+
+  /* The size of this file. */
+  svn_filesize_t size;
+} svn_wc__db_fileinfo_t;
+
 
 /* ### NOTE: I have not provided docstrings for most of this file at this
    ### point in time. The shape and extent of this API is still in massive

Modified: subversion/trunk/subversion/libsvn_wc/workqueue.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_wc/workqueue.c?rev=1886923&r1=1886922&r2=1886923&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_wc/workqueue.c (original)
+++ subversion/trunk/subversion/libsvn_wc/workqueue.c Thu Feb 25 16:30:08 2021
@@ -80,11 +80,11 @@ struct work_item_dispatch {
 };
 
 /* Forward definition */
-static svn_error_t *
-get_and_record_fileinfo(work_item_baton_t *wqb,
-                        const char *local_abspath,
-                        svn_boolean_t ignore_enoent,
-                        apr_pool_t *scratch_pool);
+static void
+wq_record_fileinfo(work_item_baton_t *wqb,
+                   const char *local_abspath,
+                   apr_time_t mtime,
+                   svn_filesize_t size);
 
 /* ------------------------------------------------------------------------ */
 /* OP_REMOVE_BASE  */
@@ -489,6 +489,8 @@ run_file_install(work_item_baton_t *wqb,
   const char *repos_relpath;
   const char *repos_root_url;
   svn_wc__working_file_writer_t *file_writer;
+  apr_time_t record_mtime;
+  apr_off_t record_size;
 
   local_relpath = apr_pstrmemdup(scratch_pool, arg1->data, arg1->len);
   SVN_ERR(svn_wc__db_from_relpath(&local_abspath, db, wri_abspath,
@@ -608,17 +610,25 @@ run_file_install(work_item_baton_t *wqb,
                            cancel_func, cancel_baton,
                            scratch_pool));
 
-  SVN_ERR(svn_wc__working_file_writer_finalize(NULL, NULL, file_writer,
-                                               scratch_pool));
+  if (record_fileinfo)
+    {
+      SVN_ERR(svn_wc__working_file_writer_finalize(&record_mtime, &record_size,
+                                                   file_writer, scratch_pool));
+    }
+  else
+    {
+      SVN_ERR(svn_wc__working_file_writer_finalize(NULL, NULL, file_writer,
+                                                   scratch_pool));
+      record_mtime = -1;
+      record_size = -1;
+    }
+
   SVN_ERR(svn_wc__working_file_writer_install(file_writer, local_abspath,
                                               scratch_pool));
 
-  /* ### this should happen before we rename the file into place.  */
   if (record_fileinfo)
     {
-      SVN_ERR(get_and_record_fileinfo(wqb, local_abspath,
-                                      FALSE /* ignore_enoent */,
-                                      scratch_pool));
+      wq_record_fileinfo(wqb, local_abspath, record_mtime, record_size);
     }
 
   return SVN_NO_ERROR;
@@ -1173,6 +1183,7 @@ run_record_fileinfo(work_item_baton_t *w
   const char *local_relpath;
   const char *local_abspath;
   apr_time_t set_time = 0;
+  const svn_io_dirent2_t *dirent;
 
   local_relpath = apr_pstrmemdup(scratch_pool, arg1->data, arg1->len);
 
@@ -1206,10 +1217,17 @@ run_record_fileinfo(work_item_baton_t *w
          filesystem might have a different timestamp granularity */
     }
 
+  SVN_ERR(svn_io_stat_dirent2(&dirent, local_abspath,
+                              FALSE /* verify_truename */,
+                              TRUE /* ignore_enoent */,
+                              scratch_pool, scratch_pool));
 
-  return svn_error_trace(get_and_record_fileinfo(wqb, local_abspath,
-                                                 TRUE /* ignore_enoent */,
-                                                 scratch_pool));
+  if (dirent->kind == svn_node_file)
+    {
+      wq_record_fileinfo(wqb, local_abspath, dirent->mtime, dirent->filesize);
+    }
+
+  return SVN_NO_ERROR;
 }
 
 /* ------------------------------------------------------------------------ */
@@ -1407,7 +1425,7 @@ struct work_item_baton_t
 
   svn_boolean_t used; /* needs reset */
 
-  apr_hash_t *record_map; /* const char * -> svn_io_dirent2_t map */
+  apr_hash_t *record_map; /* const char * -> svn_wc__db_fileinfo_t map */
 };
 
 
@@ -1608,27 +1626,23 @@ svn_wc__wq_merge(svn_skel_t *work_item1,
 }
 
 
-static svn_error_t *
-get_and_record_fileinfo(work_item_baton_t *wqb,
-                        const char *local_abspath,
-                        svn_boolean_t ignore_enoent,
-                        apr_pool_t *scratch_pool)
+static void
+wq_record_fileinfo(work_item_baton_t *wqb,
+                   const char *local_abspath,
+                   apr_time_t mtime,
+                   svn_filesize_t size)
 {
-  const svn_io_dirent2_t *dirent;
-
-  SVN_ERR(svn_io_stat_dirent2(&dirent, local_abspath, FALSE, ignore_enoent,
-                              wqb->result_pool, scratch_pool));
-
-  if (dirent->kind != svn_node_file)
-    return SVN_NO_ERROR;
+  svn_wc__db_fileinfo_t *info;
 
   wqb->used = TRUE;
 
   if (! wqb->record_map)
     wqb->record_map = apr_hash_make(wqb->result_pool);
 
-  svn_hash_sets(wqb->record_map, apr_pstrdup(wqb->result_pool, local_abspath),
-                dirent);
+  info = apr_pcalloc(wqb->result_pool, sizeof(*info));
+  info->mtime = mtime;
+  info->size = size;
 
-  return SVN_NO_ERROR;
+  svn_hash_sets(wqb->record_map, apr_pstrdup(wqb->result_pool, local_abspath),
+                info);
 }