---------------------
PatchSet 870 
Date: 2000/11/27 09:50:42
Author: rbcollins
Branch: store_check
Tag: (none) 
Log:
aufs & diskd changes

Members: 
	src/fs/aufs/store_dir_aufs.c:1.5.6.1->1.5.6.2 
	src/fs/diskd/store_dir_diskd.c:1.4.6.1->1.4.6.2 

Index: squid/src/fs/aufs/store_dir_aufs.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/fs/aufs/store_dir_aufs.c,v
retrieving revision 1.5.6.1
retrieving revision 1.5.6.2
diff -u -r1.5.6.1 -r1.5.6.2
--- squid/src/fs/aufs/store_dir_aufs.c	25 Nov 2000 22:34:44 -0000	1.5.6.1
+++ squid/src/fs/aufs/store_dir_aufs.c	27 Nov 2000 09:50:42 -0000	1.5.6.2
@@ -119,7 +119,8 @@
 static int storeAufsDirIs(SwapDir * sd);
 static int storeAufsFilenoBelongsHere(int fn, int F0, int F1, int F2);
 static int storeAufsCleanupDoubleCheck(SwapDir *, StoreEntry *);
-static int storeAufsCheckFile(SwapDir * sd, sfileno filn, size_t swap_file_sz );
+static int storeAufsBackgroundCheck(SwapDir * sd, StoreEntry * e);
+static int storeAufsCheckFile(SwapDir * sd, sfileno filn, size_t swap_file_sz, int debuglevel );
 static void storeAufsDirStats(SwapDir *, StoreEntry *);
 static void storeAufsDirInitBitmap(SwapDir *);
 static int storeAufsDirValidFileno(SwapDir *, sfileno, int);
@@ -526,7 +527,6 @@
     int count;
     int used;			/* is swapfile already in use? */
     int disk_entry_newer;	/* is the log entry newer than current entry? */
-    int file_bad;
     double x;
     assert(rb != NULL);
     /* load a number of objects per invocation */
@@ -612,21 +612,7 @@
 	 * appear to have a newer entry?  Compare 'lastref' from the
 	 * swap log to e->lastref. */
 	disk_entry_newer = e ? (s.lastref > e->lastref ? 1 : 0) : 0;
