Robert Collins wrote:
> The patch changes the code to
> *remove missing cache files from the swap state
> *remove and unlink from disk files with inconsistent lengths
>
> and then debug the number of errors found at the end of validation.
>
> It hasn't been tested in large scale production caches however. I have
> checked it does the job in small scale stuff.
The odd thing is that the cache validation procedure done after startup
is supposed to be doing this on a dirty startup if I remember the
correctly, and the -S option is supposed to run this in a strict mode
trapping errors to allow them to be diagnosed...
So I think that the real bug is that the current Squids does not
actually validate the cache content on dirty startups, not that the -S
option asserts.
Please correct me if I am wrong here.
/Henrik
Index: squid/src/globals.h
diff -u squid/src/globals.h:1.36 squid/src/globals.h:1.37
--- squid/src/globals.h:1.36 Tue Feb 10 22:44:33 1998
+++ squid/src/globals.h Fri Feb 13 00:35:58 1998
@@ -60,6 +60,7 @@
extern int opt_syslog_enable; /* 0 */
extern int opt_udp_hit_obj; /* 0 */
extern int opt_create_swap_dirs; /* 0 */
+extern int opt_store_doublecheck; /* 0 */
extern int syslog_enable; /* 0 */
extern int theInIcpConnection; /* -1 */
extern int theOutIcpConnection; /* -1 */
Index: squid/src/main.c
diff -u squid/src/main.c:1.217 squid/src/main.c:1.218
--- squid/src/main.c:1.217 Tue Feb 10 23:28:57 1998
+++ squid/src/main.c Fri Feb 13 00:35:59 1998
@@ -167,7 +167,7 @@
extern char *optarg;
int c;
- while ((c = getopt(argc, argv, "CDFNRVYXa:df:hk:m:su:vz?")) != -1) {
+ while ((c = getopt(argc, argv, "CDFNRSVYXa:df:hk:m:su:vz?")) != -1) {
switch (c) {
case 'C':
opt_catch_signals = 0;
@@ -183,6 +183,9 @@
break;
case 'R':
opt_reuseaddr = 0;
+ break;
+ case 'S':
+ opt_store_doublecheck = 1;
break;
case 'V':
vhost_mode = 1;
Index: squid/src/store_rebuild.c
diff -u squid/src/store_rebuild.c:1.15 squid/src/store_rebuild.c:1.17
--- squid/src/store_rebuild.c:1.15 Thu Feb 12 08:03:07 1998
+++ squid/src/store_rebuild.c Fri Feb 13 00:46:14 1998
@@ -517,6 +536,7 @@
{
static int bucketnum = -1;
static int validnum = 0;
+ static int store_errors = 0;
StoreEntry *e;
hash_link *link_ptr = NULL;
if (++bucketnum >= store_hash_buckets) {
@@ -524,6 +544,8 @@
debug(20, 1) (" Validated %d Entries\n", validnum);
debug(20, 1) (" store_swap_size = %dk\n", store_swap_size);
store_rebuilding = 0;
+ if (opt_store_doublecheck)
+ assert(store_errors == 0);
return;
}
link_ptr = hash_get_bucket(store_table, bucketnum);
@@ -532,44 +554,47 @@
if (EBIT_TEST(e->flag, ENTRY_VALIDATED))
continue;
if (e->swap_file_number < 0)
continue;
-#if STORE_DOUBLECHECK
- {
+ }
+ if (opt_store_doublecheck) {
struct stat sb;
if (stat(storeSwapFullPath(e->swap_file_number, NULL), &sb) < 0) {
+ store_errors++;
debug(0, 0) ("storeCleanup: MISSING SWAP FILE\n");
debug(0, 0) ("storeCleanup: FILENO %08X\n", e->swap_file_number);
debug(0, 0) ("storeCleanup: PATH %s\n",
storeSwapFullPath(e->swap_file_number, NULL));
storeEntryDump(e, 0);
- assert(0);
+ continue;
}
+ if (e->swap_file_sz != sb.st_size) {
+ store_errors++;
+ debug(0, 0) ("storeCleanup: SIZE MISMATCH\n");
+ debug(0, 0) ("storeCleanup: FILENO %08X\n", e->swap_file_number);
+ debug(0, 0) ("storeCleanup: PATH %s\n",
+ storeSwapFullPath(e->swap_file_number, NULL));
+ debug(0, 0) ("storeCleanup: ENTRY SIZE: %d, FILE SIZE: %d\n",
+ e->swap_file_sz, sb.st_size);
+ storeEntryDump(e, 0);
+ continue;
+ }
}
-#endif
EBIT_SET(e->flag, ENTRY_VALIDATED);
/* Only set the file bit if we know its a valid entry */
/* otherwise, set it in the validation procedure */
storeDirUpdateSwapSize(e->swap_file_number, e->swap_file_sz, 1);
if ((++validnum & 0xFFFF) == 0)
debug(20, 1) (" %7d Entries Validated so far.\n", validnum);
- assert(validnum <= memInUse(MEM_STOREENTRY));
}
eventAdd("storeCleanup", storeCleanup, NULL, 0);
}
Received on Fri Oct 20 2000 - 00:55:24 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:51 MST