FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
/*
 * Associate this zfsvfs with the given objset, which must be owned.
 * This will cache a bunch of on-disk state from the objset in the
 * zfsvfs.
 */
Associate this zfsvfs with the given objset, which must be owned.
This will cache a bunch of on-disk state from the objset in the
zfsvfs.
Associate this zfsvfs with the given objset which must be owned . This will cache a bunch of on - disk state from the objset in the zfsvfs .
static int
zfsvfs_init(zfsvfs_t *zfsvfs, objset_t *os)
{
	int error;
	uint64_t val;
	zfsvfs->z_max_blksz = SPA_OLD_MAXBLOCKSIZE;
	zfsvfs->z_show_ctldir = ZFS_SNAPDIR_VISIBLE;
	zfsvfs->z_os = os;
	error = zfs_get_zplprop(os, ZFS_PROP_VERSION, &zfsvfs->z_version);
	if (error != 0)
		return (error);
	if (zfsvfs->z_version >
	    zfs_zpl_version_map(spa_version(dmu_objset_spa(os)))) {
		(void) printf("Can't mount a version %lld file system "
		    "on a version %lld pool\n. Pool must be upgraded to mount "
		    "this file system.", (u_longlong_t)zfsvfs->z_version,
		    (u_longlong_t)spa_version(dmu_objset_spa(os)));
		return (SET_ERROR(ENOTSUP));
	}
	error = zfs_get_zplprop(os, ZFS_PROP_NORMALIZE, &val);
	if (error != 0)
		return (error);
	zfsvfs->z_norm = (int)val;
	error = zfs_get_zplprop(os, ZFS_PROP_UTF8ONLY, &val);
	if (error != 0)
		return (error);
	zfsvfs->z_utf8 = (val != 0);
	error = zfs_get_zplprop(os, ZFS_PROP_CASE, &val);
	if (error != 0)
		return (error);
	zfsvfs->z_case = (uint_t)val;
	if (zfsvfs->z_case == ZFS_CASE_INSENSITIVE ||
	    zfsvfs->z_case == ZFS_CASE_MIXED)
		zfsvfs->z_norm |= U8_TEXTPREP_TOUPPER;
	zfsvfs->z_use_fuids = USE_FUIDS(zfsvfs->z_version, zfsvfs->z_os);
	zfsvfs->z_use_sa = USE_SA(zfsvfs->z_version, zfsvfs->z_os);
	uint64_t sa_obj = 0;
	if (zfsvfs->z_use_sa) {
		error = zap_lookup(os, MASTER_NODE_OBJ, ZFS_SA_ATTRS, 8, 1,
		    &sa_obj);
		if (error != 0)
			return (error);
	}
	error = sa_setup(os, sa_obj, zfs_attr_table, ZPL_END,
	    &zfsvfs->z_attr_table);
	if (error != 0)
		return (error);
	if (zfsvfs->z_version >= ZPL_VERSION_SA)
		sa_register_update_callback(os, zfs_sa_upgrade);
	error = zap_lookup(os, MASTER_NODE_OBJ, ZFS_ROOT_OBJ, 8, 1,
	    &zfsvfs->z_root);
	if (error != 0)
		return (error);
	ASSERT(zfsvfs->z_root != 0);
	error = zap_lookup(os, MASTER_NODE_OBJ, ZFS_UNLINKED_SET, 8, 1,
	    &zfsvfs->z_unlinkedobj);
	if (error != 0)
		return (error);
	error = zap_lookup(os, MASTER_NODE_OBJ,
	    zfs_userquota_prop_prefixes[ZFS_PROP_USERQUOTA],
	    8, 1, &zfsvfs->z_userquota_obj);
	if (error == ENOENT)
		zfsvfs->z_userquota_obj = 0;
	else if (error != 0)
		return (error);
	error = zap_lookup(os, MASTER_NODE_OBJ,
	    zfs_userquota_prop_prefixes[ZFS_PROP_GROUPQUOTA],
	    8, 1, &zfsvfs->z_groupquota_obj);
	if (error == ENOENT)
		zfsvfs->z_groupquota_obj = 0;
	else if (error != 0)
		return (error);
	error = zap_lookup(os, MASTER_NODE_OBJ, ZFS_FUID_TABLES, 8, 1,
	    &zfsvfs->z_fuid_obj);
	if (error == ENOENT)
		zfsvfs->z_fuid_obj = 0;
	else if (error != 0)
		return (error);
	error = zap_lookup(os, MASTER_NODE_OBJ, ZFS_SHARES_DIR, 8, 1,
	    &zfsvfs->z_shares_dir);
	if (error == ENOENT)
		zfsvfs->z_shares_dir = 0;
	else if (error != 0)
		return (error);
	zfsvfs->z_use_namecache = !zfsvfs->z_norm ||
	    ((zfsvfs->z_case == ZFS_CASE_MIXED) &&
	    !(zfsvfs->z_norm & ~U8_TEXTPREP_TOUPPER));
	return (0);
}
static int zfsvfs_init ( zfsvfs_t * zfsvfs , objset_t * os ) { int error ; uint64_t val ; zfsvfs -> z_max_blksz = SPA_OLD_MAXBLOCKSIZE ; zfsvfs -> z_show_ctldir = ZFS_SNAPDIR_VISIBLE ; zfsvfs -> z_os = os ; error = zfs_get_zplprop ( os , ZFS_PROP_VERSION , & zfsvfs -> z_version ) ; if ( error != 0 ) return ( error ) ; if ( zfsvfs -> z_version > zfs_zpl_version_map ( spa_version ( dmu_objset_spa ( os ) ) ) ) { ( void ) printf ( " " " \n " " " , ( u_longlong_t ) zfsvfs -> z_version , ( u_longlong_t ) spa_version ( dmu_objset_spa ( os ) ) ) ; return ( SET_ERROR ( ENOTSUP ) ) ; } error = zfs_get_zplprop ( os , ZFS_PROP_NORMALIZE , & val ) ; if ( error != 0 ) return ( error ) ; zfsvfs -> z_norm = ( int ) val ; error = zfs_get_zplprop ( os , ZFS_PROP_UTF8ONLY , & val ) ; if ( error != 0 ) return ( error ) ; zfsvfs -> z_utf8 = ( val != 0 ) ; error = zfs_get_zplprop ( os , ZFS_PROP_CASE , & val ) ; if ( error != 0 ) return ( error ) ; zfsvfs -> z_case = ( uint_t ) val ; if ( zfsvfs -> z_case == ZFS_CASE_INSENSITIVE || zfsvfs -> z_case == ZFS_CASE_MIXED ) zfsvfs -> z_norm |= U8_TEXTPREP_TOUPPER ; zfsvfs -> z_use_fuids = USE_FUIDS ( zfsvfs -> z_version , zfsvfs -> z_os ) ; zfsvfs -> z_use_sa = USE_SA ( zfsvfs -> z_version , zfsvfs -> z_os ) ; uint64_t sa_obj = 0 ; if ( zfsvfs -> z_use_sa ) { error = zap_lookup ( os , MASTER_NODE_OBJ , ZFS_SA_ATTRS , 8 , 1 , & sa_obj ) ; if ( error != 0 ) return ( error ) ; } error = sa_setup ( os , sa_obj , zfs_attr_table , ZPL_END , & zfsvfs -> z_attr_table ) ; if ( error != 0 ) return ( error ) ; if ( zfsvfs -> z_version >= ZPL_VERSION_SA ) sa_register_update_callback ( os , zfs_sa_upgrade ) ; error = zap_lookup ( os , MASTER_NODE_OBJ , ZFS_ROOT_OBJ , 8 , 1 , & zfsvfs -> z_root ) ; if ( error != 0 ) return ( error ) ; ASSERT ( zfsvfs -> z_root != 0 ) ; error = zap_lookup ( os , MASTER_NODE_OBJ , ZFS_UNLINKED_SET , 8 , 1 , & zfsvfs -> z_unlinkedobj ) ; if ( error != 0 ) return ( error ) ; error = zap_lookup ( os , MASTER_NODE_OBJ , zfs_userquota_prop_prefixes [ ZFS_PROP_USERQUOTA ] , 8 , 1 , & zfsvfs -> z_userquota_obj ) ; if ( error == ENOENT ) zfsvfs -> z_userquota_obj = 0 ; else if ( error != 0 ) return ( error ) ; error = zap_lookup ( os , MASTER_NODE_OBJ , zfs_userquota_prop_prefixes [ ZFS_PROP_GROUPQUOTA ] , 8 , 1 , & zfsvfs -> z_groupquota_obj ) ; if ( error == ENOENT ) zfsvfs -> z_groupquota_obj = 0 ; else if ( error != 0 ) return ( error ) ; error = zap_lookup ( os , MASTER_NODE_OBJ , ZFS_FUID_TABLES , 8 , 1 , & zfsvfs -> z_fuid_obj ) ; if ( error == ENOENT ) zfsvfs -> z_fuid_obj = 0 ; else if ( error != 0 ) return ( error ) ; error = zap_lookup ( os , MASTER_NODE_OBJ , ZFS_SHARES_DIR , 8 , 1 , & zfsvfs -> z_shares_dir ) ; if ( error == ENOENT ) zfsvfs -> z_shares_dir = 0 ; else if ( error != 0 ) return ( error ) ; zfsvfs -> z_use_namecache = ! zfsvfs -> z_norm || ( ( zfsvfs -> z_case == ZFS_CASE_MIXED ) && ! ( zfsvfs -> z_norm & ~ U8_TEXTPREP_TOUPPER ) ) ; return ( 0 ) ; }
Associate this zfsvfs with the given objset, which must be owned.
Associate this zfsvfs with the given objset which must be owned .
/*
	 * Fold case on file systems that are always or sometimes case
	 * insensitive.
	 */ /* should either have both of these objects or none */ /*
	 * Only use the name cache if we are looking for a
	 * name on a file system that does not require normalization
	 * or case folding.  We can also look there if we happen to be
	 * on a non-normalizing, mixed sensitivity file system IF we
	 * are looking for the exact name (which is always the case on
	 * FreeBSD).
	 */