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 } |