From: David van Moolenbroek Date: Fri, 30 Aug 2013 11:00:44 +0000 (+0200) Subject: VFS: remove FP_BLOCKED_ON_DOPEN X-Git-Tag: v3.3.0~611 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/index.css?a=commitdiff_plain;h=c7fbafe1ad112827b81d7b17a49a6513d22ee062;p=minix.git VFS: remove FP_BLOCKED_ON_DOPEN These days, DEV_OPEN calls to character drivers block the calling thread until completion or failure, and thus never return SUSPEND to the caller. The same already applied to BDEV_OPEN calls to block drivers. It has thus become impossible for a process to enter a state of being blocked on a device open call. There is currently no support for restarting device open calls to restarted character drivers. This support was present in the _DOPEN logic, but was already no longer triggering. In the future, this case should be handled by the thread performing the open request. Change-Id: I6cc1e7b4c9ed116c6ce160b315e6e060124dce00 --- diff --git a/commands/ps/ps.c b/commands/ps/ps.c index c421c7ab9..0b69eb21a 100644 --- a/commands/ps/ps.c +++ b/commands/ps/ps.c @@ -203,7 +203,6 @@ static char *prrecv(struct pstat *ps) case FSTATE_LOCK: blkstr = "flock"; break; case FSTATE_POPEN: blkstr = "popen"; break; case FSTATE_SELECT: blkstr = "select"; break; - case FSTATE_DOPEN: blkstr = "dopen"; break; case FSTATE_TASK: blkstr = taskname(ps->ps_ftask); break; default: blkstr = "??"; break; } diff --git a/include/minix/procfs.h b/include/minix/procfs.h index fec097b61..eb6733644 100644 --- a/include/minix/procfs.h +++ b/include/minix/procfs.h @@ -35,7 +35,6 @@ #define FSTATE_LOCK 'L' #define FSTATE_POPEN 'O' #define FSTATE_SELECT 'S' -#define FSTATE_DOPEN 'D' #define FSTATE_TASK 'T' #define FSTATE_UNKNOWN '?' diff --git a/servers/procfs/pid.c b/servers/procfs/pid.c index f37e049a1..b6e7becc9 100644 --- a/servers/procfs/pid.c +++ b/servers/procfs/pid.c @@ -136,7 +136,6 @@ static void pid_psinfo(int i) case FP_BLOCKED_ON_LOCK: f_state = FSTATE_LOCK; break; case FP_BLOCKED_ON_POPEN: f_state = FSTATE_POPEN; break; case FP_BLOCKED_ON_SELECT: f_state = FSTATE_SELECT; break; - case FP_BLOCKED_ON_DOPEN: f_state = FSTATE_DOPEN; break; case FP_BLOCKED_ON_OTHER: f_state = FSTATE_TASK; break; default: f_state = FSTATE_UNKNOWN; } diff --git a/servers/vfs/const.h b/servers/vfs/const.h index 3705a8a1f..b587f0e5f 100644 --- a/servers/vfs/const.h +++ b/servers/vfs/const.h @@ -20,8 +20,7 @@ #define FP_BLOCKED_ON_LOCK 2 /* susp'd on lock */ #define FP_BLOCKED_ON_POPEN 3 /* susp'd on pipe open */ #define FP_BLOCKED_ON_SELECT 4 /* susp'd on select */ -#define FP_BLOCKED_ON_DOPEN 5 /* susp'd on device open */ -#define FP_BLOCKED_ON_OTHER 6 /* blocked on other process, check +#define FP_BLOCKED_ON_OTHER 5 /* blocked on other process, check fp_task to find out */ /* test if the process is blocked on something */ diff --git a/servers/vfs/device.c b/servers/vfs/device.c index 64f7fa6aa..759cc6896 100644 --- a/servers/vfs/device.c +++ b/servers/vfs/device.c @@ -928,30 +928,10 @@ void cdev_up(int maj) { /* A new character device driver has been mapped in. */ - int needs_reopen, fd_nr; + int needs_reopen; struct filp *rfilp; - struct fproc *rfp; struct vnode *vp; - /* Look for processes that are suspended in an OPEN call. Set FP_SUSP_REOPEN - * to indicate that this process was suspended before the call to dev_up. - */ - for (rfp = &fproc[0]; rfp < &fproc[NR_PROCS]; rfp++) { - if(rfp->fp_pid == PID_FREE) continue; - if(rfp->fp_blocked_on != FP_BLOCKED_ON_DOPEN) continue; - - fd_nr = scratch(rfp).file.fd_nr; - printf("VFS: dev_up: found process in FP_BLOCKED_ON_DOPEN, fd %d\n", - fd_nr); - rfilp = rfp->fp_filp[fd_nr]; - vp = rfilp->filp_vno; - if (!vp) panic("VFS: cdev_up: no vp"); - if (!S_ISCHR(vp->v_mode)) continue; - if (major(vp->v_sdev) != maj) continue; - - rfp->fp_flags |= FP_SUSP_REOPEN; - } - needs_reopen= FALSE; for (rfilp = filp; rfilp < &filp[NR_FILPS]; rfilp++) { if (rfilp->filp_count < 1 || !(vp = rfilp->filp_vno)) continue; @@ -1017,7 +997,7 @@ void dev_reply(struct dmap *dp) static void restart_reopen(maj) int maj; { - int n, r, minor_dev, major_dev, fd_nr; + int n, r, minor_dev, major_dev; endpoint_t driver_e; struct vnode *vp; struct filp *rfilp; @@ -1074,34 +1054,6 @@ int maj; reply(&m_out, rfp->fp_endpoint, ERESTART); } } - - /* Look for processes that are suspened in an OPEN call */ - for (rfp = &fproc[0]; rfp < &fproc[NR_PROCS]; rfp++) { - if (rfp->fp_pid == PID_FREE) continue; - if (rfp->fp_blocked_on == FP_BLOCKED_ON_DOPEN || - !(rfp->fp_flags & FP_SUSP_REOPEN)) continue; - - fd_nr = scratch(rfp).file.fd_nr; - printf("VFS: restart_reopen: process in FP_BLOCKED_ON_DOPEN fd=%d\n", - fd_nr); - rfilp = rfp->fp_filp[fd_nr]; - - if (!rfilp) { - /* Open failed, and automatic reopen was not requested */ - rfp->fp_blocked_on = FP_BLOCKED_ON_NONE; - FD_CLR(fd_nr, &rfp->fp_filp_inuse); - reply(&m_out, rfp->fp_endpoint, EIO); - continue; - } - - vp = rfilp->filp_vno; - if (!vp) panic("VFS: restart_reopen: no vp"); - if (!S_ISCHR(vp->v_mode)) continue; - if (major(vp->v_sdev) != maj) continue; - - rfp->fp_blocked_on = FP_BLOCKED_ON_NONE; - reply(&m_out, rfp->fp_endpoint, fd_nr); - } } diff --git a/servers/vfs/open.c b/servers/vfs/open.c index 1a20796f1..045e8c6b8 100644 --- a/servers/vfs/open.c +++ b/servers/vfs/open.c @@ -160,9 +160,8 @@ int common_open(char path[PATH_MAX], int oflags, mode_t omode) dev = (dev_t) vp->v_sdev; /* TTY needs to know about the O_NOCTTY flag. */ r = dev_open(dev, who_e, bits | (oflags & O_NOCTTY)); - if (r == SUSPEND) suspend(FP_BLOCKED_ON_DOPEN); - else vp = filp->filp_vno; /* Might be updated by - * dev_open/clone_opcl */ + vp = filp->filp_vno; /* Might be updated by + * dev_open/clone_opcl */ break; case S_IFBLK: diff --git a/servers/vfs/pipe.c b/servers/vfs/pipe.c index 9d0a0a83b..c0c896f93 100644 --- a/servers/vfs/pipe.c +++ b/servers/vfs/pipe.c @@ -436,7 +436,6 @@ int count; /* max number of processes to release */ */ if (rp->fp_blocked_on == FP_BLOCKED_ON_POPEN || - rp->fp_blocked_on == FP_BLOCKED_ON_DOPEN || rp->fp_blocked_on == FP_BLOCKED_ON_LOCK || rp->fp_blocked_on == FP_BLOCKED_ON_OTHER) { if (!FD_ISSET(scratch(rp).file.fd_nr, @@ -474,7 +473,6 @@ void revive(endpoint_t proc_e, int returned) struct fproc *rfp; int blocked_on; int fd_nr, slot; - struct filp *fil_ptr; if (proc_e == NONE || isokendpt(proc_e, &slot) != OK) return; @@ -492,26 +490,6 @@ void revive(endpoint_t proc_e, int returned) /* Revive a process suspended on a pipe or lock. */ rfp->fp_flags |= FP_REVIVED; reviving++; /* process was waiting on pipe or lock */ - } else if (blocked_on == FP_BLOCKED_ON_DOPEN) { - rfp->fp_blocked_on = FP_BLOCKED_ON_NONE; - scratch(rfp).file.fd_nr = 0; - if (returned < 0) { - fil_ptr = rfp->fp_filp[fd_nr]; - lock_filp(fil_ptr, VNODE_OPCL); - rfp->fp_filp[fd_nr] = NULL; - FD_CLR(fd_nr, &rfp->fp_filp_inuse); - if (fil_ptr->filp_count != 1) { - panic("VFS: revive: bad count in filp: %d", - fil_ptr->filp_count); - } - fil_ptr->filp_count = 0; - unlock_filp(fil_ptr); - put_vnode(fil_ptr->filp_vno); - fil_ptr->filp_vno = NULL; - replycode(proc_e, returned); - } else { - replycode(proc_e, fd_nr); - } } else { rfp->fp_blocked_on = FP_BLOCKED_ON_NONE; scratch(rfp).file.fd_nr = 0; @@ -586,10 +564,6 @@ void unpause(endpoint_t proc_e) case FP_BLOCKED_ON_POPEN: /* process trying to open a fifo */ break; - case FP_BLOCKED_ON_DOPEN:/* process trying to open a device */ - /* Don't cancel OPEN. Just wait until the open completes. */ - return; - case FP_BLOCKED_ON_OTHER:/* process trying to do device I/O (e.g. tty)*/ if (rfp->fp_flags & FP_SUSP_REOPEN) { /* Process is suspended while waiting for a reopen.