-        if (!used && (rb->flags.need_to_validate ||
-            (opt_store_doublecheck != DBLCHECK_NONE))){
-            file_bad = storeAufsCheckFile(SD, s.swap_filen, s.swap_file_sz);
-        } else
-            file_bad = 0;
-        if (file_bad){
-            if (file_bad==-2){
-                  if (opt_store_doublecheck == DBLCHECK_FORCE)
-                      storeAufsDirUnlinkFile(SD, s.swap_filen);
-                  rb->counts.filesizemismatchcount++;
-                  continue;
-            }
-            rb->counts.missingcount++;
-            continue;
-	} else if (used && !disk_entry_newer) {
+	if (used && !disk_entry_newer) {
 	    /* log entry is old, ignore it */
 	    rb->counts.clashcount++;
 	    continue;
@@ -1603,33 +1589,56 @@
 static int
 storeAufsCleanupDoubleCheck(SwapDir * sd, StoreEntry * e)
 {
-    int rv= storeAufsCheckFile(sd, e->swap_filen, e->swap_file_sz);
+    int rv= storeAufsCheckFile(sd, e->swap_filen, e->swap_file_sz, 1);
     if (rv) storeEntryDump(e, 0);
     return rv;
 }
 
 /*
+ * storeAufsBackgroundCheck 
+ * 
+ * This is called by storeBackgroundCheck() to perform background consistency 
+ * checking. 
+ */ 
+static int  
+storeAufsBackgroundCheck(SwapDir  * sd, StoreEntry * e) 
+{ 
+    int rv; 
+    /* we shouldn't be called until the rebuild finishes... but who knows? */ 
+    if (store_dirs_rebuilding)  
+        return 0; 
+    rv = storeAufsCheckFile(sd, e->swap_filen, e->swap_file_sz, 3); 
+    
+    if (rv) { 
+        /* the file is faulty - missing or has a size mismatch from the  
+         * in-memory swap.state */ 
+        storeRelease(e); 
+    } 
+    return rv; 
+} 
+
+/*
  * storeAufsCheckFile
  *
  * This is called by storerebuildFromSwapLog if -S was given on the command 
  * line. or a Dirty state is found
  */
 static int
-storeAufsCheckFile(SwapDir * sd, sfileno filen, size_t swap_file_sz )
+storeAufsCheckFile(SwapDir * sd, sfileno filen, size_t swap_file_sz, int debuglevel)
 {
     struct stat sb;
 
     if (stat(storeAufsDirFullPath(sd, filen, NULL), &sb) < 0) {
-        debug(20, 1) ("storeAufsCheckFile: MISSING SWAP FILE\n");
-        debug(20, 1) ("storeAufsCheckFile: FILENO %08X\n", filen);
-        debug(20, 1) ("storeAufsCheckFile: PATH %s\n", storeAufsDirFullPath(sd, filen, NULL));
+        debug(20, debuglevel) ("storeAufsCheckFile: MISSING SWAP FILE\n");
+        debug(20, debuglevel) ("storeAufsCheckFile: FILENO %08X\n", filen);
+        debug(20, debuglevel) ("storeAufsCheckFile: PATH %s\n", storeAufsDirFullPath(sd, filen, NULL));
         return -1;
     }
     if (swap_file_sz != sb.st_size) {
-        debug(20, 1) ("storeAufsCheckFile: SIZE MISMATCH\n");
-        debug(20, 1) ("storeAufsCheckFile: FILENO %08X\n", filen);
-        debug(20, 1) ("storeAufsCheckFile: PATH %s\n", storeAufsDirFullPath(sd, filen, NULL));
-        debug(20, 1) ("storeAufsCheckFile: ENTRY SIZE: %d, FILE SIZE: %d\n", swap_file_sz, (int) sb.st_size);
+        debug(20, debuglevel) ("storeAufsCheckFile: SIZE MISMATCH\n");
+        debug(20, debuglevel) ("storeAufsCheckFile: FILENO %08X\n", filen);
+        debug(20, debuglevel) ("storeAufsCheckFile: PATH %s\n", storeAufsDirFullPath(sd, filen, NULL));
+        debug(20, debuglevel) ("storeAufsCheckFile: ENTRY SIZE: %d, FILE SIZE: %d\n", swap_file_sz, (int) sb.st_size);
         return -2;
     }
     return 0;
@@ -1686,7 +1695,7 @@
     sd->dump = storeAufsDirDump;
     sd->freefs = storeAufsDirFree;
     sd->dblcheck = storeAufsCleanupDoubleCheck;
-    sd->bkgcheck = NULL;
+    sd->bkgcheck = storeAufsBackgroundCheck;
     sd->statfs = storeAufsDirStats;
     sd->maintainfs = storeAufsDirMaintain;
     sd->checkobj = storeAufsDirCheckObj;
Index: squid/src/fs/diskd/store_dir_diskd.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/fs/diskd/store_dir_diskd.c,v
retrieving revision 1.4.6.1
retrieving revision 1.4.6.2
diff -u -r1.4.6.1 -r1.4.6.2
--- squid/src/fs/diskd/store_dir_diskd.c	25 Nov 2000 22:34:45 -0000	1.4.6.1
+++ squid/src/fs/diskd/store_dir_diskd.c	27 Nov 2000 09:50:43 -0000	1.4.6.2
@@ -127,7 +127,8 @@
 static int storeDiskdDirIs(SwapDir * sd);
 static int storeDiskdFilenoBelongsHere(int fn, int F0, int F1, int F2);
 static int storeDiskdCleanupDoubleCheck(SwapDir *, StoreEntry *);
-static int storeDiskdCheckFile(SwapDir * sd, sfileno filn, size_t swap_file_sz);
+static int storeDiskdCheckFile(SwapDir * sd, sfileno filn, size_t swap_file_sz, int debuglevel);
+static int storeDiskdBackgroundCheck(SwapDir * sd, StoreEntry * e);
 static void storeDiskdDirStats(SwapDir *, StoreEntry *);
 static void storeDiskdDirInitBitmap(SwapDir *);
 static int storeDiskdDirValidFileno(SwapDir *, sfileno, int);
@@ -692,7 +693,6 @@
     int count;
     int used;			/* is swapfile already in use? */
     int disk_entry_newer;	/* is the log entry newer than current entry? */
-    int file_bad;
     double x;
     assert(rb != NULL);
     /* load a number of objects per invocation */
@@ -803,21 +803,7 @@
 	 * appear to have a newer entry?  Compare 'lastref' from the
 	 * swap log to e->lastref. */
 	disk_entry_newer = e ? (s.lastref > e->lastref ? 1 : 0) : 0;
-        if (!used && (rb->flags.need_to_validate ||
-            (opt_store_doublecheck != DBLCHECK_NONE))){
-            file_bad = storeDiskdCheckFile(SD, s.swap_filen, s.swap_file_sz);
-        } else
-            file_bad = 0;
-        if (file_bad){
-            if (file_bad==-2){
-                  if (opt_store_doublecheck == DBLCHECK_FORCE)
-                      storeDiskdDirUnlinkFile(SD, s.swap_filen);
-                  rb->counts.filesizemismatchcount++;
-                  continue;
-            }
-            rb->counts.missingcount++;
-            continue;
-       } else if (used && !disk_entry_newer) {
+       if (used && !disk_entry_newer) {
 	    /* log entry is old, ignore it */
 	    rb->counts.clashcount++;
 	    continue;
@@ -1845,33 +1831,58 @@
 static int
 storeDiskdCleanupDoubleCheck(SwapDir * sd, StoreEntry * e)
 {
-    int rv= storeDiskdCheckFile(sd, e->swap_filen, e->swap_file_sz);
+    int rv= storeDiskdCheckFile(sd, e->swap_filen, e->swap_file_sz, 1);
     if (rv) storeEntryDump(e, 0);
     return rv;
 }
 
+
+/*
+ * storeDiskdBackgroundCheck
+ *
+ * This is called by storeBackgroundCheck() to perform background consistency
+ * checking.
+ */
+static int
+storeDiskdBackgroundCheck(SwapDir  * sd, StoreEntry * e)
+{
+    int rv;
+    /* we shouldn't be called until the rebuild finishes... but who knows? */
+    if (store_dirs_rebuilding)
+        return 0;
+    rv = storeAufsCheckFile(sd, e->swap_filen, e->swap_file_sz, 3);
+
+    if (rv) {
+        /* the file is faulty - missing or has a size mismatch from the
+         * in-memory swap.state */
+        storeRelease(e);
+    }
+    return rv;
+}
+
+
 /*
  * storeDiskdCheckFile
  *
  * This is called by storerebuildFromSwapLog if -S was given on the command line * or a Dirty state is found
  */
 static int
-storeDiskdCheckFile(SwapDir * sd, sfileno filen, size_t swap_file_sz )
+storeDiskdCheckFile(SwapDir * sd, sfileno filen, size_t swap_file_sz, int debuglevel)
 {
      struct stat sb;
 
     if (stat(storeDiskdDirFullPath(sd, filen, NULL), &sb) < 0) {
-        debug(20, 1) ("storeDiskdCheckFile: MISSING SWAP FILE\n");
-        debug(20, 1) ("storeDiskdCheckFile: FILENO %08X\n", filen);
-        debug(20, 1) ("storeDiskdCheckFile: PATH %s\n", storeDiskdDirFullPath(sd, filen, NULL));
+        debug(20, debuglevel) ("storeDiskdCheckFile: MISSING SWAP FILE\n");
+        debug(20, debuglevel) ("storeDiskdCheckFile: FILENO %08X\n", filen);
+        debug(20, debuglevel) ("storeDiskdCheckFile: PATH %s\n", storeDiskdDirFullPath(sd, filen, NULL));
 
         return -1;
     }
     if (swap_file_sz != sb.st_size) {
-        debug(20, 1) ("storeDiskdCheckFile: SIZE MISMATCH\n");
-        debug(20, 1) ("storeDiskdCheckFile: FILENO %08X\n", filen);
-        debug(20, 1) ("storeDiskdCheckFile: PATH %s\n", storeDiskdDirFullPath(sd, filen, NULL));
-        debug(20, 1) ("storeDiskdCheckFile: ENTRY SIZE: %d, FILE SIZE: %d\n", swap_file_sz, (int) sb.st_size);
+        debug(20, debuglevel) ("storeDiskdCheckFile: SIZE MISMATCH\n");
+        debug(20, debuglevel) ("storeDiskdCheckFile: FILENO %08X\n", filen);
+        debug(20, debuglevel) ("storeDiskdCheckFile: PATH %s\n", storeDiskdDirFullPath(sd, filen, NULL));
+        debug(20, debuglevel) ("storeDiskdCheckFile: ENTRY SIZE: %d, FILE SIZE: %d\n", swap_file_sz, (int) sb.st_size);
         return -2;
      }
     return 0;
@@ -1937,7 +1948,7 @@
     sd->dump = storeDiskdDirDump;
     sd->freefs = storeDiskdDirFree;
     sd->dblcheck = storeDiskdCleanupDoubleCheck;
-    sd->bkgcheck = NULL;
+    sd->bkgcheck = storeDiskdBackgroundCheck;
     sd->statfs = storeDiskdDirStats;
     sd->maintainfs = storeDiskdDirMaintain;
     sd->checkobj = storeDiskdDirCheckObj;
