From 0fd95094fddbfd131c02a81dcb04b43af6742d78 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Fri, 5 Dec 2008 10:33:53 -0800 Subject: [PATCH] Refresh linux-have-zvol --- .topdeps | 4 +--- .topmsg | 17 ++--------------- zfs/lib/libzfs/libzfs_dataset.c | 10 ++++++++++ zfs/lib/libzfs/libzfs_pool.c | 2 ++ zfs/lib/libzpool/zvol.c | 19 ++++++++++++++++++- 5 files changed, 33 insertions(+), 19 deletions(-) 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 e9722e1075..5143e12acd 100644 --- a/.topmsg +++ b/.topmsg @@ -1,19 +1,6 @@ From: Brian Behlendorf -Subject: [PATCH] zfs branch +Subject: [PATCH] linux have zvol -Merged result of all changes which are relevant to both Solaris -and Linux builds of the ZFS code. These are changes where there -is a reasonable chance they will be accepted upstream. - -Additionally, since this is effectively the root of the linux -ZFS tree the core linux build system is added here. This -includes autogen.sh, configure.ac, m4 macros, some scripts/*, -and makefiles for all the core ZFS components. Linux-only -features which require tweaks to the build system should appear -on the relevant topic branches. All autotools products which -result from autogen.sh are commited to the linux-configure-branch. - -This branch also contains the META, ChangeLog, AUTHORS, -README, and GIT files. +Use ZVOL if HAVE_ZVOL defined Signed-off-by: Brian Behlendorf diff --git a/zfs/lib/libzfs/libzfs_dataset.c b/zfs/lib/libzfs/libzfs_dataset.c index 3f49652abb..c2c34ed176 100644 --- a/zfs/lib/libzfs/libzfs_dataset.c +++ b/zfs/lib/libzfs/libzfs_dataset.c @@ -3981,6 +3981,11 @@ zvol_create_link(libzfs_handle_t *hdl, const char *dataset) static int zvol_create_link_common(libzfs_handle_t *hdl, const char *dataset, int ifexists) { +#if !defined(HAVE_ZVOL) + return (zfs_standard_error_fmt(hdl, ENOTSUP, + dgettext(TEXT_DOMAIN, "cannot create device links " + "for '%s'"), dataset)); +#else zfs_cmd_t zc = { 0 }; di_devlink_handle_t dhdl; priv_set_t *priv_effective; @@ -4069,6 +4074,7 @@ zvol_create_link_common(libzfs_handle_t *hdl, const char *dataset, int ifexists) } return (0); +#endif } /* @@ -4205,6 +4211,9 @@ zfs_expand_proplist(zfs_handle_t *zhp, zprop_list_t **plp) int zfs_iscsi_perm_check(libzfs_handle_t *hdl, char *dataset, ucred_t *cred) { +#if !defined(HAVE_ZVOL) + return (ENOTSUP); +#else zfs_cmd_t zc = { 0 }; nvlist_t *nvp; gid_t gid; @@ -4246,6 +4255,7 @@ zfs_iscsi_perm_check(libzfs_handle_t *hdl, char *dataset, ucred_t *cred) error = ioctl(hdl->libzfs_fd, ZFS_IOC_ISCSI_PERM_CHECK, &zc); nvlist_free(nvp); return (error); +#endif } int diff --git a/zfs/lib/libzfs/libzfs_pool.c b/zfs/lib/libzfs/libzfs_pool.c index ae4b19adba..123123f7ba 100644 --- a/zfs/lib/libzfs/libzfs_pool.c +++ b/zfs/lib/libzfs/libzfs_pool.c @@ -2087,6 +2087,7 @@ int zpool_iter_zvol(zpool_handle_t *zhp, int (*cb)(const char *, void *), void *data) { +#ifdef HAVE_ZVOL libzfs_handle_t *hdl = zhp->zpool_hdl; char (*paths)[MAXPATHLEN]; size_t size = 4; @@ -2178,6 +2179,7 @@ zpool_iter_zvol(zpool_handle_t *zhp, int (*cb)(const char *, void *), err: free(paths); (void) close(base); +#endif return (-1); } diff --git a/zfs/lib/libzpool/zvol.c b/zfs/lib/libzpool/zvol.c index 4e993060ce..e686816af6 100644 --- a/zfs/lib/libzpool/zvol.c +++ b/zfs/lib/libzpool/zvol.c @@ -76,6 +76,11 @@ #include #include +#ifdef HAVE_SPL +#include +#include +#endif + #include "zfs_namecheck.h" static void *zvol_state; @@ -159,10 +164,22 @@ zvol_check_volsize(uint64_t volsize, uint64_t blocksize) if (volsize % blocksize != 0) return (EINVAL); -#ifdef _ILP32 +#ifdef HAVE_SPL + if (volsize % 512 != 0) + return (EINVAL); + + /* + * On Linux, the maximum allowed block device size depends on the size + * of sector_t. + */ + if (fls64(volsize / 512 - 1) > NBBY * sizeof (sector_t)) + return (EOVERFLOW); + +#elif defined(_ILP32) if (volsize - 1 > SPEC_MAXOFFSET_T) return (EOVERFLOW); #endif + return (0); }