vfs - split fp_fd field into fd + callnr fields

This commit is contained in:
Ben Gras 2010-07-22 14:55:28 +00:00
parent 1c2dd749eb
commit 3badab8b70
4 changed files with 20 additions and 21 deletions

View file

@ -870,8 +870,8 @@ PUBLIC void dev_up(int maj)
if(rfp->fp_blocked_on != FP_BLOCKED_ON_DOPEN) continue;
printf("dev_up: found process in FP_BLOCKED_ON_DOPEN, fd %d\n",
rfp->fp_fd >> 8);
fd_nr = (rfp->fp_fd >> 8);
rfp->fp_block_fd);
fd_nr = rfp->fp_block_fd;
fp = rfp->fp_filp[fd_nr];
vp = fp->filp_vno;
if (!vp) panic("restart_reopen: no vp");
@ -963,8 +963,8 @@ int maj;
!(rfp->fp_flags & SUSP_REOPEN)) continue;
printf("restart_reopen: found process in FP_BLOCKED_ON_DOPEN, fd %d\n",
rfp->fp_fd >> 8);
fd_nr = (rfp->fp_fd >> 8);
rfp->fp_block_fd);
fd_nr = rfp->fp_block_fd;
fp = rfp->fp_filp[fd_nr];
if (!fp) {

View file

@ -26,7 +26,8 @@ EXTERN struct fproc {
int fp_ngroups; /* number of supplemental groups */
gid_t fp_sgroups[NGROUPS_MAX];/* supplemental groups */
dev_t fp_tty; /* major/minor of controlling tty */
int fp_fd; /* place to save fd if rd/wr can't finish */
int fp_block_fd; /* place to save fd if rd/wr can't finish */
int fp_block_callnr; /* blocked call if rd/wr can't finish */
char *fp_buffer; /* place to save buffer if rd/wr can't finish*/
int fp_nbytes; /* place to save bytes if rd/wr can't finish */
int fp_cum_io_partial; /* partial byte count if rd/wr can't finish */

View file

@ -254,11 +254,7 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
mess.m_type = OK; /* tell PM that we succeeded */
s = send(PM_PROC_NR, &mess); /* send synchronization message */
/* All process table entries have been set. Continue with FS initialization.
* Certain relations must hold for the file system to work at all. Some
* extra block_size requirements are checked at super-block-read-in time.
*/
if (OPEN_MAX > 127) panic("OPEN_MAX > 127");
/* All process table entries have been set. Continue with initialization. */
/* The following initializations are needed to let dev_opcl succeed .*/
fp = (struct fproc *) NULL;
@ -341,9 +337,9 @@ PRIVATE void get_work()
found_one= TRUE;
who_p = (int)(rp - fproc);
who_e = rp->fp_endpoint;
call_nr = rp->fp_fd & BYTE;
call_nr = rp->fp_block_callnr;
m_in.fd = (rp->fp_fd >>8) & BYTE;
m_in.fd = rp->fp_block_fd;
m_in.buffer = rp->fp_buffer;
m_in.nbytes = rp->fp_nbytes;
/*no longer hanging*/
@ -358,7 +354,7 @@ PRIVATE void get_work()
if (blocked_on == FP_BLOCKED_ON_PIPE)
{
fp= rp;
fd_nr= (rp->fp_fd >> 8);
fd_nr= rp->fp_block_fd;
f= get_filp(fd_nr);
assert(f != NULL);
r= rw_pipe((call_nr == READ) ? READING :

View file

@ -266,7 +266,8 @@ PUBLIC void suspend(int why)
fp->fp_blocked_on = why;
assert(fp->fp_grant == GRANT_INVALID || !GRANT_VALID(fp->fp_grant));
fp->fp_fd = m_in.fd << 8 | call_nr;
fp->fp_block_fd = m_in.fd;
fp->fp_block_callnr = call_nr;
fp->fp_flags &= ~SUSP_REOPEN; /* Clear this flag. The caller
* can set it when needed.
*/
@ -315,7 +316,8 @@ size_t size;
susp_count++; /* #procs susp'ed on pipe*/
fp->fp_blocked_on = FP_BLOCKED_ON_PIPE;
assert(!GRANT_VALID(fp->fp_grant));
fp->fp_fd = (fd_nr << 8) | ((rw_flag == READING) ? READ : WRITE);
fp->fp_block_fd = fd_nr;
fp->fp_block_callnr = ((rw_flag == READING) ? READ : WRITE);
fp->fp_buffer = buf;
fp->fp_nbytes = size;
}
@ -383,8 +385,8 @@ int count; /* max number of processes to release */
/* Search the proc table. */
for (rp = &fproc[0]; rp < &fproc[NR_PROCS] && count > 0; rp++) {
if (rp->fp_pid != PID_FREE && fp_is_blocked(rp) &&
rp->fp_revived == NOT_REVIVING && (rp->fp_fd & BYTE) == call_nr &&
rp->fp_filp[rp->fp_fd>>8]->filp_vno == vp) {
rp->fp_revived == NOT_REVIVING && rp->fp_block_callnr == call_nr &&
rp->fp_filp[rp->fp_block_fd]->filp_vno == vp) {
revive(rp->fp_endpoint, 0);
susp_count--; /* keep track of who is suspended */
if(susp_count < 0)
@ -427,7 +429,7 @@ int returned; /* if hanging on task, how many bytes read */
reviving++; /* process was waiting on pipe or lock */
} else if (blocked_on == FP_BLOCKED_ON_DOPEN) {
rfp->fp_blocked_on = FP_BLOCKED_ON_NONE;
fd_nr = rfp->fp_fd>>8;
fd_nr = rfp->fp_block_fd;
if (returned < 0) {
fil_ptr = rfp->fp_filp[fd_nr];
rfp->fp_filp[fd_nr] = NULL;
@ -446,7 +448,7 @@ int returned; /* if hanging on task, how many bytes read */
rfp->fp_blocked_on = FP_BLOCKED_ON_NONE;
if (blocked_on == FP_BLOCKED_ON_POPEN) {
/* process blocked in open or create */
reply(proc_nr_e, rfp->fp_fd>>8);
reply(proc_nr_e, rfp->fp_block_fd);
} else if (blocked_on == FP_BLOCKED_ON_SELECT) {
reply(proc_nr_e, returned);
} else {
@ -530,7 +532,7 @@ int proc_nr_e;
break;
}
fild = (rfp->fp_fd >> 8) & BYTE;/* extract file descriptor */
fild = rfp->fp_block_fd;
if (fild < 0 || fild >= OPEN_MAX)
panic("unpause err 2");
f = rfp->fp_filp[fild];
@ -540,7 +542,7 @@ int proc_nr_e;
mess.IO_GRANT = (char *) rfp->fp_grant;
/* Tell kernel R or W. Mode is from current call, not open. */
mess.COUNT = (rfp->fp_fd & BYTE) == READ ? R_BIT : W_BIT;
mess.COUNT = rfp->fp_block_callnr == READ ? R_BIT : W_BIT;
mess.m_type = CANCEL;
fp = rfp; /* hack - ctty_io uses fp */
(*dmap[(dev >> MAJOR) & BYTE].dmap_io)(rfp->fp_task, &mess);