convert more insque/remque style queuing to use a queue(3) TAILQ,
this necessitates using a flag to indicate vc_open instead of abusing the queue pointer but apart from that there is no functional difference.
This commit is contained in:
parent
0c65d1b648
commit
72ac0bcc50
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cnode.h,v 1.16 2007/03/04 06:01:11 christos Exp $ */
|
||||
/* $NetBSD: cnode.h,v 1.17 2008/03/21 17:59:57 plunky Exp $ */
|
||||
|
||||
/*
|
||||
*
|
||||
|
@ -54,11 +54,6 @@
|
|||
MALLOC_DECLARE(M_CODA);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* tmp below since we need struct queue
|
||||
*/
|
||||
#include <coda/coda_kernel.h>
|
||||
|
||||
/*
|
||||
* Cnode lookup stuff.
|
||||
* NOTE: CODA_CACHESIZE must be a power of 2 for cfshash to work!
|
||||
|
@ -129,16 +124,19 @@ struct cnode {
|
|||
#define VALID_SYMLINK(cp) ((cp->c_flags) & C_SYMLINK)
|
||||
#define IS_UNMOUNTING(cp) ((cp)->c_flags & C_UNMOUNTING)
|
||||
|
||||
struct vmsg;
|
||||
|
||||
struct vcomm {
|
||||
u_long vc_seq;
|
||||
struct selinfo vc_selproc;
|
||||
struct queue vc_requests;
|
||||
struct queue vc_replys;
|
||||
u_long vc_seq;
|
||||
int vc_open;
|
||||
struct selinfo vc_selproc;
|
||||
TAILQ_HEAD(,vmsg) vc_requests;
|
||||
TAILQ_HEAD(,vmsg) vc_replies;
|
||||
};
|
||||
|
||||
#define VC_OPEN(vcp) ((vcp)->vc_requests.forw != NULL)
|
||||
#define MARK_VC_CLOSED(vcp) (vcp)->vc_requests.forw = NULL;
|
||||
#define MARK_VC_OPEN(vcp) /* MT */
|
||||
#define VC_OPEN(vcp) ((vcp)->vc_open == 1)
|
||||
#define MARK_VC_CLOSED(vcp) ((vcp)->vc_open = 0)
|
||||
#define MARK_VC_OPEN(vcp) ((vcp)->vc_open = 1)
|
||||
|
||||
struct coda_clstat {
|
||||
int ncalls; /* client requests */
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
/* $NetBSD: coda_kernel.h,v 1.6 2005/12/11 12:19:50 christos Exp $ */
|
||||
|
||||
/*
|
||||
*
|
||||
* Coda: an Experimental Distributed File System
|
||||
* Release 3.1
|
||||
*
|
||||
* Copyright (c) 1987-1998 Carnegie Mellon University
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Permission to use, copy, modify and distribute this software and its
|
||||
* documentation is hereby granted, provided that both the copyright
|
||||
* notice and this permission notice appear in all copies of the
|
||||
* software, derivative works or modified versions, and any portions
|
||||
* thereof, and that both notices appear in supporting documentation, and
|
||||
* that credit is given to Carnegie Mellon University in all documents
|
||||
* and publicity pertaining to direct or indirect use of this code or its
|
||||
* derivatives.
|
||||
*
|
||||
* CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
|
||||
* SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON ALLOWS
|
||||
* FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON
|
||||
* DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
|
||||
* ANY DERIVATIVE WORK.
|
||||
*
|
||||
* Carnegie Mellon encourages users of this software to return any
|
||||
* improvements or extensions that they make, and to grant Carnegie
|
||||
* Mellon the rights to redistribute these changes without encumbrance.
|
||||
*
|
||||
* @(#) coda/coda_kernel.h,v 1.1.1.1 1998/08/29 21:26:46 rvb Exp $
|
||||
*/
|
||||
|
||||
/* Macros to manipulate the queue */
|
||||
#ifndef INIT_QUEUE
|
||||
struct queue {
|
||||
struct queue *forw, *back;
|
||||
};
|
||||
|
||||
#define INIT_QUEUE(head) \
|
||||
do { \
|
||||
(head).forw = (struct queue *)&(head); \
|
||||
(head).back = (struct queue *)&(head); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define GETNEXT(head) (head).forw
|
||||
|
||||
#define EMPTY(head) ((head).forw == &(head))
|
||||
|
||||
#define EOQ(el, head) ((struct queue *)(el) == (struct queue *)&(head))
|
||||
|
||||
#define INSQUE(el, head) \
|
||||
do { \
|
||||
(el).forw = ((head).back)->forw; \
|
||||
(el).back = (head).back; \
|
||||
((head).back)->forw = (struct queue *)&(el); \
|
||||
(head).back = (struct queue *)&(el); \
|
||||
} while (/*CONSTCOND*/ 0)
|
||||
|
||||
#define REMQUE(el) \
|
||||
do { \
|
||||
((el).forw)->back = (el).back; \
|
||||
(el).back->forw = (el).forw; \
|
||||
} while (0)
|
||||
|
||||
#endif
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: coda_psdev.c,v 1.40 2008/03/01 17:26:07 plunky Exp $ */
|
||||
/* $NetBSD: coda_psdev.c,v 1.41 2008/03/21 17:59:57 plunky Exp $ */
|
||||
|
||||
/*
|
||||
*
|
||||
|
@ -54,7 +54,7 @@
|
|||
/* These routines are the device entry points for Venus. */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: coda_psdev.c,v 1.40 2008/03/01 17:26:07 plunky Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: coda_psdev.c,v 1.41 2008/03/21 17:59:57 plunky Exp $");
|
||||
|
||||
extern int coda_nc_initialized; /* Set if cache has been initialized */
|
||||
|
||||
|
@ -112,7 +112,7 @@ const struct cdevsw vcoda_cdevsw = {
|
|||
};
|
||||
|
||||
struct vmsg {
|
||||
struct queue vm_chain;
|
||||
TAILQ_ENTRY(vmsg) vm_chain;
|
||||
void * vm_data;
|
||||
u_short vm_flags;
|
||||
u_short vm_inSize; /* Size is at most 5000 bytes */
|
||||
|
@ -154,8 +154,8 @@ vc_nb_open(dev_t dev, int flag, int mode,
|
|||
return(EBUSY);
|
||||
|
||||
selinit(&vcp->vc_selproc);
|
||||
INIT_QUEUE(vcp->vc_requests);
|
||||
INIT_QUEUE(vcp->vc_replys);
|
||||
TAILQ_INIT(&vcp->vc_requests);
|
||||
TAILQ_INIT(&vcp->vc_replies);
|
||||
MARK_VC_OPEN(vcp);
|
||||
|
||||
coda_mnttbl[minor(dev)].mi_vfsp = NULL;
|
||||
|
@ -168,7 +168,7 @@ int
|
|||
vc_nb_close(dev_t dev, int flag, int mode, struct lwp *l)
|
||||
{
|
||||
struct vcomm *vcp;
|
||||
struct vmsg *vmp, *nvmp = NULL;
|
||||
struct vmsg *vmp;
|
||||
struct coda_mntinfo *mi;
|
||||
int err;
|
||||
|
||||
|
@ -209,11 +209,9 @@ vc_nb_close(dev_t dev, int flag, int mode, struct lwp *l)
|
|||
coda_unmounting(mi->mi_vfsp);
|
||||
|
||||
/* Wakeup clients so they can return. */
|
||||
for (vmp = (struct vmsg *)GETNEXT(vcp->vc_requests);
|
||||
!EOQ(vmp, vcp->vc_requests);
|
||||
vmp = nvmp)
|
||||
{
|
||||
nvmp = (struct vmsg *)GETNEXT(vmp->vm_chain);
|
||||
while ((vmp = TAILQ_FIRST(&vcp->vc_requests)) != NULL) {
|
||||
TAILQ_REMOVE(&vcp->vc_requests, vmp, vm_chain);
|
||||
|
||||
/* Free signal request messages and don't wakeup cause
|
||||
no one is waiting. */
|
||||
if (vmp->vm_opcode == CODA_SIGNAL) {
|
||||
|
@ -225,10 +223,9 @@ vc_nb_close(dev_t dev, int flag, int mode, struct lwp *l)
|
|||
wakeup(&vmp->vm_sleep);
|
||||
}
|
||||
|
||||
for (vmp = (struct vmsg *)GETNEXT(vcp->vc_replys);
|
||||
!EOQ(vmp, vcp->vc_replys);
|
||||
vmp = (struct vmsg *)GETNEXT(vmp->vm_chain))
|
||||
{
|
||||
while ((vmp = TAILQ_FIRST(&vcp->vc_replies)) != NULL) {
|
||||
TAILQ_REMOVE(&vcp->vc_replies, vmp, vm_chain);
|
||||
|
||||
outstanding_upcalls++;
|
||||
wakeup(&vmp->vm_sleep);
|
||||
}
|
||||
|
@ -266,11 +263,11 @@ vc_nb_read(dev_t dev, struct uio *uiop, int flag)
|
|||
return(ENXIO);
|
||||
|
||||
vcp = &coda_mnttbl[minor(dev)].mi_vcomm;
|
||||
/* Get message at head of request queue. */
|
||||
if (EMPTY(vcp->vc_requests))
|
||||
return(0); /* Nothing to read */
|
||||
|
||||
vmp = (struct vmsg *)GETNEXT(vcp->vc_requests);
|
||||
/* Get message at head of request queue. */
|
||||
vmp = TAILQ_FIRST(&vcp->vc_requests);
|
||||
if (vmp == NULL)
|
||||
return(0); /* Nothing to read */
|
||||
|
||||
/* Move the input args into userspace */
|
||||
uiop->uio_rw = UIO_READ;
|
||||
|
@ -280,12 +277,7 @@ vc_nb_read(dev_t dev, struct uio *uiop, int flag)
|
|||
error = EINVAL;
|
||||
}
|
||||
|
||||
#ifdef OLD_DIAGNOSTIC
|
||||
if (vmp->vm_chain.forw == 0 || vmp->vm_chain.back == 0)
|
||||
panic("vc_nb_read: bad chain");
|
||||
#endif
|
||||
|
||||
REMQUE(vmp->vm_chain);
|
||||
TAILQ_REMOVE(&vcp->vc_requests, vmp, vm_chain);
|
||||
|
||||
/* If request was a signal, free up the message and don't
|
||||
enqueue it in the reply queue. */
|
||||
|
@ -299,7 +291,7 @@ vc_nb_read(dev_t dev, struct uio *uiop, int flag)
|
|||
}
|
||||
|
||||
vmp->vm_flags |= VM_READ;
|
||||
INSQUE(vmp->vm_chain, vcp->vc_replys);
|
||||
TAILQ_INSERT_TAIL(&vcp->vc_replies, vmp, vm_chain);
|
||||
|
||||
return(error);
|
||||
}
|
||||
|
@ -352,22 +344,19 @@ vc_nb_write(dev_t dev, struct uio *uiop, int flag)
|
|||
}
|
||||
|
||||
/* Look for the message on the (waiting for) reply queue. */
|
||||
for (vmp = (struct vmsg *)GETNEXT(vcp->vc_replys);
|
||||
!EOQ(vmp, vcp->vc_replys);
|
||||
vmp = (struct vmsg *)GETNEXT(vmp->vm_chain))
|
||||
{
|
||||
TAILQ_FOREACH(vmp, &vcp->vc_replies, vm_chain) {
|
||||
if (vmp->vm_unique == seq) break;
|
||||
}
|
||||
|
||||
if (EOQ(vmp, vcp->vc_replys)) {
|
||||
if (vmp == NULL) {
|
||||
if (codadebug)
|
||||
myprintf(("vcwrite: msg (%ld, %ld) not found\n", opcode, seq));
|
||||
|
||||
return(ESRCH);
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove the message from the reply queue */
|
||||
REMQUE(vmp->vm_chain);
|
||||
TAILQ_REMOVE(&vcp->vc_replies, vmp, vm_chain);
|
||||
|
||||
/* move data into response buffer. */
|
||||
out = (struct coda_out_hdr *)vmp->vm_data;
|
||||
|
@ -468,7 +457,7 @@ vc_nb_poll(dev_t dev, int events, struct lwp *l)
|
|||
if (!event_msk)
|
||||
return(0);
|
||||
|
||||
if (!EMPTY(vcp->vc_requests))
|
||||
if (!TAILQ_EMPTY(&vcp->vc_requests))
|
||||
return(events & (POLLIN|POLLRDNORM));
|
||||
|
||||
selrecord(l, &(vcp->vc_selproc));
|
||||
|
@ -490,11 +479,10 @@ filt_vc_nb_read(struct knote *kn, long hint)
|
|||
struct vcomm *vcp = kn->kn_hook;
|
||||
struct vmsg *vmp;
|
||||
|
||||
if (EMPTY(vcp->vc_requests))
|
||||
vmp = TAILQ_FIRST(&vcp->vc_requests);
|
||||
if (vmp == NULL)
|
||||
return (0);
|
||||
|
||||
vmp = (struct vmsg *)GETNEXT(vcp->vc_requests);
|
||||
|
||||
kn->kn_data = vmp->vm_inSize;
|
||||
return (1);
|
||||
}
|
||||
|
@ -590,7 +578,7 @@ coda_call(struct coda_mntinfo *mntinfo, int inSize, int *outSize,
|
|||
((struct coda_in_hdr *)buffer)->unique = vmp->vm_unique;
|
||||
|
||||
/* Append msg to request queue and poke Venus. */
|
||||
INSQUE(vmp->vm_chain, vcp->vc_requests);
|
||||
TAILQ_INSERT_TAIL(&vcp->vc_requests, vmp, vm_chain);
|
||||
selnotify(&(vcp->vc_selproc), 0, 0);
|
||||
|
||||
/* We can be interrupted while we wait for Venus to process
|
||||
|
@ -678,7 +666,8 @@ coda_call(struct coda_mntinfo *mntinfo, int inSize, int *outSize,
|
|||
#endif
|
||||
myprintf(("interrupted before read: op = %d.%d, flags = %x\n",
|
||||
vmp->vm_opcode, vmp->vm_unique, vmp->vm_flags));
|
||||
REMQUE(vmp->vm_chain);
|
||||
|
||||
TAILQ_REMOVE(&vcp->vc_requests, vmp, vm_chain);
|
||||
error = EINTR;
|
||||
}
|
||||
|
||||
|
@ -697,7 +686,7 @@ coda_call(struct coda_mntinfo *mntinfo, int inSize, int *outSize,
|
|||
myprintf(("Sending Venus a signal: op = %d.%d, flags = %x\n",
|
||||
vmp->vm_opcode, vmp->vm_unique, vmp->vm_flags));
|
||||
|
||||
REMQUE(vmp->vm_chain);
|
||||
TAILQ_REMOVE(&vcp->vc_replies, vmp, vm_chain);
|
||||
error = EINTR;
|
||||
|
||||
CODA_ALLOC(svmp, struct vmsg *, sizeof (struct vmsg));
|
||||
|
@ -716,7 +705,7 @@ coda_call(struct coda_mntinfo *mntinfo, int inSize, int *outSize,
|
|||
svmp->vm_opcode, svmp->vm_unique));
|
||||
|
||||
/* insert at head of queue! */
|
||||
INSQUE(svmp->vm_chain, vcp->vc_requests);
|
||||
TAILQ_INSERT_TAIL(&vcp->vc_requests, svmp, vm_chain);
|
||||
selnotify(&(vcp->vc_selproc), 0, 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue