Merge commit 'refs/top-bases/linux-zfs-branch' into linux-zfs-branch

This commit is contained in:
Brian Behlendorf 2009-11-20 12:12:35 -08:00
commit de48561bb8
33 changed files with 1830 additions and 398 deletions

View File

@ -554,6 +554,7 @@ zfs_do_clone(int argc, char **argv)
ret = zfs_clone(zhp, argv[1], props); ret = zfs_clone(zhp, argv[1], props);
/* create the mountpoint if necessary */ /* create the mountpoint if necessary */
#ifdef HAVE_ZPL
if (ret == 0) { if (ret == 0) {
zfs_handle_t *clone; zfs_handle_t *clone;
@ -564,6 +565,7 @@ zfs_do_clone(int argc, char **argv)
zfs_close(clone); zfs_close(clone);
} }
} }
#endif /* HAVE_ZPL */
zfs_close(zhp); zfs_close(zhp);
nvlist_free(props); nvlist_free(props);
@ -761,6 +763,7 @@ zfs_do_create(int argc, char **argv)
* in fact created, even if we failed to mount or share it. * in fact created, even if we failed to mount or share it.
*/ */
ret = 0; ret = 0;
#ifdef HAVE_ZPL
if (canmount == ZFS_CANMOUNT_ON) { if (canmount == ZFS_CANMOUNT_ON) {
if (zfs_mount(zhp, NULL, 0) != 0) { if (zfs_mount(zhp, NULL, 0) != 0) {
(void) fprintf(stderr, gettext("filesystem " (void) fprintf(stderr, gettext("filesystem "
@ -772,6 +775,7 @@ zfs_do_create(int argc, char **argv)
ret = 1; ret = 1;
} }
} }
#endif /* HAVE_ZPL */
error: error:
if (zhp) if (zhp)
@ -2787,6 +2791,7 @@ typedef struct get_all_cbdata {
#define SPINNER_TIME 3 /* seconds */ #define SPINNER_TIME 3 /* seconds */
#define MOUNT_TIME 5 /* seconds */ #define MOUNT_TIME 5 /* seconds */
#ifdef HAVE_ZPL
static int static int
get_one_dataset(zfs_handle_t *zhp, void *data) get_one_dataset(zfs_handle_t *zhp, void *data)
{ {
@ -3338,6 +3343,7 @@ share_mount(int op, int argc, char **argv)
return (ret); return (ret);
} }
#endif /* HAVE_ZPL */
/* /*
* zfs mount -a [nfs | iscsi] * zfs mount -a [nfs | iscsi]
@ -3348,7 +3354,11 @@ share_mount(int op, int argc, char **argv)
static int static int
zfs_do_mount(int argc, char **argv) zfs_do_mount(int argc, char **argv)
{ {
#ifdef HAVE_ZPL
return (share_mount(OP_MOUNT, argc, argv)); return (share_mount(OP_MOUNT, argc, argv));
#else
return ENOSYS;
#endif /* HAVE_ZPL */
} }
/* /*
@ -3360,9 +3370,14 @@ zfs_do_mount(int argc, char **argv)
static int static int
zfs_do_share(int argc, char **argv) zfs_do_share(int argc, char **argv)
{ {
#ifdef HAVE_ZPL
return (share_mount(OP_SHARE, argc, argv)); return (share_mount(OP_SHARE, argc, argv));
#else
return ENOSYS;
#endif /* HAVE_ZPL */
} }
#ifdef HAVE_ZPL
typedef struct unshare_unmount_node { typedef struct unshare_unmount_node {
zfs_handle_t *un_zhp; zfs_handle_t *un_zhp;
char *un_mountp; char *un_mountp;
@ -3815,6 +3830,7 @@ unshare_unmount(int op, int argc, char **argv)
return (ret); return (ret);
} }
#endif /* HAVE_ZPL */
/* /*
* zfs unmount -a * zfs unmount -a
@ -3825,7 +3841,11 @@ unshare_unmount(int op, int argc, char **argv)
static int static int
zfs_do_unmount(int argc, char **argv) zfs_do_unmount(int argc, char **argv)
{ {
#ifdef HAVE_ZPL
return (unshare_unmount(OP_MOUNT, argc, argv)); return (unshare_unmount(OP_MOUNT, argc, argv));
#else
return ENOSYS;
#endif /* HAVE_ZPL */
} }
/* /*
@ -3837,7 +3857,11 @@ zfs_do_unmount(int argc, char **argv)
static int static int
zfs_do_unshare(int argc, char **argv) zfs_do_unshare(int argc, char **argv)
{ {
#ifdef HAVE_ZPL
return (unshare_unmount(OP_SHARE, argc, argv)); return (unshare_unmount(OP_SHARE, argc, argv));
#else
return ENOSYS;
#endif /* HAVE_ZPL */
} }
/* ARGSUSED */ /* ARGSUSED */
@ -3853,6 +3877,7 @@ zfs_do_python(int argc, char **argv)
* Called when invoked as /etc/fs/zfs/mount. Do the mount if the mountpoint is * Called when invoked as /etc/fs/zfs/mount. Do the mount if the mountpoint is
* 'legacy'. Otherwise, complain that use should be using 'zfs mount'. * 'legacy'. Otherwise, complain that use should be using 'zfs mount'.
*/ */
#ifdef HAVE_ZPL
static int static int
manual_mount(int argc, char **argv) manual_mount(int argc, char **argv)
{ {
@ -3983,6 +4008,7 @@ manual_unmount(int argc, char **argv)
return (unshare_unmount_path(OP_MOUNT, argv[0], flags, B_TRUE)); return (unshare_unmount_path(OP_MOUNT, argv[0], flags, B_TRUE));
} }
#endif /* HAVE_ZPL */
static int static int
volcheck(zpool_handle_t *zhp, void *data) volcheck(zpool_handle_t *zhp, void *data)
@ -4027,7 +4053,9 @@ main(int argc, char **argv)
{ {
int ret; int ret;
int i = 0; int i = 0;
#ifdef HAVE_ZPL
char *progname; char *progname;
#endif
char *cmdname; char *cmdname;
(void) setlocale(LC_ALL, ""); (void) setlocale(LC_ALL, "");
@ -4052,6 +4080,7 @@ main(int argc, char **argv)
return (1); return (1);
} }
#ifdef HAVE_ZPL
/* /*
* This command also doubles as the /etc/fs mount and unmount program. * This command also doubles as the /etc/fs mount and unmount program.
* Determine if we should take this behavior based on argv[0]. * Determine if we should take this behavior based on argv[0].
@ -4062,6 +4091,9 @@ main(int argc, char **argv)
} else if (strcmp(progname, "umount") == 0) { } else if (strcmp(progname, "umount") == 0) {
ret = manual_unmount(argc, argv); ret = manual_unmount(argc, argv);
} else { } else {
#else
{
#endif /* HAVE_ZPL */
/* /*
* Make sure the user has specified some command. * Make sure the user has specified some command.
*/ */

View File

@ -751,17 +751,20 @@ main(int argc, char **argv)
if (dataset[0] != '\0' && domount) { if (dataset[0] != '\0' && domount) {
if ((zhp = zfs_open(g_zfs, dataset, ZFS_TYPE_DATASET)) == NULL) if ((zhp = zfs_open(g_zfs, dataset, ZFS_TYPE_DATASET)) == NULL)
return (1); return (1);
#ifdef HAVE_ZPL
if (zfs_unmount(zhp, NULL, 0) != 0) if (zfs_unmount(zhp, NULL, 0) != 0)
return (1); return (1);
#endif /* HAVE_ZPL */
} }
record.zi_error = error; record.zi_error = error;
ret = register_handler(pool, flags, &record, quiet); ret = register_handler(pool, flags, &record, quiet);
#ifdef HAVE_ZPL
if (dataset[0] != '\0' && domount) if (dataset[0] != '\0' && domount)
ret = (zfs_mount(zhp, NULL, 0) != 0); ret = (zfs_mount(zhp, NULL, 0) != 0);
#endif /* HAVE_ZPL */
libzfs_fini(g_zfs); libzfs_fini(g_zfs);

View File

