]> git.proxmox.com Git - mirror_zfs.git/blobdiff - module/zfs/zfs_vfsops.c
OpenZFS 7431 - ZFS Channel Programs
[mirror_zfs.git] / module / zfs / zfs_vfsops.c
index 18b4ec3d6cf1a0ec5fb9fcdb1e2ded07657c9047..bb380c920cbc10e24a7e9cd81ef3cb04bd34456f 100644 (file)
@@ -1053,13 +1053,26 @@ zfsvfs_create(const char *osname, zfsvfs_t **zfvp)
         * We claim to always be readonly so we can open snapshots;
         * other ZPL code will prevent us from writing to snapshots.
         */
+
        error = dmu_objset_own(osname, DMU_OST_ZFS, B_TRUE, B_TRUE,
            zfsvfs, &os);
-       if (error) {
+       if (error != 0) {
                kmem_free(zfsvfs, sizeof (zfsvfs_t));
                return (error);
        }
 
+       error = zfsvfs_create_impl(zfvp, zfsvfs, os);
+       if (error != 0) {
+               dmu_objset_disown(os, B_TRUE, zfsvfs);
+       }
+       return (error);
+}
+
+int
+zfsvfs_create_impl(zfsvfs_t **zfvp, zfsvfs_t *zfsvfs, objset_t *os)
+{
+       int error;
+
        zfsvfs->z_vfs = NULL;
        zfsvfs->z_sb = NULL;
        zfsvfs->z_parent = zfsvfs;
@@ -1086,7 +1099,6 @@ zfsvfs_create(const char *osname, zfsvfs_t **zfvp)
 
        error = zfsvfs_init(zfsvfs, os);
        if (error != 0) {
-               dmu_objset_disown(os, B_TRUE, zfsvfs);
                *zfvp = NULL;
                kmem_free(zfsvfs, sizeof (zfsvfs_t));
                return (error);