From: wessels <> Date: Wed, 1 Nov 2000 10:35:40 +0000 (+0000) Subject: DW: X-Git-Tag: SQUID_3_0_PRE1~1799 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=5a797987070da7fcd833c6679c46c222ac46d89c;p=thirdparty%2Fsquid.git DW: - Replaced "xxx Entries read so far" messages with a global, friendlier "Store rebuilding is XX% complete" message. --- diff --git a/src/fs/aufs/store_dir_aufs.cc b/src/fs/aufs/store_dir_aufs.cc index 392a0af8b0..0a63ce2846 100644 --- a/src/fs/aufs/store_dir_aufs.cc +++ b/src/fs/aufs/store_dir_aufs.cc @@ -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(); diff --git a/src/fs/coss/store_dir_coss.cc b/src/fs/coss/store_dir_coss.cc index 166778b1a2..5bc928dbce 100644 --- a/src/fs/coss/store_dir_coss.cc +++ b/src/fs/coss/store_dir_coss.cc @@ -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; diff --git a/src/fs/diskd/store_dir_diskd.cc b/src/fs/diskd/store_dir_diskd.cc index 3e705077db..a43878312b 100644 --- a/src/fs/diskd/store_dir_diskd.cc +++ b/src/fs/diskd/store_dir_diskd.cc @@ -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; diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index 3bc74637e8..9d64aa172f 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -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; diff --git a/src/protos.h b/src/protos.h index e9168a5e9b..e9a0657466 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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 diff --git a/src/store_rebuild.cc b/src/store_rebuild.cc index 5e41e60cad..17678d3f65 100644 --- a/src/store_rebuild.cc +++ b/src/store_rebuild.cc @@ -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; }