vol-salvage: VOL_DONE deleted volumes
[openafs.git] / src / vol / fssync-server.c
index 56bac3c..bec018d 100644 (file)
@@ -727,7 +727,7 @@ FSYNC_com_VolOn(FSSYNC_VolOp_command * vcom, SYNC_response * res)
     if (vcom->hdr->command == FSYNC_VOL_LEAVE_OFF) {
        /* nothing much to do if we're leaving the volume offline */
 #ifdef AFS_DEMAND_ATTACH_FS
-       if (vp) {
+       if (vp && V_attachState(vp) != VOL_STATE_DELETED) {
            if (FSYNC_partMatch(vcom, vp, 1)) {
                if ((V_attachState(vp) == VOL_STATE_UNATTACHED) ||
                    (V_attachState(vp) == VOL_STATE_PREATTACHED)) {
@@ -758,7 +758,7 @@ FSYNC_com_VolOn(FSSYNC_VolOp_command * vcom, SYNC_response * res)
        VDeregisterVolOp_r(vp);
     }
 #else /* !AFS_DEMAND_ATTACH_FS */
-    tvolName[0] = '/';
+    tvolName[0] = OS_DIRSEPC;
     snprintf(&tvolName[1], sizeof(tvolName)-1, VFORMAT, afs_printable_uint32_lu(vcom->vop->volume));
     tvolName[sizeof(tvolName)-1] = '\0';
 
@@ -1008,8 +1008,8 @@ FSYNC_com_VolOff(FSSYNC_VolOp_command * vcom, SYNC_response * res)
                 break;
             }
 
-           Log("FSYNC_com_VolOff: failed to get heavyweight reference to volume %u\n",
-               vcom->vop->volume);
+           Log("FSYNC_com_VolOff: failed to get heavyweight reference to volume %u (state=%u, flags=0x%x)\n",
+               vcom->vop->volume, V_attachState(vp), V_attachFlags(vp));
            res->hdr.reason = FSYNC_VOL_PKG_ERROR;
            goto deny;
        } else if (nvp != vp) {
@@ -1219,7 +1219,8 @@ FSYNC_com_VolDone(FSSYNC_VolOp_command * vcom, SYNC_response * res)
        if (FSYNC_partMatch(vcom, vp, 1)) {
 #ifdef AFS_DEMAND_ATTACH_FS
            if ((V_attachState(vp) == VOL_STATE_UNATTACHED) ||
-               (V_attachState(vp) == VOL_STATE_PREATTACHED)) {
+               (V_attachState(vp) == VOL_STATE_PREATTACHED) ||
+               VIsErrorState(V_attachState(vp))) {
 
                /* Change state to DELETED, not UNATTACHED, so clients get
                 * a VNOVOL error when they try to access from now on. */
@@ -1227,6 +1228,9 @@ FSYNC_com_VolDone(FSSYNC_VolOp_command * vcom, SYNC_response * res)
                VChangeState_r(vp, VOL_STATE_DELETED);
                VDeregisterVolOp_r(vp);
 
+               /* Volume is gone; clear out old salvage stats */
+               memset(&vp->salvage, 0, sizeof(vp->salvage));
+
                /* Someday we should free the vp, too, after about 2 hours,
                 * possibly by putting the vp back on the VLRU. */
 
@@ -1934,7 +1938,7 @@ FSYNC_Drop(osi_socket fd)
 
            Volume *vp;
 
-           tvolName[0] = '/';
+           tvolName[0] = OS_DIRSEPC;
            sprintf(&tvolName[1], VFORMAT, afs_printable_uint32_lu(p[i].volumeID));
            vp = VAttachVolumeByName_r(&error, p[i].partName, tvolName,
                                       V_VOLUPD);