From 713893a2052cdc0ea35c323eabbd6becd387c453 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Wed, 23 Mar 2011 11:07:03 -0500 Subject: [PATCH] DAFS: Do not VDeregisterVolOp_r while exclusive We should wait for a volume to transition out of an exclusive state before calling VDeregisterVolOp_r on a volume, since some code may be examining the vol op outside of VOL_LOCK in an exclusive state. We should be doing this anyway before performing volume state checks, since we may be trying to e.g. attach the volume at the same time. Reviewed-on: http://gerrit.openafs.org/4287 Tested-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Derrick Brashear (cherry picked from commit d4ebebd0c3f89b65e93f0da6d53665271e6d2a61) Change-Id: I55f07806a4e089577252ddb527a86142b10f797d Reviewed-on: http://gerrit.openafs.org/4306 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/vol/fssync-server.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/vol/fssync-server.c b/src/vol/fssync-server.c index edd0910be..ac09b565f 100644 --- a/src/vol/fssync-server.c +++ b/src/vol/fssync-server.c @@ -728,6 +728,10 @@ 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) { + VCreateReservation_r(vp); + VWaitExclusiveState_r(vp); + } if (vp && V_attachState(vp) != VOL_STATE_DELETED) { if (FSYNC_partMatch(vcom, vp, 1)) { if ((V_attachState(vp) == VOL_STATE_UNATTACHED) || @@ -746,6 +750,11 @@ FSYNC_com_VolOn(FSSYNC_VolOp_command * vcom, SYNC_response * res) code = SYNC_FAILED; res->hdr.reason = FSYNC_UNKNOWN_VOLID; } + + if (vp) { + VCancelReservation_r(vp); + vp = NULL; + } #endif goto done; } @@ -756,7 +765,11 @@ FSYNC_com_VolOn(FSSYNC_VolOp_command * vcom, SYNC_response * res) vcom->vop->partName, vcom->vop->volume); if (vp) { + VCreateReservation_r(vp); + VWaitExclusiveState_r(vp); VDeregisterVolOp_r(vp); + VCancelReservation_r(vp); + vp = NULL; } #else /* !AFS_DEMAND_ATTACH_FS */ tvolName[0] = OS_DIRSEPC; @@ -1060,15 +1073,18 @@ FSYNC_com_VolOff(FSSYNC_VolOp_command * vcom, SYNC_response * res) } #ifdef AFS_DEMAND_ATTACH_FS + VCreateReservation_r(vp); VOfflineForVolOp_r(&error, vp, "A volume utility is running."); if (error==0) { osi_Assert(vp->nUsers==0); vp->pending_vol_op->vol_op_state = FSSYNC_VolOpRunningOffline; } else { + VWaitExclusiveState_r(vp); VDeregisterVolOp_r(vp); code = SYNC_DENIED; } + VCancelReservation_r(vp); #else VOffline_r(vp, "A volume utility is running."); #endif @@ -1219,6 +1235,9 @@ FSYNC_com_VolDone(FSSYNC_VolOp_command * vcom, SYNC_response * res) if (vp) { if (FSYNC_partMatch(vcom, vp, 1)) { #ifdef AFS_DEMAND_ATTACH_FS + VCreateReservation_r(vp); + VWaitExclusiveState_r(vp); + if ((V_attachState(vp) == VOL_STATE_UNATTACHED) || (V_attachState(vp) == VOL_STATE_PREATTACHED) || VIsErrorState(V_attachState(vp))) { @@ -1240,6 +1259,9 @@ FSYNC_com_VolDone(FSSYNC_VolOp_command * vcom, SYNC_response * res) code = SYNC_DENIED; res->hdr.reason = FSYNC_BAD_STATE; } + + VCancelReservation_r(vp); + vp = NULL; #else /* AFS_DEMAND_ATTACH_FS */ if (!vp->specialStatus) { vp->specialStatus = VNOVOL; @@ -1318,6 +1340,9 @@ FSYNC_com_VolError(FSSYNC_VolOp_command * vcom, SYNC_response * res) if (FSYNC_partMatch(vcom, vp, 0)) { /* null out salvsync control state, as it's no longer relevant */ memset(&vp->salvage, 0, sizeof(vp->salvage)); + + VCreateReservation_r(vp); + VWaitExclusiveState_r(vp); VDeregisterVolOp_r(vp); if (vcom->hdr->reason == FSYNC_SALVAGE) { @@ -1326,6 +1351,9 @@ FSYNC_com_VolError(FSSYNC_VolOp_command * vcom, SYNC_response * res) VChangeState_r(vp, VOL_STATE_ERROR); } + VCancelReservation_r(vp); + vp = NULL; + code = SYNC_OK; } else { res->hdr.reason = FSYNC_WRONG_PART; -- 2.39.5