From d5d2d00a47cf53054bd18d7404be26bea34cba6f Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Wed, 30 Nov 2011 17:35:56 -0600 Subject: [PATCH] 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. Change-Id: I7776b933599ec0488941ccbd9a8e1279f5a552f4 Reviewed-on: http://gerrit.openafs.org/6167 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/vol/fssync-server.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/vol/fssync-server.c b/src/vol/fssync-server.c index d8f274c..14d2247 100644 --- a/src/vol/fssync-server.c +++ b/src/vol/fssync-server.c @@ -751,10 +751,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); -- 1.9.4