/*
- * $Id: store_rebuild.cc,v 1.63 1999/05/25 07:02:00 wessels Exp $
+ * $Id: store_rebuild.cc,v 1.64 1999/05/26 04:58:52 wessels Exp $
*
* DEBUG: section 20 Store Rebuild Routines
* AUTHOR: Duane Wessels
static struct timeval rebuild_start;
static void storeCleanup(void *);
+static int
+storeCleanupDoubleCheck(const StoreEntry * e)
+{
+ /* XXX too UFS specific */
+ struct stat sb;
+ int dirn = e->swap_file_number >> SWAP_DIR_SHIFT;
+ if (Config.cacheSwap.swapDirs[dirn].type == SWAPDIR_UFS)
+ (void) 0;
+ if (Config.cacheSwap.swapDirs[dirn].type == SWAPDIR_UFS_ASYNC)
+ (void) 0;
+ else
+ return 0;
+ if (stat(storeUfsFullPath(e->swap_file_number, NULL), &sb) < 0) {
+ debug(20, 0) ("storeCleanup: MISSING SWAP FILE\n");
+ debug(20, 0) ("storeCleanup: FILENO %08X\n", e->swap_file_number);
+ debug(20, 0) ("storeCleanup: PATH %s\n",
+ storeUfsFullPath(e->swap_file_number, NULL));
+ storeEntryDump(e, 0);
+ return -1;
+ }
+ if (e->swap_file_sz != sb.st_size) {
+ debug(20, 0) ("storeCleanup: SIZE MISMATCH\n");
+ debug(20, 0) ("storeCleanup: FILENO %08X\n", e->swap_file_number);
+ debug(20, 0) ("storeCleanup: PATH %s\n",
+ storeUfsFullPath(e->swap_file_number, NULL));
+ debug(20, 0) ("storeCleanup: ENTRY SIZE: %d, FILE SIZE: %d\n",
+ e->swap_file_sz, (int) sb.st_size);
+ storeEntryDump(e, 0);
+ return -1;
+ }
+ return 0;
+}
+
static void
storeCleanup(void *datanotused)
{
static int bucketnum = -1;
static int validnum = 0;
static int store_errors = 0;
+ int validnum_start;
StoreEntry *e;
hash_link *link_ptr = NULL;
hash_link *link_next = NULL;
- if (++bucketnum >= store_hash_buckets) {
- debug(20, 1) (" Completed Validation Procedure\n");
- debug(20, 1) (" Validated %d Entries\n", validnum);
- debug(20, 1) (" store_swap_size = %dk\n", store_swap_size);
- store_dirs_rebuilding--;
- assert(0 == store_dirs_rebuilding);
- if (opt_store_doublecheck)
- assert(store_errors == 0);
- if (store_digest)
- storeDigestNoteStoreReady();
- return;
- }
- link_next = hash_get_bucket(store_table, bucketnum);
- while (NULL != (link_ptr = link_next)) {
- link_next = link_ptr->next;
- e = (StoreEntry *) link_ptr;
- if (EBIT_TEST(e->flags, ENTRY_VALIDATED))
- continue;
- /*
- * Calling storeRelease() has no effect because we're
- * still in 'store_rebuilding' state
- */
- if (e->swap_file_number < 0)
- continue;
- if (opt_store_doublecheck) {
- /* XXX too UFS specific */
- struct stat sb;
- int dirn = e->swap_file_number >> SWAP_DIR_SHIFT;
- if (Config.cacheSwap.swapDirs[dirn].type == SWAPDIR_UFS)
- (void) 0;
- else if (Config.cacheSwap.swapDirs[dirn].type == SWAPDIR_UFS_ASYNC)
- (void) 0;
- else
- continue;
- if (stat(storeUfsFullPath(e->swap_file_number, NULL), &sb) < 0) {
- store_errors++;
- debug(20, 0) ("storeCleanup: MISSING SWAP FILE\n");
- debug(20, 0) ("storeCleanup: FILENO %08X\n", e->swap_file_number);
- debug(20, 0) ("storeCleanup: PATH %s\n",
- storeUfsFullPath(e->swap_file_number, NULL));
- storeEntryDump(e, 0);
+ validnum_start = validnum;
+ while (validnum - validnum_start < 50) {
+ if (++bucketnum >= store_hash_buckets) {
+ debug(20, 1) (" Completed Validation Procedure\n");
+ debug(20, 1) (" Validated %d Entries\n", validnum);
+ debug(20, 1) (" store_swap_size = %dk\n", store_swap_size);
+ store_dirs_rebuilding--;
+ assert(0 == store_dirs_rebuilding);
+ if (opt_store_doublecheck)
+ assert(store_errors == 0);
+ if (store_digest)
+ storeDigestNoteStoreReady();
+ return;
+ }
+ link_next = hash_get_bucket(store_table, bucketnum);
+ while (NULL != (link_ptr = link_next)) {
+ link_next = link_ptr->next;
+ e = (StoreEntry *) link_ptr;
+ if (EBIT_TEST(e->flags, ENTRY_VALIDATED))
continue;
- }
- if (e->swap_file_sz != sb.st_size) {
- store_errors++;
- debug(20, 0) ("storeCleanup: SIZE MISMATCH\n");
- debug(20, 0) ("storeCleanup: FILENO %08X\n", e->swap_file_number);
- debug(20, 0) ("storeCleanup: PATH %s\n",
- storeUfsFullPath(e->swap_file_number, NULL));
- debug(20, 0) ("storeCleanup: ENTRY SIZE: %d, FILE SIZE: %d\n",
- e->swap_file_sz, (int) sb.st_size);
- storeEntryDump(e, 0);
+ /*
+ * Calling storeRelease() has no effect because we're
+ * still in 'store_rebuilding' state
+ */
+ if (e->swap_file_number < 0)
continue;
- }
+ if (opt_store_doublecheck)
+ if (storeCleanupDoubleCheck(e))
+ store_errors++;
+ EBIT_SET(e->flags, 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);
}
- EBIT_SET(e->flags, 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);
}
eventAdd("storeCleanup", storeCleanup, NULL, 0.0, 1);
}