@ -696,7 +696,9 @@ zpool_do_create(int argc, char **argv)
(strcmp(mountpoint, ZFS_MOUNTPOINT_LEGACY) != 0 && (strcmp(mountpoint, ZFS_MOUNTPOINT_LEGACY) != 0 &&
strcmp(mountpoint, ZFS_MOUNTPOINT_NONE) != 0)) { strcmp(mountpoint, ZFS_MOUNTPOINT_NONE) != 0)) {
char buf[MAXPATHLEN]; char buf[MAXPATHLEN];
#ifdef HAVE_ZPL
DIR *dirp; DIR *dirp;
#endif
if (mountpoint && mountpoint[0] != '/') { if (mountpoint && mountpoint[0] != '/') {
(void) fprintf(stderr, gettext("invalid mountpoint " (void) fprintf(stderr, gettext("invalid mountpoint "
@ -721,6 +723,7 @@ zpool_do_create(int argc, char **argv)
mountpoint); mountpoint);
} }
#ifdef HAVE_ZPL
if ((dirp = opendir(buf)) == NULL && errno != ENOENT) { if ((dirp = opendir(buf)) == NULL && errno != ENOENT) {
(void) fprintf(stderr, gettext("mountpoint '%s' : " (void) fprintf(stderr, gettext("mountpoint '%s' : "
"%s\n"), buf, strerror(errno)); "%s\n"), buf, strerror(errno));
@ -743,6 +746,7 @@ zpool_do_create(int argc, char **argv)
goto errout; goto errout;
} }
} }
#endif /* HAVE_ZPL */
} }
if (dryrun) { if (dryrun) {
@ -773,8 +777,12 @@ zpool_do_create(int argc, char **argv)
zfs_prop_to_name( zfs_prop_to_name(
ZFS_PROP_MOUNTPOINT), ZFS_PROP_MOUNTPOINT),
mountpoint) == 0); mountpoint) == 0);
#ifdef HAVE_ZPL
if (zfs_mount(pool, NULL, 0) == 0) if (zfs_mount(pool, NULL, 0) == 0)
ret = zfs_shareall(pool); ret = zfs_shareall(pool);
#else
ret = 0;
#endif /* HAVE_ZPL */
zfs_close(pool); zfs_close(pool);
} }
} else if (libzfs_errno(g_zfs) == EZFS_INVALIDNAME) { } else if (libzfs_errno(g_zfs) == EZFS_INVALIDNAME) {
@ -1531,11 +1539,13 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts,
if ((zhp = zpool_open_canfail(g_zfs, name)) == NULL) if ((zhp = zpool_open_canfail(g_zfs, name)) == NULL)
return (1); return (1);
#if HAVE_ZPL
if (zpool_get_state(zhp) != POOL_STATE_UNAVAIL && if (zpool_get_state(zhp) != POOL_STATE_UNAVAIL &&
zpool_enable_datasets(zhp, mntopts, 0) != 0) { zpool_enable_datasets(zhp, mntopts, 0) != 0) {
zpool_close(zhp); zpool_close(zhp);
return (1); return (1);
} }
#endif /* HAVE_ZPL */
zpool_close(zhp); zpool_close(zhp);
return (error); return (error);

View File

@ -593,9 +593,6 @@ extern int zpool_read_label(int, nvlist_t **);
extern int zpool_create_zvol_links(zpool_handle_t *); extern int zpool_create_zvol_links(zpool_handle_t *);
extern int zpool_remove_zvol_links(zpool_handle_t *); extern int zpool_remove_zvol_links(zpool_handle_t *);
/* is this zvol valid for use as a dump device? */
extern int zvol_check_dump_config(char *);
/* /*
* Management interfaces for SMB ACL files * Management interfaces for SMB ACL files
*/ */

View File

@ -93,6 +93,7 @@ struct prop_changelist {
int int
changelist_prefix(prop_changelist_t *clp) changelist_prefix(prop_changelist_t *clp)
{ {
#ifdef HAVE_ZPL
prop_changenode_t *cn; prop_changenode_t *cn;
int ret = 0; int ret = 0;
@ -168,6 +169,9 @@ changelist_prefix(prop_changelist_t *clp)
(void) changelist_postfix(clp); (void) changelist_postfix(clp);
return (ret); return (ret);
#else
return 0;
#endif /* HAVE_ZPL */
} }
/* /*
@ -182,6 +186,7 @@ changelist_prefix(prop_changelist_t *clp)
int int
changelist_postfix(prop_changelist_t *clp) changelist_postfix(prop_changelist_t *clp)
{ {
#ifdef HAVE_ZPL
prop_changenode_t *cn; prop_changenode_t *cn;
char shareopts[ZFS_MAXPROPLEN]; char shareopts[ZFS_MAXPROPLEN];
int errors = 0; int errors = 0;
@ -306,6 +311,9 @@ changelist_postfix(prop_changelist_t *clp)
} }
return (errors ? -1 : 0); return (errors ? -1 : 0);
#else
return 0;
#endif /* HAVE_ZPL */
} }
/* /*
@ -368,6 +376,7 @@ changelist_rename(prop_changelist_t *clp, const char *src, const char *dst)
int int
changelist_unshare(prop_changelist_t *clp, zfs_share_proto_t *proto) changelist_unshare(prop_changelist_t *clp, zfs_share_proto_t *proto)
{ {
#ifdef HAVE_ZPL
prop_changenode_t *cn; prop_changenode_t *cn;
int ret = 0; int ret = 0;
@ -382,6 +391,9 @@ changelist_unshare(prop_changelist_t *clp, zfs_share_proto_t *proto)
} }
return (ret); return (ret);
#else
return 0;
#endif
} }
/* /*

View File

@ -967,6 +967,7 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
/*FALLTHRU*/ /*FALLTHRU*/
#ifdef HAVE_ZPL
case ZFS_PROP_SHARESMB: case ZFS_PROP_SHARESMB:
case ZFS_PROP_SHARENFS: case ZFS_PROP_SHARENFS:
/* /*
@ -1077,6 +1078,7 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
} }
break; break;
#endif /* HAVE_ZPL */
case ZFS_PROP_UTF8ONLY: case ZFS_PROP_UTF8ONLY:
chosen_utf = (int)intval; chosen_utf = (int)intval;
break; break;
@ -2534,6 +2536,7 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen)
goto ancestorerr; goto ancestorerr;
} }
#ifdef HAVE_ZPL
if (zfs_mount(h, NULL, 0) != 0) { if (zfs_mount(h, NULL, 0) != 0) {
opname = dgettext(TEXT_DOMAIN, "mount"); opname = dgettext(TEXT_DOMAIN, "mount");
goto ancestorerr; goto ancestorerr;
@ -2543,6 +2546,7 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen)
opname = dgettext(TEXT_DOMAIN, "share"); opname = dgettext(TEXT_DOMAIN, "share");
goto ancestorerr; goto ancestorerr;
} }
#endif /* HAVE_ZPL */
zfs_close(h); zfs_close(h);
} }
@ -3632,7 +3636,7 @@ error:
/* /*
* Given a zvol dataset, issue the ioctl to create the appropriate minor node, * Given a zvol dataset, issue the ioctl to create the appropriate minor node,
* poke devfsadm to create the /dev link, and then wait for the link to appear. * and wait briefly for udev to create the /dev link.
*/ */
int int
zvol_create_link(libzfs_handle_t *hdl, const char *dataset) zvol_create_link(libzfs_handle_t *hdl, const char *dataset)
@ -3644,9 +3648,8 @@ 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)
{ {
zfs_cmd_t zc = { "\0", "\0", "\0", 0 }; zfs_cmd_t zc = { "\0", "\0", "\0", 0 };
di_devlink_handle_t dhdl; char path[MAXPATHLEN];
priv_set_t *priv_effective; int error;
int privileged;
(void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name)); (void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name));
@ -3683,52 +3686,13 @@ zvol_create_link_common(libzfs_handle_t *hdl, const char *dataset, int ifexists)
} }
/* /*
* If privileged call devfsadm and wait for the links to * Wait up to 10 seconds for udev to create the device.
* magically appear.
* Otherwise, print out an informational message.
*/ */
(void) snprintf(path, sizeof (path), "/dev/%s", dataset);
priv_effective = priv_allocset(); error = zpool_label_disk_wait(path, 10000);
(void) getppriv(PRIV_EFFECTIVE, priv_effective); if (error)
privileged = (priv_isfullset(priv_effective) == B_TRUE); (void) printf(gettext("%s may not be immediately "
priv_freeset(priv_effective); "available\n"), path);
if (privileged) {
if ((dhdl = di_devlink_init(ZFS_DRIVER,
DI_MAKE_LINK)) == NULL) {
zfs_error_aux(hdl, strerror(errno));
(void) zfs_error_fmt(hdl, errno,
dgettext(TEXT_DOMAIN, "cannot create device links "
"for '%s'"), dataset);
(void) ioctl(hdl->libzfs_fd, ZFS_IOC_REMOVE_MINOR, &zc);
return (-1);
} else {
(void) di_devlink_fini(&dhdl);
}
} else {
char pathname[MAXPATHLEN];
struct stat64 statbuf;
int i;
#define MAX_WAIT 10
/*
* This is the poor mans way of waiting for the link
* to show up. If after 10 seconds we still don't
* have it, then print out a message.
*/
(void) snprintf(pathname, sizeof (pathname), "/dev/zvol/dsk/%s",
dataset);
for (i = 0; i != MAX_WAIT; i++) {
if (stat64(pathname, &statbuf) == 0)
break;
(void) sleep(1);
}
if (i == MAX_WAIT)
(void) printf(gettext("%s may not be immediately "
"available\n"), pathname);
}
return (0); return (0);
} }
@ -3864,6 +3828,7 @@ zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp)
return (0); return (0);
} }
#ifdef HAVE_ZPL
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)
{ {
@ -3929,6 +3894,7 @@ zfs_deleg_share_nfs(libzfs_handle_t *hdl, char *dataset, char *path,
error = ioctl(hdl->libzfs_fd, ZFS_IOC_SHARE, &zc); error = ioctl(hdl->libzfs_fd, ZFS_IOC_SHARE, &zc);
return (error); return (error);
} }
#endif /* HAVE_ZPL */
void void
zfs_prune_proplist(zfs_handle_t *zhp, uint8_t *props) zfs_prune_proplist(zfs_handle_t *zhp, uint8_t *props)

View File

@ -85,6 +85,7 @@
#include <sys/systeminfo.h> #include <sys/systeminfo.h>
#define MAXISALEN 257 /* based on sysinfo(2) man page */ #define MAXISALEN 257 /* based on sysinfo(2) man page */
#ifdef HAVE_ZPL
static int zfs_share_proto(zfs_handle_t *, zfs_share_proto_t *); static int zfs_share_proto(zfs_handle_t *, zfs_share_proto_t *);
zfs_share_type_t zfs_is_shared_proto(zfs_handle_t *, char **, zfs_share_type_t zfs_is_shared_proto(zfs_handle_t *, char **,
zfs_share_proto_t); zfs_share_proto_t);
@ -1225,7 +1226,6 @@ out:
return (ret); return (ret);
} }
static int static int
zvol_cb(const char *dataset, void *data) zvol_cb(const char *dataset, void *data)
{ {
@ -1398,3 +1398,53 @@ out:
return (ret); return (ret);
} }
#else /* HAVE_ZPL */
int
zfs_unshare_iscsi(zfs_handle_t *zhp)
{
return 0;
}
int
zfs_unmount(zfs_handle_t *zhp, const char *mountpoint, int flags)
{
return 0;
}
void
remove_mountpoint(zfs_handle_t *zhp) {
return;
}
boolean_t
is_mounted(libzfs_handle_t *zfs_hdl, const char *special, char **where)
{
return B_FALSE;
}
boolean_t
zfs_is_mounted(zfs_handle_t *zhp, char **where)
{
return is_mounted(zhp->zfs_hdl, zfs_get_name(zhp), where);
}
boolean_t
zfs_is_shared(zfs_handle_t *zhp)
{
return B_FALSE;
}
int
zpool_enable_datasets(zpool_handle_t *zhp, const char *mntopts, int flags)
{
return B_FALSE;
}
int
zpool_disable_datasets(zpool_handle_t *zhp, boolean_t force)
{
return B_FALSE;
}
#endif /* HAVE_ZPL */

View File

