usr/src/uts/common/fs/zfs/zfs_ioctl.c
changeset 11185 f0c31008e395
parent 11181 daeb45eeb9fb
child 11209 462283cb4096
equal deleted inserted replaced
11184:6cb17428ddec 11185:f0c31008e395
   952 	zc->zc_nvlist_dst_size = size;
   952 	zc->zc_nvlist_dst_size = size;
   953 	return (error);
   953 	return (error);
   954 }
   954 }
   955 
   955 
   956 static int
   956 static int
   957 getzfsvfs(const char *dsname, zfsvfs_t **zvp)
   957 getzfsvfs(const char *dsname, zfsvfs_t **zfvp)
   958 {
   958 {
   959 	objset_t *os;
   959 	objset_t *os;
   960 	int error;
   960 	int error;
   961 
   961 
   962 	error = dmu_objset_hold(dsname, FTAG, &os);
   962 	error = dmu_objset_hold(dsname, FTAG, &os);
   966 		dmu_objset_rele(os, FTAG);
   966 		dmu_objset_rele(os, FTAG);
   967 		return (EINVAL);
   967 		return (EINVAL);
   968 	}
   968 	}
   969 
   969 
   970 	mutex_enter(&os->os_user_ptr_lock);
   970 	mutex_enter(&os->os_user_ptr_lock);
   971 	*zvp = dmu_objset_get_user(os);
   971 	*zfvp = dmu_objset_get_user(os);
   972 	if (*zvp) {
   972 	if (*zfvp) {
   973 		VFS_HOLD((*zvp)->z_vfs);
   973 		VFS_HOLD((*zfvp)->z_vfs);
   974 	} else {
   974 	} else {
   975 		error = ESRCH;
   975 		error = ESRCH;
   976 	}
   976 	}
   977 	mutex_exit(&os->os_user_ptr_lock);
   977 	mutex_exit(&os->os_user_ptr_lock);
   978 	dmu_objset_rele(os, FTAG);
   978 	dmu_objset_rele(os, FTAG);
   982 /*
   982 /*
   983  * Find a zfsvfs_t for a mounted filesystem, or create our own, in which
   983  * Find a zfsvfs_t for a mounted filesystem, or create our own, in which
   984  * case its z_vfs will be NULL, and it will be opened as the owner.
   984  * case its z_vfs will be NULL, and it will be opened as the owner.
   985  */
   985  */
   986 static int
   986 static int
   987 zfsvfs_hold(const char *name, void *tag, zfsvfs_t **zvp)
   987 zfsvfs_hold(const char *name, void *tag, zfsvfs_t **zfvp)
   988 {
   988 {
   989 	int error = 0;
   989 	int error = 0;
   990 
   990 
   991 	if (getzfsvfs(name, zvp) != 0)
   991 	if (getzfsvfs(name, zfvp) != 0)
   992 		error = zfsvfs_create(name, zvp);
   992 		error = zfsvfs_create(name, zfvp);
   993 	if (error == 0) {
   993 	if (error == 0) {
   994 		rrw_enter(&(*zvp)->z_teardown_lock, RW_READER, tag);
   994 		rrw_enter(&(*zfvp)->z_teardown_lock, RW_READER, tag);
   995 		if ((*zvp)->z_unmounted) {
   995 		if ((*zfvp)->z_unmounted) {
   996 			/*
   996 			/*
   997 			 * XXX we could probably try again, since the unmounting
   997 			 * XXX we could probably try again, since the unmounting
   998 			 * thread should be just about to disassociate the
   998 			 * thread should be just about to disassociate the
   999 			 * objset from the zfsvfs.
   999 			 * objset from the zfsvfs.
  1000 			 */
  1000 			 */
  1001 			rrw_exit(&(*zvp)->z_teardown_lock, tag);
  1001 			rrw_exit(&(*zfvp)->z_teardown_lock, tag);
  1002 			return (EBUSY);
  1002 			return (EBUSY);
  1003 		}
  1003 		}
  1004 	}
  1004 	}
  1005 	return (error);
  1005 	return (error);
  1006 }
  1006 }