Clean up logging from vldb_check.
authorRod Widdowson <rdw@steadingsoftware.com>
Wed, 12 May 2010 14:48:25 +0000 (15:48 +0100)
committerDerrick Brashear <shadow@dementia.org>
Mon, 17 May 2010 12:41:37 +0000 (05:41 -0700)
vldb_check used to say "%<index>: Volume '<name>' <id>not found in <type> hash <hash>" for two sorts of failures

- If the volume really wasn't in a hash chain of that type at all
- If volume's next pointer (for the hash type) pointed to a volume with a different hash.

In both cases it would then print out some confusing (and spurious)
information about the next element in the chain, prior to applying the
same fix (of zeroing the next pointer).

This change fixes the error message.

Change-Id: I5eb6ae1a461628d401b997dde4bab53a0cc7571d
Reviewed-on: http://gerrit.openafs.org/1955
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>

src/vlserver/vldb_check.c

index d04af37..43c37d2 100644 (file)
@@ -1166,6 +1166,7 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
         */
        if (record[i].type & VL) {
            int foundbad = 0;
+           int foundbroken = 0;
            char volidbuf[256];
 
            readentry(record[i].addr, &vlentry, &type);
@@ -1224,7 +1225,7 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
                readentry(nextp, &vlentry2, &type);
                nexthash = NameHash(vlentry2.name);
                if (hash != nexthash)
-                   foundbad = 1;
+                   foundbroken = 1;
            }
 
            if ((record[ADDR(vlentry.nextIdHash[0])].type & MULTRW)) {
@@ -1237,7 +1238,7 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
                readentry(nextp, &vlentry2, &type);
                nexthash = IdHash(vlentry2.volumeId[0]);
                if (hash != nexthash)
-                   foundbad = 1;
+                   foundbroken = 1;
            }
 
            if ((record[ADDR(vlentry.nextIdHash[1])].type & MULTRO)) {
@@ -1250,7 +1251,7 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
                readentry(nextp, &vlentry2, &type);
                nexthash = IdHash(vlentry2.volumeId[1]);
                if (hash != nexthash)
-                   foundbad = 1;
+                   foundbroken = 1;
            }
 
            if ((record[ADDR(vlentry.nextIdHash[2])].type & MULTBK)) {
@@ -1263,30 +1264,28 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
                readentry(nextp, &vlentry2, &type);
                nexthash = IdHash(vlentry2.volumeId[2]);
                if (hash != nexthash)
-                   foundbad = 1;
+                   foundbroken = 1;
            }
 
-           if (foundbad) {
-               log_error(VLDB_CHECK_ERROR,"%d: Volume '%s' %snot found in %s hash %d", i, 
+           if (foundbroken) {
+               log_error(VLDB_CHECK_ERROR, "%d: Volume '%s' %s forward link in %s is broken (hash %d != %d)", i,
+                         vlentry.name, volidbuf, which, hash, nexthash);
+           } else if (foundbad) {
+               log_error(VLDB_CHECK_ERROR, "%d: Volume '%s' %snot found in %s hash %d", i,
                       vlentry.name, volidbuf, which, hash);
-               if (nextp) {
-                   log_error(VLDB_CHECK_ERROR," (next %d", nextp);
-                   if (!(record[nextp].type & reft)) {
-                       log_error(VLDB_CHECK_ERROR," not in chain ");
-                       record[nextp].type |= reft;
-                   } else if (nextp != 0) {
-                       log_error(VLDB_CHECK_ERROR," next in chain");
-                       if (fix) {
-                           log_error(VLDB_CHECK_ERROR,", unchaining");
-                           *nextpp = 0;
-                           writeentry(record[i].addr, &vlentry);
-                       }
-                   }
-                   log_error(VLDB_CHECK_ERROR,")");
+           }
+
+           if (foundbad || foundbroken) {
+               if (nextp && fix) {
+                   log_error(VLDB_CHECK_ERROR, ", unchaining next (%d)\n", nextp);
+                   *nextpp = 0;
+                   writeentry(record[i].addr, &vlentry);
+               } else {
+                   log_error(VLDB_CHECK_ERROR, "\n");
                }
-               log_error(VLDB_CHECK_ERROR,"\n");
+               
            }
-       
+
            for (j = 0; j < NMAXNSERVERS; j++) {
                if ((vlentry.serverNumber[j] != 255)
                    && (serveraddrs[vlentry.serverNumber[j]] == 0)) {