@ -3285,113 +3285,3 @@ zpool_label_disk(libzfs_handle_t *hdl, zpool_handle_t *zhp, char *name)
return 0; return 0;
} }
static boolean_t
supported_dump_vdev_type(libzfs_handle_t *hdl, nvlist_t *config, char *errbuf)
{
char *type;
nvlist_t **child;
uint_t children, c;
verify(nvlist_lookup_string(config, ZPOOL_CONFIG_TYPE, &type) == 0);
if (strcmp(type, VDEV_TYPE_RAIDZ) == 0 ||
strcmp(type, VDEV_TYPE_FILE) == 0 ||
strcmp(type, VDEV_TYPE_LOG) == 0 ||
strcmp(type, VDEV_TYPE_MISSING) == 0) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"vdev type '%s' is not supported"), type);
(void) zfs_error(hdl, EZFS_VDEVNOTSUP, errbuf);
return (B_FALSE);
}
if (nvlist_lookup_nvlist_array(config, ZPOOL_CONFIG_CHILDREN,
&child, &children) == 0) {
for (c = 0; c < children; c++) {
if (!supported_dump_vdev_type(hdl, child[c], errbuf))
return (B_FALSE);
}
}
return (B_TRUE);
}
/*
* check if this zvol is allowable for use as a dump device; zero if
* it is, > 0 if it isn't, < 0 if it isn't a zvol
*/
int
zvol_check_dump_config(char *arg)
{
zpool_handle_t *zhp = NULL;
nvlist_t *config, *nvroot;
char *p, *volname;
nvlist_t **top;
uint_t toplevels;
libzfs_handle_t *hdl;
char errbuf[1024];
char poolname[ZPOOL_MAXNAMELEN];
int pathlen = strlen(ZVOL_FULL_DEV_DIR);
int ret = 1;
if (strncmp(arg, ZVOL_FULL_DEV_DIR, pathlen)) {
return (-1);
}
(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
"dump is not supported on device '%s'"), arg);
if ((hdl = libzfs_init()) == NULL)
return (1);
libzfs_print_on_error(hdl, B_TRUE);
volname = arg + pathlen;
/* check the configuration of the pool */
if ((p = strchr(volname, '/')) == NULL) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"malformed dataset name"));
(void) zfs_error(hdl, EZFS_INVALIDNAME, errbuf);
return (1);
} else if (p - volname >= ZFS_MAXNAMELEN) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"dataset name is too long"));
(void) zfs_error(hdl, EZFS_NAMETOOLONG, errbuf);
return (1);
} else {
(void) strncpy(poolname, volname, p - volname);
poolname[p - volname] = '\0';
}
if ((zhp = zpool_open(hdl, poolname)) == NULL) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"could not open pool '%s'"), poolname);
(void) zfs_error(hdl, EZFS_OPENFAILED, errbuf);
goto out;
}
config = zpool_get_config(zhp, NULL);
if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
&nvroot) != 0) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"could not obtain vdev configuration for '%s'"), poolname);
(void) zfs_error(hdl, EZFS_INVALCONFIG, errbuf);
goto out;
}
verify(nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN,
&top, &toplevels) == 0);
if (toplevels != 1) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"'%s' has multiple top level vdevs"), poolname);
(void) zfs_error(hdl, EZFS_DEVOVERFLOW, errbuf);
goto out;
}
if (!supported_dump_vdev_type(hdl, top[0], errbuf)) {
goto out;
}
ret = 0;
out:
if (zhp)
zpool_close(zhp);
libzfs_fini(hdl);
return (ret);
}

View File

@ -1975,6 +1975,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
* if we did a replication receive (indicated by stream_avl * if we did a replication receive (indicated by stream_avl
* being non-NULL). * being non-NULL).
*/ */
#ifdef HAVE_ZPL
cp = strchr(zc.zc_value, '@'); cp = strchr(zc.zc_value, '@');
if (cp && (ioctl_err == 0 || !newfs)) { if (cp && (ioctl_err == 0 || !newfs)) {
zfs_handle_t *h; zfs_handle_t *h;
@ -2001,6 +2002,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
} }
*cp = '@'; *cp = '@';
} }
#endif /* HAVE_ZPL */
if (clp) { if (clp) {
err |= changelist_postfix(clp); err |= changelist_postfix(clp);

View File

@ -615,7 +615,9 @@ libzfs_fini(libzfs_handle_t *hdl)
#endif #endif
if (hdl->libzfs_sharetab) if (hdl->libzfs_sharetab)
(void) fclose(hdl->libzfs_sharetab); (void) fclose(hdl->libzfs_sharetab);
#ifdef HAVE_ZPL
zfs_uninit_libshare(hdl); zfs_uninit_libshare(hdl);
#endif
if (hdl->libzfs_log_str) if (hdl->libzfs_log_str)
(void) free(hdl->libzfs_log_str); (void) free(hdl->libzfs_log_str);
zpool_free_handles(hdl); zpool_free_handles(hdl);

View File

@ -533,23 +533,13 @@ typedef struct vdev_stat {
uint64_t vs_scrub_end; /* UTC scrub end time */ uint64_t vs_scrub_end; /* UTC scrub end time */
} vdev_stat_t; } vdev_stat_t;
#define ZVOL_DRIVER "zvol" #define ZVOL_DRIVER "zvol"
#define ZFS_DRIVER "zfs" #define ZFS_DRIVER "zfs"
#define ZFS_DEV "/dev/zfs" #define ZFS_DEV "/dev/zfs"
#define ZVOL_MAJOR 230
/* #define ZVOL_MINOR_BITS 4
* zvol paths. Irritatingly, the devfsadm interfaces want all these #define ZVOL_MINOR_MASK ((1U << ZVOL_MINOR_BITS) - 1)
* paths without the /dev prefix, but for some things, we want the #define ZVOL_MINORS (1 << 4)
* /dev prefix. Below are the names without /dev.
*/
#define ZVOL_DEV_DIR "zvol/dsk"
#define ZVOL_RDEV_DIR "zvol/rdsk"
/*
* And here are the things we need with /dev, etc. in front of them.
*/
#define ZVOL_PSEUDO_DEV "/devices/pseudo/zfs@0:"
#define ZVOL_FULL_DEV_DIR "/dev/" ZVOL_DEV_DIR "/"
#define ZVOL_PROP_NAME "name" #define ZVOL_PROP_NAME "name"

View File

@ -669,9 +669,58 @@ dmu_prealloc(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
} }
#ifdef _KERNEL #ifdef _KERNEL
int
dmu_read_uio(objset_t *os, uint64_t object, uio_t *uio, uint64_t size) /*
* Copy up to size bytes between arg_buf and req based on the data direction
* described by the req. If an entire req's data cannot be transfered the
* req's is updated such that it's current index and bv offsets correctly
* reference any residual data which could not be copied. The return value
* is the number of bytes successfully copied to arg_buf.
*/
static int
dmu_req_copy(void *arg_buf, int size, int *offset, struct request *req)
{ {
struct bio_vec *bv;
struct req_iterator iter;
char *bv_buf;
int tocpy;
*offset = 0;
rq_for_each_segment(bv, req, iter) {
/* Fully consumed the passed arg_buf */
ASSERT3S(offset, <=, size);
if (size == *offset)
break;
/* Skip fully consumed bv's */
if (bv->bv_len == 0)
continue;
tocpy = MIN(bv->bv_len, size - *offset);
ASSERT3S(tocpy, >=, 0);
bv_buf = page_address(bv->bv_page) + bv->bv_offset;
ASSERT3P(bv_buf, !=, NULL);
if (rq_data_dir(req) == WRITE)
memcpy(arg_buf + *offset, bv_buf, tocpy);
else
memcpy(bv_buf, arg_buf + *offset, tocpy);
*offset += tocpy;
bv->bv_offset += tocpy;
bv->bv_len -= tocpy;
}
return 0;
}
int
dmu_read_req(objset_t *os, uint64_t object, struct request *req)
{
uint64_t size = blk_rq_bytes(req);
uint64_t offset = blk_rq_pos(req) << 9;
dmu_buf_t **dbp; dmu_buf_t **dbp;
int numbufs, i, err; int numbufs, i, err;
@ -679,27 +728,33 @@ dmu_read_uio(objset_t *os, uint64_t object, uio_t *uio, uint64_t size)
* NB: we could do this block-at-a-time, but it's nice * NB: we could do this block-at-a-time, but it's nice
* to be reading in parallel. * to be reading in parallel.
*/ */
err = dmu_buf_hold_array(os, object, uio->uio_loffset, size, TRUE, FTAG, err = dmu_buf_hold_array(os, object, offset, size, TRUE, FTAG,
&numbufs, &dbp); &numbufs, &dbp);
if (err) if (err)
return (err); return (err);
for (i = 0; i < numbufs; i++) { for (i = 0; i < numbufs; i++) {
int tocpy; int tocpy, didcpy, bufoff;
int bufoff;
dmu_buf_t *db = dbp[i]; dmu_buf_t *db = dbp[i];
ASSERT(size > 0); bufoff = offset - db->db_offset;
ASSERT3S(bufoff, >=, 0);
bufoff = uio->uio_loffset - db->db_offset;
tocpy = (int)MIN(db->db_size - bufoff, size); tocpy = (int)MIN(db->db_size - bufoff, size);
if (tocpy == 0)
break;
err = dmu_req_copy(db->db_data + bufoff, tocpy, &didcpy, req);
if (didcpy < tocpy)
err = EIO;
err = uiomove((char *)db->db_data + bufoff, tocpy,
UIO_READ, uio);
if (err) if (err)
break; break;
size -= tocpy; size -= tocpy;
offset += didcpy;
err = 0;
} }
dmu_buf_rele_array(dbp, numbufs, FTAG); dmu_buf_rele_array(dbp, numbufs, FTAG);
@ -707,30 +762,31 @@ dmu_read_uio(objset_t *os, uint64_t object, uio_t *uio, uint64_t size)
} }
int int
dmu_write_uio(objset_t *os, uint64_t object, uio_t *uio, uint64_t size, dmu_write_req(objset_t *os, uint64_t object, struct request *req, dmu_tx_t *tx)
dmu_tx_t *tx)
{ {
uint64_t size = blk_rq_bytes(req);
uint64_t offset = blk_rq_pos(req) << 9;
dmu_buf_t **dbp; dmu_buf_t **dbp;
int numbufs, i; int numbufs, i, err;
int err = 0;
if (size == 0) if (size == 0)
return (0); return (0);
err = dmu_buf_hold_array(os, object, uio->uio_loffset, size, err = dmu_buf_hold_array(os, object, offset, size, FALSE, FTAG,
FALSE, FTAG, &numbufs, &dbp); &numbufs, &dbp);
if (err) if (err)
return (err); return (err);
for (i = 0; i < numbufs; i++) { for (i = 0; i < numbufs; i++) {
int tocpy; int tocpy, didcpy, bufoff;
int bufoff;
dmu_buf_t *db = dbp[i]; dmu_buf_t *db = dbp[i];
ASSERT(size > 0); bufoff = offset - db->db_offset;
ASSERT3S(bufoff, >=, 0);
bufoff = uio->uio_loffset - db->db_offset;
tocpy = (int)MIN(db->db_size - bufoff, size); tocpy = (int)MIN(db->db_size - bufoff, size);
if (tocpy == 0)
break;
ASSERT(i == 0 || i == numbufs-1 || tocpy == db->db_size); ASSERT(i == 0 || i == numbufs-1 || tocpy == db->db_size);
@ -739,27 +795,27 @@ dmu_write_uio(objset_t *os, uint64_t object, uio_t *uio, uint64_t size,
else else
dmu_buf_will_dirty(db, tx); dmu_buf_will_dirty(db, tx);
/* err = dmu_req_copy(db->db_data + bufoff, tocpy, &didcpy, req);
* XXX uiomove could block forever (eg. nfs-backed
* pages). There needs to be a uiolockdown() function
* to lock the pages in memory, so that uiomove won't
* block.
*/
err = uiomove((char *)db->db_data + bufoff, tocpy,
UIO_WRITE, uio);
if (tocpy == db->db_size) if (tocpy == db->db_size)
dmu_buf_fill_done(db, tx); dmu_buf_fill_done(db, tx);
if (didcpy < tocpy)
err = EIO;
if (err) if (err)
break; break;
size -= tocpy; size -= tocpy;
offset += didcpy;
err = 0;
} }
dmu_buf_rele_array(dbp, numbufs, FTAG); dmu_buf_rele_array(dbp, numbufs, FTAG);
return (err); return (err);
} }
#endif
#ifdef HAVE_ZPL
int int
dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
page_t *pp, dmu_tx_t *tx) page_t *pp, dmu_tx_t *tx)

