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

This commit is contained in:
Brian Behlendorf 2008-12-22 12:09:08 -08:00
commit a6d6f31db6
17 changed files with 89 additions and 383 deletions

View File

@ -504,8 +504,7 @@ zfs_do_clone(int argc, char **argv)
/* pass to libzfs */ /* pass to libzfs */
ret = zfs_clone(zhp, argv[1], props); ret = zfs_clone(zhp, argv[1], props);
/* In zfs-lustre we can't mount the filesystem */ /* create the mountpoint if necessary */
#ifdef HAVE_ZPL
if (ret == 0) { if (ret == 0) {
zfs_handle_t *clone; zfs_handle_t *clone;
@ -516,7 +515,6 @@ 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);
@ -712,11 +710,8 @@ zfs_do_create(int argc, char **argv)
* Mount and/or share the new filesystem as appropriate. We provide a * Mount and/or share the new filesystem as appropriate. We provide a
* verbose error message to let the user know that their filesystem was * verbose error message to let the user know that their filesystem was
* in fact created, even if we failed to mount or share it. * in fact created, even if we failed to mount or share it.
*
* In zfs-lustre, this is not supported.
*/ */
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 "
@ -728,7 +723,6 @@ zfs_do_create(int argc, char **argv)
ret = 1; ret = 1;
} }
} }
#endif /* HAVE_ZPL */
error: error:
if (zhp) if (zhp)
@ -837,7 +831,7 @@ destroy_callback(zfs_handle_t *zhp, void *data)
zfs_close(zhp); zfs_close(zhp);
return (0); return (0);
} }
#ifdef HAVE_ZPL
/* /*
* Bail out on the first error. * Bail out on the first error.
*/ */
@ -846,7 +840,6 @@ destroy_callback(zfs_handle_t *zhp, void *data)
zfs_close(zhp); zfs_close(zhp);
return (-1); return (-1);
} }
#endif /* HAVE_ZPL */
zfs_close(zhp); zfs_close(zhp);
return (0); return (0);
@ -3013,7 +3006,6 @@ dataset_cmp(const void *a, const void *b)
return (strcmp(zfs_get_name(a), zfs_get_name(b))); return (strcmp(zfs_get_name(a), zfs_get_name(b)));
} }
#if HAVE_ZPL
/* /*
* Generic callback for sharing or mounting filesystems. Because the code is so * Generic callback for sharing or mounting filesystems. Because the code is so
* similar, we have a common function with an extra parameter to determine which * similar, we have a common function with an extra parameter to determine which
@ -3148,6 +3140,7 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol,
*/ */
switch (op) { switch (op) {
case OP_SHARE: case OP_SHARE:
shared_nfs = zfs_is_shared_nfs(zhp, NULL); shared_nfs = zfs_is_shared_nfs(zhp, NULL);
shared_smb = zfs_is_shared_smb(zhp, NULL); shared_smb = zfs_is_shared_smb(zhp, NULL);
@ -3207,7 +3200,6 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol,
if (zfs_mount(zhp, options, flags) != 0) if (zfs_mount(zhp, options, flags) != 0)
return (1); return (1);
break; break;
} }
} else { } else {
@ -3248,7 +3240,6 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, char *protocol,
return (0); return (0);
} }
#endif /* HAVE_ZPL */
/* /*
* Reports progress in the form "(current/total)". Not thread-safe. * Reports progress in the form "(current/total)". Not thread-safe.
@ -3304,7 +3295,6 @@ append_options(char *mntopts, char *newopts)
(void) strcpy(&mntopts[len], newopts); (void) strcpy(&mntopts[len], newopts);
} }
#ifdef HAVE_ZPL
static int static int
share_mount(int op, int argc, char **argv) share_mount(int op, int argc, char **argv)
{ {
@ -3453,7 +3443,6 @@ 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]
@ -3464,11 +3453,7 @@ 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 */
} }
/* /*
@ -3480,14 +3465,9 @@ 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;
@ -3940,7 +3920,6 @@ unshare_unmount(int op, int argc, char **argv)
return (ret); return (ret);
} }
#endif /* HAVE_ZPL */
/* /*
* zfs unmount -a * zfs unmount -a
@ -3951,11 +3930,7 @@ 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 */
} }
/* /*
@ -3967,18 +3942,13 @@ 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 */
} }
/* /*
* 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)
{ {
@ -4109,7 +4079,6 @@ 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)
@ -4179,7 +4148,6 @@ 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].
@ -4190,10 +4158,6 @@ 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
/* zfs-lustre: we always do this */
if (1) {
#endif /* HAVE_ZPL */
/* /*
* Make sure the user has specified some command. * Make sure the user has specified some command.
*/ */

View File

@ -722,8 +722,6 @@ zpool_do_create(int argc, char **argv)
mountpoint); mountpoint);
} }
/* zfs-lustre: not necessary */
#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));
@ -746,7 +744,6 @@ zpool_do_create(int argc, char **argv)
goto errout; goto errout;
} }
} }
#endif /* HAVE_ZPL */
} }
if (dryrun) { if (dryrun) {
@ -777,13 +774,8 @@ 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);
/* zfs-lustre: not supported */
#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) {
@ -1323,13 +1315,10 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts,
verify((zhp = zpool_open_canfail(g_zfs, name)) != NULL); verify((zhp = zpool_open_canfail(g_zfs, name)) != NULL);
/* zfs-lustre: not needed */
#if HAVE_ZPL
if (zpool_enable_datasets(zhp, mntopts, 0) != 0) { if (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

@ -93,7 +93,6 @@ 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;
@ -169,9 +168,6 @@ changelist_prefix(prop_changelist_t *clp)
(void) changelist_postfix(clp); (void) changelist_postfix(clp);
return (ret); return (ret);
#else
return 0;
#endif /* HAVE_ZPL */
} }
/* /*
@ -186,7 +182,6 @@ 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;
@ -301,9 +296,6 @@ changelist_postfix(prop_changelist_t *clp)
} }
return (errors ? -1 : 0); return (errors ? -1 : 0);
#else
return 0;
#endif /* HAVE_ZPL */
} }
/* /*
@ -366,7 +358,6 @@ 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;
@ -381,9 +372,6 @@ changelist_unshare(prop_changelist_t *clp, zfs_share_proto_t *proto)
} }
return (ret); return (ret);
#else
return 0;
#endif
} }
/* /*

View File

@ -735,7 +735,6 @@ 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:
/* /*
@ -846,7 +845,6 @@ 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;
@ -2875,8 +2873,6 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen)
goto ancestorerr; goto ancestorerr;
} }
/* zfs-lustre: not needed */
#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;
@ -2886,7 +2882,6 @@ 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);
} }
@ -3103,11 +3098,9 @@ zfs_destroy(zfs_handle_t *zhp)
* abort the request. This would only happen for a * abort the request. This would only happen for a
* non-privileged user. * non-privileged user.
*/ */
#ifdef HAVE_ZPL
if (zfs_unshare_iscsi(zhp) != 0) { if (zfs_unshare_iscsi(zhp) != 0) {
return (-1); return (-1);
} }
#endif
if (zvol_remove_link(zhp->zfs_hdl, zhp->zfs_name) != 0) if (zvol_remove_link(zhp->zfs_hdl, zhp->zfs_name) != 0)
return (-1); return (-1);

