From: Andrew Deason Date: Thu, 17 Dec 2009 19:59:57 +0000 (-0600) Subject: DAFS: avoid saving fileserver state when panicing X-Git-Tag: openafs-devel-1_5_69~37 X-Git-Url: http://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=7c24f660474dea82a96e6c65883e53c9ad77379f DAFS: avoid saving fileserver state when panicing When ShutDownAndCore is called with dopanic=1, avoid trying to save fileserver state. When we are panic'ing it is very possible that the thread that called ShutDownAndCore is one of the background threads we are waiting for, or that the calling thread is holding H_LOCK. Since we are panicing, the fileserver state is probably not consistent anyway, so just avoid trying to save state altogether, and avoid a possible deadlock. Change-Id: If727808bfdfda74a4ec0e65b27ef9c77fbee4aae Reviewed-on: http://gerrit.openafs.org/997 Tested-by: Andrew Deason Reviewed-by: Derrick Brashear --- diff --git a/src/viced/viced.c b/src/viced/viced.c index a2c0478..80c3a94 100644 --- a/src/viced/viced.c +++ b/src/viced/viced.c @@ -848,22 +848,27 @@ ShutDownAndCore(int dopanic) * demand attach fs * save fileserver state to disk */ - /* make sure background threads have finished all of their asynchronous - * work on host and callback structures */ - FS_STATE_RDLOCK; - while (!fs_state.FiveMinuteLWP_tranquil || - !fs_state.HostCheckLWP_tranquil || - !fs_state.FsyncCheckLWP_tranquil) { - FS_LOCK; - FS_STATE_UNLOCK; - ViceLog(0, ("waiting for background host/callback threads to quiesce before saving fileserver state...\n")); - assert(pthread_cond_wait(&fs_state.worker_done_cv, &fileproc_glock_mutex) == 0); - FS_UNLOCK; + if (dopanic) { + ViceLog(0, ("Not saving fileserver state; abnormal shutdown\n")); + + } else { + /* make sure background threads have finished all of their asynchronous + * work on host and callback structures */ FS_STATE_RDLOCK; - } + while (!fs_state.FiveMinuteLWP_tranquil || + !fs_state.HostCheckLWP_tranquil || + !fs_state.FsyncCheckLWP_tranquil) { + FS_LOCK; + FS_STATE_UNLOCK; + ViceLog(0, ("waiting for background host/callback threads to quiesce before saving fileserver state...\n")); + assert(pthread_cond_wait(&fs_state.worker_done_cv, &fileproc_glock_mutex) == 0); + FS_UNLOCK; + FS_STATE_RDLOCK; + } - /* ok. it should now be fairly safe. let's do the state dump */ - fs_stateSave(); + /* ok. it should now be fairly safe. let's do the state dump */ + fs_stateSave(); + } } #endif /* AFS_DEMAND_ATTACH_FS */