View File

@ -246,7 +246,13 @@ dsl_dataset_evict(dmu_buf_t *db, void *dsv)
ASSERT(ds->ds_owner == NULL || DSL_DATASET_IS_DESTROYED(ds)); ASSERT(ds->ds_owner == NULL || DSL_DATASET_IS_DESTROYED(ds));
dprintf_ds(ds, "evicting %s\n", ""); /*
* XXX: Commented out because dsl_dataset_name() is called
* which references ds->ds_dir which it seems may be NULL.
* This is easily trigged with 'zfs destroy <pool>/<ds>.
* *
* dprintf_ds(ds, "evicting %s\n", "");
*/
unique_remove(ds->ds_fsid_guid); unique_remove(ds->ds_fsid_guid);

View File

@ -0,0 +1,164 @@
#ifndef _SYS_BLKDEV_H
#define _SYS_BLKDEV_H
#ifdef _KERNEL
#include <linux/blkdev.h>
#include <linux/elevator.h>
#include "zfs_config.h"
#ifndef HAVE_BLK_FETCH_REQUEST
static inline struct request *
blk_fetch_request(struct request_queue *q)
{
struct request *req;
req = elv_next_request(q);
if (req)
blkdev_dequeue_request(req);
return req;
}
#endif /* HAVE_BLK_FETCH_REQUEST */
#ifndef HAVE_BLK_REQUEUE_REQUEST
static inline void
blk_requeue_request(request_queue_t *q, struct request *req)
{
elv_requeue_request(q, req);
}
#endif /* HAVE_BLK_REQUEUE_REQUEST */
#ifndef HAVE_BLK_END_REQUEST
static inline bool
blk_end_request(struct request *req, int error, unsigned int nr_bytes)
{
struct request_queue *q = req->q;
LIST_HEAD(list);
/*
* Request has already been dequeued but 2.6.18 version of
* end_request() unconditionally dequeues the request so we
* add it to a local list to prevent hitting the BUG_ON.
*/
list_add(&req->queuelist, &list);
/*
* The old API required the driver to end each segment and not
* the entire request. In our case we always need to end the
* entire request partial requests are not supported.
*/
req->hard_cur_sectors = nr_bytes >> 9;
spin_lock_irq(q->queue_lock);
end_request(req, ((error == 0) ? 1 : error));
spin_unlock_irq(q->queue_lock);
return 0;
}
#else
# ifdef HAVE_BLK_END_REQUEST_GPL_ONLY
/*
* Define required to avoid conflicting 2.6.29 non-static prototype for a
* GPL-only version of the helper. As of 2.6.31 the helper is available
* to non-GPL modules and is not explicitly exported GPL-only.
*/
# define blk_end_request ___blk_end_request
static inline bool
___blk_end_request(struct request *req, int error, unsigned int nr_bytes)
{
struct request_queue *q = req->q;
/*
* The old API required the driver to end each segment and not
* the entire request. In our case we always need to end the
* entire request partial requests are not supported.
*/
req->hard_cur_sectors = nr_bytes >> 9;
spin_lock_irq(q->queue_lock);
end_request(req, ((error == 0) ? 1 : error));
spin_unlock_irq(q->queue_lock);
return 0;
}
# endif /* HAVE_BLK_END_REQUEST_GPL_ONLY */
#endif /* HAVE_BLK_END_REQUEST */
#ifndef HAVE_BLK_RQ_POS
static inline sector_t
blk_rq_pos(struct request *req)
{
return req->sector;
}
#endif /* HAVE_BLK_RQ_POS */
#ifndef HAVE_BLK_RQ_SECTORS
static inline unsigned int
blk_rq_sectors(struct request *req)
{
return req->nr_sectors;
}
#endif /* HAVE_BLK_RQ_SECTORS */
#if !defined(HAVE_BLK_RQ_BYTES) || defined(HAVE_BLK_RQ_BYTES_GPL_ONLY)
/*
* Define required to avoid conflicting 2.6.29 non-static prototype for a
* GPL-only version of the helper. As of 2.6.31 the helper is available
* to non-GPL modules in the form of a static inline in the header.
*/
#define blk_rq_bytes __blk_rq_bytes
static inline unsigned int
__blk_rq_bytes(struct request *req)
{
return blk_rq_sectors(req) << 9;
}
#endif /* !HAVE_BLK_RQ_BYTES || HAVE_BLK_RQ_BYTES_GPL_ONLY */
#ifndef HAVE_GET_DISK_RO
static inline int
get_disk_ro(struct gendisk *disk)
{
int policy = 0;
if (disk->part[0])
policy = disk->part[0]->policy;
return policy;
}
#endif /* HAVE_GET_DISK_RO */
#ifndef HAVE_RQ_IS_SYNC
static inline bool
rq_is_sync(struct request *req)
{
return (req->flags & REQ_RW_SYNC);
}
#endif /* HAVE_RQ_IS_SYNC */
#ifndef HAVE_RQ_FOR_EACH_SEGMENT
struct req_iterator {
int i;
struct bio *bio;
};
# define for_each_bio(_bio) \
for (; _bio; _bio = _bio->bi_next)
# define __rq_for_each_bio(_bio, rq) \
if ((rq->bio)) \
for (_bio = (rq)->bio; _bio; _bio = _bio->bi_next)
# define rq_for_each_segment(bvl, _rq, _iter) \
__rq_for_each_bio(_iter.bio, _rq) \
bio_for_each_segment(bvl, _iter.bio, _iter.i)
#endif /* HAVE_RQ_FOR_EACH_SEGMENT */
#ifndef DISK_NAME_LEN
#define DISK_NAME_LEN 32
#endif /* DISK_NAME_LEN */
#endif /* KERNEL */
#endif /* _SYS_BLKDEV_H */

View File

@ -38,12 +38,14 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/cred.h> #include <sys/cred.h>
#ifdef _KERNEL
#include <sys/blkdev.h>
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
struct uio;
struct page; struct page;
struct vnode; struct vnode;
struct spa; struct spa;
@ -490,11 +492,14 @@ void dmu_write(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
const void *buf, dmu_tx_t *tx); const void *buf, dmu_tx_t *tx);
void dmu_prealloc(objset_t *os, uint64_t object, uint64_t offset, uint64_t size, void dmu_prealloc(objset_t *os, uint64_t object, uint64_t offset, uint64_t size,
dmu_tx_t *tx); dmu_tx_t *tx);
int dmu_read_uio(objset_t *os, uint64_t object, struct uio *uio, uint64_t size); #ifdef _KERNEL
int dmu_write_uio(objset_t *os, uint64_t object, struct uio *uio, uint64_t size, int dmu_read_req(objset_t *os, uint64_t object, struct request *req);
dmu_tx_t *tx); int dmu_write_req(objset_t *os, uint64_t object, struct request *req, dmu_tx_t *tx);
#endif
#ifdef HAVE_ZPL
int dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset, int dmu_write_pages(objset_t *os, uint64_t object, uint64_t offset,
uint64_t size, struct page *pp, dmu_tx_t *tx); uint64_t size, struct page *pp, dmu_tx_t *tx);
#endif
struct arc_buf *dmu_request_arcbuf(dmu_buf_t *handle, int size); struct arc_buf *dmu_request_arcbuf(dmu_buf_t *handle, int size);
void dmu_return_arcbuf(struct arc_buf *buf); void dmu_return_arcbuf(struct arc_buf *buf);
void dmu_assign_arcbuf(dmu_buf_t *handle, uint64_t offset, struct arc_buf *buf, void dmu_assign_arcbuf(dmu_buf_t *handle, uint64_t offset, struct arc_buf *buf,

View File

@ -456,7 +456,6 @@ extern uint64_t spa_get_dspace(spa_t *spa);
extern uint64_t spa_get_asize(spa_t *spa, uint64_t lsize); extern uint64_t spa_get_asize(spa_t *spa, uint64_t lsize);
extern uint64_t spa_version(spa_t *spa); extern uint64_t spa_version(spa_t *spa);
extern int spa_max_replication(spa_t *spa); extern int spa_max_replication(spa_t *spa);
extern int spa_busy(void);
extern uint8_t spa_get_failmode(spa_t *spa); extern uint8_t spa_get_failmode(spa_t *spa);
extern boolean_t spa_suspended(spa_t *spa); extern boolean_t spa_suspended(spa_t *spa);

View File

@ -98,6 +98,7 @@ typedef struct zfs_fuid_info {
} zfs_fuid_info_t; } zfs_fuid_info_t;
#ifdef _KERNEL #ifdef _KERNEL
#ifdef HAVE_ZPL
struct znode; struct znode;
extern uid_t zfs_fuid_map_id(zfsvfs_t *, uint64_t, cred_t *, zfs_fuid_type_t); extern uid_t zfs_fuid_map_id(zfsvfs_t *, uint64_t, cred_t *, zfs_fuid_type_t);
extern void zfs_fuid_destroy(zfsvfs_t *); extern void zfs_fuid_destroy(zfsvfs_t *);
@ -115,6 +116,7 @@ extern int zfs_fuid_find_by_domain(zfsvfs_t *, const char *domain,
char **retdomain, boolean_t addok); char **retdomain, boolean_t addok);
extern const char *zfs_fuid_find_by_idx(zfsvfs_t *zfsvfs, uint32_t idx); extern const char *zfs_fuid_find_by_idx(zfsvfs_t *zfsvfs, uint32_t idx);
extern void zfs_fuid_txhold(zfsvfs_t *zfsvfs, dmu_tx_t *tx); extern void zfs_fuid_txhold(zfsvfs_t *zfsvfs, dmu_tx_t *tx);
#endif /* HAVE_ZPL */
#endif #endif
char *zfs_fuid_idx_domain(avl_tree_t *, uint32_t); char *zfs_fuid_idx_domain(avl_tree_t *, uint32_t);