View File

@ -86,7 +86,6 @@
#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);
@ -1235,6 +1234,7 @@ out:
return (ret); return (ret);
} }
static int static int
zvol_cb(const char *dataset, void *data) zvol_cb(const char *dataset, void *data)
{ {
@ -1407,42 +1407,3 @@ out:
return (ret); return (ret);
} }
#else /* HAVE_ZPL */
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_TRUE;
}
int
zpool_disable_datasets(zpool_handle_t *zhp, boolean_t force)
{
return B_TRUE;
}
#endif /* HAVE_ZPL */

View File

@ -1936,8 +1936,6 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
* created). Also mount any children of the target filesystem * created). Also mount any children of the target filesystem
* if we did an incremental receive. * if we did an incremental receive.
*/ */
/* zfs-lustre: not needed */
#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;
@ -1964,7 +1962,6 @@ 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

@ -560,11 +560,6 @@ libzfs_init(void)
return (NULL); return (NULL);
} }
#if defined(HAVE_SPL) && !defined(HAVE_GPL_ONLY_SYMBOLS)
/* If we don't have access to GPL-only symbols then we may not use
* the udev APIs, therefore we must mknod the device ourselves. */
(void)mknod(ZFS_DEV, S_IFCHR | 0600, makedev(ZFS_MAJOR, 0));
#endif
if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR)) < 0) { if ((hdl->libzfs_fd = open(ZFS_DEV, O_RDWR)) < 0) {
free(hdl); free(hdl);
return (NULL); return (NULL);
@ -600,9 +595,7 @@ 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

@ -304,8 +304,8 @@ typedef enum zfs_cache_type {
#define ZPL_VERSION_1 1ULL #define ZPL_VERSION_1 1ULL
#define ZPL_VERSION_2 2ULL #define ZPL_VERSION_2 2ULL
#define ZPL_VERSION_3 3ULL #define ZPL_VERSION_3 3ULL
#define ZPL_VERSION ZPL_VERSION_1 #define ZPL_VERSION ZPL_VERSION_3
#define ZPL_VERSION_STRING "1" #define ZPL_VERSION_STRING "3"
#define ZPL_VERSION_INITIAL ZPL_VERSION_1 #define ZPL_VERSION_INITIAL ZPL_VERSION_1
#define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2 #define ZPL_VERSION_DIRENT_TYPE ZPL_VERSION_2
@ -491,8 +491,6 @@ typedef struct vdev_stat {
#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 ZFS_MAJOR 230 /* XXX: Arbitrary */
#define ZFS_MINORS 16 /* XXX: Arbitrary */
/* /*
* zvol paths. Irritatingly, the devfsadm interfaces want all these * zvol paths. Irritatingly, the devfsadm interfaces want all these

View File

@ -35,7 +35,6 @@
#include <sys/zfs_vfsops.h> #include <sys/zfs_vfsops.h>
#endif #endif
#include <sys/avl.h> #include <sys/avl.h>
#include <sys/list.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -172,57 +172,23 @@ typedef struct zfs_cmd {
#define ZFS_MIN_MINOR (ZVOL_MAX_MINOR + 1) #define ZFS_MIN_MINOR (ZVOL_MAX_MINOR + 1)
#ifdef _KERNEL #ifdef _KERNEL
#ifdef HAVE_SPL
/* XXX: DISABLE ALL PERMISSION CHECKS */
static __inline__ int
zfs_secpolicy_destroy_perms(const char *name, cred_t *cr)
{
return 0;
}
static __inline__ int typedef struct zfs_creat {
secpolicy_zfs(const cred_t *cr) nvlist_t *zct_zplprops;
{ nvlist_t *zct_props;
return 0; } zfs_creat_t;
}
static __inline__ int
secpolicy_fs_unmount(cred_t *cr, struct vfs *vfsp)
{
return 0;
}
static __inline__ int
secpolicy_sys_config(cred_t *cr, boolean_t flag)
{
return 0;
}
static __inline__ int
secpolicy_zinject(cred_t *cr)
{
return 0;
}
#else
extern dev_info_t *zfs_dip; extern dev_info_t *zfs_dip;
extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr); 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);
#endif /* HAVE_SPL */
extern int zfs_busy(void); extern int zfs_busy(void);
extern int zfs_unmount_snap(char *, void *); extern int zfs_unmount_snap(char *, void *);
#endif /* _KERNEL */ #endif /* _KERNEL */
#if defined(_KERNEL) || defined(WANT_KERNEL_EMUL) || defined(HAVE_SPL)
typedef struct zfs_creat {
nvlist_t *zct_zplprops;
nvlist_t *zct_props;
} zfs_creat_t;
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -267,6 +267,21 @@ typedef struct znode {
#define ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num) \ #define ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num) \
mutex_exit(ZFS_OBJ_MUTEX((zfsvfs), (obj_num))) mutex_exit(ZFS_OBJ_MUTEX((zfsvfs), (obj_num)))
/*
* Macros to encode/decode ZFS stored time values from/to struct timespec
*/
#define ZFS_TIME_ENCODE(tp, stmp) \
{ \
(stmp)[0] = (uint64_t)(tp)->tv_sec; \
(stmp)[1] = (uint64_t)(tp)->tv_nsec; \
}
#define ZFS_TIME_DECODE(tp, stmp) \
{ \
(tp)->tv_sec = (time_t)(stmp)[0]; \
(tp)->tv_nsec = (long)(stmp)[1]; \
}
/* /*
* Timestamp defines * Timestamp defines
*/ */
@ -280,6 +295,8 @@ typedef struct znode {
extern int zfs_init_fs(zfsvfs_t *, znode_t **); extern int zfs_init_fs(zfsvfs_t *, znode_t **);
extern void zfs_set_dataprop(objset_t *); extern void zfs_set_dataprop(objset_t *);
extern void zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *,
dmu_tx_t *tx);
extern void zfs_time_stamper(znode_t *, uint_t, dmu_tx_t *); extern void zfs_time_stamper(znode_t *, uint_t, dmu_tx_t *);
extern void zfs_time_stamper_locked(znode_t *, uint_t, dmu_tx_t *); extern void zfs_time_stamper_locked(znode_t *, uint_t, dmu_tx_t *);
extern void zfs_grow_blocksize(znode_t *, uint64_t, dmu_tx_t *); extern void zfs_grow_blocksize(znode_t *, uint64_t, dmu_tx_t *);
@ -295,6 +312,8 @@ extern void zfs_remove_op_tables(void);
extern int zfs_create_op_tables(void); extern int zfs_create_op_tables(void);
extern int zfs_sync(vfs_t *vfsp, short flag, cred_t *cr); extern int zfs_sync(vfs_t *vfsp, short flag, cred_t *cr);
extern dev_t zfs_cmpldev(uint64_t); extern dev_t zfs_cmpldev(uint64_t);
extern int zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value);
extern int zfs_set_version(const char *name, uint64_t newvers);
extern int zfs_get_stats(objset_t *os, nvlist_t *nv); extern int zfs_get_stats(objset_t *os, nvlist_t *nv);
extern void zfs_znode_dmu_fini(znode_t *); extern void zfs_znode_dmu_fini(znode_t *);
@ -331,30 +350,6 @@ extern int zfsfstype;
#endif /* _KERNEL */ #endif /* _KERNEL */
#if defined(_KERNEL) || defined(WANT_KERNEL_EMUL)
extern int zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value);
extern int zfs_set_version(const char *name, uint64_t newvers);
#endif
/*
* Macros to encode/decode ZFS stored time values from/to struct timespec
*/
#define ZFS_TIME_ENCODE(tp, stmp) \
{ \
(stmp)[0] = (uint64_t)(tp)->tv_sec; \
(stmp)[1] = (uint64_t)(tp)->tv_nsec; \
}
#define ZFS_TIME_DECODE(tp, stmp) \
{ \
(tp)->tv_sec = (time_t)(stmp)[0]; \
(tp)->tv_nsec = (long)(stmp)[1]; \
}
extern void zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *,
dmu_tx_t *tx);
extern int zfs_obj_to_path(objset_t *osp, uint64_t obj, char *buf, int len); extern int zfs_obj_to_path(objset_t *osp, uint64_t obj, char *buf, int len);
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -38,13 +38,10 @@ extern "C" {
#define ZVOL_OBJ 1ULL #define ZVOL_OBJ 1ULL
#define ZVOL_ZAP_OBJ 2ULL #define ZVOL_ZAP_OBJ 2ULL
#if defined(_KERNEL) || defined(WANT_KERNEL_EMUL)
extern int zvol_get_stats(objset_t *os, nvlist_t *nv);
#endif
#ifdef _KERNEL #ifdef _KERNEL
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 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 *, major_t);
extern int zvol_remove_minor(const char *); extern int zvol_remove_minor(const char *);

