* Allocate and zero fill the next sized hash table from the appropriate * backing store. * * Arguments: * hash A new hash structure with the old hash size in uh_hashsize * * Returns: * 1 on success and 0 on failure. */
| 1042 | * 1 on success and 0 on failure. |
| 1043 | */ |
| 1044 | static int |
| 1045 | hash_alloc(struct uma_hash *hash, u_int size) |
| 1046 | { |
| 1047 | size_t alloc; |
| 1048 | |
| 1049 | KASSERT(powerof2(size), ("hash size must be power of 2")); |
| 1050 | if (size > UMA_HASH_SIZE_INIT) { |
| 1051 | hash->uh_hashsize = size; |
| 1052 | alloc = sizeof(hash->uh_slab_hash[0]) * hash->uh_hashsize; |
| 1053 | hash->uh_slab_hash = malloc(alloc, M_UMAHASH, M_NOWAIT); |
| 1054 | } else { |
| 1055 | alloc = sizeof(hash->uh_slab_hash[0]) * UMA_HASH_SIZE_INIT; |
| 1056 | hash->uh_slab_hash = zone_alloc_item(hashzone, NULL, |
| 1057 | UMA_ANYDOMAIN, M_WAITOK); |
| 1058 | hash->uh_hashsize = UMA_HASH_SIZE_INIT; |
| 1059 | } |
| 1060 | if (hash->uh_slab_hash) { |
| 1061 | bzero(hash->uh_slab_hash, alloc); |
| 1062 | hash->uh_hashmask = hash->uh_hashsize - 1; |
| 1063 | return (1); |
| 1064 | } |
| 1065 | |
| 1066 | return (0); |
| 1067 | } |
| 1068 | |
| 1069 | /* |
| 1070 | * Expands the hash table for HASH zones. This is done from zone_timeout |
no test coverage detected