DAFS: Avoid unnecessary preattach on FSYNC_VOL_ON

FSYNC_VOL_ON/FSYNC_VOL_ATTACH can be called to "online" a volume that
was actually kept online for the duration of the volume operation.
Avoid calling VPreAttachVolumeByVp_r for such a volume if it's already
attached, in order to avoid an unnecessary log message and to save a
tiny bit of processing.

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

Change-Id: I2a7f4b214176570e787978dbe0aa2eb8dc57730f
Reviewed-on: http://gerrit.openafs.org/6323
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
This commit is contained in:
Andrew Deason 2011-11-30 17:35:56 -06:00 committed by Derrick Brashear
parent c5f26e035b
commit 4868585c2e

View File

@ -771,10 +771,25 @@ FSYNC_com_VolOn(FSSYNC_VolOp_command * vcom, SYNC_response * res)
}
#ifdef AFS_DEMAND_ATTACH_FS
/* first, check to see whether we have such a volume defined */
vp = VPreAttachVolumeById_r(&error,
vcom->vop->partName,
vcom->vop->volume);
if (vp &&
FSYNC_partMatch(vcom, vp, 0) &&
vp->pending_vol_op &&
vp->pending_vol_op->vol_op_state == FSSYNC_VolOpRunningOnline &&
V_attachState(vp) == VOL_STATE_ATTACHED) {
/* noop; the volume stayed online for the volume operation and we were
* simply told that the vol op is done. The vp we already have is fine,
* so avoid confusing volume routines with trying to preattach an
* attached volume. */
} else {
/* first, check to see whether we have such a volume defined */
vp = VPreAttachVolumeById_r(&error,
vcom->vop->partName,
vcom->vop->volume);
}
if (vp) {
VCreateReservation_r(vp);
VWaitExclusiveState_r(vp);