4314 /* If FEM was in use, make sure everything gets cleaned up */
4315 if (vfsp->vfs_femhead) {
4316 ASSERT(vfsp->vfs_femhead->femh_list == NULL);
4317 mutex_destroy(&vfsp->vfs_femhead->femh_lock);
4318 kmem_free(vfsp->vfs_femhead, sizeof (*(vfsp->vfs_femhead)));
4319 vfsp->vfs_femhead = NULL;
4320 }
4321
4322 if (vfsp->vfs_implp)
4323 vfsimpl_teardown(vfsp);
4324 sema_destroy(&vfsp->vfs_reflock);
4325 kmem_cache_free(vfs_cache, vfsp);
4326 }
4327
4328 /*
4329 * Increments the vfs reference count by one atomically.
4330 */
4331 void
4332 vfs_hold(vfs_t *vfsp)
4333 {
4334 atomic_add_32(&vfsp->vfs_count, 1);
4335 ASSERT(vfsp->vfs_count != 0);
4336 }
4337
4338 /*
4339 * Decrements the vfs reference count by one atomically. When
4340 * vfs reference count becomes zero, it calls the file system
4341 * specific vfs_freevfs() to free up the resources.
4342 */
4343 void
4344 vfs_rele(vfs_t *vfsp)
4345 {
4346 ASSERT(vfsp->vfs_count != 0);
4347 if (atomic_add_32_nv(&vfsp->vfs_count, -1) == 0) {
4348 VFS_FREEVFS(vfsp);
4349 lofi_remove(vfsp);
4350 if (vfsp->vfs_zone)
4351 zone_rele_ref(&vfsp->vfs_implp->vi_zone_ref,
4352 ZONE_REF_VFS);
4353 vfs_freemnttab(vfsp);
4354 vfs_free(vfsp);
4355 }
4356 }
4357
4358 /*
4359 * Generic operations vector support.
4360 *
4361 * This is used to build operations vectors for both the vfs and vnode.
4362 * It's normally called only when a file system is loaded.
4363 *
4364 * There are many possible algorithms for this, including the following:
4365 *
4366 * (1) scan the list of known operations; for each, see if the file system
4367 * includes an entry for it, and fill it in as appropriate.
|
4314 /* If FEM was in use, make sure everything gets cleaned up */
4315 if (vfsp->vfs_femhead) {
4316 ASSERT(vfsp->vfs_femhead->femh_list == NULL);
4317 mutex_destroy(&vfsp->vfs_femhead->femh_lock);
4318 kmem_free(vfsp->vfs_femhead, sizeof (*(vfsp->vfs_femhead)));
4319 vfsp->vfs_femhead = NULL;
4320 }
4321
4322 if (vfsp->vfs_implp)
4323 vfsimpl_teardown(vfsp);
4324 sema_destroy(&vfsp->vfs_reflock);
4325 kmem_cache_free(vfs_cache, vfsp);
4326 }
4327
4328 /*
4329 * Increments the vfs reference count by one atomically.
4330 */
4331 void
4332 vfs_hold(vfs_t *vfsp)
4333 {
4334 atomic_inc_32(&vfsp->vfs_count);
4335 ASSERT(vfsp->vfs_count != 0);
4336 }
4337
4338 /*
4339 * Decrements the vfs reference count by one atomically. When
4340 * vfs reference count becomes zero, it calls the file system
4341 * specific vfs_freevfs() to free up the resources.
4342 */
4343 void
4344 vfs_rele(vfs_t *vfsp)
4345 {
4346 ASSERT(vfsp->vfs_count != 0);
4347 if (atomic_dec_32_nv(&vfsp->vfs_count) == 0) {
4348 VFS_FREEVFS(vfsp);
4349 lofi_remove(vfsp);
4350 if (vfsp->vfs_zone)
4351 zone_rele_ref(&vfsp->vfs_implp->vi_zone_ref,
4352 ZONE_REF_VFS);
4353 vfs_freemnttab(vfsp);
4354 vfs_free(vfsp);
4355 }
4356 }
4357
4358 /*
4359 * Generic operations vector support.
4360 *
4361 * This is used to build operations vectors for both the vfs and vnode.
4362 * It's normally called only when a file system is loaded.
4363 *
4364 * There are many possible algorithms for this, including the following:
4365 *
4366 * (1) scan the list of known operations; for each, see if the file system
4367 * includes an entry for it, and fill it in as appropriate.
|