Merge commit 'refs/remotes/origin/linux-have-zvol' into HEAD

This commit is contained in:
Brian Behlendorf 2009-06-26 14:35:02 -07:00
commit 73a044f416
6 changed files with 82 additions and 21 deletions

View File

@ -1,3 +1 @@
gcc-branch
fix-branch
feature-branch
zfs-branch

17
.topmsg
View File

@ -1,19 +1,6 @@
From: Brian Behlendorf <behlendorf1@llnl.gov>
Subject: [PATCH] zfs branch
Subject: [PATCH] linux have zvol
Merged result of all changes which are relevant to both Solaris
and Linux builds of the ZFS code. These are changes where there
is a reasonable chance they will be accepted upstream.
Additionally, since this is effectively the root of the linux
ZFS tree the core linux build system is added here. This
includes autogen.sh, configure.ac, m4 macros, some scripts/*,
and makefiles for all the core ZFS components. Linux-only
features which require tweaks to the build system should appear
on the relevant topic branches. All autotools products which
result from autogen.sh are commited to the linux-configure-branch.
This branch also contains the META, ChangeLog, AUTHORS, TODO,
and README, files.
Use ZVOL if HAVE_ZVOL defined
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>

View File

@ -4130,6 +4130,11 @@ zvol_create_link(libzfs_handle_t *hdl, const char *dataset)
static int
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 };
di_devlink_handle_t dhdl;
priv_set_t *priv_effective;
@ -4218,6 +4223,7 @@ zvol_create_link_common(libzfs_handle_t *hdl, const char *dataset, int ifexists)
}
return (0);
#endif
}
/*
@ -4354,6 +4360,9 @@ zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp)
int
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 };
nvlist_t *nvp;
gid_t gid;
@ -4395,6 +4404,7 @@ zfs_iscsi_perm_check(libzfs_handle_t *hdl, char *dataset, ucred_t *cred)
error = ioctl(hdl->libzfs_fd, ZFS_IOC_ISCSI_PERM_CHECK, &zc);
nvlist_free(nvp);
return (error);
#endif
}
int

View File

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

View File

@ -1532,6 +1532,7 @@ zfs_set_prop_nvlist(const char *name, nvlist_t *nvl)
return (error);
break;
#ifdef HAVE_ZVOL
case ZFS_PROP_VOLSIZE:
if ((error = nvpair_value_uint64(elem, &intval)) != 0 ||
(error = zvol_set_volsize(name,
@ -1544,6 +1545,11 @@ zfs_set_prop_nvlist(const char *name, nvlist_t *nvl)
(error = zvol_set_volblocksize(name, intval)) != 0)
return (error);
break;
#else
case ZFS_PROP_VOLSIZE:
case ZFS_PROP_VOLBLOCKSIZE:
return (ENOTSUP);
#endif /* HAVE_ZVOL */
case ZFS_PROP_VERSION:
if ((error = nvpair_value_uint64(elem, &intval)) != 0 ||
@ -1850,7 +1856,11 @@ zfs_ioc_get_fsacl(zfs_cmd_t *zc)
static int
zfs_ioc_create_minor(zfs_cmd_t *zc)
{
#ifdef HAVE_ZVOL
return (zvol_create_minor(zc->zc_name, ddi_driver_major(zfs_dip)));
#else
return (ENOTSUP);
#endif /* HAVE_ZVOL */
}
/*
@ -1862,7 +1872,11 @@ zfs_ioc_create_minor(zfs_cmd_t *zc)
static int
zfs_ioc_remove_minor(zfs_cmd_t *zc)
{
#ifdef HAVE_ZVOL
return (zvol_remove_minor(zc->zc_name));
#else
return (ENOTSUP);
#endif /* HAVE_ZVOL */
}
/*
@ -2075,9 +2089,11 @@ zfs_ioc_create(zfs_cmd_t *zc)
cbfunc = zfs_create_cb;
break;
#ifdef HAVE_ZVOL
case DMU_OST_ZVOL:
cbfunc = zvol_create_cb;
break;
#endif /* HAVE_ZVOL */
default:
cbfunc = NULL;
@ -2128,6 +2144,7 @@ zfs_ioc_create(zfs_cmd_t *zc)
return (EINVAL);
}
#ifdef HAVE_ZVOL
if (type == DMU_OST_ZVOL) {
uint64_t volsize, volblocksize;
@ -2157,7 +2174,9 @@ zfs_ioc_create(zfs_cmd_t *zc)
nvlist_free(nvprops);
return (error);
}
} else if (type == DMU_OST_ZFS) {
} else
#endif /* HAVE_ZVOL */
if (type == DMU_OST_ZFS) {
int error;
/*
@ -2993,8 +3012,10 @@ zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
uint_t vec;
int error, rc;
#ifdef HAVE_ZVOL
if (getminor(dev) != 0)
return (zvol_ioctl(dev, cmd, arg, flag, cr, rvalp));
#endif
vec = cmd - ZFS_IOC;
ASSERT3U(getmajor(dev), ==, ddi_driver_major(zfs_dip));
@ -3106,6 +3127,7 @@ 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.
*/
static struct cb_ops zfs_cb_ops = {
#ifdef HAVE_ZVOL
zvol_open, /* open */
zvol_close, /* close */
zvol_strategy, /* strategy */
@ -3113,6 +3135,15 @@ static struct cb_ops zfs_cb_ops = {
zvol_dump, /* dump */
zvol_read, /* read */
zvol_write, /* write */
#else
nodev, /* open */
nodev, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
#endif /* HAVE_ZVOL */
zfsdev_ioctl, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */

View File

@ -77,8 +77,14 @@
#include <sys/dumphdr.h>
#include <sys/zil_impl.h>
#ifdef HAVE_SPL
#include <linux/bitops.h>
#include <linux/bitops_compat.h>
#endif
#include "zfs_namecheck.h"
#ifdef HAVE_ZVOL
static void *zvol_state;
#define ZVOL_DUMPSIZE "dumpsize"
@ -149,6 +155,7 @@ zvol_size_changed(zvol_state_t *zv, major_t maj)
spec_size_invalidate(dev, VBLK);
spec_size_invalidate(dev, VCHR);
}
#endif /* HAVE_ZVOL */
int
zvol_check_volsize(uint64_t volsize, uint64_t blocksize)
@ -159,10 +166,22 @@ zvol_check_volsize(uint64_t volsize, uint64_t blocksize)
if (volsize % blocksize != 0)
return (EINVAL);
#ifdef _ILP32
#ifdef HAVE_SPL
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)
return (EOVERFLOW);
#endif
return (0);
}
@ -177,6 +196,7 @@ zvol_check_volblocksize(uint64_t volblocksize)
return (0);
}
#ifdef HAVE_ZVOL
static void
zvol_readonly_changed_cb(void *arg, uint64_t newval)
{
@ -187,6 +207,7 @@ zvol_readonly_changed_cb(void *arg, uint64_t newval)
else
zv->zv_flags &= ~ZVOL_RDONLY;
}
#endif /* HAVE_ZVOL */
int
zvol_get_stats(objset_t *os, nvlist_t *nv)
@ -212,6 +233,7 @@ zvol_get_stats(objset_t *os, nvlist_t *nv)
return (error);
}
#ifdef HAVE_ZVOL
/*
* Find a free minor number.
*/
@ -1482,27 +1504,37 @@ zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
mutex_exit(&zvol_state_lock);
return (error);
}
#endif /* HAVE_ZVOL */
int
zvol_busy(void)
{
#ifdef HAVE_ZVOL
return (zvol_minors != 0);
#else
return 0;
#endif /* HAVE_ZVOL */
}
void
zvol_init(void)
{
#ifdef HAVE_ZVOL
VERIFY(ddi_soft_state_init(&zvol_state, sizeof (zvol_state_t), 1) == 0);
mutex_init(&zvol_state_lock, NULL, MUTEX_DEFAULT, NULL);
#endif /* HAVE_ZVOL */
}
void
zvol_fini(void)
{
#ifdef HAVE_ZVOL
mutex_destroy(&zvol_state_lock);
ddi_soft_state_fini(&zvol_state);
#endif /* HAVE_ZVOL */
}
#ifdef HAVE_ZVOL
static boolean_t
zvol_is_swap(zvol_state_t *zv)
{
@ -1730,3 +1762,4 @@ zvol_dump_fini(zvol_state_t *zv)
return (0);
}
#endif /* HAVE_ZVOL */