This is an automated email from the ASF dual-hosted git repository.

cmcfarlen pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 14eed821faaebfb61b7b0ec79a44cde29108bbf1
Author: Masaori Koshiba <[email protected]>
AuthorDate: Tue Jun 23 06:59:49 2026 +0900

    cache: apply per-volume settings on first start after clear (#13252)
    
    Per-volume tuning (ram_cache, ram_cache_size, ram_cache_cutoff,
    avg_obj_size, fragment_size) was only copied onto the CacheVol when
    matching an existing on-disk volume, so volumes created fresh (e.g.
    the first start after a cache clear) ignored the config until the
    next restart. Apply the settings in one pass after all CacheVols
    exist.
    
    Extend cache_volume_features to verify the settings take effect via
    per-volume metrics.
    
    (cherry picked from commit ec72cf41dadf4876be0e83addbb91d8ddf104290)
---
 src/iocore/cache/CacheProcessor.cc                 | 23 ++++++++++++++++++----
 .../traffic_ctl/remap_inc/wait_reload.sh           |  8 +++-----
 2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/src/iocore/cache/CacheProcessor.cc 
b/src/iocore/cache/CacheProcessor.cc
index a1f6c827a0..b1acbfc6e0 100644
--- a/src/iocore/cache/CacheProcessor.cc
+++ b/src/iocore/cache/CacheProcessor.cc
@@ -68,6 +68,7 @@ void           register_cache_stats(CacheStatsBlock *rsb, 
const std::string &pre
 static void    cplist_update();
 static int     create_volume(int volume_number, off_t size_in_blocks, int 
scheme, CacheVol *cp);
 static int     fillExclusiveDisks(CacheVol *cp);
+static void    cplist_apply_config_settings(CacheVol *cp, const ConfigVol 
*config_vol);
 
 static size_t DEFAULT_RAM_CACHE_MULTIPLIER = 10; // I.e. 10x 1MB per 1GB of 
disk.
 
@@ -1053,6 +1054,14 @@ cplist_reconfigure()
     }
   }
 
+  // Apply per-volume settings after all CacheVols exist; otherwise volumes 
created on the first
+  // start after a cache clear keep defaults and ignore the config until the 
next restart.
+  for (ConfigVol *config_vol = config_volumes.cp_queue.head; config_vol; 
config_vol = config_vol->link.next) {
+    if (config_vol->cachep) {
+      cplist_apply_config_settings(config_vol->cachep, config_vol);
+    }
+  }
+
   ts::Metrics::Gauge::store(cache_rsb.stripes, gnstripes);
 
   return 0;
@@ -1164,6 +1173,15 @@ register_cache_stats(CacheStatsBlock *rsb, const 
std::string &prefix)
   rsb->span_online           = ts::Metrics::Gauge::createPtr(prefix + 
".span.online");
 }
 
+// Copy the per-volume tuning fields from the volume config onto the CacheVol.
+void
+cplist_apply_config_settings(CacheVol *cp, const ConfigVol *config_vol)
+{
+  cp->ramcache_enabled = config_vol->ramcache_enabled;
+  cp->avg_obj_size     = config_vol->avg_obj_size;
+  cp->fragment_size    = config_vol->fragment_size;
+}
+
 void
 cplist_update()
 {
@@ -1175,10 +1193,7 @@ cplist_update()
     for (config_vol = config_volumes.cp_queue.head; config_vol; config_vol = 
config_vol->link.next) {
       if (config_vol->number == cp->vol_number) {
         if (cp->scheme == config_vol->scheme) {
-          cp->ramcache_enabled = config_vol->ramcache_enabled;
-          cp->avg_obj_size     = config_vol->avg_obj_size;
-          cp->fragment_size    = config_vol->fragment_size;
-          config_vol->cachep   = cp;
+          config_vol->cachep = cp;
         } else {
           /* delete this volume from all the disks */
           int d_no;
diff --git a/tests/gold_tests/traffic_ctl/remap_inc/wait_reload.sh 
b/tests/gold_tests/traffic_ctl/remap_inc/wait_reload.sh
index e0ace41f87..89c0fcc17e 100755
--- a/tests/gold_tests/traffic_ctl/remap_inc/wait_reload.sh
+++ b/tests/gold_tests/traffic_ctl/remap_inc/wait_reload.sh
@@ -17,14 +17,12 @@
 #  limitations under the License.
 
 # Wait till remap.config finishes loading two times.
-
 WAIT=60
 LOG_FILE="$1"
 
-while (( WAIT > 0 ))
-do
-    N=$( grep -F 'NOTE: remap.config finished loading' $LOG_FILE | wc -l )
-    if [[ $N = 2 ]] ; then
+while ((WAIT > 0)); do
+    N=$(grep -F 'NOTE: remap.config finished loading' $LOG_FILE | wc -l)
+    if [[ $N = 2 ]]; then
         exit 0
     fi
     sleep 1

Reply via email to