* Copyright (c) 1982, 1986, 1989, 1991 Regents of the University of California.
* %sccs.include.redist.c%
* @(#)ufs_ihash.c 7.3 (Berkeley) %G%
#include <ufs/ufs/quota.h>
#include <ufs/ufs/inode.h>
#include <ufs/ufs/ufs_extern.h>
* Structures associated with inode cacheing.
struct inode
*ih_chain
[2];
#define ih_forw ih_chain[0]
#define ih_back ih_chain[1]
u_long ihash
; /* size of hash table - 1 */
#define INOHASH(dev, ino) (((dev) + (ino)) & ihash)
* Initialize inode hash table.
register union ihash
*ihp
;
ihashsize
= roundup((desiredvnodes
+ 1) * sizeof *ihp
/ 2,
ihashtbl
= (union ihash
*)malloc((u_long
)ihashsize
,
for (ihash
= 1; ihash
<= ihashsize
/ sizeof *ihp
; ihash
<<= 1)
ihash
= (ihash
>> 1) - 1;
for (ihp
= &ihashtbl
[ihash
]; ihp
>= ihashtbl
; ihp
--) {
* Use the dev/ino pair to find the incore inode, and return a pointer to it.
* If it is in core, but locked, wait for it.
register union ihash
*ihp
;
register struct inode
*ip
;
ihp
= &ihashtbl
[INOHASH(dev
, ino
)];
for (ip
= ihp
->ih_forw
; ip
!= (struct inode
*)ihp
; ip
= ip
->i_forw
) {
if (ino
!= ip
->i_number
|| dev
!= ip
->i_dev
)
if ((ip
->i_flag
& ILOCKED
) != 0) {
sleep((caddr_t
)ip
, PINOD
);
* Insert the inode into the hash table, and return it locked.
insque(ip
, &ihashtbl
[INOHASH(ip
->i_dev
, ip
->i_number
)]);