Lines Matching refs:hash
151 #define MH_KEY_DESTROY(hash, key) ((hash->mh_kdtor)(key)) argument
157 #define MH_VAL_DESTROY(hash, val) ((hash->mh_vdtor)(val)) argument
163 #define MH_KEYCMP(hash, key1, key2) ((hash->mh_keycmp)(key1, key2)) argument
207 uint_t hash = 0; in mod_hash_bystr() local
213 hash = (hash << 4) + *p; in mod_hash_bystr()
214 if ((g = (hash & 0xf0000000)) != 0) { in mod_hash_bystr()
215 hash ^= (g >> 24); in mod_hash_bystr()
216 hash ^= g; in mod_hash_bystr()
219 return (hash); in mod_hash_bystr()
317 mod_hash_destroy_ptrhash(mod_hash_t *hash) in mod_hash_destroy_ptrhash() argument
319 ASSERT(hash); in mod_hash_destroy_ptrhash()
320 mod_hash_destroy_hash(hash); in mod_hash_destroy_ptrhash()
393 mod_hash_destroy_idhash(mod_hash_t *hash) in mod_hash_destroy_idhash() argument
395 ASSERT(hash); in mod_hash_destroy_idhash()
396 mod_hash_destroy_hash(hash); in mod_hash_destroy_idhash()
474 mod_hash_destroy_hash(mod_hash_t *hash) in mod_hash_destroy_hash() argument
482 if (hash == mh_head) { /* removing 1st list elem */ in mod_hash_destroy_hash()
491 if (mhp == hash) { in mod_hash_destroy_hash()
503 mod_hash_clear(hash); in mod_hash_destroy_hash()
505 kmem_free(hash->mh_name, strlen(hash->mh_name) + 1); in mod_hash_destroy_hash()
506 kmem_free(hash, MH_SIZE(hash->mh_nchains)); in mod_hash_destroy_hash()
514 i_mod_hash(mod_hash_t *hash, mod_hash_key_t key) in i_mod_hash() argument
521 if (hash->mh_nchains == 1) in i_mod_hash()
524 h = (hash->mh_hashalg)(hash->mh_hashalg_data, key); in i_mod_hash()
525 return (h % (hash->mh_nchains - 1)); in i_mod_hash()
541 i_mod_hash_insert_nosync(mod_hash_t *hash, mod_hash_key_t key, in i_mod_hash_insert_nosync() argument
547 ASSERT(hash); in i_mod_hash_insert_nosync()
554 entry = kmem_cache_alloc(mh_e_cache, hash->mh_sleep); in i_mod_hash_insert_nosync()
556 hash->mh_stat.mhs_nomem++; in i_mod_hash_insert_nosync()
563 hashidx = i_mod_hash(hash, key); in i_mod_hash_insert_nosync()
566 entry->mhe_next = hash->mh_entries[hashidx]; in i_mod_hash_insert_nosync()
568 hash->mh_entries[hashidx] = entry; in i_mod_hash_insert_nosync()
569 hash->mh_stat.mhs_nelems++; in i_mod_hash_insert_nosync()
575 mod_hash_insert(mod_hash_t *hash, mod_hash_key_t key, mod_hash_val_t val) in mod_hash_insert() argument
580 rw_enter(&hash->mh_contents, RW_WRITER); in mod_hash_insert()
585 if (i_mod_hash_find_nosync(hash, key, &v) == 0) { in mod_hash_insert()
586 rw_exit(&hash->mh_contents); in mod_hash_insert()
587 hash->mh_stat.mhs_coll++; in mod_hash_insert()
591 res = i_mod_hash_insert_nosync(hash, key, val, (mod_hash_hndl_t)0); in mod_hash_insert()
592 rw_exit(&hash->mh_contents); in mod_hash_insert()
598 mod_hash_insert_reserve(mod_hash_t *hash, mod_hash_key_t key, in mod_hash_insert_reserve() argument
604 rw_enter(&hash->mh_contents, RW_WRITER); in mod_hash_insert_reserve()
609 if (i_mod_hash_find_nosync(hash, key, &v) == 0) { in mod_hash_insert_reserve()
610 rw_exit(&hash->mh_contents); in mod_hash_insert_reserve()
611 hash->mh_stat.mhs_coll++; in mod_hash_insert_reserve()
614 res = i_mod_hash_insert_nosync(hash, key, val, handle); in mod_hash_insert_reserve()
615 rw_exit(&hash->mh_contents); in mod_hash_insert_reserve()
628 mod_hash_reserve(mod_hash_t *hash, mod_hash_hndl_t *handlep) in mod_hash_reserve() argument
630 *handlep = kmem_cache_alloc(mh_e_cache, hash->mh_sleep); in mod_hash_reserve()
632 hash->mh_stat.mhs_nomem++; in mod_hash_reserve()
640 mod_hash_reserve_nosleep(mod_hash_t *hash, mod_hash_hndl_t *handlep) in mod_hash_reserve_nosleep() argument
644 hash->mh_stat.mhs_nomem++; in mod_hash_reserve_nosleep()
654 mod_hash_cancel(mod_hash_t *hash, mod_hash_hndl_t *handlep) in mod_hash_cancel() argument
666 i_mod_hash_remove_nosync(mod_hash_t *hash, mod_hash_key_t key, in i_mod_hash_remove_nosync() argument
672 hashidx = i_mod_hash(hash, key); in i_mod_hash_remove_nosync()
675 for (e = hash->mh_entries[hashidx]; e != NULL; e = e->mhe_next) { in i_mod_hash_remove_nosync()
676 if (MH_KEYCMP(hash, e->mhe_key, key) == 0) in i_mod_hash_remove_nosync()
686 hash->mh_entries[hashidx] = e->mhe_next; in i_mod_hash_remove_nosync()
693 MH_KEY_DESTROY(hash, e->mhe_key); in i_mod_hash_remove_nosync()
697 hash->mh_stat.mhs_nelems--; in i_mod_hash_remove_nosync()
703 mod_hash_remove(mod_hash_t *hash, mod_hash_key_t key, mod_hash_val_t *val) in mod_hash_remove() argument
707 rw_enter(&hash->mh_contents, RW_WRITER); in mod_hash_remove()
708 res = i_mod_hash_remove_nosync(hash, key, val); in mod_hash_remove()
709 rw_exit(&hash->mh_contents); in mod_hash_remove()
721 mod_hash_replace(mod_hash_t *hash, mod_hash_key_t key, mod_hash_val_t val) in mod_hash_replace() argument
726 rw_enter(&hash->mh_contents, RW_WRITER); in mod_hash_replace()
728 if (i_mod_hash_remove_nosync(hash, key, &v) == 0) { in mod_hash_replace()
732 MH_VAL_DESTROY(hash, v); in mod_hash_replace()
734 res = i_mod_hash_insert_nosync(hash, key, val, (mod_hash_hndl_t)0); in mod_hash_replace()
736 rw_exit(&hash->mh_contents); in mod_hash_replace()
746 mod_hash_destroy(mod_hash_t *hash, mod_hash_key_t key) in mod_hash_destroy() argument
751 rw_enter(&hash->mh_contents, RW_WRITER); in mod_hash_destroy()
753 if ((rv = i_mod_hash_remove_nosync(hash, key, &val)) == 0) { in mod_hash_destroy()
757 MH_VAL_DESTROY(hash, val); in mod_hash_destroy()
760 rw_exit(&hash->mh_contents); in mod_hash_destroy()
770 i_mod_hash_find_nosync(mod_hash_t *hash, mod_hash_key_t key, in i_mod_hash_find_nosync() argument
776 hashidx = i_mod_hash(hash, key); in i_mod_hash_find_nosync()
778 for (e = hash->mh_entries[hashidx]; e != NULL; e = e->mhe_next) { in i_mod_hash_find_nosync()
779 if (MH_KEYCMP(hash, e->mhe_key, key) == 0) { in i_mod_hash_find_nosync()
781 hash->mh_stat.mhs_hit++; in i_mod_hash_find_nosync()
785 hash->mh_stat.mhs_miss++; in i_mod_hash_find_nosync()
790 mod_hash_find(mod_hash_t *hash, mod_hash_key_t key, mod_hash_val_t *val) in mod_hash_find() argument
794 rw_enter(&hash->mh_contents, RW_READER); in mod_hash_find()
795 res = i_mod_hash_find_nosync(hash, key, val); in mod_hash_find()
796 rw_exit(&hash->mh_contents); in mod_hash_find()
802 mod_hash_find_cb(mod_hash_t *hash, mod_hash_key_t key, mod_hash_val_t *val, in mod_hash_find_cb() argument
807 rw_enter(&hash->mh_contents, RW_READER); in mod_hash_find_cb()
808 res = i_mod_hash_find_nosync(hash, key, val); in mod_hash_find_cb()
812 rw_exit(&hash->mh_contents); in mod_hash_find_cb()
818 mod_hash_find_cb_rval(mod_hash_t *hash, mod_hash_key_t key, mod_hash_val_t *val, in mod_hash_find_cb_rval() argument
823 rw_enter(&hash->mh_contents, RW_READER); in mod_hash_find_cb_rval()
824 res = i_mod_hash_find_nosync(hash, key, val); in mod_hash_find_cb_rval()
828 rw_exit(&hash->mh_contents); in mod_hash_find_cb_rval()
834 i_mod_hash_walk_nosync(mod_hash_t *hash, in i_mod_hash_walk_nosync() argument
842 (hashidx < (hash->mh_nchains - 1)) && (res == MH_WALK_CONTINUE); in i_mod_hash_walk_nosync()
844 e = hash->mh_entries[hashidx]; in i_mod_hash_walk_nosync()
862 mod_hash_walk(mod_hash_t *hash, in mod_hash_walk() argument
865 rw_enter(&hash->mh_contents, RW_READER); in mod_hash_walk()
866 i_mod_hash_walk_nosync(hash, callback, arg); in mod_hash_walk()
867 rw_exit(&hash->mh_contents); in mod_hash_walk()
878 i_mod_hash_clear_nosync(mod_hash_t *hash) in i_mod_hash_clear_nosync() argument
883 for (i = 0; i < hash->mh_nchains; i++) { in i_mod_hash_clear_nosync()
884 e = hash->mh_entries[i]; in i_mod_hash_clear_nosync()
886 MH_KEY_DESTROY(hash, e->mhe_key); in i_mod_hash_clear_nosync()
887 MH_VAL_DESTROY(hash, e->mhe_val); in i_mod_hash_clear_nosync()
892 hash->mh_entries[i] = NULL; in i_mod_hash_clear_nosync()
894 hash->mh_stat.mhs_nelems = 0; in i_mod_hash_clear_nosync()
898 mod_hash_clear(mod_hash_t *hash) in mod_hash_clear() argument
900 ASSERT(hash); in mod_hash_clear()
901 rw_enter(&hash->mh_contents, RW_WRITER); in mod_hash_clear()
902 i_mod_hash_clear_nosync(hash); in mod_hash_clear()
903 rw_exit(&hash->mh_contents); in mod_hash_clear()