summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys-kernel/spl/ChangeLog8
-rw-r--r--sys-kernel/spl/files/spl-0.6.0_rc11-linux-3.6-compat.patch258
-rw-r--r--sys-kernel/spl/spl-0.6.0_rc11-r1.ebuild92
3 files changed, 357 insertions, 1 deletions
diff --git a/sys-kernel/spl/ChangeLog b/sys-kernel/spl/ChangeLog
index a94872dc2e41..c703719cf76a 100644
--- a/sys-kernel/spl/ChangeLog
+++ b/sys-kernel/spl/ChangeLog
@@ -1,6 +1,12 @@
# ChangeLog for sys-kernel/spl
# Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-kernel/spl/ChangeLog,v 1.30 2012/10/03 00:06:36 ryao Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-kernel/spl/ChangeLog,v 1.31 2012/10/17 04:57:33 ryao Exp $
+
+*spl-0.6.0_rc11-r1 (17 Oct 2012)
+
+ 17 Oct 2012; Richard Yao <ryao@gentoo.org>
+ +files/spl-0.6.0_rc11-linux-3.6-compat.patch, +spl-0.6.0_rc11-r1.ebuild:
+ Linux 3.6 support
03 Oct 2012; Richard Yao <ryao@gentoo.org> spl-9999.ebuild:
Sync spl-9999.ebuild with spl-0.6.0_rc11.ebuild - thanks prometheanfire
diff --git a/sys-kernel/spl/files/spl-0.6.0_rc11-linux-3.6-compat.patch b/sys-kernel/spl/files/spl-0.6.0_rc11-linux-3.6-compat.patch
new file mode 100644
index 000000000000..92676186c30f
--- /dev/null
+++ b/sys-kernel/spl/files/spl-0.6.0_rc11-linux-3.6-compat.patch
@@ -0,0 +1,258 @@
+From bcb15891ab394e11615eee08bba1fd85ac32e158 Mon Sep 17 00:00:00 2001
+From: Yuxuan Shui <yshuiv7@gmail.com>
+Date: Thu, 11 Oct 2012 22:41:33 +0800
+Subject: [PATCH] Linux 3.6 compat, kern_path_locked() added
+
+The kern_path_parent() function was removed from Linux 3.6 because
+it was observed that all the callers just want the parent dentry.
+The simpler kern_path_locked() function replaces kern_path_parent()
+and does the lookup while holding the ->i_mutex lock.
+
+This is good news for the vn implementation because it removes the
+need for us to handle the locking. However, it makes it harder to
+implement a single readable vn_remove()/vn_rename() function which
+is usually what we prefer.
+
+Therefore, we implement a new version of vn_remove()/vn_rename()
+for Linux 3.6 and newer kernels. This allows us to leave the
+existing working implementation untouched, and to add a simpler
+version for newer kernels.
+
+Long term I would very much like to see all of the vn code removed
+since what this code enabled is generally frowned upon in the kernel.
+But that can't happen util we either abondon the zpool.cache file
+or implement alternate infrastructure to update is correctly in
+user space.
+
+Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
+Signed-off-by: Richard Yao <ryao@cs.stonybrook.edu>
+Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
+Closes #154
+---
+ config/spl-build.m4 | 16 +++++
+ include/linux/file_compat.h | 6 ++
+ module/spl/spl-vnode.c | 136 +++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 158 insertions(+)
+
+diff --git a/config/spl-build.m4 b/config/spl-build.m4
+index 0c7a03c..eb644a1 100644
+--- a/config/spl-build.m4
++++ b/config/spl-build.m4
+@@ -86,6 +86,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
+ SPL_AC_SHRINK_ICACHE_MEMORY
+ SPL_AC_KERN_PATH_PARENT_HEADER
+ SPL_AC_KERN_PATH_PARENT_SYMBOL
++ SPL_AC_KERN_PATH_LOCKED
+ SPL_AC_2ARGS_ZLIB_DEFLATE_WORKSPACESIZE
+ SPL_AC_SHRINK_CONTROL_STRUCT
+ SPL_AC_RWSEM_SPINLOCK_IS_RAW
+@@ -2188,6 +2189,21 @@ AC_DEFUN([SPL_AC_KERN_PATH_PARENT_SYMBOL],
+ ])
+
+ dnl #
++dnl # 3.6 API compat,
++dnl # The kern_path_parent() function was replaced by the kern_path_locked()
++dnl # function to eliminate all struct nameidata usage outside fs/namei.c.
++dnl #
++AC_DEFUN([SPL_AC_KERN_PATH_LOCKED], [
++ SPL_CHECK_SYMBOL_HEADER(
++ [kern_path_locked],
++ [struct dentry \*kern_path_locked(const char \*, struct path \*)],
++ [include/linux/namei.h],
++ [AC_DEFINE(HAVE_KERN_PATH_LOCKED, 1,
++ [kern_path_locked() is available])],
++ [])
++])
++
++dnl #
+ dnl # 2.6.39 API compat,
+ dnl # The function zlib_deflate_workspacesize() now take 2 arguments.
+ dnl # This was done to avoid always having to allocate the maximum size
+diff --git a/include/linux/file_compat.h b/include/linux/file_compat.h
+index 2b5b7d2..27819d5 100644
+--- a/include/linux/file_compat.h
++++ b/include/linux/file_compat.h
+@@ -83,6 +83,12 @@
+ # define spl_kern_path_parent(path, nd) path_lookup(path, LOOKUP_PARENT, nd)
+ #endif /* HAVE_KERN_PATH_PARENT_HEADER */
+
++#ifdef HAVE_KERN_PATH_LOCKED
++typedef struct dentry * (*kern_path_locked_t)(const char *, struct path *);
++extern kern_path_locked_t kern_path_locked_fn;
++# define spl_kern_path_locked(name, path) kern_path_locked_fn(name, path)
++#endif /* HAVE_KERN_PATH_LOCKED */
++
+ #ifndef HAVE_CLEAR_CLOSE_ON_EXEC
+ #define __clear_close_on_exec(fd, fdt) FD_CLR(fd, fdt->close_on_exec)
+ #endif
+diff --git a/module/spl/spl-vnode.c b/module/spl/spl-vnode.c
+index f5fc65d..a0fed32 100644
+--- a/module/spl/spl-vnode.c
++++ b/module/spl/spl-vnode.c
+@@ -50,6 +50,10 @@
+ #endif /* HAVE_KERN_PATH_PARENT_SYMBOL */
+ #endif /* HAVE_KERN_PATH_PARENT_HEADER */
+
++#ifdef HAVE_KERN_PATH_LOCKED
++kern_path_locked_t kern_path_locked_fn = SYMBOL_POISON;
++#endif /* HAVE_KERN_PATH_LOCKED */
++
+ vtype_t
+ vn_mode_to_vtype(mode_t mode)
+ {
+@@ -298,6 +302,128 @@
+ }
+ EXPORT_SYMBOL(vn_seek);
+
++#ifdef HAVE_KERN_PATH_LOCKED
++/* Based on do_unlinkat() from linux/fs/namei.c */
++int
++vn_remove(const char *path, uio_seg_t seg, int flags)
++{
++ struct dentry *dentry;
++ struct path parent;
++ struct inode *inode = NULL;
++ int rc = 0;
++ SENTRY;
++
++ ASSERT(seg == UIO_SYSSPACE);
++ ASSERT(flags == RMFILE);
++
++ dentry = spl_kern_path_locked(path, &parent);
++ rc = PTR_ERR(dentry);
++ if (!IS_ERR(dentry)) {
++ if (parent.dentry->d_name.name[parent.dentry->d_name.len])
++ SGOTO(slashes, rc = 0);
++
++ inode = dentry->d_inode;
++ if (!inode)
++ SGOTO(slashes, rc = 0);
++
++ if (inode)
++ ihold(inode);
++
++ rc = vfs_unlink(parent.dentry->d_inode, dentry);
++exit1:
++ dput(dentry);
++ }
++
++ spl_inode_unlock(parent.dentry->d_inode);
++ if (inode)
++ iput(inode); /* truncate the inode here */
++
++ path_put(&parent);
++ SRETURN(-rc);
++
++slashes:
++ rc = !dentry->d_inode ? -ENOENT :
++ S_ISDIR(dentry->d_inode->i_mode) ? -EISDIR : -ENOTDIR;
++ SGOTO(exit1, rc);
++} /* vn_remove() */
++EXPORT_SYMBOL(vn_remove);
++
++/* Based on do_rename() from linux/fs/namei.c */
++int
++vn_rename(const char *oldname, const char *newname, int x1)
++{
++ struct dentry *old_dir, *new_dir;
++ struct dentry *old_dentry, *new_dentry;
++ struct dentry *trap;
++ struct path old_parent, new_parent;
++ int rc = 0;
++ SENTRY;
++
++ old_dentry = spl_kern_path_locked(oldname, &old_parent);
++ if (IS_ERR(old_dentry))
++ SGOTO(exit, rc = PTR_ERR(old_dentry));
++
++ spl_inode_unlock(old_parent.dentry->d_inode);
++
++ new_dentry = spl_kern_path_locked(newname, &new_parent);
++ if (IS_ERR(new_dentry))
++ SGOTO(exit2, rc = PTR_ERR(new_dentry));
++
++ spl_inode_unlock(new_parent.dentry->d_inode);
++
++ rc = -EXDEV;
++ if (old_parent.mnt != new_parent.mnt)
++ SGOTO(exit3, rc);
++
++ old_dir = old_parent.dentry;
++ new_dir = new_parent.dentry;
++ trap = lock_rename(new_dir, old_dir);
++
++ /* source should not be ancestor of target */
++ rc = -EINVAL;
++ if (old_dentry == trap)
++ SGOTO(exit4, rc);
++
++ /* target should not be an ancestor of source */
++ rc = -ENOTEMPTY;
++ if (new_dentry == trap)
++ SGOTO(exit4, rc);
++
++ /* source must exist */
++ rc = -ENOENT;
++ if (!old_dentry->d_inode)
++ SGOTO(exit4, rc);
++
++ /* unless the source is a directory trailing slashes give -ENOTDIR */
++ if (!S_ISDIR(old_dentry->d_inode->i_mode)) {
++ rc = -ENOTDIR;
++ if (old_dentry->d_name.name[old_dentry->d_name.len])
++ SGOTO(exit4, rc);
++ if (new_dentry->d_name.name[new_dentry->d_name.len])
++ SGOTO(exit4, rc);
++ }
++
++#ifdef HAVE_4ARGS_VFS_RENAME
++ rc = vfs_rename(old_dir->d_inode, old_dentry,
++ new_dir->d_inode, new_dentry);
++#else
++ rc = vfs_rename(old_dir->d_inode, old_dentry, oldnd.nd_mnt,
++ new_dir->d_inode, new_dentry, newnd.nd_mnt);
++#endif /* HAVE_4ARGS_VFS_RENAME */
++exit4:
++ unlock_rename(new_dir, old_dir);
++exit3:
++ dput(new_dentry);
++ path_put(&new_parent);
++exit2:
++ dput(old_dentry);
++ path_put(&old_parent);
++exit:
++ SRETURN(-rc);
++}
++EXPORT_SYMBOL(vn_rename);
++
++#else
+ static struct dentry *
+ vn_lookup_hash(struct nameidata *nd)
+ {
+@@ -458,6 +584,7 @@
+ SRETURN(-rc);
+ }
+ EXPORT_SYMBOL(vn_rename);
++#endif /* HAVE_KERN_PATH_LOCKED */
+
+ int
+ vn_getattr(vnode_t *vp, vattr_t *vap, int flags, void *x3, void *x4)
+@@ -862,6 +989,15 @@ int spl_vn_init_kallsyms_lookup(void)
+ #endif /* HAVE_KERN_PATH_PARENT_SYMBOL */
+ #endif /* HAVE_KERN_PATH_PARENT_HEADER */
+
++#ifdef HAVE_KERN_PATH_LOCKED
++ kern_path_locked_fn = (kern_path_locked_t)
++ spl_kallsyms_lookup_name("kern_path_locked");
++ if (!kern_path_locked_fn) {
++ printk(KERN_ERR "Error: Unknown symbol kern_path_locked\n");
++ return -EFAULT;
++ }
++#endif
++
+ return (0);
+ }
+
+--
+1.7.10
+
diff --git a/sys-kernel/spl/spl-0.6.0_rc11-r1.ebuild b/sys-kernel/spl/spl-0.6.0_rc11-r1.ebuild
new file mode 100644
index 000000000000..af7a82750022
--- /dev/null
+++ b/sys-kernel/spl/spl-0.6.0_rc11-r1.ebuild
@@ -0,0 +1,92 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-kernel/spl/spl-0.6.0_rc11-r1.ebuild,v 1.1 2012/10/17 04:57:33 ryao Exp $
+
+EAPI="4"
+AUTOTOOLS_AUTORECONF="1"
+
+inherit flag-o-matic linux-mod autotools-utils
+
+if [[ ${PV} == "9999" ]] ; then
+ inherit git-2
+ EGIT_REPO_URI="git://github.com/zfsonlinux/${PN}.git"
+else
+ inherit eutils versionator
+ MY_PV=$(replace_version_separator 3 '-')
+ SRC_URI="https://github.com/downloads/zfsonlinux/${PN}/${PN}-${MY_PV}.tar.gz"
+ S="${WORKDIR}/${PN}-${MY_PV}"
+ KEYWORDS="~amd64"
+fi
+
+DESCRIPTION="The Solaris Porting Layer is a Linux kernel module which provides many of the Solaris kernel APIs"
+HOMEPAGE="http://zfsonlinux.org/"
+
+LICENSE="|| ( GPL-2 GPL-3 )"
+SLOT="0"
+IUSE="custom-cflags debug"
+RESTRICT="test"
+
+RDEPEND="!sys-devel/spl"
+
+AT_M4DIR="config"
+AUTOTOOLS_IN_SOURCE_BUILD="1"
+
+pkg_setup() {
+ CONFIG_CHECK="
+ !DEBUG_LOCK_ALLOC
+ !GRKERNSEC_HIDESYM
+ MODULES
+ KALLSYMS
+ !PAX_KERNEXEC_PLUGIN_METHOD_OR
+ ZLIB_DEFLATE
+ ZLIB_INFLATE
+ "
+
+ kernel_is ge 2 6 26 || die "Linux 2.6.26 or newer required"
+
+ [ ${PV} != "9999" ] && \
+ { kernel_is le 3 6 || die "Linux 3.6 is the latest supported version."; }
+
+ check_extra_config
+}
+
+src_prepare() {
+ # Workaround for hard coded path
+ sed -i "s|/sbin/lsmod|/bin/lsmod|" scripts/check.sh || die
+
+ # Linux 3.6 Support
+ epatch "${FILESDIR}/${P}-linux-3.6-compat.patch"
+
+ autotools-utils_src_prepare
+}
+
+src_configure() {
+ use custom-cflags || strip-flags
+ set_arch_to_kernel
+ local myeconfargs=(
+ --bindir="${EPREFIX}/bin"
+ --sbindir="${EPREFIX}/sbin"
+ --with-config=all
+ --with-linux="${KV_DIR}"
+ --with-linux-obj="${KV_OUT_DIR}"
+ $(use_enable debug)
+ )
+ autotools-utils_src_configure
+}
+
+src_test() {
+ if [[ ! -e /proc/modules ]]
+ then
+ die "Missing /proc/modules"
+ elif [[ $UID -ne 0 ]]
+ then
+ ewarn "Cannot run make check tests with FEATURES=userpriv."
+ ewarn "Skipping make check tests."
+ elif grep -q '^spl ' /proc/modules
+ then
+ ewarn "Cannot run make check tests with module spl loaded."
+ ewarn "Skipping make check tests."
+ else
+ autotools-utils_src_test
+ fi
+}