void ntfs_nthashreinit() { struct ntnode *ip; struct nthashhead *oldhash, *hash; u_long oldmask, mask, val; int i; hash = HASHINIT(desiredvnodes, M_NTFSNTHASH, M_WAITOK, &mask); simple_lock(&ntfs_nthash_slock); oldhash = ntfs_nthashtbl; oldmask = ntfs_nthash; ntfs_nthashtbl = hash; ntfs_nthash = mask; for (i = 0; i <= oldmask; i++) { while ((ip = LIST_FIRST(&oldhash[i])) != NULL) { LIST_REMOVE(ip, i_hash); val = NTNOHASH(ip->i_dev, ip->i_number); LIST_INSERT_HEAD(&hash[val], ip, i_hash); } } simple_unlock(&ntfs_nthash_slock); hashdone(oldhash, M_NTFSNTHASH); }
void ntfs_nthashreinit(void) { struct ntnode *ip; struct nthashhead *oldhash, *hash; u_long oldmask, mask, val; int i; hash = hashinit(desiredvnodes, HASH_LIST, true, &mask); mutex_enter(&ntfs_nthash_lock); oldhash = ntfs_nthashtbl; oldmask = ntfs_nthash; ntfs_nthashtbl = hash; ntfs_nthash = mask; for (i = 0; i <= oldmask; i++) { while ((ip = LIST_FIRST(&oldhash[i])) != NULL) { LIST_REMOVE(ip, i_hash); val = NTNOHASH(ip->i_dev, ip->i_number); LIST_INSERT_HEAD(&hash[val], ip, i_hash); } } mutex_exit(&ntfs_nthash_lock); hashdone(oldhash, HASH_LIST, oldmask); }
/* * Insert the ntnode into the hash table. */ void ntfs_nthashins(struct ntnode *ip) { struct nthashhead *ipp; /* XXXLOCKING lock hash list? */ ipp = &ntfs_nthashtbl[NTNOHASH(ip->i_dev, ip->i_number)]; LIST_INSERT_HEAD(ipp, ip, i_hash); ip->i_flag |= IN_HASHED; /* XXXLOCKING unlock hash list? */ }
/* * Insert the ntnode into the hash table. */ void ntfs_nthashins(struct ntnode *ip) { struct nthashhead *ipp; mutex_enter(&ntfs_nthash_lock); ipp = &ntfs_nthashtbl[NTNOHASH(ip->i_dev, ip->i_number)]; LIST_INSERT_HEAD(ipp, ip, i_hash); ip->i_flag |= IN_HASHED; mutex_exit(&ntfs_nthash_lock); }
/* * Use the device/inum pair to find the incore inode, and return a pointer * to it. If it is in core, return it, even if it is locked. */ struct ntnode * ntfs_nthashlookup(dev_t dev, ntfsino_t inum) { struct ntnode *ip; struct nthashhead *ipp; /* XXXLOCKING lock hash list? */ ipp = &ntfs_nthashtbl[NTNOHASH(dev, inum)]; LIST_FOREACH(ip, ipp, i_hash) { if (inum == ip->i_number && dev == ip->i_dev) break; } /* XXXLOCKING unlock hash list? */ return (ip); }
/* * Use the device/inum pair to find the incore inode, and return a pointer * to it. If it is in core, return it, even if it is locked. */ struct ntnode * ntfs_nthashlookup(dev_t dev, ino_t inum) { struct ntnode *ip; struct nthashhead *ipp; mutex_enter(&ntfs_nthash_lock); ipp = &ntfs_nthashtbl[NTNOHASH(dev, inum)]; LIST_FOREACH(ip, ipp, i_hash) { if (inum == ip->i_number && dev == ip->i_dev) break; } mutex_exit(&ntfs_nthash_lock); return (ip); }