DAFS: Put back volumes we get in FSSYNC handlers openafs-devel-1_5_64
authorAndrew Deason <adeason@sinenomine.net>
Mon, 21 Sep 2009 16:09:56 +0000 (11:09 -0500)
committerDerrick Brashear <shadow|account-1000005@unknown>
Mon, 21 Sep 2009 16:44:37 +0000 (09:44 -0700)
fssync-server.c has a few issues with not properly VPutVolume_r'ing
volumes that were VGetVolume_r'd. The most important of these was that
the handler for FSYNC_VOL_MOVE can put back a volume it did not get,
when DAFS is enabled.

Fix that, and another erroneous edge case in the FSYNC_VOL_QUERY_HDR
handler when DAFS is not enabled.

Reviewed-on: http://gerrit.openafs.org/477
Tested-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Derrick Brashear <shadow@dementia.org>

src/vol/fssync-server.c

index 482bd24..86bd5fd 100644 (file)
@@ -905,7 +905,9 @@ FSYNC_com_VolMove(FSSYNC_VolOp_command * vcom, SYNC_response * res)
        } else {
            res->hdr.reason = FSYNC_WRONG_PART;
        }
+#ifndef AFS_DEMAND_ATTACH_FS
        VPutVolume_r(vp);
+#endif /* !AFS_DEMAND_ATTACH_FS */
     } else {
        res->hdr.reason = FSYNC_UNKNOWN_VOLID;
     }
@@ -1188,17 +1190,17 @@ FSYNC_com_VolHdrQuery(FSSYNC_VolOp_command * vcom, SYNC_response * res)
                !(V_attachFlags(vp) & VOL_HDR_ATTACHED) ||
                !(V_attachFlags(vp) & VOL_HDR_LOADED)) {
                res->hdr.reason = FSYNC_HDR_NOT_ATTACHED;
-               goto done;
+               goto cleanup;
            }
 #else /* !AFS_DEMAND_ATTACH_FS */
            if (!vp || !vp->header) {
                res->hdr.reason = FSYNC_HDR_NOT_ATTACHED;
-               goto done;
+               goto cleanup;
            }
 #endif /* !AFS_DEMAND_ATTACH_FS */
        } else {
            res->hdr.reason = FSYNC_WRONG_PART;
-           goto done;
+           goto cleanup;
        }
     } else {
        res->hdr.reason = FSYNC_UNKNOWN_VOLID;
@@ -1207,10 +1209,12 @@ FSYNC_com_VolHdrQuery(FSSYNC_VolOp_command * vcom, SYNC_response * res)
 
     memcpy(res->payload.buf, &V_disk(vp), sizeof(VolumeDiskData));
     res->hdr.response_len += sizeof(VolumeDiskData);
+    code = SYNC_OK;
+
+ cleanup:
 #ifndef AFS_DEMAND_ATTACH_FS
     VPutVolume_r(vp);
 #endif
-    code = SYNC_OK;
 
  done:
     return code;