]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
DAFS: Correct FSYNC_VOL_QUERY_VOP checks
authorAndrew Deason <adeason@sinenomine.net>
Thu, 24 Mar 2011 15:22:52 +0000 (10:22 -0500)
committerDerrick Brashear <shadow@dementix.org>
Wed, 2 Nov 2011 02:43:04 +0000 (19:43 -0700)
Check that the given partition matches the vp partition, and ensure
the vp is not in an exclusive state when we check the state.
Otherwise, we may return pending vol ops for a volume on a different
partition, or we may incorrectly return that there is no pending vol
op when in fact the volume does not exist at all.

Reviewed-on: http://gerrit.openafs.org/4308
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit 8234cc254406173a7ada9fb1b4a63ca8aa626bca)

Change-Id: I912c1d0b34fbbaae9ce4bd8edf6e3dd7f718be00
Reviewed-on: http://gerrit.openafs.org/5763
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
src/vol/fssync-server.c

index dfd790d56078ca3bd24a9dd396e68669d1d81b29..616db044541e6c58f8baad0e15c1c71f188120d2 100644 (file)
@@ -1561,10 +1561,20 @@ FSYNC_com_VolOpQuery(FSSYNC_VolOp_command * vcom, SYNC_response * res)
 
     vp = VLookupVolume_r(&error, vcom->vop->volume, NULL);
 
+    if (vp) {
+       VCreateReservation_r(vp);
+       VWaitExclusiveState_r(vp);
+    }
+
     if (vp && vp->pending_vol_op) {
-       osi_Assert(sizeof(FSSYNC_VolOp_info) <= res->payload.len);
-       memcpy(res->payload.buf, vp->pending_vol_op, sizeof(FSSYNC_VolOp_info));
-       res->hdr.response_len += sizeof(FSSYNC_VolOp_info);
+       if (!FSYNC_partMatch(vcom, vp, 1)) {
+           res->hdr.reason = FSYNC_WRONG_PART;
+           code = SYNC_FAILED;
+       } else {
+           osi_Assert(sizeof(FSSYNC_VolOp_info) <= res->payload.len);
+           memcpy(res->payload.buf, vp->pending_vol_op, sizeof(FSSYNC_VolOp_info));
+           res->hdr.response_len += sizeof(FSSYNC_VolOp_info);
+       }
     } else {
        if (!vp || V_attachState(vp) == VOL_STATE_DELETED) {
            res->hdr.reason = FSYNC_UNKNOWN_VOLID;
@@ -1575,6 +1585,10 @@ FSYNC_com_VolOpQuery(FSSYNC_VolOp_command * vcom, SYNC_response * res)
        }
        code = SYNC_FAILED;
     }
+
+    if (vp) {
+       VCancelReservation_r(vp);
+    }
     return code;
 }