]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
DW:
authorwessels <>
Wed, 1 Nov 2000 10:35:40 +0000 (10:35 +0000)
committerwessels <>
Wed, 1 Nov 2000 10:35:40 +0000 (10:35 +0000)
 - Replaced "xxx Entries read so far" messages with a global, friendlier
   "Store rebuilding is XX% complete" message.

src/fs/aufs/store_dir_aufs.cc
src/fs/coss/store_dir_coss.cc
src/fs/diskd/store_dir_diskd.cc
src/fs/ufs/store_dir_ufs.cc
src/protos.h
src/store_rebuild.cc

index 392a0af8b09391010535c454e2bfbe871852fcc1..0a63ce2846eaa4aa470ddeee5ad3c9d597e89f35 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_aufs.cc,v 1.11 2000/10/31 23:48:17 wessels Exp $
+ * $Id: store_dir_aufs.cc,v 1.12 2000/11/01 03:35:47 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -589,9 +589,12 @@ storeAufsDirRebuildFromSwapLog(void *data)
            rb->counts.invalid++;
            continue;
        }
-       if ((++rb->counts.scancount & 0xFFFF) == 0)
-           debug(20, 3) ("  %7d %s Entries read so far.\n",
-               rb->counts.scancount, rb->sd->path);
+       if ((++rb->counts.scancount & 0xFFF) == 0) {
+           struct stat sb;
+           if (0 == fstat(fileno(rb->log), &sb))
+               storeRebuildProgress(SD->index,
+                   (int) sb.st_size / ss, rb->n_read);
+       }
        if (!storeAufsDirValidFileno(SD, s.swap_filen, 0)) {
            rb->counts.invalid++;
            continue;
@@ -1711,9 +1714,9 @@ storeFsSetup_aufs(storefs_entry_t * storefs)
     storefs->donefunc = storeAufsDirDone;
     aio_state_pool = memPoolCreate("AUFS IO State data", sizeof(aiostate_t));
     aio_qread_pool = memPoolCreate("AUFS Queued read data",
-        sizeof(queued_read));
+       sizeof(queued_read));
     aio_qwrite_pool = memPoolCreate("AUFS Queued write data",
-        sizeof(queued_write));
+       sizeof(queued_write));
 
     asyncufs_initialised = 1;
     aioInit();
index 166778b1a29b9861bc5e4b87781adf9a77077e6f..5bc928dbcecee3e79fee2359a2f8a24eb4b2f384 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_coss.cc,v 1.7 2000/11/01 03:32:03 wessels Exp $
+ * $Id: store_dir_coss.cc,v 1.8 2000/11/01 03:35:48 wessels Exp $
  *
  * DEBUG: section 81    Store COSS Directory Routines
  * AUTHOR: Eric Stern
@@ -250,9 +250,12 @@ storeCossRebuildFromSwapLog(void *data)
            rb->counts.invalid++;
            continue;
        }
-       if ((++rb->counts.scancount & 0xFFFF) == 0)
-           debug(20, 3) ("  %7d %s Entries read so far.\n",
-               rb->counts.scancount, rb->sd->path);
+       if ((++rb->counts.scancount & 0xFFF) == 0) {
+           struct stat sb;
+           if (0 == fstat(fileno(rb->log), &sb))
+               storeRebuildProgress(SD->index,
+                   (int) sb.st_size / ss, rb->n_read);
+       }
        if (EBIT_TEST(s.flags, KEY_PRIVATE)) {
            rb->counts.badflags++;
            continue;
index 3e705077dbf83f9f257b84622af7bad65484a9ec..a43878312b9d76cb3f7a645f3345880fcff9628d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_diskd.cc,v 1.22 2000/10/31 23:48:18 wessels Exp $
+ * $Id: store_dir_diskd.cc,v 1.23 2000/11/01 03:35:48 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -780,9 +780,12 @@ storeDiskdDirRebuildFromSwapLog(void *data)
            rb->counts.invalid++;
            continue;
        }
