| 2571 | } |
| 2572 | |
| 2573 | void |
| 2574 | cache_changesize(u_long newmaxvnodes) |
| 2575 | { |
| 2576 | struct nchashhead *new_nchashtbl, *old_nchashtbl; |
| 2577 | u_long new_nchash, old_nchash; |
| 2578 | struct namecache *ncp; |
| 2579 | uint32_t hash; |
| 2580 | u_long newncsize; |
| 2581 | int i; |
| 2582 | |
| 2583 | newncsize = newmaxvnodes * ncsizefactor; |
| 2584 | newmaxvnodes = cache_roundup_2(newmaxvnodes * 2); |
| 2585 | if (newmaxvnodes < numbucketlocks) |
| 2586 | newmaxvnodes = numbucketlocks; |
| 2587 | |
| 2588 | new_nchashtbl = nchinittbl(newmaxvnodes, &new_nchash); |
| 2589 | /* If same hash table size, nothing to do */ |
| 2590 | if (nchash == new_nchash) { |
| 2591 | ncfreetbl(new_nchashtbl); |
| 2592 | return; |
| 2593 | } |
| 2594 | /* |
| 2595 | * Move everything from the old hash table to the new table. |
| 2596 | * None of the namecache entries in the table can be removed |
| 2597 | * because to do so, they have to be removed from the hash table. |
| 2598 | */ |
| 2599 | cache_lock_all_vnodes(); |
| 2600 | cache_lock_all_buckets(); |
| 2601 | old_nchashtbl = nchashtbl; |
| 2602 | old_nchash = nchash; |
| 2603 | nchashtbl = new_nchashtbl; |
| 2604 | nchash = new_nchash; |
| 2605 | for (i = 0; i <= old_nchash; i++) { |
| 2606 | while ((ncp = CK_SLIST_FIRST(&old_nchashtbl[i])) != NULL) { |
| 2607 | hash = cache_get_hash(ncp->nc_name, ncp->nc_nlen, |
| 2608 | ncp->nc_dvp); |
| 2609 | CK_SLIST_REMOVE(&old_nchashtbl[i], ncp, namecache, nc_hash); |
| 2610 | CK_SLIST_INSERT_HEAD(NCHHASH(hash), ncp, nc_hash); |
| 2611 | } |
| 2612 | } |
| 2613 | ncsize = newncsize; |
| 2614 | cache_recalc_neg_min(ncnegminpct); |
| 2615 | cache_unlock_all_buckets(); |
| 2616 | cache_unlock_all_vnodes(); |
| 2617 | ncfreetbl(old_nchashtbl); |
| 2618 | } |
| 2619 | |
| 2620 | /* |
| 2621 | * Remove all entries from and to a particular vnode. |
no test coverage detected