vldb_check: rebuild free list with -fix
[openafs.git] / src / vlserver / vldb_check.c
index 33938b9..0a9d2e0 100644 (file)
@@ -1429,8 +1429,9 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
 
     if (fix) {
        /*
-        * If we are fixing we will rebuild all the hash lists from the ground up
+        * If we are fixing we will rebuild the free and hash lists from the ground up.
         */
+       header.vital_header.freePtr = 0;
        memcpy(oldnamehash, header.VolnameHash, sizeof(oldnamehash));
        memset(header.VolnameHash, 0, sizeof(header.VolnameHash));
 
@@ -1585,6 +1586,18 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
                }
                writeMH(record[i].addr, block, MHblock);
            }
+       } else if (record[i].type & FR) {
+           if (fix) {
+               readentry(record[i].addr, &vlentry, &type);
+               vlentry.nextIdHash[0] = header.vital_header.freePtr;
+               header.vital_header.freePtr = record[i].addr;
+               if ((record[i].type & FRC) == 0) {
+                   quiet_println
+                       ("FIX: Putting free entry on the free chain: addr=%lu (offset 0x%0x)\n",
+                        record[i].addr, OFFSET(record[i].addr));
+               }
+               writeentry(record[i].addr, &vlentry);
+           }
        }
     }
     if (fix) {