From 3f101a9ef49dbb31f516d08b82c716548b66882e Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Wed, 14 Apr 2010 18:33:47 -0400 Subject: [PATCH] drop afs_xserver lock during GetCapabilities new contact to a fileserver can trigger an InitCallBackStateN RPC to us, which our agent will need afs_xserver to handle. don't hold it; we only need it to fill in capabilities. racing here is ok. Change-Id: Ie0aaea3ab462e421bd31ba3b703d8cd0cb0d61df Reviewed-on: http://gerrit.openafs.org/1754 Reviewed-by: Marc Dionne Tested-by: Marc Dionne Reviewed-by: Andrew Deason Tested-by: Andrew Deason Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/afs/afs_server.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/afs/afs_server.c b/src/afs/afs_server.c index 01e81a4af1..6b4a02c08e 100644 --- a/src/afs/afs_server.c +++ b/src/afs/afs_server.c @@ -1703,12 +1703,18 @@ afs_GetCapabilities(struct server *ts) SHARED_LOCK); if ( !tc ) return; + /* InitCallBackStateN, triggered by our RPC, may need this */ + ReleaseWriteLock(&afs_xserver); code = RXAFS_GetCapabilities(tc->id, &caps); - if ( code && code != RXGEN_OPCODE ) - afs_warn("RXAFS_GetCapabilities failed with code %d\n", code); - else - ts->flags |= SCAPS_KNOWN; + ObtainWriteLock(&afs_xserver, 723); afs_PutConn(tc, SHARED_LOCK); + if ( code && code != RXGEN_OPCODE ) { + afs_warn("RXAFS_GetCapabilities failed with code %d\n", code); + /* better not be anything to free. we failed! */ + return; + } + + ts->flags |= SCAPS_KNOWN; if ( caps.Capabilities_len > 0 ) { ts->capabilities = caps.Capabilities_val[0]; @@ -1919,10 +1925,11 @@ afs_GetServer(afs_uint32 * aserverp, afs_int32 nservers, afs_int32 acell, afs_stats_cmperf.srvRecordsHWM = afs_stats_cmperf.srvRecords; } + ReleaseWriteLock(&afs_xsrvAddr); + if ( aport == AFS_FSPORT && !(newts->flags & SCAPS_KNOWN)) afs_GetCapabilities(newts); - ReleaseWriteLock(&afs_xsrvAddr); ReleaseWriteLock(&afs_xserver); return (newts); } /* afs_GetServer */