| 199 | } |
| 200 | |
| 201 | void |
| 202 | vfs_hash_changesize(u_long newmaxvnodes) |
| 203 | { |
| 204 | struct vfs_hash_head *vfs_hash_newtbl, *vfs_hash_oldtbl; |
| 205 | u_long vfs_hash_newmask, vfs_hash_oldmask; |
| 206 | struct vnode *vp; |
| 207 | int i; |
| 208 | |
| 209 | vfs_hash_newtbl = hashinit(newmaxvnodes, M_VFS_HASH, |
| 210 | &vfs_hash_newmask); |
| 211 | /* If same hash table size, nothing to do */ |
| 212 | if (vfs_hash_mask == vfs_hash_newmask) { |
| 213 | free(vfs_hash_newtbl, M_VFS_HASH); |
| 214 | return; |
| 215 | } |
| 216 | /* |
| 217 | * Move everything from the old hash table to the new table. |
| 218 | * None of the vnodes in the table can be recycled because to |
| 219 | * do so, they have to be removed from the hash table. |
| 220 | */ |
| 221 | rw_wlock(&vfs_hash_lock); |
| 222 | vfs_hash_oldtbl = vfs_hash_tbl; |
| 223 | vfs_hash_oldmask = vfs_hash_mask; |
| 224 | vfs_hash_tbl = vfs_hash_newtbl; |
| 225 | vfs_hash_mask = vfs_hash_newmask; |
| 226 | for (i = 0; i <= vfs_hash_oldmask; i++) { |
| 227 | while ((vp = LIST_FIRST(&vfs_hash_oldtbl[i])) != NULL) { |
| 228 | LIST_REMOVE(vp, v_hashlist); |
| 229 | LIST_INSERT_HEAD( |
| 230 | vfs_hash_bucket(vp->v_mount, vp->v_hash), |
| 231 | vp, v_hashlist); |
| 232 | } |
| 233 | } |
| 234 | rw_wunlock(&vfs_hash_lock); |
| 235 | free(vfs_hash_oldtbl, M_VFS_HASH); |
| 236 | } |
no test coverage detected