-       if ((++rb->counts.scancount & 0xFFFF) == 0)
-           debug(20, 3) ("  %7d %s Entries read so far.\n",
-               rb->counts.scancount, rb->sd->path);
+       if ((++rb->counts.scancount & 0xFFF) == 0) {
+           struct stat sb;
+           if (0 == fstat(fileno(rb->log), &sb))
+               storeRebuildProgress(SD->index,
+                   (int) sb.st_size / ss, rb->n_read);
+       }
        if (!storeDiskdDirValidFileno(SD, s.swap_filen, 0)) {
            rb->counts.invalid++;
            continue;
index 3bc74637e8e6c12bb114c10d83796f508166a65d..9d64aa172fee8ddcf0a0b520165451308aa8c64f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_ufs.cc,v 1.11 2000/10/31 23:48:18 wessels Exp $
+ * $Id: store_dir_ufs.cc,v 1.12 2000/11/01 03:35:49 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -587,9 +587,12 @@ storeUfsDirRebuildFromSwapLog(void *data)
            rb->counts.invalid++;
            continue;
        }
-       if ((++rb->counts.scancount & 0xFFFF) == 0)
-           debug(20, 3) ("  %7d %s Entries read so far.\n",
-               rb->counts.scancount, rb->sd->path);
+       if ((++rb->counts.scancount & 0xFFF) == 0) {
+           struct stat sb;
+           if (0 == fstat(fileno(rb->log), &sb))
+               storeRebuildProgress(SD->index,
+                   (int) sb.st_size / ss, rb->n_read);
+       }
        if (!storeUfsDirValidFileno(SD, s.swap_filen, 0)) {
            rb->counts.invalid++;
            continue;
index e9168a5e9b8a65ac6be6784c65b4df41b17b2c59..e9a0657466f945924318d65fc2f41aa6b12856e2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.384 2000/10/31 23:48:14 wessels Exp $
+ * $Id: protos.h,v 1.385 2000/11/01 03:35:40 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -944,6 +944,7 @@ extern void storeSwapTLVFree(tlv * n);
  */
 extern void storeRebuildStart(void);
 extern void storeRebuildComplete(struct _store_rebuild_data *);
+extern void storeRebuildProgress(int index, int total, int sofar);
 
 /*
  * store_swapin.c
index 5e41e60cade281815578ec025a26aad740d48e79..17678d3f65acae90f0ac27e45ca63efdf05e0f3d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_rebuild.cc,v 1.70 2000/05/03 17:15:44 adrian Exp $
+ * $Id: store_rebuild.cc,v 1.71 2000/11/01 03:35:41 wessels Exp $
  *
  * DEBUG: section 20    Store Rebuild Routines
  * AUTHOR: Duane Wessels
@@ -39,6 +39,15 @@ static struct _store_rebuild_data counts;
 static struct timeval rebuild_start;
 static void storeCleanup(void *);
 
+typedef struct {
+    /* total number of "swap.state" entries that will be read */
+    int total;
+    /* number of entries read so far */
+    int scanned;
+} store_rebuild_progress;
+
+static store_rebuild_progress *RebuildProgress = NULL;
+
 static int
 storeCleanupDoubleCheck(StoreEntry * e)
 {
@@ -134,6 +143,8 @@ storeRebuildComplete(struct _store_rebuild_data *dc)
        (double) counts.objcount / (dt > 0.0 ? dt : 1.0));
     debug(20, 1) ("Beginning Validation Procedure\n");
     eventAdd("storeCleanup", storeCleanup, NULL, 0.0, 1);
+    xfree(RebuildProgress);
+    RebuildProgress = NULL;
 }
 
 /*
@@ -152,4 +163,34 @@ storeRebuildStart(void)
      * finished rebuilding for sure.  The corresponding decrement
      * occurs in storeCleanup(), when it is finished.
      */
+    RebuildProgress = xcalloc(Config.cacheSwap.n_configured,
+       sizeof(store_rebuild_progress));
+}
+
+/*
+ * A fs-specific rebuild procedure periodically reports its
+ * progress.
+ */
+void
+storeRebuildProgress(int index, int total, int sofar)
+{
+    static time_t last_report = 0;
+    double n = 0.0;
+    double d = 0.0;
+    if (index < 0)
+       return;
+    if (index >= Config.cacheSwap.n_configured)
+       return;
+    if (NULL == RebuildProgress)
+       return;
+    RebuildProgress[index].total = total;
+    RebuildProgress[index].scanned = sofar;
+    if (squid_curtime - last_report < 15)
+       return;
+    for (index = 0; index < Config.cacheSwap.n_configured; index++) {
+       n += (double) RebuildProgress[index].scanned;
+       d += (double) RebuildProgress[index].total;
+    }
+    debug(20, 1) ("Store rebuilding is %4.1f%% complete\n", 100.0 * n / d);
+    last_report = squid_curtime;
 }