View File

@ -191,7 +191,6 @@ extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr);
extern int zfs_secpolicy_rename_perms(const char *from, extern int zfs_secpolicy_rename_perms(const char *from,
const char *to, cred_t *cr); const char *to, cred_t *cr);
extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr); extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr);
extern int zfs_busy(void);
extern int zfs_unmount_snap(char *, void *); extern int zfs_unmount_snap(char *, void *);
#endif /* _KERNEL */ #endif /* _KERNEL */

View File

@ -345,8 +345,10 @@ extern void zfs_xvattr_set(znode_t *zp, xvattr_t *xvap);
extern void zfs_upgrade(zfsvfs_t *zfsvfs, dmu_tx_t *tx); extern void zfs_upgrade(zfsvfs_t *zfsvfs, dmu_tx_t *tx);
extern int zfs_create_share_dir(zfsvfs_t *zfsvfs, dmu_tx_t *tx); extern int zfs_create_share_dir(zfsvfs_t *zfsvfs, dmu_tx_t *tx);
#if defined(HAVE_UIO_RW)
extern caddr_t zfs_map_page(page_t *, enum seg_rw); extern caddr_t zfs_map_page(page_t *, enum seg_rw);
extern void zfs_unmap_page(page_t *, caddr_t); extern void zfs_unmap_page(page_t *, caddr_t);
#endif /* HAVE_UIO_RW */
extern zil_get_data_t zfs_get_data; extern zil_get_data_t zfs_get_data;
extern zil_replay_func_t *zfs_replay_vector[TX_MAX_TYPE]; extern zil_replay_func_t *zfs_replay_vector[TX_MAX_TYPE];

View File

@ -20,51 +20,33 @@
*/ */
/* /*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#ifndef _SYS_ZVOL_H #ifndef _SYS_ZVOL_H
#define _SYS_ZVOL_H #define _SYS_ZVOL_H
#include <sys/zfs_context.h> #include <sys/zfs_context.h>
#ifdef __cplusplus
extern "C" {
#endif
#define ZVOL_OBJ 1ULL #define ZVOL_OBJ 1ULL
#define ZVOL_ZAP_OBJ 2ULL #define ZVOL_ZAP_OBJ 2ULL
#ifdef _KERNEL #ifdef _KERNEL
#include <sys/blkdev.h>
extern int zvol_check_volsize(uint64_t volsize, uint64_t blocksize); extern int zvol_check_volsize(uint64_t volsize, uint64_t blocksize);
extern int zvol_check_volblocksize(uint64_t volblocksize); extern int zvol_check_volblocksize(uint64_t volblocksize);
extern int zvol_get_stats(objset_t *os, nvlist_t *nv); extern int zvol_get_stats(objset_t *os, nvlist_t *nv);
extern void zvol_create_cb(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx); extern void zvol_create_cb(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx);
extern int zvol_create_minor(const char *, major_t); extern int zvol_create_minor(const char *);
extern int zvol_remove_minor(const char *); extern int zvol_remove_minor(const char *);
extern int zvol_set_volsize(const char *, major_t, uint64_t); extern int zvol_set_volsize(const char *, uint64_t);
extern int zvol_set_volblocksize(const char *, uint64_t); extern int zvol_set_volblocksize(const char *, uint64_t);
extern int zvol_open(dev_t *devp, int flag, int otyp, cred_t *cr); extern int zvol_init(void);
extern int zvol_dump(dev_t dev, caddr_t addr, daddr_t offset, int nblocks);
extern int zvol_close(dev_t dev, int flag, int otyp, cred_t *cr);
extern int zvol_strategy(buf_t *bp);
extern int zvol_read(dev_t dev, uio_t *uiop, cred_t *cr);
extern int zvol_write(dev_t dev, uio_t *uiop, cred_t *cr);
extern int zvol_aread(dev_t dev, struct aio_req *aio, cred_t *cr);
extern int zvol_awrite(dev_t dev, struct aio_req *aio, cred_t *cr);
extern int zvol_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr,
int *rvalp);
extern int zvol_busy(void);
extern void zvol_init(void);
extern void zvol_fini(void); extern void zvol_fini(void);
#endif #endif /* KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_ZVOL_H */ #endif /* _SYS_ZVOL_H */

View File

@ -23,6 +23,8 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#ifdef HAVE_ZPL
#include <sys/refcount.h> #include <sys/refcount.h>
#include <sys/rrwlock.h> #include <sys/rrwlock.h>
@ -262,3 +264,4 @@ rrw_held(rrwlock_t *rrl, krw_t rw)
return (held); return (held);
} }
#endif /* HAVE_ZPL */

View File

@ -1348,12 +1348,6 @@ spa_name_compare(const void *a1, const void *a2)
return (0); return (0);
} }
int
spa_busy(void)
{
return (spa_active_count);
}
void void
spa_boot_init(void) spa_boot_init(void)
{ {

View File

@ -23,6 +23,8 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#ifdef HAVE_ZPL
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/time.h> #include <sys/time.h>
@ -2848,3 +2850,5 @@ zfs_zaccess_rename(znode_t *sdzp, znode_t *szp, znode_t *tdzp,
return (error); return (error);
} }
#endif /* HAVE_ZPL */

View File

@ -64,6 +64,8 @@
* so that it cannot be freed until all snapshots have been unmounted. * so that it cannot be freed until all snapshots have been unmounted.
*/ */
#ifdef HAVE_ZPL
#include <fs/fs_subr.h> #include <fs/fs_subr.h>
#include <sys/zfs_ctldir.h> #include <sys/zfs_ctldir.h>
#include <sys/zfs_ioctl.h> #include <sys/zfs_ioctl.h>
@ -1333,3 +1335,4 @@ zfsctl_umount_snapshots(vfs_t *vfsp, int fflags, cred_t *cr)
return (error); return (error);
} }
#endif /* HAVE_ZPL */

View File

@ -23,6 +23,8 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#ifdef HAVE_ZPL
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/time.h> #include <sys/time.h>
@ -962,3 +964,4 @@ zfs_sticky_remove_access(znode_t *zdp, znode_t *zp, cred_t *cr)
else else
return (secpolicy_vnode_remove(cr)); return (secpolicy_vnode_remove(cr));
} }
#endif /* HAVE_ZPL */

View File

@ -194,6 +194,7 @@ zfs_fuid_idx_domain(avl_tree_t *idx_tree, uint32_t idx)
} }
#ifdef _KERNEL #ifdef _KERNEL
#ifdef HAVE_ZPL
/* /*
* Load the fuid table(s) into memory. * Load the fuid table(s) into memory.
*/ */
@ -743,4 +744,5 @@ zfs_fuid_txhold(zfsvfs_t *zfsvfs, dmu_tx_t *tx)
FUID_SIZE_ESTIMATE(zfsvfs)); FUID_SIZE_ESTIMATE(zfsvfs));
} }
} }
#endif /* HAVE_ZPL */
#endif #endif

View File

