6865fbe90b6846fbe1108ea449f7ccb2846fa953
* Copyright (c) 1982, 1986, 1989, 1991, 1993
* The Regents of the University of California. All rights reserved.
* %sccs.include.redist.c%
* @(#)ufs_ihash.c 8.1 (Berkeley) %G%
#include <ufs/ufs/quota.h>
#include <ufs/ufs/inode.h>
#include <ufs/ufs/ufs_extern.h>
* Structures associated with inode cacheing.
u_long ihash
; /* size of hash table - 1 */
#define INOHASH(dev, ino) (((dev) + (ino)) & ihash)
* Initialize inode hash table.
ihashtbl
= hashinit(desiredvnodes
, M_UFSMNT
, &ihash
);
* Use the dev/ino pair to find the incore inode, and return a pointer to it.
* If it is in core, return it, even if it is locked.
ufs_ihashlookup(dev
, ino
)
register struct inode
**ipp
, *ip
;
ipp
= &ihashtbl
[INOHASH(dev
, ino
)];
for (ip
= *ipp
; ip
; ip
= ip
->i_next
) {
if (ino
!= ip
->i_number
|| dev
!= ip
->i_dev
)
* 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 struct inode
**ipp
, *ip
;
ipp
= &ihashtbl
[INOHASH(dev
, ino
)];
for (ip
= *ipp
; ip
; ip
= ip
->i_next
) {
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.
ipp
= &ihashtbl
[INOHASH(ip
->i_dev
, ip
->i_number
)];
iq
->i_prev
= &ip
->i_next
;
if ((ip
->i_flag
& ILOCKED
) != 0)
panic("ufs_ihashins: already locked");
ip
->i_lockholder
= curproc
->p_pid
;
* Remove the inode from the hash table.
register struct inode
*ip
;
register struct inode
*iq
;