Skip to content

Commit

Permalink
Merge branch 'builtin-clean'
Browse files Browse the repository at this point in the history
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 openzfs/spl@7440380).
  - 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
f09398c).

Signed-off-by: Brian Behlendorf <[email protected]>
Issue #851
  • Loading branch information
behlendorf committed Jul 26, 2012
2 parents 739a1a8 + f09398c commit 4ab8a72
Show file tree
Hide file tree
Showing 29 changed files with 3,037 additions and 1,229 deletions.
80 changes: 39 additions & 41 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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>
4 changes: 4 additions & 0 deletions config/arch.am
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions config/deb.am
Original file line number Diff line number Diff line change
Expand Up @@ -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"`; \
Expand All @@ -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`; \
Expand All @@ -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
20 changes: 13 additions & 7 deletions config/kernel-bdi-setup-and-register.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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)
])
])
20 changes: 13 additions & 7 deletions config/kernel-blkdev-get-by-path.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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)
])
])
20 changes: 13 additions & 7 deletions config/kernel-check-disk-size-change.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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)
])
])
19 changes: 12 additions & 7 deletions config/kernel-clear-inode.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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)
])
])
19 changes: 12 additions & 7 deletions config/kernel-d-make-root.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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)
])
])
20 changes: 13 additions & 7 deletions config/kernel-d-obtain-alias.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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)
])
])
20 changes: 13 additions & 7 deletions config/kernel-get-gendisk.m4
Original file line number Diff line number Diff line change
@@ -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)
])
])
20 changes: 13 additions & 7 deletions config/kernel-insert-inode-locked.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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)
])
])
19 changes: 12 additions & 7 deletions config/kernel-mount-nodev.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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)
])
])
Loading

0 comments on commit 4ab8a72

Please sign in to comment.