@ -64,18 +64,16 @@
#include <sharefs/share.h> #include <sharefs/share.h>
#include <sys/dmu_objset.h> #include <sys/dmu_objset.h>
#include <linux/miscdevice.h>
#include "zfs_namecheck.h" #include "zfs_namecheck.h"
#include "zfs_prop.h" #include "zfs_prop.h"
#include "zfs_deleg.h" #include "zfs_deleg.h"
#include "zfs_config.h"
extern struct modlfs zfs_modlfs;
extern void zfs_init(void); extern void zfs_init(void);
extern void zfs_fini(void); extern void zfs_fini(void);
ldi_ident_t zfs_li = NULL;
dev_info_t *zfs_dip;
typedef int zfs_ioc_func_t(zfs_cmd_t *); typedef int zfs_ioc_func_t(zfs_cmd_t *);
typedef int zfs_secpolicy_func_t(zfs_cmd_t *, cred_t *); typedef int zfs_secpolicy_func_t(zfs_cmd_t *, cred_t *);
@ -403,6 +401,7 @@ zfs_secpolicy_send(zfs_cmd_t *zc, cred_t *cr)
ZFS_DELEG_PERM_SEND, cr)); ZFS_DELEG_PERM_SEND, cr));
} }
#ifdef HAVE_ZPL
static int static int
zfs_secpolicy_deleg_share(zfs_cmd_t *zc, cred_t *cr) zfs_secpolicy_deleg_share(zfs_cmd_t *zc, cred_t *cr)
{ {
@ -426,10 +425,12 @@ zfs_secpolicy_deleg_share(zfs_cmd_t *zc, cred_t *cr)
return (dsl_deleg_access(zc->zc_name, return (dsl_deleg_access(zc->zc_name,
ZFS_DELEG_PERM_SHARE, cr)); ZFS_DELEG_PERM_SHARE, cr));
} }
#endif /* HAVE_ZPL */
int int
zfs_secpolicy_share(zfs_cmd_t *zc, cred_t *cr) zfs_secpolicy_share(zfs_cmd_t *zc, cred_t *cr)
{ {
#ifdef HAVE_ZPL
if (!INGLOBALZONE(curproc)) if (!INGLOBALZONE(curproc))
return (EPERM); return (EPERM);
@ -438,11 +439,15 @@ zfs_secpolicy_share(zfs_cmd_t *zc, cred_t *cr)
} else { } else {
return (zfs_secpolicy_deleg_share(zc, cr)); return (zfs_secpolicy_deleg_share(zc, cr));
} }
#else
return (ENOTSUP);
#endif /* HAVE_ZPL */
} }
int int
zfs_secpolicy_smb_acl(zfs_cmd_t *zc, cred_t *cr) zfs_secpolicy_smb_acl(zfs_cmd_t *zc, cred_t *cr)
{ {
#ifdef HAVE_ZPL
if (!INGLOBALZONE(curproc)) if (!INGLOBALZONE(curproc))
return (EPERM); return (EPERM);
@ -451,6 +456,9 @@ zfs_secpolicy_smb_acl(zfs_cmd_t *zc, cred_t *cr)
} else { } else {
return (zfs_secpolicy_deleg_share(zc, cr)); return (zfs_secpolicy_deleg_share(zc, cr));
} }
#else
return (ENOTSUP);
#endif /* HAVE_ZPL */
} }
static int static int
@ -645,6 +653,7 @@ zfs_secpolicy_create(zfs_cmd_t *zc, cred_t *cr)
return (error); return (error);
} }
#ifdef HAVE_ZPL
static int static int
zfs_secpolicy_umount(zfs_cmd_t *zc, cred_t *cr) zfs_secpolicy_umount(zfs_cmd_t *zc, cred_t *cr)
{ {
@ -656,6 +665,7 @@ zfs_secpolicy_umount(zfs_cmd_t *zc, cred_t *cr)
} }
return (error); return (error);
} }
#endif /* HAVE_ZPL */
/* /*
* Policy for pool operations - create/destroy pools, add vdevs, etc. Requires * Policy for pool operations - create/destroy pools, add vdevs, etc. Requires
@ -836,6 +846,7 @@ put_nvlist(zfs_cmd_t *zc, nvlist_t *nvl)
return (error); return (error);
} }
#ifdef HAVE_ZPL
static int static int
getzfsvfs(const char *dsname, zfsvfs_t **zvp) getzfsvfs(const char *dsname, zfsvfs_t **zvp)
{ {
@ -898,6 +909,7 @@ zfsvfs_rele(zfsvfs_t *zfsvfs, void *tag)
zfsvfs_free(zfsvfs); zfsvfs_free(zfsvfs);
} }
} }
#endif /* HAVE_ZPL */
static int static int
zfs_ioc_pool_create(zfs_cmd_t *zc) zfs_ioc_pool_create(zfs_cmd_t *zc)
@ -1713,6 +1725,7 @@ zfs_set_prop_nvlist(const char *name, nvlist_t *nvl)
if (prop == ZPROP_INVAL) { if (prop == ZPROP_INVAL) {
if (zfs_prop_userquota(propname)) { if (zfs_prop_userquota(propname)) {
#ifdef HAVE_ZPL
uint64_t *valary; uint64_t *valary;
unsigned int vallen; unsigned int vallen;
const char *domain; const char *domain;
@ -1741,6 +1754,10 @@ zfs_set_prop_nvlist(const char *name, nvlist_t *nvl)
continue; continue;
else else
goto out; goto out;
#else
error = ENOTSUP;
goto out;
#endif
} else if (zfs_prop_user(propname)) { } else if (zfs_prop_user(propname)) {
VERIFY(nvpair_value_string(elem, &strval) == 0); VERIFY(nvpair_value_string(elem, &strval) == 0);
error = dsl_prop_set(name, propname, 1, error = dsl_prop_set(name, propname, 1,
@ -1781,8 +1798,7 @@ zfs_set_prop_nvlist(const char *name, nvlist_t *nvl)
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, intval)) != 0)
ddi_driver_major(zfs_dip), intval)) != 0)
goto out; goto out;
break; break;
@ -1794,6 +1810,7 @@ zfs_set_prop_nvlist(const char *name, nvlist_t *nvl)
case ZFS_PROP_VERSION: case ZFS_PROP_VERSION:
{ {
#ifdef HAVE_ZPL
zfsvfs_t *zfsvfs; zfsvfs_t *zfsvfs;
if ((error = nvpair_value_uint64(elem, &intval)) != 0) if ((error = nvpair_value_uint64(elem, &intval)) != 0)
@ -1812,6 +1829,10 @@ zfs_set_prop_nvlist(const char *name, nvlist_t *nvl)
if (error) if (error)
goto out; goto out;
break; break;
#else
error = ENOTSUP;
goto out;
#endif /* HAVE_ZPL */
} }
default: default:
@ -2023,6 +2044,7 @@ zfs_ioc_pool_get_props(zfs_cmd_t *zc)
static int static int
zfs_ioc_iscsi_perm_check(zfs_cmd_t *zc) zfs_ioc_iscsi_perm_check(zfs_cmd_t *zc)
{ {
#ifdef HAVE_ZPL
nvlist_t *nvp; nvlist_t *nvp;
int error; int error;
uint32_t uid; uint32_t uid;
@ -2065,6 +2087,9 @@ zfs_ioc_iscsi_perm_check(zfs_cmd_t *zc)
zfs_prop_to_name(ZFS_PROP_SHAREISCSI), usercred); zfs_prop_to_name(ZFS_PROP_SHAREISCSI), usercred);
crfree(usercred); crfree(usercred);
return (error); return (error);
#else
return (ENOTSUP);
#endif /* HAVE_ZPL */
} }
/* /*
@ -2147,7 +2172,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)
{ {
return (zvol_create_minor(zc->zc_name, ddi_driver_major(zfs_dip))); return (zvol_create_minor(zc->zc_name));
} }
/* /*
@ -2162,6 +2187,7 @@ zfs_ioc_remove_minor(zfs_cmd_t *zc)
return (zvol_remove_minor(zc->zc_name)); return (zvol_remove_minor(zc->zc_name));
} }
#ifdef HAVE_ZPL
/* /*
* Search the vfs list for a specified resource. Returns a pointer to it * Search the vfs list for a specified resource. Returns a pointer to it
* or NULL if no suitable entry is found. The caller of this routine * or NULL if no suitable entry is found. The caller of this routine
@ -2186,6 +2212,7 @@ zfs_get_vfs(const char *resource)
vfs_list_unlock(); vfs_list_unlock();
return (vfs_found); return (vfs_found);
} }
#endif /* HAVE_ZPL */
/* ARGSUSED */ /* ARGSUSED */
static void static void
@ -2535,6 +2562,7 @@ out:
int int
zfs_unmount_snap(char *name, void *arg) zfs_unmount_snap(char *name, void *arg)
{ {
#ifdef HAVE_ZPL
vfs_t *vfsp = NULL; vfs_t *vfsp = NULL;
if (arg) { if (arg) {
@ -2566,6 +2594,7 @@ zfs_unmount_snap(char *name, void *arg)
if ((err = dounmount(vfsp, flag, kcred)) != 0) if ((err = dounmount(vfsp, flag, kcred)) != 0)
return (err); return (err);
} }
#endif /* HAVE_ZPL */
return (0); return (0);
} }
@ -2621,6 +2650,7 @@ zfs_ioc_destroy(zfs_cmd_t *zc)
static int static int
zfs_ioc_rollback(zfs_cmd_t *zc) zfs_ioc_rollback(zfs_cmd_t *zc)
{ {
#ifdef HAVE_ZPL
objset_t *os; objset_t *os;
int error; int error;
zfsvfs_t *zfsvfs = NULL; zfsvfs_t *zfsvfs = NULL;
@ -2654,6 +2684,9 @@ zfs_ioc_rollback(zfs_cmd_t *zc)
/* Note, the dmu_objset_rollback() releases the objset for us. */ /* Note, the dmu_objset_rollback() releases the objset for us. */
return (error); return (error);
#else
return (ENOTSUP);
#endif /* HAVE_ZPL */
} }
/* /*
@ -2727,7 +2760,9 @@ static int
zfs_ioc_recv(zfs_cmd_t *zc) zfs_ioc_recv(zfs_cmd_t *zc)
{ {
file_t *fp; file_t *fp;
#ifdef HAVE_ZPL
objset_t *os; objset_t *os;
#endif /* HAVE_ZPL */
dmu_recv_cookie_t drc; dmu_recv_cookie_t drc;
boolean_t force = (boolean_t)zc->zc_guid; boolean_t force = (boolean_t)zc->zc_guid;
int error, fd; int error, fd;
@ -2760,6 +2795,7 @@ zfs_ioc_recv(zfs_cmd_t *zc)
return (EBADF); return (EBADF);
} }
#ifdef HAVE_ZPL
if (props && dmu_objset_open(tofs, DMU_OST_ANY, if (props && dmu_objset_open(tofs, DMU_OST_ANY,
DS_MODE_USER | DS_MODE_READONLY, &os) == 0) { DS_MODE_USER | DS_MODE_READONLY, &os) == 0) {
/* /*
@ -2770,6 +2806,7 @@ zfs_ioc_recv(zfs_cmd_t *zc)
dmu_objset_close(os); dmu_objset_close(os);
} }
#endif /* HAVE_ZPL */
if (zc->zc_string[0]) { if (zc->zc_string[0]) {
error = dmu_objset_open(zc->zc_string, DMU_OST_ANY, error = dmu_objset_open(zc->zc_string, DMU_OST_ANY,
@ -2801,6 +2838,7 @@ zfs_ioc_recv(zfs_cmd_t *zc)
error = dmu_recv_stream(&drc, fp->f_vnode, &off); error = dmu_recv_stream(&drc, fp->f_vnode, &off);
if (error == 0) { if (error == 0) {
#ifdef HAVE_ZPL
zfsvfs_t *zfsvfs = NULL; zfsvfs_t *zfsvfs = NULL;
if (getzfsvfs(tofs, &zfsvfs) == 0) { if (getzfsvfs(tofs, &zfsvfs) == 0) {
@ -2827,6 +2865,9 @@ zfs_ioc_recv(zfs_cmd_t *zc)
} else { } else {
error = dmu_recv_end(&drc); error = dmu_recv_end(&drc);
} }
#else
error = dmu_recv_end(&drc);
#endif /* HAVE_ZPL */
} }
zc->zc_cookie = off - fp->f_offset; zc->zc_cookie = off - fp->f_offset;
@ -3057,6 +3098,7 @@ zfs_ioc_promote(zfs_cmd_t *zc)
static int static int
zfs_ioc_userspace_one(zfs_cmd_t *zc) zfs_ioc_userspace_one(zfs_cmd_t *zc)
{ {
#ifdef HAVE_ZPL
zfsvfs_t *zfsvfs; zfsvfs_t *zfsvfs;
int error; int error;
@ -3072,6 +3114,9 @@ zfs_ioc_userspace_one(zfs_cmd_t *zc)
zfsvfs_rele(zfsvfs, FTAG); zfsvfs_rele(zfsvfs, FTAG);
return (error); return (error);
#else
return (ENOTSUP);
#endif /* HAVE_ZPL */
} }
/* /*
@ -3088,6 +3133,7 @@ zfs_ioc_userspace_one(zfs_cmd_t *zc)
static int static int
zfs_ioc_userspace_many(zfs_cmd_t *zc) zfs_ioc_userspace_many(zfs_cmd_t *zc)
{ {
#ifdef HAVE_ZPL
zfsvfs_t *zfsvfs; zfsvfs_t *zfsvfs;
int error; int error;
@ -3110,6 +3156,9 @@ zfs_ioc_userspace_many(zfs_cmd_t *zc)
zfsvfs_rele(zfsvfs, FTAG); zfsvfs_rele(zfsvfs, FTAG);
return (error); return (error);
#else
return (ENOTSUP);
#endif /* HAVE_ZPL */
} }
/* /*
@ -3122,6 +3171,7 @@ zfs_ioc_userspace_many(zfs_cmd_t *zc)
static int static int
zfs_ioc_userspace_upgrade(zfs_cmd_t *zc) zfs_ioc_userspace_upgrade(zfs_cmd_t *zc)
{ {
#ifdef HAVE_ZPL
objset_t *os; objset_t *os;
int error; int error;
zfsvfs_t *zfsvfs; zfsvfs_t *zfsvfs;
@ -3154,6 +3204,9 @@ zfs_ioc_userspace_upgrade(zfs_cmd_t *zc)
} }
return (error); return (error);
#else
return (ENOTSUP);
#endif /* HAVE_ZPL */
} }
/* /*
@ -3163,6 +3216,7 @@ zfs_ioc_userspace_upgrade(zfs_cmd_t *zc)
* the first file system is shared. * the first file system is shared.
* Neither sharefs, nfs or smbsrv are unloadable modules. * Neither sharefs, nfs or smbsrv are unloadable modules.
*/ */
#ifdef HAVE_ZPL
int (*znfsexport_fs)(void *arg); int (*znfsexport_fs)(void *arg);
int (*zshare_fs)(enum sharefs_sys_op, share_t *, uint32_t); int (*zshare_fs)(enum sharefs_sys_op, share_t *, uint32_t);
int (*zsmbexport_fs)(void *arg, boolean_t add_share); int (*zsmbexport_fs)(void *arg, boolean_t add_share);
@ -3194,10 +3248,12 @@ zfs_init_sharefs()
} }
return (0); return (0);
} }
#endif /* HAVE_ZPL */
static int static int
zfs_ioc_share(zfs_cmd_t *zc) zfs_ioc_share(zfs_cmd_t *zc)
{ {
#ifdef HAVE_ZPL
int error; int error;
int opcode; int opcode;
@ -3287,7 +3343,9 @@ zfs_ioc_share(zfs_cmd_t *zc)
zc->zc_share.z_sharemax); zc->zc_share.z_sharemax);
return (error); return (error);
#else
return (ENOTSUP);
#endif /* HAVE_ZPL */
} }
ace_t full_access[] = { ace_t full_access[] = {
@ -3297,6 +3355,7 @@ ace_t full_access[] = {
/* /*
* Remove all ACL files in shares dir * Remove all ACL files in shares dir
*/ */
#ifdef HAVE_ZPL
static int static int
zfs_smb_acl_purge(znode_t *dzp) zfs_smb_acl_purge(znode_t *dzp)
{ {
@ -3315,10 +3374,12 @@ zfs_smb_acl_purge(znode_t *dzp)
zap_cursor_fini(&zc); zap_cursor_fini(&zc);
return (error); return (error);
} }
#endif /* HAVE ZPL */
static int static int
zfs_ioc_smb_acl(zfs_cmd_t *zc) zfs_ioc_smb_acl(zfs_cmd_t *zc)
{ {
#ifdef HAVE_ZPL
vnode_t *vp; vnode_t *vp;
znode_t *dzp; znode_t *dzp;
vnode_t *resourcevp = NULL; vnode_t *resourcevp = NULL;
@ -3440,6 +3501,9 @@ zfs_ioc_smb_acl(zfs_cmd_t *zc)
ZFS_EXIT(zfsvfs); ZFS_EXIT(zfsvfs);
return (error); return (error);
#else
return (ENOTSUP);
#endif /* HAVE_ZPL */
} }
/* /*
@ -3632,28 +3696,23 @@ pool_status_check(const char *name, zfs_ioc_namecheck_t type)
return (error); return (error);
} }
static int static long
zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp) zfs_ioctl(struct file *filp, unsigned cmd, unsigned long arg)
{ {
zfs_cmd_t *zc; zfs_cmd_t *zc;
uint_t vec; uint_t vec;
int error, rc; int error, rc, flag = 0;
if (getminor(dev) != 0)
return (zvol_ioctl(dev, cmd, arg, flag, cr, rvalp));
vec = cmd - ZFS_IOC; vec = cmd - ZFS_IOC;
ASSERT3U(getmajor(dev), ==, ddi_driver_major(zfs_dip));
if (vec >= sizeof (zfs_ioc_vec) / sizeof (zfs_ioc_vec[0])) if (vec >= sizeof (zfs_ioc_vec) / sizeof (zfs_ioc_vec[0]))
return (EINVAL); return (-EINVAL);
zc = vmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP); zc = vmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP);
error = ddi_copyin((void *)arg, zc, sizeof (zfs_cmd_t), flag); error = ddi_copyin((void *)arg, zc, sizeof (zfs_cmd_t), flag);
if (error == 0) if (error == 0)
error = zfs_ioc_vec[vec].zvec_secpolicy(zc, cr); error = zfs_ioc_vec[vec].zvec_secpolicy(zc, NULL);
/* /*
* Ensure that all pool/dataset names are valid before we pass down to * Ensure that all pool/dataset names are valid before we pass down to
@ -3695,121 +3754,59 @@ zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
} }
vmem_free(zc, sizeof (zfs_cmd_t)); vmem_free(zc, sizeof (zfs_cmd_t));
return (error); return (-error);
} }
static int #ifdef CONFIG_COMPAT
zfs_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) static long
zfs_compat_ioctl(struct file *filp, unsigned cmd, unsigned long arg)
{ {
if (cmd != DDI_ATTACH) return zfs_ioctl(filp, cmd, arg);
return (DDI_FAILURE);
if (ddi_create_minor_node(dip, "zfs", S_IFCHR, 0,
DDI_PSEUDO, 0) == DDI_FAILURE)
return (DDI_FAILURE);
zfs_dip = dip;
ddi_report_dev(dip);
return (DDI_SUCCESS);
} }
#else
#define zfs_compat_ioctl NULL
#endif
static const struct file_operations zfs_fops = {
.unlocked_ioctl = zfs_ioctl,
.compat_ioctl = zfs_compat_ioctl,
.owner = THIS_MODULE,
};
static struct miscdevice zfs_misc = {
.minor = MISC_DYNAMIC_MINOR,
.name = ZFS_DRIVER,
.fops = &zfs_fops,
};
static int static int
zfs_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) zfs_attach(void)
{ {
if (spa_busy() || zfs_busy() || zvol_busy()) int error;
return (DDI_FAILURE);
if (cmd != DDI_DETACH) error = misc_register(&zfs_misc);
return (DDI_FAILURE); if (error) {
printk(KERN_INFO "ZFS: misc_register() failed %d\n", error);
zfs_dip = NULL; return (error);
ddi_prop_remove_all(dip);
ddi_remove_minor_node(dip, NULL);
return (DDI_SUCCESS);
}
/*ARGSUSED*/
static int
zfs_info(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
{
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
*result = zfs_dip;
return (DDI_SUCCESS);
case DDI_INFO_DEVT2INSTANCE:
*result = (void *)0;
return (DDI_SUCCESS);
} }
return (DDI_FAILURE); return (0);
} }
/* static void
* OK, so this is a little weird. zfs_detach(void)
* {
* /dev/zfs is the control node, i.e. minor 0. int error;
* /dev/zvol/[r]dsk/pool/dataset are the zvols, minor > 0.
*
* /dev/zfs has basically nothing to do except serve up ioctls,
* so most of the standard driver entry points are in zvol.c.
*/
static struct cb_ops zfs_cb_ops = {
zvol_open, /* open */
zvol_close, /* close */
zvol_strategy, /* strategy */
nodev, /* print */
zvol_dump, /* dump */
zvol_read, /* read */
zvol_write, /* write */
zfsdev_ioctl, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* poll */
ddi_prop_op, /* prop_op */
NULL, /* streamtab */
D_NEW | D_MP | D_64BIT, /* Driver compatibility flag */
CB_REV, /* version */
nodev, /* async read */
nodev, /* async write */
};
static struct dev_ops zfs_dev_ops = {
DEVO_REV, /* version */
0, /* refcnt */
zfs_info, /* info */
nulldev, /* identify */
nulldev, /* probe */
zfs_attach, /* attach */
zfs_detach, /* detach */
nodev, /* reset */
&zfs_cb_ops, /* driver operations */
NULL, /* no bus operations */
NULL, /* power */
ddi_quiesce_not_needed, /* quiesce */
};
static struct modldrv zfs_modldrv = {
&mod_driverops,
"ZFS storage pool",
&zfs_dev_ops
};
static struct modlinkage modlinkage = {
MODREV_1,
(void *)&zfs_modlfs,
(void *)&zfs_modldrv,
NULL
};
error = misc_deregister(&zfs_misc);
if (error)
printk(KERN_INFO "ZFS: misc_deregister() failed %d\n", error);
}
#ifdef HAVE_ZPL
uint_t zfs_fsyncer_key; uint_t zfs_fsyncer_key;
extern uint_t rrw_tsd_key; extern uint_t rrw_tsd_key;
#endif
int int
_init(void) _init(void)
@ -3818,21 +3815,28 @@ _init(void)
spa_init(FREAD | FWRITE); spa_init(FREAD | FWRITE);
zfs_init(); zfs_init();
zvol_init();
if ((error = mod_install(&modlinkage)) != 0) { if ((error = zvol_init()) != 0) {
zvol_fini();
zfs_fini(); zfs_fini();
spa_fini(); spa_fini();
return (error); return (error);
} }
if ((error = zfs_attach()) != 0) {
(void)zvol_fini();
zfs_fini();
spa_fini();
return (error);
}
#ifdef HAVE_ZPL
tsd_create(&zfs_fsyncer_key, NULL); tsd_create(&zfs_fsyncer_key, NULL);
tsd_create(&rrw_tsd_key, NULL); tsd_create(&rrw_tsd_key, NULL);
error = ldi_ident_from_mod(&modlinkage, &zfs_li);
ASSERT(error == 0);
mutex_init(&zfs_share_lock, NULL, MUTEX_DEFAULT, NULL); mutex_init(&zfs_share_lock, NULL, MUTEX_DEFAULT, NULL);
#endif /* HAVE_ZPL */
printk(KERN_INFO "ZFS: Loaded ZFS Filesystem v%s\n", ZFS_META_VERSION);
return (0); return (0);
} }
@ -3840,17 +3844,11 @@ _init(void)
int int
_fini(void) _fini(void)
{ {
int error; zfs_detach();
if (spa_busy() || zfs_busy() || zvol_busy() || zio_injection_enabled)
return (EBUSY);
if ((error = mod_remove(&modlinkage)) != 0)
return (error);
zvol_fini(); zvol_fini();
zfs_fini(); zfs_fini();
spa_fini(); spa_fini();
#ifdef HAVE_ZPL
if (zfs_nfsshare_inited) if (zfs_nfsshare_inited)
(void) ddi_modclose(nfs_mod); (void) ddi_modclose(nfs_mod);
if (zfs_smbshare_inited) if (zfs_smbshare_inited)
@ -3858,16 +3856,18 @@ _fini(void)
if (zfs_nfsshare_inited || zfs_smbshare_inited) if (zfs_nfsshare_inited || zfs_smbshare_inited)
(void) ddi_modclose(sharefs_mod); (void) ddi_modclose(sharefs_mod);
tsd_destroy(&zfs_fsyncer_key);
ldi_ident_release(zfs_li);
zfs_li = NULL;
mutex_destroy(&zfs_share_lock); mutex_destroy(&zfs_share_lock);
tsd_destroy(&zfs_fsyncer_key);
#endif /* HAVE_ZPL */
return (error); return (0);
} }
int #ifdef HAVE_SPL
_info(struct modinfo *modinfop) spl_module_init(_init);
{ spl_module_exit(_fini);
return (mod_info(&modlinkage, modinfop));
} MODULE_AUTHOR("Sun Microsystems, Inc");
MODULE_DESCRIPTION("ZFS");
MODULE_LICENSE("CDDL");
#endif /* HAVE_SPL */

