From f08c714f8800aaa28177c3d58e7a5641af61d7de Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Mon, 2 Nov 2009 12:19:45 -0600 Subject: [PATCH] DAFS: Avoid SALVSYNC communication during shutdown Avoid trying to contact the salvageserver for any reason while we are shutting down. During shutdown the salvageserver may not be around anymore, so any SALVSYNC communication will appear to hang. Just set a global flag to indicate 'no-SALVSYNC' on shutdown, in addition to the thread-local flag we already have. Change-Id: Id96f20917fd0753b4934a0377b91032b2ea3d0dc Reviewed-on: http://gerrit.openafs.org/765 Tested-by: Andrew Deason Tested-by: Derrick Brashear Reviewed-by: Derrick Brashear --- src/viced/viced.c | 2 ++ src/vol/volume.c | 28 +++++++++++++++++++++++++++- src/vol/volume.h | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/viced/viced.c b/src/viced/viced.c index 3e52e2c33..e16665756 100644 --- a/src/viced/viced.c +++ b/src/viced/viced.c @@ -782,6 +782,8 @@ ShutDownAndCore(int dopanic) * are returned with an error code of RX_RESTARTING ( transient failure ) */ rx_SetRxTranquil(); /* dhruba */ + VSetTranquil(); + #ifdef AFS_DEMAND_ATTACH_FS FS_STATE_WRLOCK; fs_state.mode = FS_MODE_SHUTDOWN; diff --git a/src/vol/volume.c b/src/vol/volume.c index b271e5e06..313cb4256 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -157,6 +157,12 @@ int vol_attach_threads = 1; #ifdef AFS_DEMAND_ATTACH_FS pthread_mutex_t vol_salvsync_mutex; + +/* + * Set this to 1 to disallow SALVSYNC communication in all threads; used + * during shutdown, since the salvageserver may have gone away. + */ +static volatile sig_atomic_t vol_disallow_salvsync = 0; #endif /* AFS_DEMAND_ATTACH_FS */ #ifdef AFS_OSF_ENV @@ -901,6 +907,26 @@ VShutdown(void) VOL_UNLOCK; } +/** + * stop new activity (e.g. SALVSYNC) from occurring + * + * Use this to make the volume package less busy; for example, during + * shutdown. This doesn't actually shutdown/detach anything in the + * volume package, but prevents certain processes from ocurring. For + * example, preventing new SALVSYNC communication in DAFS. In theory, we + * could also use this to prevent new volume attachment, or prevent + * other programs from checking out volumes, etc. + */ +void +VSetTranquil(void) +{ +#ifdef AFS_DEMAND_ATTACH_FS + /* make sure we don't try to contact the salvageserver, since it may + * not be around anymore */ + vol_disallow_salvsync = 1; +#endif +} + #ifdef AFS_DEMAND_ATTACH_FS /* * demand attach fs @@ -4170,7 +4196,7 @@ VScheduleSalvage_r(Volume * vp) if (thread_opts == NULL) { thread_opts = &VThread_defaults; } - if (thread_opts->disallow_salvsync) { + if (thread_opts->disallow_salvsync || vol_disallow_salvsync) { return 1; } diff --git a/src/vol/volume.h b/src/vol/volume.h index 96565bb5f..d1d4d5416 100644 --- a/src/vol/volume.h +++ b/src/vol/volume.h @@ -763,6 +763,7 @@ extern Volume *VAttachVolumeByName(Error * ec, char *partition, char *name, extern Volume *VAttachVolumeByName_r(Error * ec, char *partition, char *name, int mode); extern void VShutdown(void); +extern void VSetTranquil(void); extern void VUpdateVolume(Error * ec, Volume * vp); extern void VUpdateVolume_r(Error * ec, Volume * vp, int flags); extern void VAddToVolumeUpdateList(Error * ec, Volume * vp); -- 2.39.5