Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/filemon/filemon.c
Show First 20 Lines • Show All 204 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/* | /* | ||||
* Invalidate the passed filemon in all processes. | * Invalidate the passed filemon in all processes. | ||||
*/ | */ | ||||
static void | static void | ||||
filemon_untrack_processes(struct filemon *filemon) | filemon_untrack_processes(struct filemon *filemon) | ||||
{ | { | ||||
VPS_ITERATOR_DECL(vps_iter); | |||||
struct proc *p; | struct proc *p; | ||||
sx_assert(&filemon->lock, SA_XLOCKED); | sx_assert(&filemon->lock, SA_XLOCKED); | ||||
/* Avoid allproc loop if there is no need. */ | /* Avoid allproc loop if there is no need. */ | ||||
if (filemon->proccnt == 0) | if (filemon->proccnt == 0) | ||||
return; | return; | ||||
/* | /* | ||||
* Processes in this list won't go away while here since | * Processes in this list won't go away while here since | ||||
* filemon_event_process_exit() will lock on filemon->lock | * filemon_event_process_exit() will lock on filemon->lock | ||||
* which we hold. | * which we hold. | ||||
*/ | */ | ||||
sx_slock(&allproc_lock); | VPS_LIST_RLOCK(); | ||||
VPS_FOREACH(vps_iter) { | |||||
CURVPS_SET(vps_iter); | |||||
sx_slock(&V_allproc_lock); | |||||
FOREACH_PROC_IN_SYSTEM(p) { | FOREACH_PROC_IN_SYSTEM(p) { | ||||
/* | /* | ||||
* No PROC_LOCK is needed to compare here since it is | * No PROC_LOCK is needed to compare here since it is | ||||
* guaranteed to not change since we have its filemon | * guaranteed to not change since we have its filemon | ||||
* locked. Everything that changes this p_filemon will | * locked. Everything that changes this p_filemon will | ||||
* be locked on it. | * be locked on it. | ||||
*/ | */ | ||||
if (p->p_filemon == filemon) | if (p->p_filemon == filemon) | ||||
filemon_proc_drop(p); | filemon_proc_drop(p); | ||||
} | } | ||||
sx_sunlock(&allproc_lock); | sx_sunlock(&V_allproc_lock); | ||||
CURVPS_RESTORE(); | |||||
} | |||||
VPS_LIST_RUNLOCK(); | |||||
/* | /* | ||||
* It's possible some references were acquired but will be | * It's possible some references were acquired but will be | ||||
* dropped shortly as they are restricted from being | * dropped shortly as they are restricted from being | ||||
* inherited. There is at least the reference in cdevpriv remaining. | * inherited. There is at least the reference in cdevpriv remaining. | ||||
*/ | */ | ||||
KASSERT(filemon->refcnt > 0, ("%s: filemon %p should have " | KASSERT(filemon->refcnt > 0, ("%s: filemon %p should have " | ||||
"references still.", __func__, filemon)); | "references still.", __func__, filemon)); | ||||
▲ Show 20 Lines • Show All 266 Lines • Show Last 20 Lines |