From 5c2e87190c9d36898831a400d9146ac533a8d844 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 24 Mar 2011 10:22:52 -0500 Subject: [PATCH] DAFS: Correct FSYNC_VOL_QUERY_VOP checks 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 Reviewed-by: Derrick Brashear (cherry picked from commit 8234cc254406173a7ada9fb1b4a63ca8aa626bca) Change-Id: I912c1d0b34fbbaae9ce4bd8edf6e3dd7f718be00 Reviewed-on: http://gerrit.openafs.org/5763 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/vol/fssync-server.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/vol/fssync-server.c b/src/vol/fssync-server.c index dfd790d56..616db0445 100644 --- a/src/vol/fssync-server.c +++ b/src/vol/fssync-server.c @@ -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; } -- 2.39.5