View File

@ -60,7 +60,6 @@
#include <sys/systeminfo.h> #include <sys/systeminfo.h>
#include <sys/sunddi.h> #include <sys/sunddi.h>
#include <sys/spa_boot.h> #include <sys/spa_boot.h>
#include <sys/zfs_znode.h>
#include "zfs_prop.h" #include "zfs_prop.h"
#include "zfs_comutil.h" #include "zfs_comutil.h"
@ -1908,11 +1907,10 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
dsl_pool_t *dp; dsl_pool_t *dp;
dmu_tx_t *tx; dmu_tx_t *tx;
int c, error = 0; int c, error = 0;
uint64_t txg = TXG_INITIAL, zpl_version; uint64_t txg = TXG_INITIAL;
nvlist_t **spares, **l2cache, *zprops; nvlist_t **spares, **l2cache;
uint_t nspares, nl2cache; uint_t nspares, nl2cache;
uint64_t version; uint64_t version;
objset_t *os;
/* /*
* If this pool already exists, return failure. * If this pool already exists, return failure.

View File

@ -23,14 +23,19 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#include <sys/zfs_ioctl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/errno.h> #include <sys/errno.h>
#include <sys/uio.h> #include <sys/uio.h>
#include <sys/buf.h>
#include <sys/modctl.h>
#include <sys/open.h>
#include <sys/file.h> #include <sys/file.h>
#include <sys/kmem.h>
#include <sys/conf.h>
#include <sys/cmn_err.h> #include <sys/cmn_err.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/zfs_ioctl.h>
#include <sys/zfs_znode.h> #include <sys/zfs_znode.h>
#include <sys/zap.h> #include <sys/zap.h>
#include <sys/spa.h> #include <sys/spa.h>
@ -43,34 +48,33 @@
#include <sys/dsl_prop.h> #include <sys/dsl_prop.h>
#include <sys/dsl_deleg.h> #include <sys/dsl_deleg.h>
#include <sys/dmu_objset.h> #include <sys/dmu_objset.h>
#include <sys/ddi.h>
#include <sys/sunddi.h> #include <sys/sunddi.h>
#include <sys/sunldi.h>
#include <sys/policy.h> #include <sys/policy.h>
#include <sys/zone.h>
#include <sys/nvpair.h> #include <sys/nvpair.h>
#include <sys/pathname.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/sdt.h> #include <sys/sdt.h>
#include <sys/fs/zfs.h> #include <sys/fs/zfs.h>
#include <sys/zfs_ctldir.h>
#include <sys/zfs_dir.h>
#include <sys/zvol.h> #include <sys/zvol.h>
#include <sharefs/share.h>
#include <sys/dmu_objset.h> #include <sys/dmu_objset.h>
#include <sys/systm.h>
#ifndef _KERNEL
#include <pthread.h>
#endif
#include "zfs_namecheck.h" #include "zfs_namecheck.h"
#include "zfs_prop.h" #include "zfs_prop.h"
#include "zfs_deleg.h" #include "zfs_deleg.h"
#ifdef HAVE_ZPL
extern struct modlfs zfs_modlfs; extern struct modlfs zfs_modlfs;
#endif
extern void zfs_init(void); extern void zfs_init(void);
extern void zfs_fini(void); extern void zfs_fini(void);
#ifdef _KERNEL
ldi_ident_t zfs_li = NULL; ldi_ident_t zfs_li = NULL;
dev_info_t *zfs_dip; dev_info_t *zfs_dip;
#endif
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 *);
@ -92,7 +96,6 @@ static int zfs_fill_zplprops_root(uint64_t, nvlist_t *, nvlist_t *,
int zfs_set_prop_nvlist(const char *, nvlist_t *); int zfs_set_prop_nvlist(const char *, nvlist_t *);
/* _NOTE(PRINTFLIKE(4)) - this is printf-like, but lint is too whiney */ /* _NOTE(PRINTFLIKE(4)) - this is printf-like, but lint is too whiney */
#if 0
void void
__dprintf(const char *file, const char *func, int line, const char *fmt, ...) __dprintf(const char *file, const char *func, int line, const char *fmt, ...)
{ {
@ -127,7 +130,6 @@ __dprintf(const char *file, const char *func, int line, const char *fmt, ...)
DTRACE_PROBE4(zfs__dprintf, DTRACE_PROBE4(zfs__dprintf,
char *, newfile, char *, func, int, line, char *, buf); char *, newfile, char *, func, int, line, char *, buf);
} }
#endif
static void static void
history_str_free(char *buf) history_str_free(char *buf)
@ -392,8 +394,6 @@ zfs_secpolicy_send(zfs_cmd_t *zc, cred_t *cr)
int int
zfs_secpolicy_share(zfs_cmd_t *zc, cred_t *cr) zfs_secpolicy_share(zfs_cmd_t *zc, cred_t *cr)
{ {
return (ENOTSUP);
#ifdef HAVE_ZPL
if (!INGLOBALZONE(curproc)) if (!INGLOBALZONE(curproc))
return (EPERM); return (EPERM);
@ -420,7 +420,6 @@ zfs_secpolicy_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 */
} }
static int static int
@ -445,8 +444,6 @@ zfs_get_parent(const char *datasetname, char *parent, int parentsize)
return (0); return (0);
} }
/* For zfs-lustre function is already defined in kernel.c */
#ifdef _KERENL
int int
zfs_secpolicy_destroy_perms(const char *name, cred_t *cr) zfs_secpolicy_destroy_perms(const char *name, cred_t *cr)
{ {
@ -458,7 +455,6 @@ zfs_secpolicy_destroy_perms(const char *name, cred_t *cr)
return (zfs_secpolicy_write_perms(name, ZFS_DELEG_PERM_DESTROY, cr)); return (zfs_secpolicy_write_perms(name, ZFS_DELEG_PERM_DESTROY, cr));
} }
#endif /* _KERNEL */
static int static int
zfs_secpolicy_destroy(zfs_cmd_t *zc, cred_t *cr) zfs_secpolicy_destroy(zfs_cmd_t *zc, cred_t *cr)
@ -476,8 +472,6 @@ zfs_secpolicy_iscsi(zfs_cmd_t *zc, cred_t *cr)
return (secpolicy_zfs(cr)); return (secpolicy_zfs(cr));
} }
/* For zfs-lustre function is already defined in kernel.c */
#ifdef _KERNEL
int int
zfs_secpolicy_rename_perms(const char *from, const char *to, cred_t *cr) zfs_secpolicy_rename_perms(const char *from, const char *to, cred_t *cr)
{ {
@ -506,7 +500,6 @@ zfs_secpolicy_rename_perms(const char *from, const char *to, cred_t *cr)
return (error); return (error);
} }
#endif /* _KERNEL */
static int static int
zfs_secpolicy_rename(zfs_cmd_t *zc, cred_t *cr) zfs_secpolicy_rename(zfs_cmd_t *zc, cred_t *cr)
@ -573,8 +566,6 @@ zfs_secpolicy_receive(zfs_cmd_t *zc, cred_t *cr)
ZFS_DELEG_PERM_CREATE, cr)); ZFS_DELEG_PERM_CREATE, cr));
} }
/* For zfs-lustre function is already defined in kernel.c */
#ifdef _KERNEL
int int
zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr) zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr)
{ {
@ -589,7 +580,6 @@ zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr)
return (error); return (error);
} }
#endif /* _KERNEL */
static int static int
zfs_secpolicy_snapshot(zfs_cmd_t *zc, cred_t *cr) zfs_secpolicy_snapshot(zfs_cmd_t *zc, cred_t *cr)
@ -624,7 +614,6 @@ 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)
{ {
@ -636,7 +625,6 @@ 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
@ -1533,10 +1521,17 @@ zfs_set_prop_nvlist(const char *name, nvlist_t *nvl)
break; break;
case ZFS_PROP_VOLSIZE: case ZFS_PROP_VOLSIZE:
return (ENOTSUP); if ((error = nvpair_value_uint64(elem, &intval)) != 0 ||
(error = zvol_set_volsize(name,
ddi_driver_major(zfs_dip), intval)) != 0)
return (error);
break;
case ZFS_PROP_VOLBLOCKSIZE: case ZFS_PROP_VOLBLOCKSIZE:
return (ENOTSUP); if ((error = nvpair_value_uint64(elem, &intval)) != 0 ||
(error = zvol_set_volblocksize(name, intval)) != 0)
return (error);
break;
case ZFS_PROP_VERSION: case ZFS_PROP_VERSION:
if ((error = nvpair_value_uint64(elem, &intval)) != 0 || if ((error = nvpair_value_uint64(elem, &intval)) != 0 ||
@ -1693,8 +1688,6 @@ 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)
{ {
return (ENOTSUP);
#if 0
nvlist_t *nvp; nvlist_t *nvp;
int error; int error;
uint32_t uid; uint32_t uid;
@ -1737,7 +1730,6 @@ 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);
#endif
} }
/* /*
@ -1820,11 +1812,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 */
} }
/* /*
@ -1836,11 +1824,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 */
} }
/* /*
@ -1848,7 +1832,6 @@ zfs_ioc_remove_minor(zfs_cmd_t *zc)
* 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
* is responsible for releasing the returned vfs pointer. * is responsible for releasing the returned vfs pointer.
*/ */
#ifdef HAVE_ZPL
static vfs_t * static vfs_t *
zfs_get_vfs(const char *resource) zfs_get_vfs(const char *resource)
{ {
@ -1868,7 +1851,6 @@ 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
@ -2056,12 +2038,8 @@ zfs_ioc_create(zfs_cmd_t *zc)
break; break;
case DMU_OST_ZVOL: case DMU_OST_ZVOL:
#ifdef HAVE_ZPL
cbfunc = zvol_create_cb; cbfunc = zvol_create_cb;
break; break;
#else
return (ENOTSUP);
#endif /* HAVE_ZPL */
default: default:
cbfunc = NULL; cbfunc = NULL;
@ -2113,7 +2091,6 @@ zfs_ioc_create(zfs_cmd_t *zc)
} }
if (type == DMU_OST_ZVOL) { if (type == DMU_OST_ZVOL) {
#ifdef HAVE_ZVOL
uint64_t volsize, volblocksize; uint64_t volsize, volblocksize;
if (nvprops == NULL || if (nvprops == NULL ||
@ -2142,10 +2119,6 @@ zfs_ioc_create(zfs_cmd_t *zc)
nvlist_free(nvprops); nvlist_free(nvprops);
return (error); return (error);
} }
#else
/* This should never be reached in zfs-lustre */
ASSERT(0);
#endif /* HAVE_ZVOL */
} else if (type == DMU_OST_ZFS) { } else if (type == DMU_OST_ZFS) {
int error; int error;
@ -2252,8 +2225,6 @@ zfs_ioc_snapshot(zfs_cmd_t *zc)
int int
zfs_unmount_snap(char *name, void *arg) zfs_unmount_snap(char *name, void *arg)
{ {
/* Not needed in zfs-lustre */
#ifdef HAVE_ZPL
vfs_t *vfsp = NULL; vfs_t *vfsp = NULL;
if (arg) { if (arg) {
@ -2285,7 +2256,6 @@ 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);
} }
@ -2338,7 +2308,6 @@ 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;
@ -2384,13 +2353,6 @@ 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
/*
* Rollback is not supported in zfs-lustre yet.
* This functionality would require a proper implementation.
*/
return (ENOTSUP);
#endif /* HAVE_ZPL */
} }
/* /*
@ -2611,9 +2573,7 @@ zfs_ioc_send(zfs_cmd_t *zc)
{ {
objset_t *fromsnap = NULL; objset_t *fromsnap = NULL;
objset_t *tosnap; objset_t *tosnap;
#ifdef _KERNEL
file_t *fp; file_t *fp;
#endif
int error; int error;
offset_t off; offset_t off;
@ -2641,7 +2601,6 @@ zfs_ioc_send(zfs_cmd_t *zc)
} }
} }
#ifdef _KERNEL
fp = getf(zc->zc_cookie); fp = getf(zc->zc_cookie);
if (fp == NULL) { if (fp == NULL) {
dmu_objset_close(tosnap); dmu_objset_close(tosnap);
@ -2653,12 +2612,9 @@ zfs_ioc_send(zfs_cmd_t *zc)
off = fp->f_offset; off = fp->f_offset;
error = dmu_sendbackup(tosnap, fromsnap, zc->zc_obj, fp->f_vnode, &off); error = dmu_sendbackup(tosnap, fromsnap, zc->zc_obj, fp->f_vnode, &off);
if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0)
fp->f_offset = off;
releasef(zc->zc_cookie); releasef(zc->zc_cookie);
#else
off = 0;
error = dmu_sendbackup(tosnap, fromsnap, zc->zc_obj, zc->zc_cookie, &off);
#endif /* _KERNEL */
if (fromsnap) if (fromsnap)
dmu_objset_close(fromsnap); dmu_objset_close(fromsnap);
dmu_objset_close(tosnap); dmu_objset_close(tosnap);
@ -2804,7 +2760,6 @@ zfs_ioc_promote(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);
@ -2815,13 +2770,8 @@ int zfs_smbshare_inited;
ddi_modhandle_t nfs_mod; ddi_modhandle_t nfs_mod;
ddi_modhandle_t sharefs_mod; ddi_modhandle_t sharefs_mod;
ddi_modhandle_t smbsrv_mod; ddi_modhandle_t smbsrv_mod;
kmutex_t zfs_share_lock; kmutex_t zfs_share_lock;
#endif /* HAVE_ZPL */
/* Not supported in zfs-lustre */
#ifdef HAVE_ZPL
static int static int
zfs_init_sharefs() zfs_init_sharefs()
{ {
@ -2841,12 +2791,10 @@ 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;
@ -2936,10 +2884,7 @@ zfs_ioc_share(zfs_cmd_t *zc)
zc->zc_share.z_sharemax); zc->zc_share.z_sharemax);
return (error); return (error);
#else
/* Not supported in zfs-lustre */
return (ENOTSUP);
#endif /* HAVE_ZPL */
} }
/* /*
@ -3000,24 +2945,18 @@ static zfs_ioc_vec_t zfs_ioc_vec[] = {
{ zfs_ioc_inherit_prop, zfs_secpolicy_inherit, DATASET_NAME, B_TRUE }, { zfs_ioc_inherit_prop, zfs_secpolicy_inherit, DATASET_NAME, B_TRUE },
}; };
int static int
zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp) zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
{ {
zfs_cmd_t *zc; zfs_cmd_t *zc;
uint_t vec; uint_t vec;
int error, rc; int error, rc;
#ifdef _KERNEL
#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 /* HAVE_ZVOL */
vec = cmd - ZFS_IOC; vec = cmd - ZFS_IOC;
ASSERT3U(getmajor(dev), ==, ddi_driver_major(zfs_dip)); ASSERT3U(getmajor(dev), ==, ddi_driver_major(zfs_dip));
#else
vec = cmd - ZFS_IOC;
#endif /* _KERNEL */
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);
@ -3065,7 +3004,6 @@ zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
return (error); return (error);
} }
#ifdef _KERNEL
static int static int
zfs_attach(dev_info_t *dip, ddi_attach_cmd_t cmd) zfs_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
{ {
@ -3086,15 +3024,7 @@ zfs_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
static int static int
zfs_detach(dev_info_t *dip, ddi_detach_cmd_t cmd) zfs_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
{ {
#ifdef HAVE_ZVOL if (spa_busy() || zfs_busy() || zvol_busy())
if (zvol_busy())
return (DDI_FAILURE);
#endif
#ifdef HAVE_ZPL
if (zfs_busy())
return (DDI_FAILURE);
#endif
if (spa_busy())
return (DDI_FAILURE); return (DDI_FAILURE);
if (cmd != DDI_DETACH) if (cmd != DDI_DETACH)
@ -3135,22 +3065,13 @@ 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 */
nodev, /* print */
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, /* dump */
nodev, /* read */
nodev, /* write */
#endif
nodev, /* print */
zfsdev_ioctl, /* ioctl */ zfsdev_ioctl, /* ioctl */
nodev, /* devmap */ nodev, /* devmap */
nodev, /* mmap */ nodev, /* mmap */

View File

@ -23,15 +23,21 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#include <sys/zfs_znode.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
#include <sys/sysmacros.h> #include <sys/sysmacros.h>
#include <sys/kmem.h>
#include <sys/pathname.h>
#include <sys/vnode.h>
#include <sys/vfs.h> #include <sys/vfs.h>
#include <sys/vfs_opreg.h>
#include <sys/mntent.h> #include <sys/mntent.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/cmn_err.h> #include <sys/cmn_err.h>
#include "fs/fs_subr.h"
#include <sys/zfs_znode.h>
#include <sys/zfs_dir.h>
#include <sys/zil.h> #include <sys/zil.h>
#include <sys/fs/zfs.h> #include <sys/fs/zfs.h>
#include <sys/dmu.h> #include <sys/dmu.h>
@ -42,15 +48,19 @@
#include <sys/zap.h> #include <sys/zap.h>
#include <sys/varargs.h> #include <sys/varargs.h>
#include <sys/policy.h> #include <sys/policy.h>
#include <sys/atomic.h>
#include <sys/mkdev.h> #include <sys/mkdev.h>
#include <sys/modctl.h>
#include <sys/refstr.h>
#include <sys/zfs_ioctl.h> #include <sys/zfs_ioctl.h>
#include <sys/zfs_ctldir.h>
#include <sys/zfs_fuid.h> #include <sys/zfs_fuid.h>
#include <sys/bootconf.h>
#include <sys/sunddi.h> #include <sys/sunddi.h>
#include <sys/spa_boot.h> #include <sys/dnlc.h>
#include <sys/dmu_objset.h> #include <sys/dmu_objset.h>
#include <sys/spa_boot.h>
/* This code is not needed for zfs-lustre */
#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;
@ -1534,7 +1544,6 @@ zfs_busy(void)
{ {
return (zfs_active_fs_count != 0); return (zfs_active_fs_count != 0);
} }
#endif /* HAVE_ZPL */
int int
zfs_set_version(const char *name, uint64_t newvers) zfs_set_version(const char *name, uint64_t newvers)
@ -1629,7 +1638,6 @@ 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,
@ -1642,4 +1650,3 @@ 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

@ -87,7 +87,6 @@
* (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
#ifndef HAVE_SPL /* Commented out until ZPL layer is written */
static kmem_cache_t *znode_cache = NULL; static kmem_cache_t *znode_cache = NULL;
/*ARGSUSED*/ /*ARGSUSED*/
@ -1474,17 +1473,20 @@ log:
dmu_tx_commit(tx); dmu_tx_commit(tx);
return (0); return (0);
} }
#endif /* HAVE_SPL */
#endif /* _KERNEL */
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, doid, version; uint64_t moid, doid, 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;
znode_t *rootzp = NULL;
vnode_t *vp;
vattr_t vattr;
znode_t *zp;
/* /*
* First attempt to create master node. * First attempt to create master node.
@ -1539,18 +1541,10 @@ 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, &doid, tx); error = zap_add(os, moid, ZFS_UNLINKED_SET, 8, 1, &doid, tx);
ASSERT(error == 0); ASSERT(error == 0);
#if defined(_KERNEL) && defined(HAVE_VFS)
/* /*
* 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.
*/ */
{
znode_t *rootzp = NULL;
vnode_t *vp;
vattr_t vattr;
znode_t *zp;
zfsvfs_t zfsvfs;
vattr.va_mask = AT_MODE|AT_UID|AT_GID|AT_TYPE; vattr.va_mask = AT_MODE|AT_UID|AT_GID|AT_TYPE;
vattr.va_type = VDIR; vattr.va_type = VDIR;
vattr.va_mode = S_IFDIR|0755; vattr.va_mode = S_IFDIR|0755;
@ -1600,63 +1594,8 @@ zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx)
rootzp->z_dbuf = NULL; rootzp->z_dbuf = NULL;
kmem_cache_free(znode_cache, rootzp); kmem_cache_free(znode_cache, rootzp);
} }
#else
/*
* Create the root znode with code free of VFS dependencies.
* Sadly, we cannot create ACE entries as it's too tied to
* the VFS interface.
*/
{
uint64_t obj, z_norm = norm;
timestruc_t now;
dmu_buf_t *db;
znode_phys_t *pzp;
/*
* Fold case on file systems that are always or sometimes case
* insensitive.
*/
if (sense == ZFS_CASE_INSENSITIVE || sense == ZFS_CASE_MIXED)
z_norm |= U8_TEXTPREP_TOUPPER;
obj = zap_create_norm(os, z_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);
/*
* 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;
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);
dmu_buf_rele(db, FTAG);
}
#endif /* _KERNEL */ #endif /* _KERNEL */
}
/* /*
* Given an object number, return its parent object number and whether * Given an object number, return its parent object number and whether
* or not the object is an extended attribute directory. * or not the object is an extended attribute directory.

View File

@ -41,6 +41,11 @@
#include <sys/param.h> #include <sys/param.h>
#include <sys/errno.h> #include <sys/errno.h>
#include <sys/uio.h> #include <sys/uio.h>
#include <sys/buf.h>
#include <sys/modctl.h>
#include <sys/open.h>
#include <sys/kmem.h>
#include <sys/conf.h>
#include <sys/cmn_err.h> #include <sys/cmn_err.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/zap.h> #include <sys/zap.h>
@ -53,7 +58,11 @@
#include <sys/dkio.h> #include <sys/dkio.h>
#include <sys/efi_partition.h> #include <sys/efi_partition.h>
#include <sys/byteorder.h> #include <sys/byteorder.h>
#include <sys/pathname.h>
#include <sys/ddi.h>
#include <sys/sunddi.h> #include <sys/sunddi.h>
#include <sys/crc32.h>
#include <sys/dirent.h>
#include <sys/policy.h> #include <sys/policy.h>
#include <sys/fs/zfs.h> #include <sys/fs/zfs.h>
#include <sys/zfs_ioctl.h> #include <sys/zfs_ioctl.h>
@ -74,8 +83,6 @@
#include "zfs_namecheck.h" #include "zfs_namecheck.h"
/* This code is not necessary for zfs-lustre */
#ifdef HAVE_ZVOL
static void *zvol_state; static void *zvol_state;
#define ZVOL_DUMPSIZE "dumpsize" #define ZVOL_DUMPSIZE "dumpsize"
@ -147,7 +154,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)
@ -188,7 +194,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)
{ {
@ -199,7 +204,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)
@ -225,8 +229,6 @@ zvol_get_stats(objset_t *os, nvlist_t *nv)
return (error); return (error);
} }
/* This code is not necessary for zfs-lustre */
#ifdef HAVE_ZVOL
/* /*
* Find a free minor number. * Find a free minor number.
*/ */
@ -1735,4 +1737,3 @@ zvol_dump_fini(zvol_state_t *zv)
return (0); return (0);
} }
#endif /* HAVE_ZVOL */