View File

@ -23,6 +23,8 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#ifdef HAVE_ZPL
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -704,3 +706,5 @@ zfs_log_acl(zilog_t *zilog, dmu_tx_t *tx, znode_t *zp,
seq = zil_itx_assign(zilog, itx, tx); seq = zil_itx_assign(zilog, itx, tx);
zp->z_last_itx = seq; zp->z_last_itx = seq;
} }
#endif /* HAVE_ZPL */

View File

@ -23,7 +23,7 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#ifdef HAVE_ZPL
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
@ -876,3 +876,4 @@ zil_replay_func_t *zfs_replay_vector[TX_MAX_TYPE] = {
zfs_replay_create, /* TX_MKDIR_ATTR */ zfs_replay_create, /* TX_MKDIR_ATTR */
zfs_replay_create_acl, /* TX_MKDIR_ACL_ATTR */ zfs_replay_create_acl, /* TX_MKDIR_ACL_ATTR */
}; };
#endif /* HAVE_ZPL */

View File

@ -61,6 +61,7 @@
#include <sys/dmu_objset.h> #include <sys/dmu_objset.h>
#include <sys/spa_boot.h> #include <sys/spa_boot.h>
#ifdef HAVE_ZPL
int zfsfstype; int zfsfstype;
vfsops_t *zfs_vfsops = NULL; vfsops_t *zfs_vfsops = NULL;
static major_t zfs_major; static major_t zfs_major;
@ -1957,10 +1958,12 @@ zfs_vfsinit(int fstype, char *name)
return (0); return (0);
} }
#endif /* HAVE_ZPL */
void void
zfs_init(void) zfs_init(void)
{ {
#ifdef HAVE_ZPL
/* /*
* Initialize .zfs directory structures * Initialize .zfs directory structures
*/ */
@ -1972,21 +1975,19 @@ zfs_init(void)
zfs_znode_init(); zfs_znode_init();
dmu_objset_register_type(DMU_OST_ZFS, zfs_space_delta_cb); dmu_objset_register_type(DMU_OST_ZFS, zfs_space_delta_cb);
#endif /* HAVE_ZPL */
} }
void void
zfs_fini(void) zfs_fini(void)
{ {
#ifdef HAVE_ZPL
zfsctl_fini(); zfsctl_fini();
zfs_znode_fini(); zfs_znode_fini();
#endif /* HAVE_ZPL */
} }
int #ifdef HAVE_ZPL
zfs_busy(void)
{
return (zfs_active_fs_count != 0);
}
int int
zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers) zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers)
{ {
@ -2029,6 +2030,7 @@ zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers)
return (0); return (0);
} }
#endif /* HAVE_ZPL */
/* /*
* Read a property stored within the master node. * Read a property stored within the master node.
@ -2072,6 +2074,7 @@ zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value)
return (error); return (error);
} }
#ifdef HAVE_ZPL
static vfsdef_t vfw = { static vfsdef_t vfw = {
VFSDEF_VERSION, VFSDEF_VERSION,
MNTTYPE_ZFS, MNTTYPE_ZFS,
@ -2084,3 +2087,4 @@ static vfsdef_t vfw = {
struct modlfs zfs_modlfs = { struct modlfs zfs_modlfs = {
&mod_fsops, "ZFS filesystem version " SPA_VERSION_STRING, &vfw &mod_fsops, "ZFS filesystem version " SPA_VERSION_STRING, &vfw
}; };
#endif /* HAVE_ZPL */

