Merge branch 'linux-have-zvol' into refs/top-bases/linux-zfs-branch

This commit is contained in:
Brian Behlendorf 2009-11-15 15:58:22 -08:00
commit d876a087ff
5 changed files with 3 additions and 81 deletions

View File

@ -3649,11 +3649,6 @@ zvol_create_link(libzfs_handle_t *hdl, const char *dataset)
static int static int
zvol_create_link_common(libzfs_handle_t *hdl, const char *dataset, int ifexists) zvol_create_link_common(libzfs_handle_t *hdl, const char *dataset, int ifexists)
{ {
#if !defined(HAVE_ZVOL)
return (zfs_standard_error_fmt(hdl, ENOTSUP,
dgettext(TEXT_DOMAIN, "cannot create device links "
"for '%s'"), dataset));
#else
zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; zfs_cmd_t zc = { "\0", "\0", "\0", 0 };
di_devlink_handle_t dhdl; di_devlink_handle_t dhdl;
priv_set_t *priv_effective; priv_set_t *priv_effective;
@ -3742,7 +3737,6 @@ zvol_create_link_common(libzfs_handle_t *hdl, const char *dataset, int ifexists)
} }
return (0); return (0);
#endif
} }
/* /*
@ -3879,9 +3873,6 @@ zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp)
int int
zfs_iscsi_perm_check(libzfs_handle_t *hdl, char *dataset, ucred_t *cred) zfs_iscsi_perm_check(libzfs_handle_t *hdl, char *dataset, ucred_t *cred)
{ {
#if !defined(HAVE_ZVOL)
return (ENOTSUP);
#else
zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; zfs_cmd_t zc = { "\0", "\0", "\0", 0 };
nvlist_t *nvp; nvlist_t *nvp;
gid_t gid; gid_t gid;
@ -3923,7 +3914,6 @@ zfs_iscsi_perm_check(libzfs_handle_t *hdl, char *dataset, ucred_t *cred)
error = ioctl(hdl->libzfs_fd, ZFS_IOC_ISCSI_PERM_CHECK, &zc); error = ioctl(hdl->libzfs_fd, ZFS_IOC_ISCSI_PERM_CHECK, &zc);
nvlist_free(nvp); nvlist_free(nvp);
return (error); return (error);
#endif
} }
int int

View File

@ -2350,7 +2350,6 @@ int
zpool_iter_zvol(zpool_handle_t *zhp, int (*cb)(const char *, void *), zpool_iter_zvol(zpool_handle_t *zhp, int (*cb)(const char *, void *),
void *data) void *data)
{ {
#ifdef HAVE_ZVOL
libzfs_handle_t *hdl = zhp->zpool_hdl; libzfs_handle_t *hdl = zhp->zpool_hdl;
char (*paths)[MAXPATHLEN]; char (*paths)[MAXPATHLEN];
size_t size = 4; size_t size = 4;
@ -2442,8 +2441,7 @@ zpool_iter_zvol(zpool_handle_t *zhp, int (*cb)(const char *, void *),
err: err:
free(paths); free(paths);
(void) close(base); (void) close(base);
#endif return (-1);
return (0);
} }
typedef struct zvol_cb { typedef struct zvol_cb {

View File

@ -973,10 +973,8 @@ dsl_dataset_zvol_cleanup(dsl_dataset_t *ds, const char *name)
if (error) if (error)
return (error); return (error);
#ifdef HAVE_ZVOL
if (dmu_objset_type(os) == DMU_OST_ZVOL) if (dmu_objset_type(os) == DMU_OST_ZVOL)
error = zvol_remove_minor(name); error = zvol_remove_minor(name);
#endif /* HAVE_ZVOL */
dmu_objset_close(os); dmu_objset_close(os);
return (error); return (error);

View File

