Convert i_next field in struct inode to a LIST

看板DFBSD_submit作者時間21年前 (2005/04/08 02:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/10 (看更多)
--=-=-= Attached is a simple patch to convert i_next field of struct inode to a LIST. Kindly review and comment/commit. truely dheeraj --=-=-= Content-Disposition: attachment; filename=diff-inode.txt Index: inode.h =================================================================== RCS file: /home/dcvs/src/sys/vfs/ufs/inode.h,v retrieving revision 1.9 diff -u -r1.9 inode.h --- inode.h 30 Dec 2004 07:01:52 -0000 1.9 +++ inode.h 6 Apr 2005 18:01:52 -0000 @@ -81,7 +81,7 @@ * active, and is put back when the file is no longer being used. */ struct inode { - struct inode *i_next;/* Hash chain */ + LIST_ENTRY(inode) i_hash; /* Hash chain */ struct vnode *i_vnode;/* Vnode associated with this inode. */ struct vnode *i_devvp;/* Vnode for block I/O. */ uint32_t i_flag; /* flags, see below */ Index: ufs_ihash.c =================================================================== RCS file: /home/dcvs/src/sys/vfs/ufs/ufs_ihash.c,v retrieving revision 1.15 diff -u -r1.15 ufs_ihash.c --- ufs_ihash.c 20 Jan 2005 18:08:54 -0000 1.15 +++ ufs_ihash.c 6 Apr 2005 18:38:10 -0000 @@ -51,7 +51,7 @@ /* * Structures associated with inode cacheing. */ -static struct inode **ihashtbl; +static LIST_HEAD(ihashhead, inode) *ihashtbl; static u_long ihash; /* size of hash table - 1 */ static struct lwkt_token ufs_ihash_token; @@ -82,7 +82,7 @@ lwkt_tokref ilock; lwkt_gettoken(&ilock, &ufs_ihash_token); - for (ip = *INOHASH(dev, inum); ip; ip = ip->i_next) { + LIST_FOREACH(ip, INOHASH(dev, inum), i_hash) { if (inum == ip->i_number && dev == ip->i_dev) break; } @@ -111,7 +111,7 @@ lwkt_gettoken(&ilock, &ufs_ihash_token); loop: - for (ip = *INOHASH(dev, inum); ip; ip = ip->i_next) { + LIST_FOREACH(ip, INOHASH(dev, inum), i_hash) { if (inum != ip->i_number || dev != ip->i_dev) continue; vp = ITOV(ip); @@ -121,7 +121,7 @@ * We must check to see if the inode has been ripped * out from under us after blocking. */ - for (ip = *INOHASH(dev, inum); ip; ip = ip->i_next) { + LIST_FOREACH(ip, INOHASH(dev, inum), i_hash) { if (inum == ip->i_number && dev == ip->i_dev) break; } @@ -148,7 +148,7 @@ struct inode *ip; lwkt_gettoken(&ilock, &ufs_ihash_token); - for (ip = *INOHASH(dev, inum); ip; ip = ip->i_next) { + LIST_FOREACH(ip, INOHASH(dev, inum), i_hash) { if (inum == ip->i_number && dev == ip->i_dev) { if (ip->i_vnode) { printf("conflict with vnode %p", ip->i_vnode); @@ -169,22 +169,21 @@ int ufs_ihashins(struct inode *ip) { - struct inode **ipp; + struct ihashhead *ipp; struct inode *iq; lwkt_tokref ilock; KKASSERT((ip->i_flag & IN_HASHED) == 0); lwkt_gettoken(&ilock, &ufs_ihash_token); ipp = INOHASH(ip->i_dev, ip->i_number); - while ((iq = *ipp) != NULL) { + LIST_FOREACH(iq, ipp, i_hash) { if (ip->i_dev == iq->i_dev && ip->i_number == iq->i_number) { lwkt_reltoken(&ilock); return(EBUSY); } - ipp = &iq->i_next; + /* ipp = &iq->i_next; */ } - ip->i_next = NULL; - *ipp = ip; + LIST_INSERT_HEAD(ipp, ip, i_hash); ip->i_flag |= IN_HASHED; lwkt_reltoken(&ilock); return(0); @@ -197,21 +196,12 @@ ufs_ihashrem(struct inode *ip) { lwkt_tokref ilock; - struct inode **ipp; - struct inode *iq; + /* struct inode *iq; */ lwkt_gettoken(&ilock, &ufs_ihash_token); if (ip->i_flag & IN_HASHED) { - ipp = INOHASH(ip->i_dev, ip->i_number); - while ((iq = *ipp) != NULL) { - if (ip == iq) - break; - ipp = &iq->i_next; - } - KKASSERT(ip == iq); - *ipp = ip->i_next; - ip->i_next = NULL; ip->i_flag &= ~IN_HASHED; + LIST_REMOVE(ip, i_hash); } lwkt_reltoken(&ilock); } --=-=-= -- "Nature wants us to react, return blow for blow, cheating for cheating, lie for lie, and then it requires a Divine power not to hit-back, keep control and remain unattached, and act with prudence." --=-=-=--
文章代碼(AID): #12LNME00 (DFBSD_submit)
討論串 (同標題文章)
文章代碼(AID): #12LNME00 (DFBSD_submit)