View File

@ -25,6 +25,8 @@
/* Portions Copyright 2007 Jeremy Teo */ /* Portions Copyright 2007 Jeremy Teo */
#ifdef HAVE_ZPL
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/time.h> #include <sys/time.h>
@ -318,6 +320,7 @@ zfs_ioctl(vnode_t *vp, int com, intptr_t data, int flag, cred_t *cred,
return (ENOTTY); return (ENOTTY);
} }
#if defined(_KERNEL) && defined(HAVE_UIO_RW)
/* /*
* Utility functions to map and unmap a single physical page. These * Utility functions to map and unmap a single physical page. These
* are used to manage the mappable copies of ZFS file data, and therefore * are used to manage the mappable copies of ZFS file data, and therefore
@ -342,6 +345,7 @@ zfs_unmap_page(page_t *pp, caddr_t addr)
ppmapout(addr); ppmapout(addr);
} }
} }
#endif /* _KERNEL && HAVE_UIO_RW */
/* /*
* When a file is memory mapped, we must keep the IO data synchronized * When a file is memory mapped, we must keep the IO data synchronized
@ -4695,3 +4699,4 @@ const fs_operation_def_t zfs_evnodeops_template[] = {
VOPNAME_PATHCONF, { .vop_pathconf = zfs_pathconf }, VOPNAME_PATHCONF, { .vop_pathconf = zfs_pathconf },
NULL, NULL NULL, NULL
}; };
#endif /* HAVE_ZPL */

View File

@ -87,6 +87,7 @@
* (such as VFS logic) that will not compile easily in userland. * (such as VFS logic) that will not compile easily in userland.
*/ */
#ifdef _KERNEL #ifdef _KERNEL
#ifdef HAVE_ZPL
/* /*
* Needed to close a small window in zfs_znode_move() that allows the zfsvfs to * Needed to close a small window in zfs_znode_move() that allows the zfsvfs to
* be freed before it can be safely accessed. * be freed before it can be safely accessed.
@ -1473,21 +1474,28 @@ log:
dmu_tx_commit(tx); dmu_tx_commit(tx);
return (0); return (0);
} }
#endif /* HAVE_ZPL */
void void
zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx) zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx)
{ {
zfsvfs_t zfsvfs;
uint64_t moid, obj, version; uint64_t moid, obj, version;
uint64_t sense = ZFS_CASE_SENSITIVE; uint64_t sense = ZFS_CASE_SENSITIVE;
uint64_t norm = 0; uint64_t norm = 0;
nvpair_t *elem; nvpair_t *elem;
int error; int error;
#ifdef HAVE_ZPL
zfsvfs_t zfsvfs;
znode_t *rootzp = NULL; znode_t *rootzp = NULL;
vnode_t *vp; vnode_t *vp;
vattr_t vattr; vattr_t vattr;
znode_t *zp; znode_t *zp;
zfs_acl_ids_t acl_ids; zfs_acl_ids_t acl_ids;
#else
timestruc_t now;
dmu_buf_t *db;
znode_phys_t *pzp;
#endif /* HAVE_ZPL */
/* /*
* First attempt to create master node. * First attempt to create master node.
@ -1542,6 +1550,7 @@ zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx)
error = zap_add(os, moid, ZFS_UNLINKED_SET, 8, 1, &obj, tx); error = zap_add(os, moid, ZFS_UNLINKED_SET, 8, 1, &obj, tx);
ASSERT(error == 0); ASSERT(error == 0);
#ifdef HAVE_ZPL
/* /*
* Create root znode. Create minimal znode/vnode/zfsvfs * Create root znode. Create minimal znode/vnode/zfsvfs
* to allow zfs_mknode to work. * to allow zfs_mknode to work.
@ -1596,14 +1605,46 @@ zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx)
dmu_buf_rele(rootzp->z_dbuf, NULL); dmu_buf_rele(rootzp->z_dbuf, NULL);
rootzp->z_dbuf = NULL; rootzp->z_dbuf = NULL;
kmem_cache_free(znode_cache, rootzp); kmem_cache_free(znode_cache, rootzp);
error = zfs_create_share_dir(&zfsvfs, tx);
#else
/*
* Create root znode with code free of VFS dependencies
*/
obj = zap_create_norm(os, norm, DMU_OT_DIRECTORY_CONTENTS,
DMU_OT_ZNODE, sizeof (znode_phys_t), tx);
VERIFY(0 == dmu_bonus_hold(os, obj, FTAG, &db));
dmu_buf_will_dirty(db, tx);
/* /*
* Create shares directory * Initialize the znode physical data to zero.
*/ */
ASSERT(db->db_size >= sizeof (znode_phys_t));
bzero(db->db_data, db->db_size);
pzp = db->db_data;
error = zfs_create_share_dir(&zfsvfs, tx); if (USE_FUIDS(version, os))
pzp->zp_flags = ZFS_ARCHIVE | ZFS_AV_MODIFIED;
pzp->zp_size = 2; /* "." and ".." */
pzp->zp_links = 2;
pzp->zp_parent = obj;
pzp->zp_gen = dmu_tx_get_txg(tx);
pzp->zp_mode = S_IFDIR | 0755;
pzp->zp_flags = ZFS_ACL_TRIVIAL;
gethrestime(&now);
ZFS_TIME_ENCODE(&now, pzp->zp_crtime);
ZFS_TIME_ENCODE(&now, pzp->zp_ctime);
ZFS_TIME_ENCODE(&now, pzp->zp_atime);
ZFS_TIME_ENCODE(&now, pzp->zp_mtime);
error = zap_add(os, moid, ZFS_ROOT_OBJ, 8, 1, &obj, tx);
ASSERT(error == 0); ASSERT(error == 0);
dmu_buf_rele(db, FTAG);
#endif /* HAVE_ZPL */
} }
#endif /* _KERNEL */ #endif /* _KERNEL */

1199
module/zfs/zvol.c Normal file

File diff suppressed because it is too large Load Diff