@ -1799,7 +1799,6 @@ zfs_set_prop_nvlist(const char *name, nvlist_t *nvl)
goto out; goto out;
break; break;
#ifdef HAVE_ZVOL
case ZFS_PROP_VOLSIZE: case ZFS_PROP_VOLSIZE:
if ((error = nvpair_value_uint64(elem, &intval)) != 0 || if ((error = nvpair_value_uint64(elem, &intval)) != 0 ||
(error = zvol_set_volsize(name, (error = zvol_set_volsize(name,
@ -1812,11 +1811,6 @@ zfs_set_prop_nvlist(const char *name, nvlist_t *nvl)
(error = zvol_set_volblocksize(name, intval)) != 0) (error = zvol_set_volblocksize(name, intval)) != 0)
goto out; goto out;
break; break;
#else
case ZFS_PROP_VOLSIZE:
case ZFS_PROP_VOLBLOCKSIZE:
return (ENOTSUP);
#endif /* HAVE_ZVOL */
case ZFS_PROP_VERSION: case ZFS_PROP_VERSION:
{ {
@ -2182,11 +2176,7 @@ zfs_ioc_get_fsacl(zfs_cmd_t *zc)
static int static int
zfs_ioc_create_minor(zfs_cmd_t *zc) zfs_ioc_create_minor(zfs_cmd_t *zc)
{ {
#ifdef HAVE_ZVOL
return (zvol_create_minor(zc->zc_name, ddi_driver_major(zfs_dip))); return (zvol_create_minor(zc->zc_name, ddi_driver_major(zfs_dip)));
#else
return (ENOTSUP);
#endif /* HAVE_ZVOL */
} }
/* /*
@ -2198,11 +2188,7 @@ zfs_ioc_create_minor(zfs_cmd_t *zc)
static int static int
zfs_ioc_remove_minor(zfs_cmd_t *zc) zfs_ioc_remove_minor(zfs_cmd_t *zc)
{ {
#ifdef HAVE_ZVOL
return (zvol_remove_minor(zc->zc_name)); return (zvol_remove_minor(zc->zc_name));
#else
return (ENOTSUP);
#endif /* HAVE_ZVOL */
} }
#ifdef HAVE_ZPL #ifdef HAVE_ZPL
@ -2418,11 +2404,9 @@ zfs_ioc_create(zfs_cmd_t *zc)
cbfunc = zfs_create_cb; cbfunc = zfs_create_cb;
break; break;
#ifdef HAVE_ZVOL
case DMU_OST_ZVOL: case DMU_OST_ZVOL:
cbfunc = zvol_create_cb; cbfunc = zvol_create_cb;
break; break;
#endif /* HAVE_ZVOL */
default: default:
cbfunc = NULL; cbfunc = NULL;
@ -2473,7 +2457,6 @@ zfs_ioc_create(zfs_cmd_t *zc)
return (EINVAL); return (EINVAL);
} }
#ifdef HAVE_ZVOL
if (type == DMU_OST_ZVOL) { if (type == DMU_OST_ZVOL) {
uint64_t volsize, volblocksize; uint64_t volsize, volblocksize;
@ -2503,9 +2486,7 @@ zfs_ioc_create(zfs_cmd_t *zc)
nvlist_free(nvprops); nvlist_free(nvprops);
return (error); return (error);
} }
} else } else if (type == DMU_OST_ZFS) {
#endif /* HAVE_ZVOL */
if (type == DMU_OST_ZFS) {
int error; int error;
/* /*
@ -3726,10 +3707,8 @@ zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
uint_t vec; uint_t vec;
int error, rc; int error, rc;
#ifdef HAVE_ZVOL
if (getminor(dev) != 0) if (getminor(dev) != 0)
return (zvol_ioctl(dev, cmd, arg, flag, cr, rvalp)); return (zvol_ioctl(dev, cmd, arg, flag, cr, rvalp));
#endif
vec = cmd - ZFS_IOC; vec = cmd - ZFS_IOC;
ASSERT3U(getmajor(dev), ==, ddi_driver_major(zfs_dip)); ASSERT3U(getmajor(dev), ==, ddi_driver_major(zfs_dip));
@ -3848,7 +3827,6 @@ zfs_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
* so most of the standard driver entry points are in zvol.c. * so most of the standard driver entry points are in zvol.c.
*/ */
static struct cb_ops zfs_cb_ops = { static struct cb_ops zfs_cb_ops = {
#ifdef HAVE_ZVOL
zvol_open, /* open */ zvol_open, /* open */
zvol_close, /* close */ zvol_close, /* close */
zvol_strategy, /* strategy */ zvol_strategy, /* strategy */
@ -3856,15 +3834,6 @@ static struct cb_ops zfs_cb_ops = {
zvol_dump, /* dump */ zvol_dump, /* dump */
zvol_read, /* read */ zvol_read, /* read */
zvol_write, /* write */ zvol_write, /* write */
#else
nodev, /* open */
nodev, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
#endif /* HAVE_ZVOL */
zfsdev_ioctl, /* ioctl */ zfsdev_ioctl, /* ioctl */
nodev, /* devmap */ nodev, /* devmap */
nodev, /* mmap */ nodev, /* mmap */

View File

@ -77,14 +77,8 @@
#include <sys/dumphdr.h> #include <sys/dumphdr.h>
#include <sys/zil_impl.h> #include <sys/zil_impl.h>
#ifdef HAVE_SPL
#include <linux/bitops.h>
#include <linux/bitops_compat.h>
#endif
#include "zfs_namecheck.h" #include "zfs_namecheck.h"
#ifdef HAVE_ZVOL
static void *zvol_state; static void *zvol_state;
#define ZVOL_DUMPSIZE "dumpsize" #define ZVOL_DUMPSIZE "dumpsize"
@ -156,7 +150,6 @@ zvol_size_changed(zvol_state_t *zv, major_t maj)
spec_size_invalidate(dev, VBLK); spec_size_invalidate(dev, VBLK);
spec_size_invalidate(dev, VCHR); spec_size_invalidate(dev, VCHR);
} }
#endif /* HAVE_ZVOL */
int int
zvol_check_volsize(uint64_t volsize, uint64_t blocksize) zvol_check_volsize(uint64_t volsize, uint64_t blocksize)
@ -167,22 +160,10 @@ zvol_check_volsize(uint64_t volsize, uint64_t blocksize)
if (volsize % blocksize != 0) if (volsize % blocksize != 0)
return (EINVAL); return (EINVAL);
#ifdef HAVE_SPL #ifdef _ILP32
if (volsize % 512 != 0)
return (EINVAL);
/*
* On Linux, the maximum allowed block device size depends on the size
* of sector_t.
*/
if (fls64(volsize / 512 - 1) > NBBY * sizeof (sector_t))
return (EOVERFLOW);
#elif defined(_ILP32)
if (volsize - 1 > SPEC_MAXOFFSET_T) if (volsize - 1 > SPEC_MAXOFFSET_T)
return (EOVERFLOW); return (EOVERFLOW);
#endif #endif
return (0); return (0);
} }
@ -197,7 +178,6 @@ zvol_check_volblocksize(uint64_t volblocksize)
return (0); return (0);
} }
#ifdef HAVE_ZVOL
static void static void
zvol_readonly_changed_cb(void *arg, uint64_t newval) zvol_readonly_changed_cb(void *arg, uint64_t newval)
{ {
@ -208,7 +188,6 @@ zvol_readonly_changed_cb(void *arg, uint64_t newval)
else else
zv->zv_flags &= ~ZVOL_RDONLY; zv->zv_flags &= ~ZVOL_RDONLY;
} }
#endif /* HAVE_ZVOL */
int int
zvol_get_stats(objset_t *os, nvlist_t *nv) zvol_get_stats(objset_t *os, nvlist_t *nv)
@ -234,7 +213,6 @@ zvol_get_stats(objset_t *os, nvlist_t *nv)
return (error); return (error);
} }
#ifdef HAVE_ZVOL
/* /*
* Find a free minor number. * Find a free minor number.
*/ */
@ -1607,37 +1585,27 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
mutex_exit(&zvol_state_lock); mutex_exit(&zvol_state_lock);
return (error); return (error);
} }
#endif /* HAVE_ZVOL */
int int
zvol_busy(void) zvol_busy(void)
{ {
#ifdef HAVE_ZVOL
return (zvol_minors != 0); return (zvol_minors != 0);
#else
return 0;
#endif /* HAVE_ZVOL */
} }
void void
zvol_init(void) zvol_init(void)
{ {
#ifdef HAVE_ZVOL
VERIFY(ddi_soft_state_init(&zvol_state, sizeof (zvol_state_t), 1) == 0); VERIFY(ddi_soft_state_init(&zvol_state, sizeof (zvol_state_t), 1) == 0);
mutex_init(&zvol_state_lock, NULL, MUTEX_DEFAULT, NULL); mutex_init(&zvol_state_lock, NULL, MUTEX_DEFAULT, NULL);
#endif /* HAVE_ZVOL */
} }
void void
zvol_fini(void) zvol_fini(void)
{ {
#ifdef HAVE_ZVOL
mutex_destroy(&zvol_state_lock); mutex_destroy(&zvol_state_lock);
ddi_soft_state_fini(&zvol_state); ddi_soft_state_fini(&zvol_state);
#endif /* HAVE_ZVOL */
} }
#ifdef HAVE_ZVOL
static boolean_t static boolean_t
zvol_is_swap(zvol_state_t *zv) zvol_is_swap(zvol_state_t *zv)
{ {
@ -1865,4 +1833,3 @@ zvol_dump_fini(zvol_state_t *zv)
return (0); return (0);
} }
#endif /* HAVE_ZVOL */