diff --git a/.topdeps b/.topdeps index 607c231780..7f16cbcdd5 100644 --- a/.topdeps +++ b/.topdeps @@ -1,3 +1 @@ -gcc-branch -fix-branch -feature-branch +zfs-branch diff --git a/.topmsg b/.topmsg index 03967cdff5..f31623955b 100644 --- a/.topmsg +++ b/.topmsg @@ -1,19 +1,8 @@ From: Brian Behlendorf -Subject: [PATCH] zfs branch +Subject: [PATCH] linux have zpl -Merged result of all changes which are relevant to both Solaris -and Linux builds of the ZFS code. These are changes where there -is a reasonable chance they will be accepted upstream. - -Additionally, since this is effectively the root of the linux -ZFS tree the core linux build system is added here. This -includes autogen.sh, configure.ac, m4 macros, some scripts/*, -and makefiles for all the core ZFS components. Linux-only -features which require tweaks to the build system should appear -on the relevant topic branches. All autotools products which -result from autogen.sh are commited to the linux-configure-branch. - -This branch also contains the META, ChangeLog, AUTHORS, TODO, -and README, files. +Changes required to build ZFS without the ZPL layer. Or +better yet long term the changes required to integrate ZFS +in to linux's VFS layer. Signed-off-by: Brian Behlendorf diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index aacffcd95b..179f04aaba 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -498,6 +498,7 @@ zfs_do_clone(int argc, char **argv) ret = zfs_clone(zhp, argv[1], props); /* create the mountpoint if necessary */ +#ifdef HAVE_ZPL if (ret == 0) { zfs_handle_t *clone; @@ -508,6 +509,7 @@ zfs_do_clone(int argc, char **argv) zfs_close(clone); } } +#endif /* HAVE_ZPL */ zfs_close(zhp); nvlist_free(props); @@ -705,6 +707,7 @@ zfs_do_create(int argc, char **argv) * in fact created, even if we failed to mount or share it. */ ret = 0; +#ifdef HAVE_ZPL if (canmount == ZFS_CANMOUNT_ON) { if (zfs_mount(zhp, NULL, 0) != 0) { (void) fprintf(stderr, gettext("filesystem " @@ -716,6 +719,7 @@ zfs_do_create(int argc, char **argv) ret = 1; } } +#endif /* HAVE_ZPL */ error: if (zhp) @@ -813,7 +817,9 @@ out: static int destroy_callback(zfs_handle_t *zhp, void *data) { +#ifdef HAVE_ZPL destroy_cbdata_t *cbp = data; +#endif /* * Ignore pools (which we've already flagged as an error before getting @@ -825,6 +831,7 @@ destroy_callback(zfs_handle_t *zhp, void *data) return (0); } +#ifdef HAVE_ZPL /* * Bail out on the first error. */ @@ -833,6 +840,7 @@ destroy_callback(zfs_handle_t *zhp, void *data) zfs_close(zhp); return (-1); } +#endif /* HAVE_ZPL */ zfs_close(zhp); return (0); @@ -2891,6 +2899,7 @@ typedef struct get_all_cbdata { #define SPINNER_TIME 3 /* seconds */ #define MOUNT_TIME 5 /* seconds */ +#ifdef HAVE_ZPL static int get_one_dataset(zfs_handle_t *zhp, void *data) { @@ -3442,6 +3451,7 @@ share_mount(int op, int argc, char **argv) return (ret); } +#endif /* HAVE_ZPL */ /* * zfs mount -a [nfs | iscsi] @@ -3452,7 +3462,11 @@ share_mount(int op, int argc, char **argv) static int zfs_do_mount(int argc, char **argv) { +#ifdef HAVE_ZPL return (share_mount(OP_MOUNT, argc, argv)); +#else + return ENOSYS; +#endif /* HAVE_ZPL */ } /* @@ -3464,9 +3478,14 @@ zfs_do_mount(int argc, char **argv) static int zfs_do_share(int argc, char **argv) { +#ifdef HAVE_ZPL return (share_mount(OP_SHARE, argc, argv)); +#else + return ENOSYS; +#endif /* HAVE_ZPL */ } +#ifdef HAVE_ZPL typedef struct unshare_unmount_node { zfs_handle_t *un_zhp; char *un_mountp; @@ -3919,6 +3938,7 @@ unshare_unmount(int op, int argc, char **argv) return (ret); } +#endif /* HAVE_ZPL */ /* * zfs unmount -a @@ -3929,7 +3949,11 @@ unshare_unmount(int op, int argc, char **argv) static int zfs_do_unmount(int argc, char **argv) { +#ifdef HAVE_ZPL return (unshare_unmount(OP_MOUNT, argc, argv)); +#else + return ENOSYS; +#endif /* HAVE_ZPL */ } /* @@ -3941,13 +3965,18 @@ zfs_do_unmount(int argc, char **argv) static int zfs_do_unshare(int argc, char **argv) { +#ifdef HAVE_ZPL 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 * 'legacy'. Otherwise, complain that use should be using 'zfs mount'. */ +#ifdef HAVE_ZPL static int manual_mount(int argc, char **argv) { @@ -4078,6 +4107,7 @@ manual_unmount(int argc, char **argv) return (unshare_unmount_path(OP_MOUNT, argv[0], flags, B_TRUE)); } +#endif /* HAVE_ZPL */ static int volcheck(zpool_handle_t *zhp, void *data) @@ -4122,7 +4152,9 @@ main(int argc, char **argv) { int ret; int i; +#ifdef HAVE_ZPL char *progname; +#endif char *cmdname; (void) setlocale(LC_ALL, ""); @@ -4147,6 +4179,7 @@ main(int argc, char **argv) return (1); } +#ifdef HAVE_ZPL /* * This command also doubles as the /etc/fs mount and unmount program. * Determine if we should take this behavior based on argv[0]. @@ -4157,6 +4190,9 @@ main(int argc, char **argv) } else if (strcmp(progname, "umount") == 0) { ret = manual_unmount(argc, argv); } else { +#else + { +#endif /* HAVE_ZPL */ /* * Make sure the user has specified some command. */ diff --git a/cmd/zinject/zinject.c b/cmd/zinject/zinject.c index 3e2ca3554e..d5343459c8 100644 --- a/cmd/zinject/zinject.c +++ b/cmd/zinject/zinject.c @@ -750,17 +750,20 @@ main(int argc, char **argv) if (dataset[0] != '\0' && domount) { if ((zhp = zfs_open(g_zfs, dataset, ZFS_TYPE_DATASET)) == NULL) return (1); - +#ifdef HAVE_ZPL if (zfs_unmount(zhp, NULL, 0) != 0) return (1); +#endif /* HAVE_ZPL */ } record.zi_error = error; ret = register_handler(pool, flags, &record, quiet); +#ifdef HAVE_ZPL if (dataset[0] != '\0' && domount) ret = (zfs_mount(zhp, NULL, 0) != 0); +#endif /* HAVE_ZPL */ libzfs_fini(g_zfs); diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 3125cfe419..2ebda8662a 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -697,7 +697,9 @@ zpool_do_create(int argc, char **argv) (strcmp(mountpoint, ZFS_MOUNTPOINT_LEGACY) != 0 && strcmp(mountpoint, ZFS_MOUNTPOINT_NONE) != 0)) { char buf[MAXPATHLEN]; +#ifdef HAVE_ZPL DIR *dirp; +#endif if (mountpoint && mountpoint[0] != '/') { (void) fprintf(stderr, gettext("invalid mountpoint " @@ -722,6 +724,7 @@ zpool_do_create(int argc, char **argv) mountpoint); } +#ifdef HAVE_ZPL if ((dirp = opendir(buf)) == NULL && errno != ENOENT) { (void) fprintf(stderr, gettext("mountpoint '%s' : " "%s\n"), buf, strerror(errno)); @@ -744,6 +747,7 @@ zpool_do_create(int argc, char **argv) goto errout; } } +#endif /* HAVE_ZPL */ } if (dryrun) { @@ -774,8 +778,12 @@ zpool_do_create(int argc, char **argv) zfs_prop_to_name( ZFS_PROP_MOUNTPOINT), mountpoint) == 0); +#ifdef HAVE_ZPL if (zfs_mount(pool, NULL, 0) == 0) ret = zfs_shareall(pool); +#else + ret = 0; +#endif /* HAVE_ZPL */ zfs_close(pool); } } else if (libzfs_errno(g_zfs) == EZFS_INVALIDNAME) { @@ -1323,11 +1331,13 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts, verify((zhp = zpool_open_canfail(g_zfs, name)) != NULL); +#if HAVE_ZPL if (zpool_get_state(zhp) != POOL_STATE_UNAVAIL && zpool_enable_datasets(zhp, mntopts, 0) != 0) { zpool_close(zhp); return (1); } +#endif /* HAVE_ZPL */ zpool_close(zhp); return (error); diff --git a/lib/libzfs/libzfs_changelist.c b/lib/libzfs/libzfs_changelist.c index 8823b2e694..bc4654292c 100644 --- a/lib/libzfs/libzfs_changelist.c +++ b/lib/libzfs/libzfs_changelist.c @@ -93,6 +93,7 @@ struct prop_changelist { int changelist_prefix(prop_changelist_t *clp) { +#ifdef HAVE_ZPL prop_changenode_t *cn; int ret = 0; @@ -168,6 +169,9 @@ changelist_prefix(prop_changelist_t *clp) (void) changelist_postfix(clp); return (ret); +#else + return 0; +#endif /* HAVE_ZPL */ } /* @@ -182,6 +186,7 @@ changelist_prefix(prop_changelist_t *clp) int changelist_postfix(prop_changelist_t *clp) { +#ifdef HAVE_ZPL prop_changenode_t *cn; char shareopts[ZFS_MAXPROPLEN]; int errors = 0; @@ -296,6 +301,9 @@ changelist_postfix(prop_changelist_t *clp) } return (errors ? -1 : 0); +#else + return 0; +#endif /* HAVE_ZPL */ } /* @@ -358,6 +366,7 @@ changelist_rename(prop_changelist_t *clp, const char *src, const char *dst) int changelist_unshare(prop_changelist_t *clp, zfs_share_proto_t *proto) { +#ifdef HAVE_ZPL prop_changenode_t *cn; int ret = 0; @@ -372,6 +381,9 @@ changelist_unshare(prop_changelist_t *clp, zfs_share_proto_t *proto) } return (ret); +#else + return 0; +#endif } /* diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index 91d5433978..cd9cb76fa0 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -859,6 +859,7 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl, /*FALLTHRU*/ +#ifdef HAVE_ZPL case ZFS_PROP_SHARESMB: case ZFS_PROP_SHARENFS: /* @@ -969,6 +970,7 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl, } break; +#endif /* HAVE_ZPL */ case ZFS_PROP_UTF8ONLY: chosen_utf = (int)intval; break; @@ -3023,6 +3025,7 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen) goto ancestorerr; } +#ifdef HAVE_ZPL if (zfs_mount(h, NULL, 0) != 0) { opname = dgettext(TEXT_DOMAIN, "mount"); goto ancestorerr; @@ -3032,6 +3035,7 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen) opname = dgettext(TEXT_DOMAIN, "share"); goto ancestorerr; } +#endif /* HAVE_ZPL */ zfs_close(h); } @@ -3248,9 +3252,11 @@ zfs_destroy(zfs_handle_t *zhp) * abort the request. This would only happen for a * non-privileged user. */ +#ifdef HAVE_ZPL if (zfs_unshare_iscsi(zhp) != 0) { return (-1); } +#endif if (zvol_remove_link(zhp->zfs_hdl, zhp->zfs_name) != 0) return (-1); diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 1dd345a275..90789b9497 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -85,6 +85,7 @@ #include #define MAXISALEN 257 /* based on sysinfo(2) man page */ +#ifdef HAVE_ZPL 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_proto_t); @@ -1225,7 +1226,6 @@ out: return (ret); } - static int zvol_cb(const char *dataset, void *data) { @@ -1398,3 +1398,42 @@ out: 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_FALSE; +} + +int +zpool_disable_datasets(zpool_handle_t *zhp, boolean_t force) +{ + return B_FALSE; +} + +#endif /* HAVE_ZPL */ diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index 35f12c0d50..04d9016342 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -1930,6 +1930,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, * created). Also mount any children of the target filesystem * if we did an incremental receive. */ +#ifdef HAVE_ZPL cp = strchr(zc.zc_value, '@'); if (cp && (ioctl_err == 0 || !newfs)) { zfs_handle_t *h; @@ -1956,6 +1957,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, } *cp = '@'; } +#endif /* HAVE_ZPL */ if (clp) { err |= changelist_postfix(clp); diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index b0662d47d3..01f6ce09f3 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -586,7 +586,9 @@ libzfs_fini(libzfs_handle_t *hdl) (void) fclose(hdl->libzfs_mnttab); if (hdl->libzfs_sharetab) (void) fclose(hdl->libzfs_sharetab); +#ifdef HAVE_ZPL zfs_uninit_libshare(hdl); +#endif if (hdl->libzfs_log_str) (void) free(hdl->libzfs_log_str); zpool_free_handles(hdl); diff --git a/module/zcommon/include/sys/fs/zfs.h b/module/zcommon/include/sys/fs/zfs.h index 95f04d842e..c518382871 100644 --- a/module/zcommon/include/sys/fs/zfs.h +++ b/module/zcommon/include/sys/fs/zfs.h @@ -491,6 +491,8 @@ typedef struct vdev_stat { #define ZVOL_DRIVER "zvol" #define ZFS_DRIVER "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 diff --git a/module/zfs/include/sys/zfs_fuid.h b/module/zfs/include/sys/zfs_fuid.h index 3e8d36c3da..01f185ecdb 100644 --- a/module/zfs/include/sys/zfs_fuid.h +++ b/module/zfs/include/sys/zfs_fuid.h @@ -100,6 +100,7 @@ typedef struct zfs_fuid_info { } zfs_fuid_info_t; #ifdef _KERNEL +#ifdef HAVE_ZPL struct znode; extern uid_t zfs_fuid_map_id(zfsvfs_t *, uint64_t, cred_t *, zfs_fuid_type_t); extern void zfs_fuid_destroy(zfsvfs_t *); @@ -112,6 +113,7 @@ extern void zfs_fuid_map_ids(struct znode *zp, cred_t *cr, uid_t *uid, extern zfs_fuid_info_t *zfs_fuid_info_alloc(void); extern void zfs_fuid_info_free(); extern boolean_t zfs_groupmember(zfsvfs_t *, uint64_t, cred_t *); +#endif /* HAVE_ZPL */ #endif char *zfs_fuid_idx_domain(avl_tree_t *, uint32_t); diff --git a/module/zfs/rrwlock.c b/module/zfs/rrwlock.c index 1bb8a285b2..c1c91fdd4e 100644 --- a/module/zfs/rrwlock.c +++ b/module/zfs/rrwlock.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ - +#ifdef HAVE_ZPL #include #include @@ -247,3 +247,4 @@ rrw_held(rrwlock_t *rrl, krw_t rw) return (held); } +#endif /* HAVE_ZPL */ diff --git a/module/zfs/zfs_acl.c b/module/zfs/zfs_acl.c index fdf92a156e..89bd8e8c97 100644 --- a/module/zfs/zfs_acl.c +++ b/module/zfs/zfs_acl.c @@ -23,6 +23,8 @@ * Use is subject to license terms. */ +#ifdef HAVE_ZPL + #include #include #include @@ -2678,3 +2680,5 @@ zfs_zaccess_rename(znode_t *sdzp, znode_t *szp, znode_t *tdzp, return (error); } + +#endif /* HAVE_ZPL */ diff --git a/module/zfs/zfs_ctldir.c b/module/zfs/zfs_ctldir.c index 0da0261006..cebb2eb90c 100644 --- a/module/zfs/zfs_ctldir.c +++ b/module/zfs/zfs_ctldir.c @@ -64,6 +64,8 @@ * so that it cannot be freed until all snapshots have been unmounted. */ +#ifdef HAVE_ZPL + #include #include #include @@ -1177,3 +1179,4 @@ zfsctl_umount_snapshots(vfs_t *vfsp, int fflags, cred_t *cr) return (error); } +#endif /* HAVE_ZPL */ diff --git a/module/zfs/zfs_dir.c b/module/zfs/zfs_dir.c index 9353d0199e..84b279af72 100644 --- a/module/zfs/zfs_dir.c +++ b/module/zfs/zfs_dir.c @@ -23,6 +23,8 @@ * Use is subject to license terms. */ +#ifdef HAVE_ZPL + #include #include #include @@ -957,3 +959,4 @@ zfs_sticky_remove_access(znode_t *zdp, znode_t *zp, cred_t *cr) else return (secpolicy_vnode_remove(cr)); } +#endif /* HAVE_ZPL */ diff --git a/module/zfs/zfs_fuid.c b/module/zfs/zfs_fuid.c index ce2bc93030..da5797d1e6 100644 --- a/module/zfs/zfs_fuid.c +++ b/module/zfs/zfs_fuid.c @@ -185,6 +185,7 @@ zfs_fuid_idx_domain(avl_tree_t *idx_tree, uint32_t idx) } #ifdef _KERNEL +#ifdef HAVE_ZPL /* * Load the fuid table(s) into memory. */ @@ -700,4 +701,5 @@ zfs_groupmember(zfsvfs_t *zfsvfs, uint64_t id, cred_t *cr) gid = zfs_fuid_map_id(zfsvfs, id, cr, ZFS_GROUP); return (groupmember(gid, cr)); } +#endif /* HAVE_ZPL */ #endif diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index 3cdd1d8c3b..1c098512fa 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -394,6 +394,7 @@ zfs_secpolicy_send(zfs_cmd_t *zc, cred_t *cr) int zfs_secpolicy_share(zfs_cmd_t *zc, cred_t *cr) { +#ifdef HAVE_ZPL if (!INGLOBALZONE(curproc)) return (EPERM); @@ -420,6 +421,9 @@ zfs_secpolicy_share(zfs_cmd_t *zc, cred_t *cr) return (dsl_deleg_access(zc->zc_name, ZFS_DELEG_PERM_SHARE, cr)); } +#else + return (ENOTSUP); +#endif /* HAVE_ZPL */ } static int @@ -614,6 +618,7 @@ zfs_secpolicy_create(zfs_cmd_t *zc, cred_t *cr) return (error); } +#ifdef HAVE_ZPL static int zfs_secpolicy_umount(zfs_cmd_t *zc, cred_t *cr) { @@ -625,6 +630,7 @@ zfs_secpolicy_umount(zfs_cmd_t *zc, cred_t *cr) } return (error); } +#endif /* HAVE_ZPL */ /* * Policy for pool operations - create/destroy pools, add vdevs, etc. Requires @@ -1726,6 +1732,7 @@ zfs_ioc_pool_get_props(zfs_cmd_t *zc) static int zfs_ioc_iscsi_perm_check(zfs_cmd_t *zc) { +#ifdef HAVE_ZPL nvlist_t *nvp; int error; uint32_t uid; @@ -1768,6 +1775,9 @@ zfs_ioc_iscsi_perm_check(zfs_cmd_t *zc) zfs_prop_to_name(ZFS_PROP_SHAREISCSI), usercred); crfree(usercred); return (error); +#else + return (ENOTSUP); +#endif /* HAVE_ZPL */ } /* @@ -1865,6 +1875,7 @@ zfs_ioc_remove_minor(zfs_cmd_t *zc) return (zvol_remove_minor(zc->zc_name)); } +#ifdef HAVE_ZPL /* * 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 @@ -1889,6 +1900,7 @@ zfs_get_vfs(const char *resource) vfs_list_unlock(); return (vfs_found); } +#endif /* HAVE_ZPL */ /* ARGSUSED */ static void @@ -2263,6 +2275,7 @@ zfs_ioc_snapshot(zfs_cmd_t *zc) int zfs_unmount_snap(char *name, void *arg) { +#ifdef HAVE_ZPL vfs_t *vfsp = NULL; if (arg) { @@ -2294,6 +2307,7 @@ zfs_unmount_snap(char *name, void *arg) if ((err = dounmount(vfsp, flag, kcred)) != 0) return (err); } +#endif /* HAVE_ZPL */ return (0); } @@ -2346,6 +2360,7 @@ zfs_ioc_destroy(zfs_cmd_t *zc) static int zfs_ioc_rollback(zfs_cmd_t *zc) { +#ifdef HAVE_ZPL objset_t *os; int error; zfsvfs_t *zfsvfs = NULL; @@ -2391,6 +2406,9 @@ zfs_ioc_rollback(zfs_cmd_t *zc) /* Note, the dmu_objset_rollback() releases the objset for us. */ return (error); +#else + return (ENOTSUP); +#endif /* HAVE_ZPL */ } /* @@ -2464,7 +2482,9 @@ static int zfs_ioc_recv(zfs_cmd_t *zc) { file_t *fp; +#ifdef HAVE_ZPL objset_t *os; +#endif /* HAVE_ZPL */ dmu_recv_cookie_t drc; zfsvfs_t *zfsvfs = NULL; boolean_t force = (boolean_t)zc->zc_guid; @@ -2498,6 +2518,7 @@ zfs_ioc_recv(zfs_cmd_t *zc) return (EBADF); } +#ifdef HAVE_ZPL if (dmu_objset_open(tofs, DMU_OST_ANY, DS_MODE_USER | DS_MODE_READONLY, &os) == 0) { /* @@ -2527,6 +2548,7 @@ zfs_ioc_recv(zfs_cmd_t *zc) dmu_objset_close(os); } +#endif /* HAVE_ZPL */ if (zc->zc_string[0]) { error = dmu_objset_open(zc->zc_string, DMU_OST_ANY, @@ -2592,7 +2614,9 @@ zfs_ioc_recv(zfs_cmd_t *zc) out: if (zfsvfs) { mutex_exit(&zfsvfs->z_online_recv_lock); +#ifdef HAVE_ZPL VFS_RELE(zfsvfs->z_vfs); +#endif /* HAVE_ZPL */ } nvlist_free(props); nvlist_free(origprops); @@ -2801,6 +2825,7 @@ zfs_ioc_promote(zfs_cmd_t *zc) * the first file system is shared. * Neither sharefs, nfs or smbsrv are unloadable modules. */ +#ifdef HAVE_ZPL int (*znfsexport_fs)(void *arg); int (*zshare_fs)(enum sharefs_sys_op, share_t *, uint32_t); int (*zsmbexport_fs)(void *arg, boolean_t add_share); @@ -2832,10 +2857,12 @@ zfs_init_sharefs() } return (0); } +#endif /* HAVE_ZPL */ static int zfs_ioc_share(zfs_cmd_t *zc) { +#ifdef HAVE_ZPL int error; int opcode; @@ -2925,9 +2952,12 @@ zfs_ioc_share(zfs_cmd_t *zc) zc->zc_share.z_sharemax); return (error); - +#else + return (ENOTSUP); +#endif /* HAVE_ZPL */ } + /* * pool create, destroy, and export don't log the history as part of * zfsdev_ioctl, but rather zfs_ioc_pool_create, and zfs_ioc_pool_export @@ -3174,12 +3204,14 @@ _init(void) return (error); } + error = ldi_ident_from_mod(&modlinkage, &zfs_li); + ASSERT(error == 0); +#ifdef HAVE_ZPL tsd_create(&zfs_fsyncer_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); +#endif /* HAVE_ZPL */ return (0); } @@ -3198,6 +3230,7 @@ _fini(void) zvol_fini(); zfs_fini(); spa_fini(); +#ifdef HAVE_ZPL if (zfs_nfsshare_inited) (void) ddi_modclose(nfs_mod); if (zfs_smbshare_inited) @@ -3205,10 +3238,12 @@ _fini(void) if (zfs_nfsshare_inited || zfs_smbshare_inited) (void) ddi_modclose(sharefs_mod); + mutex_destroy(&zfs_share_lock); tsd_destroy(&zfs_fsyncer_key); +#endif /* HAVE_ZPL */ + ldi_ident_release(zfs_li); zfs_li = NULL; - mutex_destroy(&zfs_share_lock); return (error); } diff --git a/module/zfs/zfs_log.c b/module/zfs/zfs_log.c index 84d64b4df6..5a89bd01bb 100644 --- a/module/zfs/zfs_log.c +++ b/module/zfs/zfs_log.c @@ -23,6 +23,8 @@ * Use is subject to license terms. */ +#ifdef HAVE_ZPL + #include #include #include @@ -730,3 +732,5 @@ zfs_log_acl(zilog_t *zilog, dmu_tx_t *tx, znode_t *zp, seq = zil_itx_assign(zilog, itx, tx); zp->z_last_itx = seq; } + +#endif /* HAVE_ZPL */ diff --git a/module/zfs/zfs_replay.c b/module/zfs/zfs_replay.c index 819ba2886c..7aeff072a4 100644 --- a/module/zfs/zfs_replay.c +++ b/module/zfs/zfs_replay.c @@ -23,7 +23,7 @@ * Use is subject to license terms. */ - +#ifdef HAVE_ZPL #include #include @@ -876,3 +876,4 @@ zil_replay_func_t *zfs_replay_vector[TX_MAX_TYPE] = { zfs_replay_create, /* TX_MKDIR_ATTR */ zfs_replay_create_acl, /* TX_MKDIR_ACL_ATTR */ }; +#endif /* HAVE_ZPL */ diff --git a/module/zfs/zfs_rlock.c b/module/zfs/zfs_rlock.c index 4de8d8a2df..1a91b65ad7 100644 --- a/module/zfs/zfs_rlock.c +++ b/module/zfs/zfs_rlock.c @@ -92,6 +92,8 @@ * range to just the range to be written using zfs_reduce_range. */ +#ifdef HAVE_ZPL + #include /* @@ -600,3 +602,4 @@ zfs_range_compare(const void *arg1, const void *arg2) return (-1); return (0); } +#endif /* HAVE_ZPL */ diff --git a/module/zfs/zfs_vfsops.c b/module/zfs/zfs_vfsops.c index 1bf1bc527b..9b964689dc 100644 --- a/module/zfs/zfs_vfsops.c +++ b/module/zfs/zfs_vfsops.c @@ -61,6 +61,7 @@ #include #include +#ifdef HAVE_ZPL int zfsfstype; vfsops_t *zfs_vfsops = NULL; static major_t zfs_major; @@ -1545,10 +1546,12 @@ zfs_vfsinit(int fstype, char *name) return (0); } +#endif /* HAVE_ZPL */ void zfs_init(void) { +#ifdef HAVE_ZPL /* * Initialize .zfs directory structures */ @@ -1558,19 +1561,26 @@ zfs_init(void) * Initialize znode cache, vnode ops, etc... */ zfs_znode_init(); +#endif /* HAVE_ZPL */ } void zfs_fini(void) { +#ifdef HAVE_ZPL zfsctl_fini(); zfs_znode_fini(); +#endif /* HAVE_ZPL */ } int zfs_busy(void) { +#ifdef HAVE_ZPL return (zfs_active_fs_count != 0); +#else + return 0; +#endif /* HAVE_ZPL */ } int @@ -1666,6 +1676,7 @@ zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value) return (error); } +#ifdef HAVE_ZPL static vfsdef_t vfw = { VFSDEF_VERSION, MNTTYPE_ZFS, @@ -1678,3 +1689,4 @@ static vfsdef_t vfw = { struct modlfs zfs_modlfs = { &mod_fsops, "ZFS filesystem version " SPA_VERSION_STRING, &vfw }; +#endif /* HAVE_ZPL */ diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index e38abb28c5..576a2b2d48 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -25,6 +25,8 @@ /* Portions Copyright 2007 Jeremy Teo */ +#ifdef HAVE_ZPL + #include #include #include @@ -4536,3 +4538,4 @@ const fs_operation_def_t zfs_evnodeops_template[] = { VOPNAME_PATHCONF, { .vop_pathconf = zfs_pathconf }, NULL, NULL }; +#endif /* HAVE_ZPL */ diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c index 7542ea1af2..d31951a3d0 100644 --- a/module/zfs/zfs_znode.c +++ b/module/zfs/zfs_znode.c @@ -87,6 +87,7 @@ * (such as VFS logic) that will not compile easily in userland. */ #ifdef _KERNEL +#ifdef HAVE_ZPL static kmem_cache_t *znode_cache = NULL; /*ARGSUSED*/ @@ -1469,20 +1470,28 @@ log: dmu_tx_commit(tx); return (0); } +#endif /* HAVE_ZPL */ void 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 sense = ZFS_CASE_SENSITIVE; uint64_t norm = 0; nvpair_t *elem; int error; +#ifdef HAVE_ZPL + zfsvfs_t zfsvfs; znode_t *rootzp = NULL; vnode_t *vp; vattr_t vattr; znode_t *zp; +#else + uint64_t obj; + timestruc_t now; + dmu_buf_t *db; + znode_phys_t *pzp; +#endif /* HAVE_ZPL */ /* * First attempt to create master node. @@ -1537,6 +1546,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, &doid, tx); ASSERT(error == 0); +#ifdef HAVE_ZPL /* * Create root znode. Create minimal znode/vnode/zfsvfs * to allow zfs_mknode to work. @@ -1588,6 +1598,45 @@ zfs_create_fs(objset_t *os, cred_t *cr, nvlist_t *zplprops, dmu_tx_t *tx) dmu_buf_rele(rootzp->z_dbuf, NULL); rootzp->z_dbuf = NULL; kmem_cache_free(znode_cache, rootzp); +#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); + + /* + * 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 /* HAVE_ZPL */ } #endif /* _KERNEL */