From owner-freebsd-bugs@FreeBSD.ORG Sun Apr 17 16:00:43 2005 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9B43916A4CE for ; Sun, 17 Apr 2005 16:00:43 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2FC9643D45 for ; Sun, 17 Apr 2005 16:00:43 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j3HG0gta019666 for ; Sun, 17 Apr 2005 16:00:43 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j3HG0gQg019665; Sun, 17 Apr 2005 16:00:42 GMT (envelope-from gnats) Resent-Date: Sun, 17 Apr 2005 16:00:42 GMT Resent-Message-Id: <200504171600.j3HG0gQg019665@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Erik Greenwald Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B6AEC16A4CF for ; Sun, 17 Apr 2005 15:54:48 +0000 (GMT) Received: from phoenix.smluc.org (phoenix.smluc.org [12.28.48.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9F63543D58 for ; Sun, 17 Apr 2005 15:54:47 +0000 (GMT) (envelope-from erik@smluc.org) Received: by phoenix.smluc.org (Postfix, from userid 1000) id 330AA1CE81; Sun, 17 Apr 2005 10:56:13 -0500 (CDT) Message-Id: <20050417155613.330AA1CE81@phoenix.smluc.org> Date: Sun, 17 Apr 2005 10:56:13 -0500 (CDT) From: Erik Greenwald To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: erik@math.smsu.edu Subject: kern/80031: [Patch] Remove insque/remque from kernel land X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Erik Greenwald List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Apr 2005 16:00:43 -0000 >Number: 80031 >Category: kern >Synopsis: [Patch] Remove insque/remque from kernel land >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Apr 17 16:00:42 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Erik Greenwald >Release: FreeBSD 6.0-CURRENT i386 >Organization: >Environment: System: FreeBSD vidar.br0kenland.org 6.0-CURRENT FreeBSD 6.0-CURRENT #0: Tue Apr 12 12:31:49 EDT 2005 erik@vidar.br0kenland.org:/usr/src/sys/i386/compile/VIDAR i386 >Description: Remove insque and remque from the kernel... The last remaining use was in 'coda', so I c&p'd the stuff in and prefixed it with coda_, then removed it from sys/queue.h (testing has been very very light on this, as I'm not a real coda user... if any coda/current users can put this through the ringer, that'd be highly appreciated... thanks) >How-To-Repeat: >Fix: --- coda.patch begins here --- Index: sys/coda/coda_namecache.c =================================================================== RCS file: /home/ncvs/src/sys/coda/coda_namecache.c,v retrieving revision 1.21 diff -u -r1.21 coda_namecache.c --- sys/coda/coda_namecache.c 5 Jan 2005 23:35:00 -0000 1.21 +++ sys/coda/coda_namecache.c 17 Apr 2005 15:42:21 -0000 @@ -129,6 +129,42 @@ int coda_nc_initialized = 0; /* Initially the cache has not been initialized */ +struct coda_quehead { + struct coda_quehead *qh_link; + struct coda_quehead *qh_rlink; +}; + +static void +coda_insque(void *a, void *b) +{ + struct coda_quehead *element = (struct coda_quehead *)a, + *head = (struct coda_quehead *)b; + + element->qh_link = head->qh_link; + element->qh_rlink = head; + head->qh_link = element; + element->qh_link->qh_rlink = element; +} + +static void +coda_remque(void *a) +{ + struct coda_quehead *element = (struct coda_quehead *)a; + + element->qh_link->qh_rlink = element->qh_rlink; + element->qh_rlink->qh_link = element->qh_link; + element->qh_rlink = 0; +} + +#define CODA_NC_VALID(cncp) (cncp->dcp != (struct cnode *)0) +#define LRU_PART(cncp) (struct coda_cache *) ((char *)cncp + (2*sizeof(struct coda_cache *))) +#define LRU_TOP(cncp) (struct coda_cache *) ((char *)cncp - (2*sizeof(struct coda_cache *))) +#define DATA_PART(cncp) (struct coda_cache *) ((char *)cncp + (4*sizeof(struct coda_cache *))) +#define DATA_SIZE (sizeof(struct coda_cache)-(4*sizeof(struct coda_cache *))) + +#define CODA_NC_LRUINS(elem, pred) coda_insque(LRU_PART(elem), LRU_PART(pred)) +#define CODA_NC_LRUGET(lruhead) LRU_TOP((lruhead).lru_prev) + void coda_nc_init(void) { @@ -150,12 +186,12 @@ for (i=0; i < coda_nc_size; i++) { /* initialize the heap */ CODA_NC_LRUINS(&coda_nc_heap[i], &coda_nc_lru); - CODA_NC_HSHNUL(&coda_nc_heap[i]); + coda_nc_heap[i].hash_next = coda_nc_heap[i].hash_prev = &coda_nc_heap[i]; coda_nc_heap[i].cp = coda_nc_heap[i].dcp = (struct cnode *)0; } for (i=0; i < coda_nc_hashsize; i++) { /* initialize the hashtable */ - CODA_NC_HSHNUL((struct coda_cache *)&coda_nc_hash[i]); + ((struct coda_cache *)&coda_nc_hash[i])->hash_next = ((struct coda_cache *)&coda_nc_hash[i])->hash_prev = ((struct coda_cache *)&coda_nc_hash[i]); } coda_nc_initialized++; @@ -251,9 +287,9 @@ coda_nc_stat.enters++; /* record the enters statistic */ /* Grab the next element in the lru chain */ - cncp = CODA_NC_LRUGET(coda_nc_lru); - - CODA_NC_LRUREM(cncp); /* remove it from the lists */ + cncp = LRU_TOP(coda_nc_lru.lru_prev); + + coda_remque(LRU_PART(cncp)); /* remove it from the lists */ if (CODA_NC_VALID(cncp)) { /* Seems really ugly, but we have to decrement the appropriate @@ -262,7 +298,7 @@ coda_nc_hash[CODA_NC_HASH(cncp->name, cncp->namelen, cncp->dcp)].length--; coda_nc_stat.lru_rm++; /* zapped a valid entry */ - CODA_NC_HSHREM(cncp); + coda_remque(cncp); vrele(CTOV(cncp->dcp)); vrele(CTOV(cncp->cp)); crfree(cncp->cred); @@ -283,7 +319,7 @@ /* Insert into the lru and hash chains. */ CODA_NC_LRUINS(cncp, &coda_nc_lru); - CODA_NC_HSHINS(cncp, &coda_nc_hash[hash]); + coda_insque(cncp, &coda_nc_hash[hash]); coda_nc_hash[hash].length++; /* Used for tuning */ CODA_NC_DEBUG(CODA_NC_PRINTCODA_NC, print_coda_nc(); ) @@ -328,13 +364,13 @@ coda_nc_stat.hits++; /* put this entry at the end of the LRU */ - CODA_NC_LRUREM(cncp); + coda_remque(LRU_PART(cncp)); CODA_NC_LRUINS(cncp, &coda_nc_lru); /* move it to the front of the hash chain */ /* don't need to change the hash bucket length */ - CODA_NC_HSHREM(cncp); - CODA_NC_HSHINS(cncp, &coda_nc_hash[hash]); + coda_remque(cncp); + coda_insque(cncp, &coda_nc_hash[hash]); CODA_NC_DEBUG(CODA_NC_LOOKUP, printf("lookup: dcp %p, name %s, cred %p = cp %p\n", @@ -356,9 +392,9 @@ CODA_NC_DEBUG(CODA_NC_REMOVE, myprintf(("coda_nc_remove %s from parent %s\n", cncp->name, coda_f2s(&cncp->dcp->c_fid))); ) - CODA_NC_HSHREM(cncp); + coda_remque(cncp); - CODA_NC_HSHNUL(cncp); /* have it be a null chain */ + (cncp)->hash_next = (cncp)->hash_prev = (cncp); /* have it be a null chain */ if ((dcstat == IS_DOWNCALL) && (vrefcnt(CTOV(cncp->dcp)) == 1)) { cncp->dcp->c_flags |= C_PURGING; } @@ -374,7 +410,7 @@ /* Put the null entry just after the least-recently-used entry */ /* LRU_TOP adjusts the pointer to point to the top of the structure. */ - CODA_NC_LRUREM(cncp); + coda_remque(LRU_PART(cncp)); CODA_NC_LRUINS(cncp, LRU_TOP(coda_nc_lru.lru_prev)); } @@ -598,8 +634,8 @@ cncp = CODA_NC_LRUGET(*cncp)) { if (CODA_NC_VALID(cncp)) { - CODA_NC_HSHREM(cncp); /* only zero valid nodes */ - CODA_NC_HSHNUL(cncp); + coda_remque(cncp); /* only zero valid nodes */ + cncp->hash_next = cncp->hash_prev = cncp; if ((dcstat == IS_DOWNCALL) && (vrefcnt(CTOV(cncp->dcp)) == 1)) { Index: sys/coda/coda_namecache.h =================================================================== RCS file: /home/ncvs/src/sys/coda/coda_namecache.h,v retrieving revision 1.10 diff -u -r1.10 coda_namecache.h --- sys/coda/coda_namecache.h 5 Jan 2005 23:35:00 -0000 1.10 +++ sys/coda/coda_namecache.h 17 Apr 2005 15:42:21 -0000 @@ -76,31 +76,6 @@ (bcmp(cp->name,name,namelen) == 0)) /* - * Functions to modify the hash and lru chains. - * insque and remque assume that the pointers are the first thing - * in the list node, thus the trickery for lru. - */ - -#define CODA_NC_HSHINS(elem, pred) insque(elem,pred) -#define CODA_NC_HSHREM(elem) remque(elem) -#define CODA_NC_HSHNUL(elem) (elem)->hash_next = \ - (elem)->hash_prev = (elem) - -#define CODA_NC_LRUINS(elem, pred) insque(LRU_PART(elem), LRU_PART(pred)) -#define CODA_NC_LRUREM(elem) remque(LRU_PART(elem)); -#define CODA_NC_LRUGET(lruhead) LRU_TOP((lruhead).lru_prev) - -#define CODA_NC_VALID(cncp) (cncp->dcp != (struct cnode *)0) - -#define LRU_PART(cncp) (struct coda_cache *) \ - ((char *)cncp + (2*sizeof(struct coda_cache *))) -#define LRU_TOP(cncp) (struct coda_cache *) \ - ((char *)cncp - (2*sizeof(struct coda_cache *))) -#define DATA_PART(cncp) (struct coda_cache *) \ - ((char *)cncp + (4*sizeof(struct coda_cache *))) -#define DATA_SIZE (sizeof(struct coda_cache)-(4*sizeof(struct coda_cache *))) - -/* * Structure for an element in the CODA Name Cache. * NOTE: I use the position of arguments and their size in the * implementation of the functions CODA_NC_LRUINS, CODA_NC_LRUREM, and Index: sys/sys/queue.h =================================================================== RCS file: /home/ncvs/src/sys/sys/queue.h,v retrieving revision 1.60 diff -u -r1.60 queue.h --- sys/sys/queue.h 2 Mar 2005 21:33:29 -0000 1.60 +++ sys/sys/queue.h 17 Apr 2005 15:42:21 -0000 @@ -504,50 +504,4 @@ QMD_TRACE_ELEM(&(elm)->field); \ } while (0) - -#ifdef _KERNEL - -/* - * XXX insque() and remque() are an old way of handling certain queues. - * They bogusly assumes that all queue heads look alike. - */ - -struct quehead { - struct quehead *qh_link; - struct quehead *qh_rlink; -}; - -#ifdef __CC_SUPPORTS___INLINE - -static __inline void -insque(void *a, void *b) -{ - struct quehead *element = (struct quehead *)a, - *head = (struct quehead *)b; - - element->qh_link = head->qh_link; - element->qh_rlink = head; - head->qh_link = element; - element->qh_link->qh_rlink = element; -} - -static __inline void -remque(void *a) -{ - struct quehead *element = (struct quehead *)a; - - element->qh_link->qh_rlink = element->qh_rlink; - element->qh_rlink->qh_link = element->qh_link; - element->qh_rlink = 0; -} - -#else /* !__CC_SUPPORTS___INLINE */ - -void insque(void *a, void *b); -void remque(void *a); - -#endif /* __CC_SUPPORTS___INLINE */ - -#endif /* _KERNEL */ - #endif /* !_SYS_QUEUE_H_ */ --- coda.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: