From 3badab8b70aa1cdb67844d1df084659a0f500880 Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Thu, 22 Jul 2010 14:55:28 +0000 Subject: [PATCH] vfs - split fp_fd field into fd + callnr fields --- servers/vfs/device.c | 8 ++++---- servers/vfs/fproc.h | 3 ++- servers/vfs/main.c | 12 ++++-------- servers/vfs/pipe.c | 18 ++++++++++-------- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/servers/vfs/device.c b/servers/vfs/device.c index c1764ae88..f9809c17e 100644 --- a/servers/vfs/device.c +++ b/servers/vfs/device.c @@ -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) { diff --git a/servers/vfs/fproc.h b/servers/vfs/fproc.h index 27ed9f535..aab719e1f 100644 --- a/servers/vfs/fproc.h +++ b/servers/vfs/fproc.h @@ -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 */ diff --git a/servers/vfs/main.c b/servers/vfs/main.c index 974f16af1..0a1b6a1f3 100644 --- a/servers/vfs/main.c +++ b/servers/vfs/main.c @@ -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 : diff --git a/servers/vfs/pipe.c b/servers/vfs/pipe.c index 414992775..a46f7b3f6 100644 --- a/servers/vfs/pipe.c +++ b/servers/vfs/pipe.c @@ -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); -- 2.44.0