From: Andrew Deason Date: Wed, 23 Mar 2011 16:07:03 +0000 (-0500) Subject: DAFS: Do not VDeregisterVolOp_r while exclusive X-Git-Tag: openafs-devel-1_7_1~766 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=d4ebebd0c3f89b65e93f0da6d53665271e6d2a61 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. Change-Id: I3a5b78b7c0033887a973ce941ced592df8c4bf3d Reviewed-on: http://gerrit.openafs.org/4287 Tested-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/vol/fssync-server.c b/src/vol/fssync-server.c index bec018d..4126afd 100644 --- a/src/vol/fssync-server.c +++ b/src/vol/fssync-server.c @@ -727,6 +727,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) || @@ -745,6 +749,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; } @@ -755,7 +764,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; @@ -1059,15 +1072,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 @@ -1218,6 +1234,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))) { @@ -1239,6 +1258,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; @@ -1317,6 +1339,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) { @@ -1325,6 +1350,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;