Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/fs/cd9660/cd9660_node.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/fs/cd9660/cd9660_node.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.17.4.1 retrieving revision 1.17.4.2 diff -u -p -r1.17.4.1 -r1.17.4.2 --- src/sys/fs/cd9660/cd9660_node.c 2007/12/08 18:20:12 1.17.4.1 +++ src/sys/fs/cd9660/cd9660_node.c 2007/12/27 00:45:43 1.17.4.2 @@ -1,4 +1,4 @@ -/* $NetBSD: cd9660_node.c,v 1.17.4.1 2007/12/08 18:20:12 mjf Exp $ */ +/* $NetBSD: cd9660_node.c,v 1.17.4.2 2007/12/27 00:45:43 mjf Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1994 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: cd9660_node.c,v 1.17.4.1 2007/12/08 18:20:12 mjf Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cd9660_node.c,v 1.17.4.2 2007/12/27 00:45:43 mjf Exp $"); #include #include @@ -64,13 +64,8 @@ __KERNEL_RCSID(0, "$NetBSD: cd9660_node. LIST_HEAD(ihashhead, iso_node) *isohashtbl; u_long isohash; #define INOHASH(device, inum) (((device) + ((inum)>>12)) & isohash) -struct simplelock cd9660_ihash_slock; - -#ifdef ISODEVMAP -LIST_HEAD(idvhashhead, iso_dnode) *idvhashtbl; -u_long idvhash; -#define DNOHASH(device, inum) (((device) + ((inum)>>12)) & idvhash) -#endif +kmutex_t cd9660_ihash_lock; +kmutex_t cd9660_hashlock; extern int prtactive; /* 1 => print out reclaim of active vnodes */ @@ -90,11 +85,8 @@ cd9660_init() "cd9660nopl", &pool_allocator_nointr, IPL_NONE); isohashtbl = hashinit(desiredvnodes, HASH_LIST, M_ISOFSMNT, M_WAITOK, &isohash); - simple_lock_init(&cd9660_ihash_slock); -#ifdef ISODEVMAP - idvhashtbl = hashinit(desiredvnodes / 8, HASH_LIST, M_ISOFSMNT, - M_WAITOK, &idvhash); -#endif + mutex_init(&cd9660_ihash_lock, MUTEX_DEFAULT, IPL_NONE); + mutex_init(&cd9660_hashlock, MUTEX_DEFAULT, IPL_NONE); } /* @@ -107,38 +99,16 @@ cd9660_reinit() struct iso_node *ip; struct ihashhead *oldhash1, *hash1; u_long oldmask1, mask1, val; -#ifdef ISODEVMAP - struct iso_dnode *dp; - struct idvhashhead *oldhash2, *hash2; - u_long oldmask2, mask2; -#endif u_int i; hash1 = hashinit(desiredvnodes, HASH_LIST, M_ISOFSMNT, M_WAITOK, &mask1); -#ifdef ISODEVMAP - hash2 = hashinit(desiredvnodes / 8, HASH_LIST, M_ISOFSMNT, M_WAITOK, - &mask2); -#endif - simple_lock(&cd9660_ihash_slock); + mutex_enter(&cd9660_ihash_lock); oldhash1 = isohashtbl; oldmask1 = isohash; isohashtbl = hash1; isohash = mask1; -#ifdef ISODEVMAP - oldhash2 = idvhashtbl; - oldmask2 = idvhash; - idvhashtbl = hash2; - idvhash = mask2; - for (i = 0; i <= oldmask2; i++) { - while ((dp = LIST_FIRST(&oldhash2[i])) != NULL) { - LIST_REMOVE(dp, d_hash); - val = DNOHASH(dp->i_dev, dp->i_number); - LIST_INSERT_HEAD(&hash2[val], dp, d_hash); - } - } -#endif for (i = 0; i <= oldmask1; i++) { while ((ip = LIST_FIRST(&oldhash1[i])) != NULL) { LIST_REMOVE(ip, i_hash); @@ -146,11 +116,8 @@ cd9660_reinit() LIST_INSERT_HEAD(&hash1[val], ip, i_hash); } } - simple_unlock(&cd9660_ihash_slock); + mutex_exit(&cd9660_ihash_lock); hashdone(oldhash1, M_ISOFSMNT); -#ifdef ISODEVMAP - hashdone(oldhash2, M_ISOFSMNT); -#endif } /* @@ -160,87 +127,42 @@ void cd9660_done() { hashdone(isohashtbl, M_ISOFSMNT); -#ifdef ISODEVMAP - hashdone(idvhashtbl, M_ISOFSMNT); -#endif pool_destroy(&cd9660_node_pool); + mutex_destroy(&cd9660_ihash_lock); + mutex_destroy(&cd9660_hashlock); malloc_type_detach(M_ISOFSMNT); } -#ifdef ISODEVMAP -/* - * Enter a new node into the device hash list - */ -struct iso_dnode * -iso_dmap(device, inum, create) - dev_t device; - ino_t inum; - int create; -{ - struct iso_dnode *dp; - struct idvhashhead *hp; - - hp = &idvhashtbl[DNOHASH(device, inum)]; - LIST_FOREACH(dp, hp, d_hash) { - if (inum == dp->i_number && device == dp->i_dev) - return (dp); - } - - if (!create) - return (NULL); - - MALLOC(dp, struct iso_dnode *, sizeof(struct iso_dnode), M_CACHE, - M_WAITOK); - dp->i_dev = device; - dp->i_number = inum; - LIST_INSERT_HEAD(hp, dp, d_hash); - return (dp); -} - -void -iso_dunmap(device) - dev_t device; -{ - struct idvhashhead *dpp; - struct iso_dnode *dp, *dq; - - for (dpp = idvhashtbl; dpp <= idvhashtbl + idvhash; dpp++) { - for (dp = LIST_FIRST(dpp); dp != NULL; dp = dq) { - dq = LIST_NEXT(dp, d_hash); - if (device == dp->i_dev) { - LIST_REMOVE(dp, d_hash); - FREE(dp, M_CACHE); - } - } - } -} -#endif - /* * Use the device/inum pair to find the incore inode, and return a pointer * to it. If it is in core, but locked, wait for it. */ struct vnode * -cd9660_ihashget(dev, inum) +cd9660_ihashget(dev, inum, flags) dev_t dev; ino_t inum; + int flags; { struct iso_node *ip; struct vnode *vp; loop: - simple_lock(&cd9660_ihash_slock); + mutex_enter(&cd9660_ihash_lock); LIST_FOREACH(ip, &isohashtbl[INOHASH(dev, inum)], i_hash) { if (inum == ip->i_number && dev == ip->i_dev) { vp = ITOV(ip); - simple_lock(&vp->v_interlock); - simple_unlock(&cd9660_ihash_slock); - if (vget(vp, LK_EXCLUSIVE | LK_INTERLOCK)) - goto loop; + if (flags == 0) { + mutex_exit(&cd9660_ihash_lock); + } else { + simple_lock(&vp->v_interlock); + mutex_exit(&cd9660_ihash_lock); + if (vget(vp, flags | LK_INTERLOCK)) + goto loop; + } return (vp); } } - simple_unlock(&cd9660_ihash_slock); + mutex_exit(&cd9660_ihash_lock); return (NULL); } @@ -255,10 +177,12 @@ cd9660_ihashins(ip) { struct ihashhead *ipp; - simple_lock(&cd9660_ihash_slock); + KASSERT(mutex_owned(&cd9660_hashlock)); + + mutex_enter(&cd9660_ihash_lock); ipp = &isohashtbl[INOHASH(ip->i_dev, ip->i_number)]; LIST_INSERT_HEAD(ipp, ip, i_hash); - simple_unlock(&cd9660_ihash_slock); + mutex_exit(&cd9660_ihash_lock); lockmgr(&ip->i_vnode->v_lock, LK_EXCLUSIVE, &ip->i_vnode->v_interlock); } @@ -270,9 +194,9 @@ void cd9660_ihashrem(ip) struct iso_node *ip; { - simple_lock(&cd9660_ihash_slock); + mutex_enter(&cd9660_ihash_lock); LIST_REMOVE(ip, i_hash); - simple_unlock(&cd9660_ihash_slock); + mutex_exit(&cd9660_ihash_lock); } /*