fp->fp_buffer, fp->fp_nbytes);
if (r != SUSPEND) /* Do we have results to report? */
- (void) reply(who_e, r);
+ reply(who_e, r);
unlock_filp(f);
if (fp->fp_wtid == dl_worker.w_tid)
deadlock_resolving = 0;
}
- if (reply(who_e, error) != OK) {
- if ((vmp = find_vmnt(who_e)) != NULL) {
- for (i = 0; i < NR_PROCS; i++) {
- rfp = &fproc[i];
- if (rfp->fp_task == vmp->m_fs_e) {
- /* We found a process waiting for a
- * reply from non-responsive FS */
- worker_stop(worker_get(rfp->fp_wtid));
- }
- }
- }
- }
+ reply(who_e, error);
}
thread_cleanup(fp);
/*===========================================================================*
* reply *
*===========================================================================*/
-PUBLIC int reply(whom, result)
+PUBLIC void reply(whom, result)
int whom; /* process to reply to */
int result; /* result of the call (usually OK or error #) */
{
if (r != OK) {
printf("VFS: couldn't send reply %d to %d: %d\n", result, whom, r);
}
- return(r);
}
/*===========================================================================*
*/
unsuspend_by_endpt(exiter->fp_endpoint);
dmap_unmap_by_endpt(exiter->fp_endpoint);
+ vmnt_unmap_by_endpt(exiter->fp_endpoint);
+ worker_stop_by_endpt(exiter->fp_endpoint);
/* Release root and working directories. */
if (exiter->fp_rd) { put_vnode(exiter->fp_rd); exiter->fp_rd = NULL; }
/* main.c */
_PROTOTYPE( int main, (void) );
-_PROTOTYPE( int reply, (int whom, int result) );
+_PROTOTYPE( void reply, (int whom, int result) );
_PROTOTYPE( void lock_proc, (struct fproc *rfp, int force_lock) );
_PROTOTYPE( void unlock_proc, (struct fproc *rfp) );
_PROTOTYPE( void *do_dummy, (void *arg) );
_PROTOTYPE( void init_vmnts, (void) );
_PROTOTYPE( int lock_vmnt, (struct vmnt *vp, tll_access_t locktype) );
_PROTOTYPE( void unlock_vmnt, (struct vmnt *vp) );
+_PROTOTYPE( void vmnt_unmap_by_endpt, (endpoint_t proc_e) );
/* vnode.c */
_PROTOTYPE( void check_vnode_locks, (void) );
PUBLIC int req_mountpoint(endpoint_t fs_e, ino_t inode_nr)
{
message m;
+ int r;
/* Fill in request message */
m.m_type = REQ_MOUNTPOINT;
#include "fproc.h"
FORWARD _PROTOTYPE( int is_vmnt_locked, (struct vmnt *vmp) );
+FORWARD _PROTOTYPE( void clear_vmnt, (struct vmnt *vmp) );
/* Is vmp pointer reasonable? */
#define SANEVMP(v) ((((v) >= &vmnt[0] && (v) < &vmnt[NR_MNTS])))
#endif
}
+/*===========================================================================*
+ * clear_vmnt *
+ *===========================================================================*/
+PRIVATE void clear_vmnt(struct vmnt *vmp)
+{
+/* Reset vmp to initial parameters */
+ ASSERTVMP(vmp);
+
+ vmp->m_fs_e = NONE;
+ vmp->m_dev = NO_DEV;
+ vmp->m_flags = 0;
+ vmp->m_mounted_on = NULL;
+ vmp->m_root_node = NULL;
+ vmp->m_label[0] = '\0';
+ vmp->m_comm.c_max_reqs = 1;
+ vmp->m_comm.c_cur_reqs = 0;
+ vmp->m_comm.c_req_queue = NULL;
+}
+
/*===========================================================================*
* get_free_vmnt *
*===========================================================================*/
PUBLIC void init_vmnts(void)
{
/* Initialize vmnt table */
- struct vmnt *vp;
+ struct vmnt *vmp;
- for (vp = &vmnt[0]; vp < &vmnt[NR_MNTS]; vp++) {
- vp->m_fs_e = NONE;
- vp->m_dev = NO_DEV;
- vp->m_flags = 0;
- vp->m_mounted_on = NULL;
- vp->m_root_node = NULL;
- vp->m_label[0] = '\0';
- vp->m_comm.c_max_reqs = 1;
- vp->m_comm.c_cur_reqs = 0;
- vp->m_comm.c_req_queue = NULL;
- tll_init(&vp->m_lock);
+ for (vmp = &vmnt[0]; vmp < &vmnt[NR_MNTS]; vmp++) {
+ clear_vmnt(vmp);
+ tll_init(&vmp->m_lock);
}
}
#endif
}
+
+/*===========================================================================*
+ * vmnt_unmap_by_endpoint *
+ *===========================================================================*/
+PUBLIC void vmnt_unmap_by_endpt(endpoint_t proc_e)
+{
+ struct vmnt *vmp;
+
+ if ((vmp = find_vmnt(proc_e)) != NULL)
+ clear_vmnt(vmp);
+
+}
FORWARD _PROTOTYPE( void *worker_main, (void *arg) );
FORWARD _PROTOTYPE( void worker_sleep, (struct worker_thread *worker) );
FORWARD _PROTOTYPE( void worker_wake, (struct worker_thread *worker) );
+FORWARD _PROTOTYPE( int worker_waiting_for, (struct worker_thread *worker,
+ endpoint_t proc_e) );
PRIVATE int init = 0;
PRIVATE mthread_attr_t tattr;
/*===========================================================================*
* worker_init *
*===========================================================================*/
-PUBLIC void worker_init(struct worker_thread *worker)
+PUBLIC void worker_init(struct worker_thread *wp)
{
/* Initialize worker thread */
if (!init) {
init = 1;
}
- ASSERTW(worker);
+ ASSERTW(wp);
- worker->w_job.j_func = NULL; /* Mark not in use */
- worker->w_next = NULL;
- assert(mutex_init(&worker->w_event_mutex, NULL) == 0);
- assert(cond_init(&worker->w_event, NULL) == 0);
- assert(mthread_create(&worker->w_tid, &tattr, worker_main, (void *) worker) == 0);
+ wp->w_job.j_func = NULL; /* Mark not in use */
+ wp->w_next = NULL;
+ assert(mutex_init(&wp->w_event_mutex, NULL) == 0);
+ assert(cond_init(&wp->w_event, NULL) == 0);
+ assert(mthread_create(&wp->w_tid, &tattr, worker_main, (void *) wp) == 0);
yield();
}
PUBLIC void worker_stop(struct worker_thread *worker)
{
ASSERTW(worker); /* Make sure we have a valid thread */
- worker->w_job.j_m_in.m_type = -EIO;
+ worker->w_job.j_m_in.m_type = EIO;
worker_wake(worker);
}
+/*===========================================================================*
+ * worker_stop_by_endpt *
+ *===========================================================================*/
+PUBLIC void worker_stop_by_endpt(endpoint_t proc_e)
+{
+ struct worker_thread *worker;
+ int i;
+
+ if (proc_e == NONE) return;
+
+ if (worker_waiting_for(&sys_worker, proc_e)) worker_stop(&sys_worker);
+ if (worker_waiting_for(&dl_worker, proc_e)) worker_stop(&dl_worker);
+
+ for (i = 0; i < NR_WTHREADS; i++) {
+ worker = &workers[i];
+ if (worker_waiting_for(worker, proc_e))
+ worker_stop(worker);
+ }
+}
+
/*===========================================================================*
* worker_self *
*===========================================================================*/
return(NULL);
}
+
+/*===========================================================================*
+ * worker_waiting_for *
+ *===========================================================================*/
+PRIVATE int worker_waiting_for(struct worker_thread *worker, endpoint_t proc_e)
+{
+ ASSERTW(worker); /* Make sure we have a valid thread */
+
+ if (worker->w_job.j_func != NULL) {
+ if (worker->w_job.j_fp != NULL) {
+ return(worker->w_job.j_fp->fp_task == proc_e);
+ }
+ }
+
+ return(0);
+}