Merge branch 'builtin-clean'

Support in-tree builtin module building.

These commits add support for compiling the ZFS module as a built-in
kernel module by copying the module code into the kernel source tree.
Here's the procedure:

  - Create your kernel configuration (`.config` file) as usual. This
    has to be done first so that ZFS's configure script is able to
    detect kernel features correctly.
  - Run `make prepare scripts` inside the kernel source tree.
  - Run `./configure --enable-linux-builtin --with-linux=/usr/src/linux-...`
    inside the ZFS directory.
  - Run `./copy-builtin /usr/src/linux-...` inside the ZFS directory.
  - In the kernel source tree, enable the `CONFIG_ZFS` option (e.g. using
    `make menuconfig`). Note that this option depends on `CONFIG_SPL`
    (see zfsonlinux/spl@744038069d).
  - Build the kernel as usual.

ZFS module parameters can be set at boot time using the following syntax
on the kernel command line: `zfs.parameter_name=parameter_value`.

Note that you also need to rebuild the userspace tools (see
zfsonlinux/zfs@f09398cec6).

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #851
This commit is contained in:
Brian Behlendorf 2012-07-26 15:37:13 -07:00
commit 4ab8a725ce
29 changed files with 2839 additions and 1031 deletions

View File

@ -904,20 +904,18 @@ uninstall-am:
tags tags-recursive uninstall uninstall-am
srpm-modules:
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" srpm-common
@CONFIG_KERNEL_TRUE@ $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" srpm-common
srpm-utils:
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" srpm-common
@CONFIG_USER_TRUE@ $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" srpm-common
srpm: srpm-modules srpm-utils
rpm-modules: srpm-modules
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" rpm-common
@CONFIG_KERNEL_TRUE@ $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" rpm-common
rpm-utils: srpm-utils
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" rpm-common
rpm-modules: srpm-modules
@CONFIG_USER_TRUE@ $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" rpm-common
rpm: rpm-modules rpm-utils
@ -995,25 +993,25 @@ deb-local:
fi)
deb-modules: deb-local rpm-modules
name=${PACKAGE}-modules; \
version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \
release=`echo ${LINUX_VERSION} | $(SED) -e "s/-/_/g"`; \
arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \
pkg1=$${name}-$${version}_$${release}.$${arch}.rpm; \
pkg2=$${name}-devel-$${version}_$${release}.$${arch}.rpm; \
fakeroot $(ALIEN) --scripts --to-deb $$pkg1 $$pkg2; \
$(RM) $$pkg1 $$pkg2
@CONFIG_KERNEL_TRUE@ name=${PACKAGE}-modules; \
@CONFIG_KERNEL_TRUE@ version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \
@CONFIG_KERNEL_TRUE@ release=`echo ${LINUX_VERSION} | $(SED) -e "s/-/_/g"`; \
@CONFIG_KERNEL_TRUE@ arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \
@CONFIG_KERNEL_TRUE@ pkg1=$${name}-$${version}_$${release}.$${arch}.rpm; \
@CONFIG_KERNEL_TRUE@ pkg2=$${name}-devel-$${version}_$${release}.$${arch}.rpm; \
@CONFIG_KERNEL_TRUE@ fakeroot $(ALIEN) --scripts --to-deb $$pkg1 $$pkg2; \
@CONFIG_KERNEL_TRUE@ $(RM) $$pkg1 $$pkg2
deb-utils: deb-local rpm-utils
name=${PACKAGE}; \
version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \
arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \
pkg1=$${name}-$${version}.$${arch}.rpm; \
pkg2=$${name}-devel-$${version}.$${arch}.rpm; \
pkg3=$${name}-test-$${version}.$${arch}.rpm; \
pkg4=$${name}-dracut-$${version}.$${arch}.rpm; \
fakeroot $(ALIEN) --scripts --to-deb $$pkg1 $$pkg2 $$pkg3 $$pkg4; \
$(RM) $$pkg1 $$pkg2 $$pkg3 $$pkg4
@CONFIG_USER_TRUE@ name=${PACKAGE}; \
@CONFIG_USER_TRUE@ version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \
@CONFIG_USER_TRUE@ arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \
@CONFIG_USER_TRUE@ pkg1=$${name}-$${version}.$${arch}.rpm; \
@CONFIG_USER_TRUE@ pkg2=$${name}-devel-$${version}.$${arch}.rpm; \
@CONFIG_USER_TRUE@ pkg3=$${name}-test-$${version}.$${arch}.rpm; \
@CONFIG_USER_TRUE@ pkg4=$${name}-dracut-$${version}.$${arch}.rpm; \
@CONFIG_USER_TRUE@ fakeroot $(ALIEN) --scripts --to-deb $$pkg1 $$pkg2 $$pkg3 $$pkg4; \
@CONFIG_USER_TRUE@ $(RM) $$pkg1 $$pkg2 $$pkg3 $$pkg4
deb: deb-modules deb-utils
tgz-local:
@ -1026,24 +1024,24 @@ tgz-local:
fi)
tgz-modules: tgz-local rpm-modules
name=${PACKAGE}-modules; \
version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \
release=`echo ${LINUX_VERSION} | $(SED) -e "s/-/_/g"`; \
arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \
pkg1=$${name}-$${version}_$${release}.$${arch}.rpm; \
pkg2=$${name}-devel-$${version}_$${release}.$${arch}.rpm; \
fakeroot $(ALIEN) --scripts --to-tgz $$pkg1 $$pkg2; \
$(RM) $$pkg1 $$pkg2
@CONFIG_KERNEL_TRUE@ name=${PACKAGE}-modules; \
@CONFIG_KERNEL_TRUE@ version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \
@CONFIG_KERNEL_TRUE@ release=`echo ${LINUX_VERSION} | $(SED) -e "s/-/_/g"`; \
@CONFIG_KERNEL_TRUE@ arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \
@CONFIG_KERNEL_TRUE@ pkg1=$${name}-$${version}_$${release}.$${arch}.rpm; \
@CONFIG_KERNEL_TRUE@ pkg2=$${name}-devel-$${version}_$${release}.$${arch}.rpm; \
@CONFIG_KERNEL_TRUE@ fakeroot $(ALIEN) --scripts --to-tgz $$pkg1 $$pkg2; \
@CONFIG_KERNEL_TRUE@ $(RM) $$pkg1 $$pkg2
tgz-utils: tgz-local rpm-utils
name=${PACKAGE}; \
version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \
arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \
pkg1=$${name}-$${version}.$${arch}.rpm; \
pkg2=$${name}-devel-$${version}.$${arch}.rpm; \
pkg3=$${name}-test-$${version}.$${arch}.rpm; \
fakeroot $(ALIEN) --scripts --to-tgz $$pkg1 $$pkg2 $$pkg3; \
$(RM) $$pkg1 $$pkg2 $$pkg3
@CONFIG_USER_TRUE@ name=${PACKAGE}; \
@CONFIG_USER_TRUE@ version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \
@CONFIG_USER_TRUE@ arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \
@CONFIG_USER_TRUE@ pkg1=$${name}-$${version}.$${arch}.rpm; \
@CONFIG_USER_TRUE@ pkg2=$${name}-devel-$${version}.$${arch}.rpm; \
@CONFIG_USER_TRUE@ pkg3=$${name}-test-$${version}.$${arch}.rpm; \
@CONFIG_USER_TRUE@ fakeroot $(ALIEN) --scripts --to-tgz $$pkg1 $$pkg2 $$pkg3; \
@CONFIG_USER_TRUE@ $(RM) $$pkg1 $$pkg2 $$pkg3
tgz: tgz-modules tgz-utils
@ -1056,10 +1054,10 @@ sarch-utils:
sarch: sarch-modules sarch-utils
arch-modules:
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" arch-common
@CONFIG_KERNEL_TRUE@ $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" arch-common
arch-utils:
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" arch-common
@CONFIG_USER_TRUE@ $(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" arch-common
arch: arch-modules arch-utils

View File

@ -7,5 +7,11 @@ and ZVOL with a ZFS Posix Layer (ZPL) on the way!
$ ./configure
$ make pkg
To copy the kernel code inside your kernel source tree for builtin
compilation:
$ ./configure --enable-linux-builtin --with-linux=/usr/src/linux-...
$ ./copy-builtin /usr/src/linux-...
Full documentation for building, configuring, and using ZFS can be
found at: <http://zfsonlinux.org>

View File

@ -13,10 +13,14 @@ sarch-utils:
sarch: sarch-modules sarch-utils
arch-modules:
if CONFIG_KERNEL
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" arch-common
endif
arch-utils:
if CONFIG_USER
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" arch-common
endif
arch: arch-modules arch-utils

View File

@ -15,6 +15,7 @@ deb-local:
fi)
deb-modules: deb-local rpm-modules
if CONFIG_KERNEL
name=${PACKAGE}-modules; \
version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \
release=`echo ${LINUX_VERSION} | $(SED) -e "s/-/_/g"`; \
@ -23,8 +24,10 @@ deb-modules: deb-local rpm-modules
pkg2=$${name}-devel-$${version}_$${release}.$${arch}.rpm; \
fakeroot $(ALIEN) --scripts --to-deb $$pkg1 $$pkg2; \
$(RM) $$pkg1 $$pkg2
endif
deb-utils: deb-local rpm-utils
if CONFIG_USER
name=${PACKAGE}; \
version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \
arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \
@ -34,5 +37,6 @@ deb-utils: deb-local rpm-utils
pkg4=$${name}-dracut-$${version}.$${arch}.rpm; \
fakeroot $(ALIEN) --scripts --to-deb $$pkg1 $$pkg2 $$pkg3 $$pkg4; \
$(RM) $$pkg1 $$pkg2 $$pkg3 $$pkg4
endif
deb: deb-modules deb-utils

