From 372cf44895b368b12add5fcb9715754bbcee5599 Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Wed, 1 Dec 2010 15:23:11 -0500 Subject: [PATCH] unix: giveupallcallbacks at shutdown just try to give up callbacks at shutdown. at this point if you're running 1.4.5 or older, you're sad anyway. Reviewed-on: http://gerrit.openafs.org/3404 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Derrick Brashear (cherry picked from commit cee2c677d7de66a510d05978e3b41dcd5d8aca78) Change-Id: I56e6b9e0e5f2921126a468854a1735b257e05219 Reviewed-on: http://gerrit.openafs.org/6272 Tested-by: BuildBot Tested-by: Andrew Deason Tested-by: Stephan Wiesand Reviewed-by: Benjamin Kaduk Reviewed-by: Andrew Deason Reviewed-by: Stephan Wiesand --- src/afs/afs_vcache.c | 48 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c index 9d3a11482..d18f4e50f 100644 --- a/src/afs/afs_vcache.c +++ b/src/afs/afs_vcache.c @@ -350,6 +350,39 @@ afs_FreeCBR(struct afs_cbr *asp) return 0; } +static void +FlushAllVCBs(int nconns, struct rx_connection **rxconns, + struct afs_conn **conns) +{ + afs_int32 *results; + afs_int32 i; + + results = afs_osi_Alloc(nconns * sizeof (afs_int32)); + osi_Assert(results != NULL); + + AFS_GUNLOCK(); + multi_Rx(rxconns,nconns) + { + multi_RXAFS_GiveUpAllCallBacks(); + results[multi_i] = multi_error; + } multi_End; + AFS_GLOCK(); + + /* + * Freeing the CBR will unlink it from the server's CBR list + * do it here, not in the loop, because a dynamic CBR will call + * into the memory management routines. + */ + for ( i = 0 ; i < nconns ; i++ ) { + if (results[i] == 0) { + /* Unchain all of them */ + while (conns[i]->srvr->server->cbrs) + afs_FreeCBR(conns[i]->srvr->server->cbrs); + } + } + afs_osi_Free(results, nconns * sizeof(afs_int32)); +} + /*! * Flush all queued callbacks to all servers. * @@ -374,6 +407,10 @@ afs_FlushVCBs(afs_int32 lockit) struct afs_conn *tc; int safety1, safety2, safety3; XSTATS_DECLS; + + if (AFS_IS_DISCONNECTED) + return ENETDOWN; + if ((code = afs_InitReq(&treq, afs_osi_credp))) return code; treq.flags |= O_NONBLOCK; @@ -382,6 +419,15 @@ afs_FlushVCBs(afs_int32 lockit) if (lockit) ObtainWriteLock(&afs_xvcb, 273); + /* + * Shutting down. + * First, attempt a multi across everything, all addresses + * for all servers we know of. + */ + + if (lockit == 2) + afs_LoopServers(2, NULL, 0, FlushAllVCBs, NULL); + ObtainReadLock(&afs_xserver); for (i = 0; i < NSERVERS; i++) { for (safety1 = 0, tsp = afs_servers[i]; @@ -3116,7 +3162,7 @@ afs_DisconGiveUpCallbacks(void) ReleaseWriteLock(&afs_xvcache); - afs_FlushVCBs(1); + afs_FlushVCBs(2); } /*! -- 2.39.5