Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*


1223                 if (error = dsl_prop_get_integer(osname, "xattr", &pval, NULL))
1224                         goto out;
1225                 xattr_changed_cb(zfsvfs, pval);
1226                 zfsvfs->z_issnap = B_TRUE;
1227                 zfsvfs->z_os->os_sync = ZFS_SYNC_DISABLED;
1228 
1229                 mutex_enter(&zfsvfs->z_os->os_user_ptr_lock);
1230                 dmu_objset_set_user(zfsvfs->z_os, zfsvfs);
1231                 mutex_exit(&zfsvfs->z_os->os_user_ptr_lock);
1232         } else {
1233                 error = zfsvfs_setup(zfsvfs, B_TRUE);
1234         }
1235 
1236         if (!zfsvfs->z_issnap)
1237                 zfsctl_create(zfsvfs);
1238 out:
1239         if (error) {
1240                 dmu_objset_disown(zfsvfs->z_os, zfsvfs);
1241                 zfsvfs_free(zfsvfs);
1242         } else {
1243                 atomic_add_32(&zfs_active_fs_count, 1);
1244         }
1245 
1246         return (error);
1247 }
1248 
1249 void
1250 zfs_unregister_callbacks(zfsvfs_t *zfsvfs)
1251 {
1252         objset_t *os = zfsvfs->z_os;
1253         struct dsl_dataset *ds;
1254 
1255         /*
1256          * Unregister properties.
1257          */
1258         if (!dmu_objset_is_snapshot(os)) {
1259                 ds = dmu_objset_ds(os);
1260                 VERIFY(dsl_prop_unregister(ds, "atime", atime_changed_cb,
1261                     zfsvfs) == 0);
1262 
1263                 VERIFY(dsl_prop_unregister(ds, "xattr", xattr_changed_cb,


2141         }
2142         return (err);
2143 }
2144 
2145 static void
2146 zfs_freevfs(vfs_t *vfsp)
2147 {
2148         zfsvfs_t *zfsvfs = vfsp->vfs_data;
2149 
2150         /*
2151          * If this is a snapshot, we have an extra VFS_HOLD on our parent
2152          * from zfs_mount().  Release it here.  If we came through
2153          * zfs_mountroot() instead, we didn't grab an extra hold, so
2154          * skip the VFS_RELE for rootvfs.
2155          */
2156         if (zfsvfs->z_issnap && (vfsp != rootvfs))
2157                 VFS_RELE(zfsvfs->z_parent->z_vfs);
2158 
2159         zfsvfs_free(zfsvfs);
2160 
2161         atomic_add_32(&zfs_active_fs_count, -1);
2162 }
2163 
2164 /*
2165  * VFS_INIT() initialization.  Note that there is no VFS_FINI(),
2166  * so we can't safely do any non-idempotent initialization here.
2167  * Leave that to zfs_init() and zfs_fini(), which are called
2168  * from the module's _init() and _fini() entry points.
2169  */
2170 /*ARGSUSED*/
2171 static int
2172 zfs_vfsinit(int fstype, char *name)
2173 {
2174         int error;
2175 
2176         zfsfstype = fstype;
2177 
2178         /*
2179          * Setup vfsops and vnodeops tables.
2180          */
2181         error = vfs_setfsops(fstype, zfs_vfsops_template, &zfs_vfsops);




1223                 if (error = dsl_prop_get_integer(osname, "xattr", &pval, NULL))
1224                         goto out;
1225                 xattr_changed_cb(zfsvfs, pval);
1226                 zfsvfs->z_issnap = B_TRUE;
1227                 zfsvfs->z_os->os_sync = ZFS_SYNC_DISABLED;
1228 
1229                 mutex_enter(&zfsvfs->z_os->os_user_ptr_lock);
1230                 dmu_objset_set_user(zfsvfs->z_os, zfsvfs);
1231                 mutex_exit(&zfsvfs->z_os->os_user_ptr_lock);
1232         } else {
1233                 error = zfsvfs_setup(zfsvfs, B_TRUE);
1234         }
1235 
1236         if (!zfsvfs->z_issnap)
1237                 zfsctl_create(zfsvfs);
1238 out:
1239         if (error) {
1240                 dmu_objset_disown(zfsvfs->z_os, zfsvfs);
1241                 zfsvfs_free(zfsvfs);
1242         } else {
1243                 atomic_inc_32(&zfs_active_fs_count);
1244         }
1245 
1246         return (error);
1247 }
1248 
1249 void
1250 zfs_unregister_callbacks(zfsvfs_t *zfsvfs)
1251 {
1252         objset_t *os = zfsvfs->z_os;
1253         struct dsl_dataset *ds;
1254 
1255         /*
1256          * Unregister properties.
1257          */
1258         if (!dmu_objset_is_snapshot(os)) {
1259                 ds = dmu_objset_ds(os);
1260                 VERIFY(dsl_prop_unregister(ds, "atime", atime_changed_cb,
1261                     zfsvfs) == 0);
1262 
1263                 VERIFY(dsl_prop_unregister(ds, "xattr", xattr_changed_cb,


2141         }
2142         return (err);
2143 }
2144 
2145 static void
2146 zfs_freevfs(vfs_t *vfsp)
2147 {
2148         zfsvfs_t *zfsvfs = vfsp->vfs_data;
2149 
2150         /*
2151          * If this is a snapshot, we have an extra VFS_HOLD on our parent
2152          * from zfs_mount().  Release it here.  If we came through
2153          * zfs_mountroot() instead, we didn't grab an extra hold, so
2154          * skip the VFS_RELE for rootvfs.
2155          */
2156         if (zfsvfs->z_issnap && (vfsp != rootvfs))
2157                 VFS_RELE(zfsvfs->z_parent->z_vfs);
2158 
2159         zfsvfs_free(zfsvfs);
2160 
2161         atomic_dec_32(&zfs_active_fs_count);
2162 }
2163 
2164 /*
2165  * VFS_INIT() initialization.  Note that there is no VFS_FINI(),
2166  * so we can't safely do any non-idempotent initialization here.
2167  * Leave that to zfs_init() and zfs_fini(), which are called
2168  * from the module's _init() and _fini() entry points.
2169  */
2170 /*ARGSUSED*/
2171 static int
2172 zfs_vfsinit(int fstype, char *name)
2173 {
2174         int error;
2175 
2176         zfsfstype = fstype;
2177 
2178         /*
2179          * Setup vfsops and vnodeops tables.
2180          */
2181         error = vfs_setfsops(fstype, zfs_vfsops_template, &zfs_vfsops);