View File

@ -5,11 +5,17 @@ dnl # exported by the kernel. This is a trivial helper function but
dnl # using it significantly simplifies the code surrounding setting
dnl # up and tearing down the bdi structure.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_BDI_SETUP_AND_REGISTER], [
ZFS_CHECK_SYMBOL_EXPORT(
[bdi_setup_and_register],
[mm/backing-dev.c],
[AC_DEFINE(HAVE_BDI_SETUP_AND_REGISTER, 1,
[bdi_setup_and_register() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_BDI_SETUP_AND_REGISTER],
[AC_MSG_CHECKING([whether bdi_setup_and_register() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/backing-dev.h>
], [
bdi_setup_and_register(NULL, NULL, 0);
], [bdi_setup_and_register], [mm/backing-dev.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BDI_SETUP_AND_REGISTER, 1,
[bdi_setup_and_register() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -3,11 +3,17 @@ dnl # 2.6.38 API change
dnl # open_bdev_exclusive() changed to blkdev_get_by_path()
dnl # close_bdev_exclusive() changed to blkdev_put()
dnl #
AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH], [
ZFS_CHECK_SYMBOL_EXPORT(
[blkdev_get_by_path],
[fs/block_dev.c],
[AC_DEFINE(HAVE_BLKDEV_GET_BY_PATH, 1,
[blkdev_get_by_path() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH],
[AC_MSG_CHECKING([whether blkdev_get_by_path() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/fs.h>
], [
blkdev_get_by_path(NULL, 0, NULL);
], [blkdev_get_by_path], [fs/block_dev.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BLKDEV_GET_BY_PATH, 1,
[blkdev_get_by_path() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -2,11 +2,17 @@ dnl #
dnl # 2.6.28 API change
dnl # Added check_disk_size_change() helper function.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_CHECK_DISK_SIZE_CHANGE], [
ZFS_CHECK_SYMBOL_EXPORT(
[check_disk_size_change],
[fs/block_dev.c],
[AC_DEFINE(HAVE_CHECK_DISK_SIZE_CHANGE, 1,
[check_disk_size_change() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_CHECK_DISK_SIZE_CHANGE],
[AC_MSG_CHECKING([whether check_disk_size_change() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/fs.h>
], [
check_disk_size_change(NULL, NULL);
], [check_disk_size_change], [fs/block_dev.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_CHECK_DISK_SIZE_CHANGE, 1,
[check_disk_size_change() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -19,11 +19,16 @@ dnl # Therefore, to ensure we have the correct API we only allow the
dnl # clear_inode() compatibility code to be defined iff the evict_inode()
dnl # functionality is also detected.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_CLEAR_INODE], [
ZFS_CHECK_SYMBOL_EXPORT(
[clear_inode],
[fs/inode.c],
[AC_DEFINE(HAVE_CLEAR_INODE, 1,
[clear_inode() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_CLEAR_INODE],
[AC_MSG_CHECKING([whether clear_inode() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/fs.h>
], [
clear_inode(NULL);
], [clear_inode], [fs/inode.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_CLEAR_INODE, 1, [clear_inode() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -2,11 +2,16 @@ dnl #
dnl # 3.4.0 API change
dnl # Added d_make_root() to replace previous d_alloc_root() function.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_D_MAKE_ROOT], [
ZFS_CHECK_SYMBOL_EXPORT(
[d_make_root],
[fs/dcache.c],
[AC_DEFINE(HAVE_D_MAKE_ROOT, 1,
[d_make_root() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_D_MAKE_ROOT],
[AC_MSG_CHECKING([whether d_make_root() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/dcache.h>
], [
d_make_root(NULL);
], [d_make_root], [fs/dcache.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_D_MAKE_ROOT, 1, [d_make_root() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -2,11 +2,17 @@ dnl #
dnl # 2.6.28 API change
dnl # Added d_obtain_alias() helper function.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_D_OBTAIN_ALIAS], [
ZFS_CHECK_SYMBOL_EXPORT(
[d_obtain_alias],
[fs/dcache.c],
[AC_DEFINE(HAVE_D_OBTAIN_ALIAS, 1,
[d_obtain_alias() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_D_OBTAIN_ALIAS],
[AC_MSG_CHECKING([whether d_obtain_alias() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/dcache.h>
], [
d_obtain_alias(NULL);
], [d_obtain_alias], [fs/dcache.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_D_OBTAIN_ALIAS, 1,
[d_obtain_alias() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -1,11 +1,17 @@
dnl #
dnl # 2.6.34 API change
dnl # Verify the get_gendisk() symbol is exported.
dnl # Verify the get_gendisk() symbol is available.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_GET_GENDISK], [
ZFS_CHECK_SYMBOL_EXPORT(
[get_gendisk],
[block/genhd.c],
[AC_DEFINE(HAVE_GET_GENDISK, 1, [get_gendisk() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_GET_GENDISK],
[AC_MSG_CHECKING([whether get_gendisk() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/genhd.h>
], [
get_gendisk(0, NULL);
], [get_gendisk], [block/genhd.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GET_GENDISK, 1, [get_gendisk() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -2,11 +2,17 @@ dnl #
dnl # 2.6.28 API change
dnl # Added insert_inode_locked() helper function.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_INSERT_INODE_LOCKED], [
ZFS_CHECK_SYMBOL_EXPORT(
[insert_inode_locked],
[fs/inode.c],
[AC_DEFINE(HAVE_INSERT_INODE_LOCKED, 1,
[insert_inode_locked() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_INSERT_INODE_LOCKED],
[AC_MSG_CHECKING([whether insert_inode_locked() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/fs.h>
], [
insert_inode_locked(NULL);
], [insert_inode_locked], [fs/inode.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_INSERT_INODE_LOCKED, 1,
[insert_inode_locked() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -5,11 +5,16 @@ dnl # in the file_system_type structure. When using the new
dnl # interface the caller must now use the mount_nodev() helper.
dnl # This updated callback and helper no longer pass the vfsmount.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_MOUNT_NODEV], [
ZFS_CHECK_SYMBOL_EXPORT(
[mount_nodev],
[fs/super.c],
[AC_DEFINE(HAVE_MOUNT_NODEV, 1,
[mount_nodev() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_MOUNT_NODEV],
[AC_MSG_CHECKING([whether mount_nodev() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/fs.h>
], [
mount_nodev(NULL, 0, NULL, NULL);
], [mount_nodev], [fs/super.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_MOUNT_NODEV, 1, [mount_nodev() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -2,11 +2,17 @@ dnl #
dnl # 2.6.28 API change
dnl # open/close_bdev_excl() renamed to open/close_bdev_exclusive()
dnl #
AC_DEFUN([ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE], [
ZFS_CHECK_SYMBOL_EXPORT(
[open_bdev_exclusive],
[fs/block_dev.c],
[AC_DEFINE(HAVE_OPEN_BDEV_EXCLUSIVE, 1,
[open_bdev_exclusive() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE],
[AC_MSG_CHECKING([whether open_bdev_exclusive() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/fs.h>
], [
open_bdev_exclusive(NULL, 0, NULL);
], [open_bdev_exclusive], [fs/block_dev.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_OPEN_BDEV_EXCLUSIVE, 1,
[open_bdev_exclusive() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -2,11 +2,17 @@ dnl #
dnl # 2.6.35 API change
dnl # Added truncate_setsize() helper function.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_TRUNCATE_SETSIZE], [
ZFS_CHECK_SYMBOL_EXPORT(
[truncate_setsize],
[mm/truncate.c],
[AC_DEFINE(HAVE_TRUNCATE_SETSIZE, 1,
[truncate_setsize() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_TRUNCATE_SETSIZE],
[AC_MSG_CHECKING([whether truncate_setsize() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/mm.h>
], [
truncate_setsize(NULL, 0);
], [truncate_setsize], [mm/truncate.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_TRUNCATE_SETSIZE, 1,
[truncate_setsize() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -4,6 +4,7 @@ dnl #
AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
ZFS_AC_KERNEL
ZFS_AC_SPL
ZFS_AC_TEST_MODULE
ZFS_AC_KERNEL_CONFIG
ZFS_AC_KERNEL_BDEV_BLOCK_DEVICE_OPERATIONS
ZFS_AC_KERNEL_TYPE_FMODE_T
@ -86,7 +87,7 @@ dnl #
AC_DEFUN([ZFS_AC_MODULE_SYMVERS], [
modpost=$LINUX/scripts/Makefile.modpost
AC_MSG_CHECKING([kernel file name for module symbols])
AS_IF([test -f "$modpost"], [
AS_IF([test "x$enable_linux_builtin" != xyes -a -f "$modpost"], [
AS_IF([grep -q Modules.symvers $modpost], [
LINUX_SYMBOLS=Modules.symvers
], [
@ -158,7 +159,7 @@ AC_DEFUN([ZFS_AC_KERNEL], [
], [test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}], [
kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
], [test -d ${kernelsrc}-obj/${target_cpu}/default], [
kernelbuild=${kernelsrc}-obj/${target_cpu}/default
kernelbuild=${kernelsrc}-obj/${target_cpu}/default
], [test -d `dirname ${kernelsrc}`/build-${target_cpu}], [
kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
], [
@ -191,7 +192,13 @@ AC_DEFUN([ZFS_AC_KERNEL], [
])
], [
AC_MSG_RESULT([Not found])
AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
if test "x$enable_linux_builtin" != xyes; then
AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
else
AC_MSG_ERROR([
*** Cannot find UTS_RELEASE definition.
*** Please run 'make prepare' inside the kernel source tree.])
fi
])
AC_MSG_RESULT([$kernsrcver])
@ -312,6 +319,25 @@ AC_DEFUN([ZFS_AC_SPL], [
ZFS_AC_SPL_MODULE_SYMVERS
])
dnl #
dnl # Basic toolchain sanity check.
dnl #
AC_DEFUN([ZFS_AC_TEST_MODULE],
[AC_MSG_CHECKING([whether modules can be built])
ZFS_LINUX_TRY_COMPILE([],[],[
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
if test "x$enable_linux_builtin" != xyes; then
AC_MSG_ERROR([*** Unable to build an empty module.])
else
AC_MSG_ERROR([
*** Unable to build an empty module.
*** Please run 'make scripts' inside the kernel source tree.])
fi
])
])
dnl #
dnl # Certain kernel build options are not supported. These must be
dnl # detected at configure time and cause a build failure. Otherwise
@ -418,10 +444,12 @@ dnl # ZFS_LINUX_COMPILE_IFELSE / like AC_COMPILE_IFELSE
dnl #
AC_DEFUN([ZFS_LINUX_COMPILE_IFELSE], [
m4_ifvaln([$1], [ZFS_LINUX_CONFTEST([$1])])
rm -Rf build && mkdir -p build
rm -Rf build && mkdir -p build && touch build/conftest.mod.c
echo "obj-m := conftest.o" >build/Makefile
modpost_flag=''
test "x$enable_linux_builtin" = xyes && modpost_flag='modpost=true' # fake modpost stage
AS_IF(
[AC_TRY_COMMAND(cp conftest.c build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
[AC_TRY_COMMAND(cp conftest.c build && make [$2] -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build $modpost_flag) >/dev/null && AC_TRY_COMMAND([$3])],
[$4],
[_AC_MSG_LOG_CONFTEST m4_ifvaln([$5],[$5])]
)
@ -463,30 +491,48 @@ dnl #
dnl # ZFS_CHECK_SYMBOL_EXPORT
dnl # check symbol exported or not
dnl #
AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT],
[AC_MSG_CHECKING([whether symbol $1 is exported])
AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [
grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
$LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null
rc=$?
AS_IF([test $rc -ne 0], [
if test $rc -ne 0; then
export=0
for file in $2; do
grep -q -E "EXPORT_SYMBOL.*($1)" "$LINUX/$file" 2>/dev/null
grep -q -E "EXPORT_SYMBOL.*($1)" \
"$LINUX/$file" 2>/dev/null
rc=$?
AS_IF([test $rc -eq 0], [
if test $rc -eq 0; then
export=1
break;
])
fi
done
AS_IF([test $export -eq 0], [
AC_MSG_RESULT([no])
if test $export -eq 0; then :
$4
], [
AC_MSG_RESULT([yes])
else :
$3
])
], [
AC_MSG_RESULT([yes])
fi
else :
$3
])
fi
])
dnl #
dnl # ZFS_LINUX_TRY_COMPILE_SYMBOL
dnl # like ZFS_LINUX_TRY_COMPILE, except ZFS_CHECK_SYMBOL_EXPORT
dnl # is called if not compiling for builtin
dnl #
AC_DEFUN([ZFS_LINUX_TRY_COMPILE_SYMBOL], [
ZFS_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
if test $rc -ne 0; then :
$6
else
if test "x$enable_linux_builtin" != xyes; then
ZFS_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
fi
if test $rc -ne 0; then :
$6
else :
$5
fi
fi
])

View File

@ -1,18 +1,24 @@
srpm-modules:
if CONFIG_KERNEL
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" srpm-common
endif
srpm-utils:
if CONFIG_USER
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" srpm-common
endif
srpm: srpm-modules srpm-utils
rpm-modules: srpm-modules
if CONFIG_KERNEL
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-modules" rpm-common
endif
rpm-utils: srpm-utils
if CONFIG_USER
$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" rpm-common
rpm-modules: srpm-modules
endif
rpm: rpm-modules rpm-utils

View File

@ -8,6 +8,7 @@ tgz-local:
fi)
tgz-modules: tgz-local rpm-modules
if CONFIG_KERNEL
name=${PACKAGE}-modules; \
version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \
release=`echo ${LINUX_VERSION} | $(SED) -e "s/-/_/g"`; \
@ -16,8 +17,10 @@ tgz-modules: tgz-local rpm-modules
pkg2=$${name}-devel-$${version}_$${release}.$${arch}.rpm; \
fakeroot $(ALIEN) --scripts --to-tgz $$pkg1 $$pkg2; \
$(RM) $$pkg1 $$pkg2
endif
tgz-utils: tgz-local rpm-utils
if CONFIG_USER
name=${PACKAGE}; \
version=${ZFS_META_VERSION}-${ZFS_META_RELEASE}; \
arch=`$(RPM) -qp $${name}-$${version}.src.rpm --qf %{arch} | tail -1`; \
@ -26,5 +29,6 @@ tgz-utils: tgz-local rpm-utils
pkg3=$${name}-test-$${version}.$${arch}.rpm; \
fakeroot $(ALIEN) --scripts --to-tgz $$pkg1 $$pkg2 $$pkg3; \
$(RM) $$pkg1 $$pkg2 $$pkg3
endif
tgz: tgz-modules tgz-utils

View File

@ -73,6 +73,11 @@ AC_DEFUN([ZFS_AC_CONFIG], [
AS_HELP_STRING([--with-config=CONFIG],
[Config file 'kernel|user|all|srpm']),
[ZFS_CONFIG="$withval"])
AC_ARG_ENABLE([linux-builtin],
[AC_HELP_STRING([--enable-linux-builtin],
[Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
[],
[enable_linux_builtin=no])
AC_MSG_CHECKING([zfs config])
AC_MSG_RESULT([$ZFS_CONFIG]);
@ -93,11 +98,10 @@ AC_DEFUN([ZFS_AC_CONFIG], [
esac
AM_CONDITIONAL([CONFIG_USER],
[test "$ZFS_CONFIG" = user] ||
[test "$ZFS_CONFIG" = all])
[test "$ZFS_CONFIG" = user -o "$ZFS_CONFIG" = all])
AM_CONDITIONAL([CONFIG_KERNEL],
[test "$ZFS_CONFIG" = kernel] ||
[test "$ZFS_CONFIG" = all])
[test "$ZFS_CONFIG" = kernel -o "$ZFS_CONFIG" = all] &&
[test "x$enable_linux_builtin" != xyes ])
])
dnl #

3255
configure vendored

File diff suppressed because it is too large Load Diff

121
copy-builtin Executable file
View File

@ -0,0 +1,121 @@
#!/bin/bash
set -e
usage()
{
echo "usage: $0 <kernel source tree>" >&2
exit 1
}
[ "$#" -eq 1 ] || usage
KERNEL_DIR="$(readlink --canonicalize-existing "$1")"
MODULES=()
for MODULE_DIR in module/*
do
[ -d "$MODULE_DIR" ] || continue
MODULES+=("${MODULE_DIR##*/}")
done
if ! [ -e 'zfs_config.h' ]
then
echo >&2
echo " $0: you did not run configure, or you're not in the ZFS source directory." >&2
echo " $0: run configure with --with-linux=$KERNEL_DIR and --enable-linux-builtin." >&2
echo >&2
exit 1
fi
make clean || true
rm -rf "$KERNEL_DIR/include/zfs" "$KERNEL_DIR/fs/zfs"
cp --recursive include "$KERNEL_DIR/include/zfs"
cp --recursive module "$KERNEL_DIR/fs/zfs"
cp zfs_config.h "$KERNEL_DIR/"
adjust_obj_paths()
{
local FILE="$1"
local LINE OBJPATH
while IFS='' read -r LINE
do
OBJPATH="${LINE#\$(MODULE)-objs += }"
if [ "$OBJPATH" = "$LINE" ]
then
echo "$LINE"
else
echo "\$(MODULE)-objs += ${OBJPATH##*/}"
fi
done < "$FILE" > "$FILE.new"
mv "$FILE.new" "$FILE"
}
for MODULE in "${MODULES[@]}"
do
adjust_obj_paths "$KERNEL_DIR/fs/zfs/$MODULE/Makefile"
done
cat > "$KERNEL_DIR/fs/zfs/Kconfig" <<"EOF"
config ZFS
tristate "ZFS"
depends on SPL
help
This is the ZFS filesystem from the ZFS On Linux project.
See http://zfsonlinux.org/
To compile this file system support as a module, choose M here.
If unsure, say N.
EOF
{
cat <<-"EOF"
ZFS_MODULE_CFLAGS = -I$(srctree)/include/zfs -I$(srctree)/include/spl
ZFS_MODULE_CFLAGS += -include $(srctree)/spl_config.h -include $(srctree)/zfs_config.h
export ZFS_MODULE_CFLAGS
obj-$(CONFIG_ZFS) :=
EOF
for MODULE in "${MODULES[@]}"
do
echo 'obj-$(CONFIG_ZFS) += ' "$MODULE/"
done
} > "$KERNEL_DIR/fs/zfs/Kbuild"
add_after()
{
local FILE="$1"
local MARKER="$2"
local NEW="$3"
local LINE
while IFS='' read -r LINE
do
echo "$LINE"
if [ -n "$MARKER" -a "$LINE" = "$MARKER" ]
then
echo "$NEW"
MARKER=''
if IFS='' read -r LINE
then
[ "$LINE" != "$NEW" ] && echo "$LINE"
fi
fi
done < "$FILE" > "$FILE.new"
mv "$FILE.new" "$FILE"
}
add_after "$KERNEL_DIR/fs/Kconfig" 'if BLOCK' 'source "fs/zfs/Kconfig"'
add_after "$KERNEL_DIR/fs/Makefile" 'endif' 'obj-$(CONFIG_ZFS) += zfs/'
echo >&2
echo " $0: done." >&2
echo " $0: now you can build the kernel with ZFS support." >&2
echo " $0: make sure you enable ZFS support (CONFIG_ZFS) before building." >&2
echo >&2

View File

@ -608,27 +608,13 @@ libzfs_print_on_error(libzfs_handle_t *hdl, boolean_t printerr)
static int
libzfs_module_loaded(const char *module)
{
FILE *f;
int result = 0;
char name[256];
const char path_prefix[] = "/sys/module/";
char path[256];
f = fopen("/proc/modules", "r");
if (f == NULL)
return -1;
memcpy(path, path_prefix, sizeof(path_prefix) - 1);
strcpy(path + sizeof(path_prefix) - 1, module);
while (fgets(name, sizeof(name), f)) {
char *c = strchr(name, ' ');
if (!c)
continue;
*c = 0;
if (strcmp(module, name) == 0) {
result = 1;
break;
}
}
fclose(f);
return result;
return (access(path, F_OK) == 0);
}
int

View File

@ -5,6 +5,11 @@ subdir-m += zcommon
subdir-m += zfs
subdir-m += zpios
ZFS_MODULE_CFLAGS += -include @SPL_OBJ@/spl_config.h
ZFS_MODULE_CFLAGS += -include @abs_top_builddir@/zfs_config.h
ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/include -I@SPL@/include -I@SPL@
export ZFS_MODULE_CFLAGS
modules:
@# Make the exported SPL symbols available to these modules.
@# They may be in the root of SPL_OBJ when building against
@ -21,7 +26,7 @@ modules:
"*** - @SPL_OBJ@/module/@SPL_SYMBOLS@\n"; \
exit 1; \
fi
$(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ $@
$(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ CONFIG_ZFS=m $@
clean:
@# Only cleanup the kernel build directories when CONFIG_KERNEL

View File

@ -1,10 +1,7 @@
MODULE := zavl
EXTRA_CFLAGS = @KERNELCPPFLAGS@
EXTRA_CFLAGS += -include @SPL_OBJ@/spl_config.h
EXTRA_CFLAGS += -include @abs_top_builddir@/zfs_config.h
EXTRA_CFLAGS += -I@abs_top_srcdir@/include -I@SPL@/include -I@SPL@
EXTRA_CFLAGS = $(ZFS_MODULE_CFLAGS) @KERNELCPPFLAGS@
obj-m := $(MODULE).o
obj-$(CONFIG_ZFS) := $(MODULE).o
$(MODULE)-objs += @top_srcdir@/module/avl/avl.o

View File

@ -1,11 +1,8 @@
MODULE := znvpair
EXTRA_CFLAGS = @KERNELCPPFLAGS@
EXTRA_CFLAGS += -include @SPL_OBJ@/spl_config.h
EXTRA_CFLAGS += -include @abs_top_builddir@/zfs_config.h
EXTRA_CFLAGS += -I@abs_top_srcdir@/include -I@SPL@/include -I@SPL@
EXTRA_CFLAGS = $(ZFS_MODULE_CFLAGS) @KERNELCPPFLAGS@
obj-m := $(MODULE).o
obj-$(CONFIG_ZFS) := $(MODULE).o
$(MODULE)-objs += @top_srcdir@/module/nvpair/nvpair.o
$(MODULE)-objs += @top_srcdir@/module/nvpair/nvpair_alloc_spl.o

View File

@ -1,11 +1,8 @@
MODULE := zunicode
EXTRA_CFLAGS = @KERNELCPPFLAGS@
EXTRA_CFLAGS += -include @SPL_OBJ@/spl_config.h
EXTRA_CFLAGS += -include @abs_top_builddir@/zfs_config.h
EXTRA_CFLAGS += -I@abs_top_srcdir@/include -I@SPL@/include -I@SPL@
EXTRA_CFLAGS = $(ZFS_MODULE_CFLAGS) @KERNELCPPFLAGS@
obj-m := $(MODULE).o
obj-$(CONFIG_ZFS) := $(MODULE).o
$(MODULE)-objs += @top_srcdir@/module/unicode/u8_textprep.o
$(MODULE)-objs += @top_srcdir@/module/unicode/uconv.o

View File

@ -1,11 +1,8 @@
MODULE := zcommon
EXTRA_CFLAGS = @KERNELCPPFLAGS@
EXTRA_CFLAGS += -include @SPL_OBJ@/spl_config.h
EXTRA_CFLAGS += -include @abs_top_builddir@/zfs_config.h
EXTRA_CFLAGS += -I@abs_top_srcdir@/include -I@SPL@/include -I@SPL@
EXTRA_CFLAGS = $(ZFS_MODULE_CFLAGS) @KERNELCPPFLAGS@
obj-m := $(MODULE).o
obj-$(CONFIG_ZFS) := $(MODULE).o
$(MODULE)-objs += @top_srcdir@/module/zcommon/zfs_deleg.o
$(MODULE)-objs += @top_srcdir@/module/zcommon/zfs_prop.o

View File

@ -1,11 +1,8 @@
MODULE := zfs
EXTRA_CFLAGS += @KERNELCPPFLAGS@
EXTRA_CFLAGS += -include @SPL_OBJ@/spl_config.h
EXTRA_CFLAGS += -include @abs_top_builddir@/zfs_config.h
EXTRA_CFLAGS += -I@abs_top_srcdir@/include -I@SPL@/include -I@SPL@
EXTRA_CFLAGS = $(ZFS_MODULE_CFLAGS) @KERNELCPPFLAGS@
obj-m := $(MODULE).o
obj-$(CONFIG_ZFS) := $(MODULE).o
$(MODULE)-objs += @top_srcdir@/module/zfs/arc.o
$(MODULE)-objs += @top_srcdir@/module/zfs/bplist.o

View File

@ -1,10 +1,7 @@
MODULE := zpios
EXTRA_CFLAGS = @KERNELCPPFLAGS@
EXTRA_CFLAGS += -include @SPL_OBJ@/spl_config.h
EXTRA_CFLAGS += -include @abs_top_builddir@/zfs_config.h
EXTRA_CFLAGS += -I@abs_top_srcdir@/include -I@SPL@/include -I@SPL@
EXTRA_CFLAGS = $(ZFS_MODULE_CFLAGS) @KERNELCPPFLAGS@
obj-m := $(MODULE).o
obj-$(CONFIG_ZFS) := $(MODULE).o
$(MODULE)-objs += @top_srcdir@/module/zpios/pios.o