Linux compat 2.6.39: mount_nodev()
[zfs.git] / module / zfs / zfs_ioctl.c
index edfda76..b50f023 100644 (file)
@@ -1107,8 +1107,9 @@ get_zfs_sb(const char *dsname, zfs_sb_t **zsbp)
 
        mutex_enter(&os->os_user_ptr_lock);
        *zsbp = dmu_objset_get_user(os);
-       if (*zsbp) {
-               mntget((*zsbp)->z_vfs);
+       if (*zsbp && (*zsbp)->z_sb) {
+               if (atomic_inc_not_zero(&((*zsbp)->z_sb->s_active)))
+                       error = ESRCH;
        } else {
                error = ESRCH;
        }
@@ -1119,7 +1120,7 @@ get_zfs_sb(const char *dsname, zfs_sb_t **zsbp)
 
 /*
  * Find a zfs_sb_t for a mounted filesystem, or create our own, in which
- * case its z_vfs will be NULL, and it will be opened as the owner.
+ * case its z_sb will be NULL, and it will be opened as the owner.
  */
 static int
 zfs_sb_hold(const char *name, void *tag, zfs_sb_t **zsbp, boolean_t writer)
@@ -1149,8 +1150,8 @@ zfs_sb_rele(zfs_sb_t *zsb, void *tag)
 {
        rrw_exit(&zsb->z_teardown_lock, tag);
 
-       if (zsb->z_vfs) {
-               mntput(zsb->z_vfs);
+       if (zsb->z_sb) {
+               deactivate_super(zsb->z_sb);
        } else {
                dmu_objset_disown(zsb->z_os, zsb);
                zfs_sb_free(zsb);
@@ -1441,7 +1442,7 @@ zfs_ioc_pool_get_history(zfs_cmd_t *zc)
                return (ENOTSUP);
        }
 
-       hist_buf = kmem_alloc(size, KM_SLEEP);
+       hist_buf = vmem_alloc(size, KM_SLEEP);
        if ((error = spa_history_get(spa, &zc->zc_history_offset,
            &zc->zc_history_len, hist_buf)) == 0) {
                error = ddi_copyout(hist_buf,
@@ -1450,7 +1451,7 @@ zfs_ioc_pool_get_history(zfs_cmd_t *zc)
        }
 
        spa_close(spa, FTAG);
-       kmem_free(hist_buf, size);
+       vmem_free(hist_buf, size);
        return (error);
 }
 
@@ -3239,7 +3240,7 @@ zfs_ioc_rollback(zfs_cmd_t *zc)
                        resume_err = zfs_resume_fs(zsb, zc->zc_name);
                        error = error ? error : resume_err;
                }
-               mntput(zsb->z_vfs);
+               deactivate_super(zsb->z_sb);
        } else {
                if (dsl_dataset_tryown(ds, B_FALSE, FTAG)) {
                        error = dsl_dataset_clone_swap(clone, ds, B_TRUE);
@@ -3724,7 +3725,7 @@ zfs_ioc_recv(zfs_cmd_t *zc)
                        if (error == 0)
                                error = zfs_resume_fs(zsb, tofs);
                        error = error ? error : end_err;
-                       mntput(zsb->z_vfs);
+                       deactivate_super(zsb->z_sb);
                } else {
                        error = dmu_recv_end(&drc);
                }
@@ -4094,7 +4095,7 @@ zfs_ioc_userspace_many(zfs_cmd_t *zc)
        if (error)
                return (error);
 
-       buf = kmem_alloc(bufsize, KM_SLEEP);
+       buf = vmem_alloc(bufsize, KM_SLEEP);
 
        error = zfs_userspace_many(zsb, zc->zc_objset_type, &zc->zc_cookie,
            buf, &zc->zc_nvlist_dst_size);
@@ -4104,7 +4105,7 @@ zfs_ioc_userspace_many(zfs_cmd_t *zc)
                    (void *)(uintptr_t)zc->zc_nvlist_dst,
                    zc->zc_nvlist_dst_size);
        }
-       kmem_free(buf, bufsize);
+       vmem_free(buf, bufsize);
        zfs_sb_rele(zsb, FTAG);
 
        return (error);
@@ -4137,7 +4138,7 @@ zfs_ioc_userspace_upgrade(zfs_cmd_t *zc)
                }
                if (error == 0)
                        error = dmu_objset_userspace_upgrade(zsb->z_os);
-               mntput(zsb->z_vfs);
+               deactivate_super(zsb->z_sb);
        } else {
                /* XXX kind of reading contents without owning */
                error = dmu_objset_hold(zc->zc_name, FTAG, &os);
@@ -5047,7 +5048,7 @@ zfsdev_ioctl(struct file *filp, unsigned cmd, unsigned long arg)
                error = EFAULT;
 
        if ((error == 0) && !(flag & FKIOCTL))
-               error = zfs_ioc_vec[vec].zvec_secpolicy(zc, NULL);
+               error = zfs_ioc_vec[vec].zvec_secpolicy(zc, CRED());
 
        /*
         * Ensure that all pool/dataset names are valid before we pass down to