From fd7578215e504919b6db6d4043f68a91018271b1 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 8 Mar 2010 10:27:42 -0800 Subject: [PATCH 1/2] Configure checks for kernel build options incompatible with the license Twice now I've been bitten by building agaist a kernel which is configured such that it is incompatible with the CDDL license. These build failures don't occur until the linking phase at which point they simply callout the offending symbol. No location information can be provided at this point so it often can be confusing what the problem is particularly when building against a new kernel for the first time. To help address this I've added a configure check which can be extended over time to detect known kernel config options which if set will break the ZFS build. Currently I have just added CONFIG_DEBUG_LOCK_ALLOC which makes mutex's GPL-only and is on by default in the RHEL6 alpha builds. I know for a fact there are other similiar options which can be added as they are encountered. --- META | 2 ++ config/kernel.m4 | 25 +++++++++++++++++++++++++ config/zfs-build.m4 | 12 ++++-------- config/zfs-meta.m4 | 8 ++++++++ 4 files changed, 39 insertions(+), 8 deletions(-) diff --git a/META b/META index 2b06b650cd..90ea64efa1 100644 --- a/META +++ b/META @@ -4,3 +4,5 @@ Branch: 1.0 Version: 0.4.7 Release: 1 Release-Tags: relext +License: CDDL +Author: Sun Microsystems/Oracle, Lawrence Livermore National Laboratory diff --git a/config/kernel.m4 b/config/kernel.m4 index ae1b5e5321..9f5dd6894a 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -4,6 +4,7 @@ dnl # AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ ZFS_AC_KERNEL ZFS_AC_SPL + ZFS_AC_KERNEL_CONFIG ZFS_AC_KERNEL_BDEV_BLOCK_DEVICE_OPERATIONS ZFS_AC_KERNEL_TYPE_FMODE_T ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE @@ -238,6 +239,30 @@ AC_DEFUN([ZFS_AC_SPL], [ ZFS_AC_SPL_MODULE_SYMVERS ]) +dnl # +dnl # There are certain kernel build options which when enabled are +dnl # completely incompatible with non GPL kernel modules. It is best +dnl # to detect these at configure time and fail with a clear error +dnl # rather than build everything and fail during linking. +dnl # +dnl # CONFIG_DEBUG_LOCK_ALLOC - Maps mutex_lock() to mutex_lock_nested() +dnl # +AC_DEFUN([ZFS_AC_KERNEL_CONFIG], [ + + if test "$ZFS_META_LICENSE" = CDDL; then + ZFS_LINUX_CONFIG([DEBUG_LOCK_ALLOC], + AC_MSG_ERROR([ + *** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is + *** incompatible with the CDDL license. You must rebuild + *** your kernel without this option.]), []) + fi + + if test "$ZFS_META_LICENSE" = GPL; then + AC_DEFINE([HAVE_GPL_ONLY_SYMBOLS], [1], + [Define to 1 if licensed under the GPL]) + fi +]) + dnl # dnl # ZFS_LINUX_CONFTEST dnl # diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index d2ba2977fa..a10fd2e1ef 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -1,13 +1,9 @@ AC_DEFUN([ZFS_AC_LICENSE], [ - AC_MSG_CHECKING([zfs license]) - LICENSE=`grep MODULE_LICENSE module/zfs/zfs_ioctl.c | cut -f2 -d'"'` - AC_MSG_RESULT([$LICENSE]) - if test "$LICENSE" = GPL; then - AC_DEFINE([HAVE_GPL_ONLY_SYMBOLS], [1], - [Define to 1 if module is licensed under the GPL]) - fi + AC_MSG_CHECKING([zfs author]) + AC_MSG_RESULT([$ZFS_META_AUTHOR]) - AC_SUBST(LICENSE) + AC_MSG_CHECKING([zfs license]) + AC_MSG_RESULT([$ZFS_META_LICENSE]) ]) AC_DEFUN([ZFS_AC_DEBUG], [ diff --git a/config/zfs-meta.m4 b/config/zfs-meta.m4 index 393ced0dbe..8b3689af71 100644 --- a/config/zfs-meta.m4 +++ b/config/zfs-meta.m4 @@ -48,6 +48,14 @@ AC_DEFUN([ZFS_AC_META], [ AC_SUBST([ZFS_META_RELEASE]) fi + ZFS_META_LICENSE=_ZFS_AC_META_GETVAL([LICENSE]); + if test -n "$ZFS_META_LICENSE"; then + AC_DEFINE_UNQUOTED([ZFS_META_LICENSE], ["$ZFS_META_LICENSE"], + [Define the project license.] + ) + AC_SUBST([ZFS_META_LICENSE]) + fi + if test -n "$ZFS_META_NAME" -a -n "$ZFS_META_VERSION"; then ZFS_META_ALIAS="$ZFS_META_NAME-$ZFS_META_VERSION" test -n "$ZFS_META_RELEASE" && From 7121867aea8cfd6adef73c6224584d50f8a2dfc6 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Mon, 8 Mar 2010 10:45:19 -0800 Subject: [PATCH 2/2] Configure checks for kernel build options incompatible with the license Changes for linux-kernel-module topic branch, see commit fd75782. --- module/avl/avl.c | 6 ++++-- module/nvpair/nvpair.c | 6 ++++-- module/unicode/u8_textprep.c | 6 ++++-- module/zcommon/zfs_prop.c | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/module/avl/avl.c b/module/avl/avl.c index 728bd87234..eb8bfcd052 100644 --- a/module/avl/avl.c +++ b/module/avl/avl.c @@ -1033,15 +1033,17 @@ done: } #if defined(_KERNEL) && defined(HAVE_SPL) +#include "zfs_config.h" + static int avl_init(void) { return 0; } static int avl_fini(void) { return 0; } spl_module_init(avl_init); spl_module_exit(avl_fini); -MODULE_AUTHOR("Sun Microsystems, Inc"); MODULE_DESCRIPTION("Generic AVL tree implementation"); -MODULE_LICENSE("CDDL"); +MODULE_AUTHOR(ZFS_META_AUTHOR); +MODULE_LICENSE(ZFS_META_LICENSE); EXPORT_SYMBOL(avl_create); EXPORT_SYMBOL(avl_find); diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c index 5bee964294..02abfdbefb 100644 --- a/module/nvpair/nvpair.c +++ b/module/nvpair/nvpair.c @@ -3246,15 +3246,17 @@ nvs_xdr(nvstream_t *nvs, nvlist_t *nvl, char *buf, size_t *buflen) } #if defined(_KERNEL) && defined(HAVE_SPL) +#include "zfs_config.h" + static int nvpair_init(void) { return 0; } static int nvpair_fini(void) { return 0; } spl_module_init(nvpair_init); spl_module_exit(nvpair_fini); -MODULE_AUTHOR("Sun Microsystems, Inc"); MODULE_DESCRIPTION("Generic name/value pair implementation"); -MODULE_LICENSE("CDDL"); +MODULE_AUTHOR(ZFS_META_AUTHOR); +MODULE_LICENSE(ZFS_META_LICENSE); EXPORT_SYMBOL(nv_alloc_init); EXPORT_SYMBOL(nv_alloc_reset); diff --git a/module/unicode/u8_textprep.c b/module/unicode/u8_textprep.c index 37fb2e5a46..9f90e5056d 100644 --- a/module/unicode/u8_textprep.c +++ b/module/unicode/u8_textprep.c @@ -2133,15 +2133,17 @@ u8_textprep_str(char *inarray, size_t *inlen, char *outarray, size_t *outlen, } #if defined(_KERNEL) && defined(HAVE_SPL) +#include "zfs_config.h" + static int unicode_init(void) { return 0; } static int unicode_fini(void) { return 0; } spl_module_init(unicode_init); spl_module_exit(unicode_fini); -MODULE_AUTHOR("Sun Microsystems, Inc"); MODULE_DESCRIPTION("Unicode implementation"); -MODULE_LICENSE("CDDL"); +MODULE_AUTHOR(ZFS_META_AUTHOR); +MODULE_LICENSE(ZFS_META_LICENSE); EXPORT_SYMBOL(u8_validate); EXPORT_SYMBOL(u8_strcmp); diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c index 45943602c0..ec93ae4c99 100644 --- a/module/zcommon/zfs_prop.c +++ b/module/zcommon/zfs_prop.c @@ -534,15 +534,17 @@ zfs_prop_align_right(zfs_prop_t prop) #endif #if defined(_KERNEL) && defined(HAVE_SPL) +#include "zfs_config.h" + static int zcommon_init(void) { return 0; } static int zcommon_fini(void) { return 0; } spl_module_init(zcommon_init); spl_module_exit(zcommon_fini); -MODULE_AUTHOR("Sun Microsystems, Inc"); MODULE_DESCRIPTION("Generic ZFS support"); -MODULE_LICENSE("CDDL"); +MODULE_AUTHOR(ZFS_META_AUTHOR); +MODULE_LICENSE(ZFS_META_LICENSE); /* zfs dataset property functions */ EXPORT_SYMBOL(zfs_userquota_prop_prefixes);