mirror of
https://git.openafs.org/openafs.git
synced 2025-01-22 08:50:17 +00:00
linux-cleanup-rx-cv-locking-20020725
cleanup wait queue usage grab glock before mutex (like all other ports)
This commit is contained in:
parent
0f4021128e
commit
fc71eb6e25
@ -63,11 +63,20 @@ void afs_mutex_exit(afs_kmutex_t *l)
|
||||
* CV_WAIT and CV_TIMEDWAIT rely on the fact that the Linux kernel has
|
||||
* a global lock. Thus we can safely drop our locks before calling the
|
||||
* kernel sleep services.
|
||||
* Or not.
|
||||
*/
|
||||
int afs_cv_wait(afs_kcondvar_t *cv, afs_kmutex_t *l, int sigok)
|
||||
{
|
||||
int isAFSGlocked = ISAFS_GLOCK();
|
||||
sigset_t saved_set;
|
||||
#ifdef DECLARE_WAITQUEUE
|
||||
DECLARE_WAITQUEUE(wait, current);
|
||||
#else
|
||||
struct wait_queue wait = { current, NULL };
|
||||
#endif
|
||||
|
||||
add_wait_queue((wait_queue_head_t *)cv, &wait);
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
|
||||
if (isAFSGlocked) AFS_GUNLOCK();
|
||||
MUTEX_EXIT(l);
|
||||
@ -80,11 +89,8 @@ int afs_cv_wait(afs_kcondvar_t *cv, afs_kmutex_t *l, int sigok)
|
||||
spin_unlock_irq(¤t->sigmask_lock);
|
||||
}
|
||||
|
||||
#if defined(AFS_LINUX24_ENV)
|
||||
interruptible_sleep_on((wait_queue_head_t *)cv);
|
||||
#else
|
||||
interruptible_sleep_on((struct wait_queue**)cv);
|
||||
#endif
|
||||
schedule();
|
||||
remove_wait_queue(cv, &wait);
|
||||
|
||||
if (!sigok) {
|
||||
spin_lock_irq(¤t->sigmask_lock);
|
||||
@ -93,8 +99,8 @@ int afs_cv_wait(afs_kcondvar_t *cv, afs_kmutex_t *l, int sigok)
|
||||
spin_unlock_irq(¤t->sigmask_lock);
|
||||
}
|
||||
|
||||
MUTEX_ENTER(l);
|
||||
if (isAFSGlocked) AFS_GLOCK();
|
||||
MUTEX_ENTER(l);
|
||||
|
||||
return (sigok && signal_pending(current)) ? EINTR : 0;
|
||||
}
|
||||
@ -103,18 +109,23 @@ void afs_cv_timedwait(afs_kcondvar_t *cv, afs_kmutex_t *l, int waittime)
|
||||
{
|
||||
int isAFSGlocked = ISAFS_GLOCK();
|
||||
long t = waittime * HZ / 1000;
|
||||
#ifdef DECLARE_WAITQUEUE
|
||||
DECLARE_WAITQUEUE(wait, current);
|
||||
#else
|
||||
struct wait_queue wait = { current, NULL };
|
||||
#endif
|
||||
|
||||
add_wait_queue((wait_queue_head_t *)cv, &wait);
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
|
||||
if (isAFSGlocked) AFS_GUNLOCK();
|
||||
MUTEX_EXIT(l);
|
||||
|
||||
#if defined(AFS_LINUX24_ENV)
|
||||
t = interruptible_sleep_on_timeout((wait_queue_head_t *)cv, t);
|
||||
#else
|
||||
t = interruptible_sleep_on_timeout((struct wait_queue**)cv, t);
|
||||
#endif
|
||||
t = schedule_timeout(t);
|
||||
remove_wait_queue(cv, &wait);
|
||||
|
||||
MUTEX_ENTER(l);
|
||||
if (isAFSGlocked) AFS_GLOCK();
|
||||
MUTEX_ENTER(l);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user