diff options
author | Richard Yao <ryao@gentoo.org> | 2013-05-28 13:08:52 +0000 |
---|---|---|
committer | Richard Yao <ryao@gentoo.org> | 2013-05-28 13:08:52 +0000 |
commit | 3141c884cd22eca28f6e0a5580e43ddf240cb08d (patch) | |
tree | 5ca0d32981f753e31782b92f0debef7e37ea8402 /sys-fs/zfs-kmod | |
parent | Fix delay() (diff) | |
download | gentoo-2-3141c884cd22eca28f6e0a5580e43ddf240cb08d.tar.gz gentoo-2-3141c884cd22eca28f6e0a5580e43ddf240cb08d.tar.bz2 gentoo-2-3141c884cd22eca28f6e0a5580e43ddf240cb08d.zip |
Backport important fixes from upstream HEAD; also includes important zvol initialization fixes (by me) that were sent upstream
(Portage version: 2.2.0_alpha176/cvs/Linux x86_64, signed Manifest commit with key 0xBEE84C64)
Diffstat (limited to 'sys-fs/zfs-kmod')
7 files changed, 457 insertions, 1 deletions
diff --git a/sys-fs/zfs-kmod/ChangeLog b/sys-fs/zfs-kmod/ChangeLog index ca52e7680a87..191258a8d4e8 100644 --- a/sys-fs/zfs-kmod/ChangeLog +++ b/sys-fs/zfs-kmod/ChangeLog @@ -1,6 +1,18 @@ # ChangeLog for sys-fs/zfs-kmod # Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sys-fs/zfs-kmod/ChangeLog,v 1.29 2013/04/17 14:30:18 ryao Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-fs/zfs-kmod/ChangeLog,v 1.30 2013/05/28 13:08:52 ryao Exp $ + +*zfs-kmod-0.6.1-r1 (28 May 2013) + + 28 May 2013; Richard Yao <ryao@gentoo.org> + +files/zfs-kmod-0.6.1-fix-getdents.patch, + +files/zfs-kmod-0.6.1-fix-txg_quiesce-deadlock.patch, + +files/zfs-kmod-0.6.1-fix-xattr-behavior-1.patch, + +files/zfs-kmod-0.6.1-fix-xattr-behavior-2.patch, + +files/zfs-kmod-0.6.1-fix-zvol-initialization.patch, + +zfs-kmod-0.6.1-r1.ebuild: + Backport important fixes from upstream HEAD; also includes important zvol + initialization fixes (by me) that were sent upstream 17 Apr 2013; Richard Yao <ryao@gentoo.org> zfs-kmod-9999.ebuild: Remove /usr/src/zfs symlink from 9999 ebuild; sys-cluster/lustre (science diff --git a/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-getdents.patch b/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-getdents.patch new file mode 100644 index 000000000000..ce7d5c0494d9 --- /dev/null +++ b/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-getdents.patch @@ -0,0 +1,32 @@ +From 8f1e11b6105bf46a4258958eb3dcae2ab21ed8b2 Mon Sep 17 00:00:00 2001 +From: Caleb James DeLisle <calebdelisle@lavabit.com> +Date: Tue, 16 Apr 2013 05:23:39 -0400 +Subject: [PATCH] Remove .readdir from zpl_file_operations table + +The zpl_readdir() function shouldn't be registered as part of +the zpl_file_operations table, it must only be part of the +zpl_dir_file_operations table. By removing this callback +the VFS will now correctly return ENOTDIR when calling +getdents() on a file. + +Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> +Closes #1404 +--- + module/zfs/zpl_file.c | 1 - + 1 file changed, 1 deletion(-) + +diff --git a/module/zfs/zpl_file.c b/module/zfs/zpl_file.c +index 9c27b7f..db6a72c 100644 +--- a/module/zfs/zpl_file.c ++++ b/module/zfs/zpl_file.c +@@ -446,7 +446,6 @@ + .llseek = generic_file_llseek, + .read = zpl_read, + .write = zpl_write, +- .readdir = zpl_readdir, + .mmap = zpl_mmap, + .fsync = zpl_fsync, + #ifdef HAVE_FILE_FALLOCATE +-- +1.8.1.6 + diff --git a/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-txg_quiesce-deadlock.patch b/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-txg_quiesce-deadlock.patch new file mode 100644 index 000000000000..8513e78882b1 --- /dev/null +++ b/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-txg_quiesce-deadlock.patch @@ -0,0 +1,73 @@ +From 57f5a2008e2e6acf58934cf43c5fdca0faffa73e Mon Sep 17 00:00:00 2001 +From: Brian Behlendorf <behlendorf1@llnl.gov> +Date: Thu, 25 Apr 2013 16:29:22 -0700 +Subject: [PATCH] Fix txg_quiesce thread deadlock + +A deadlock was accidentally introduced by commit e95853a which +can occur when the system is under memory pressure. What happens +is that while the txg_quiesce thread is holding the tx->tx_cpu +locks it enters memory reclaim. In the context of this memory +reclaim it then issues synchronous I/O to a ZVOL swap device. +Because the txg_quiesce thread is holding the tx->tx_cpu locks +a new txg cannot be opened to handle the I/O. Deadlock. + +The fix is straight forward. Move the memory allocation outside +the critical region where the tx->tx_cpu locks are held. And for +good measure change the offending allocation to KM_PUSHPAGE to +ensure it never attempts to issue I/O during reclaim. + +Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> +Issue #1274 +--- + module/zfs/dsl_pool.c | 2 +- + module/zfs/txg.c | 14 +++++++------- + 2 files changed, 8 insertions(+), 8 deletions(-) + +diff --git a/module/zfs/dsl_pool.c b/module/zfs/dsl_pool.c +index 704f034..771b265 100644 +--- a/module/zfs/dsl_pool.c ++++ b/module/zfs/dsl_pool.c +@@ -143,7 +143,7 @@ + { + txg_history_t *th, *rm; + +- th = kmem_zalloc(sizeof(txg_history_t), KM_SLEEP); ++ th = kmem_zalloc(sizeof(txg_history_t), KM_PUSHPAGE); + mutex_init(&th->th_lock, NULL, MUTEX_DEFAULT, NULL); + th->th_kstat.txg = txg; + th->th_kstat.state = TXG_STATE_OPEN; +diff --git a/module/zfs/txg.c b/module/zfs/txg.c +index c7c3df3..7c820af 100644 +--- a/module/zfs/txg.c ++++ b/module/zfs/txg.c +@@ -367,6 +367,13 @@ + tx->tx_open_txg++; + + /* ++ * Now that we've incremented tx_open_txg, we can let threads ++ * enter the next transaction group. ++ */ ++ for (c = 0; c < max_ncpus; c++) ++ mutex_exit(&tx->tx_cpu[c].tc_lock); ++ ++ /* + * Measure how long the txg was open and replace the kstat. + */ + th = dsl_pool_txg_history_get(dp, txg); +@@ -376,13 +383,6 @@ + dsl_pool_txg_history_add(dp, tx->tx_open_txg); + + /* +- * Now that we've incremented tx_open_txg, we can let threads +- * enter the next transaction group. +- */ +- for (c = 0; c < max_ncpus; c++) +- mutex_exit(&tx->tx_cpu[c].tc_lock); +- +- /* + * Quiesce the transaction group by waiting for everyone to txg_exit(). + */ + start = gethrtime(); +-- +1.8.1.6 + diff --git a/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-xattr-behavior-1.patch b/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-xattr-behavior-1.patch new file mode 100644 index 000000000000..b4801708ae35 --- /dev/null +++ b/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-xattr-behavior-1.patch @@ -0,0 +1,50 @@ +From f706421173c571371afff5e2a2ee0784c5e3f95d Mon Sep 17 00:00:00 2001 +From: Brian Behlendorf <behlendorf1@llnl.gov> +Date: Wed, 17 Apr 2013 13:07:36 -0700 +Subject: [PATCH] Correctly return ERANGE in getxattr(2) + +According to the getxattr(2) man page the ERANGE errno should be +returned when the size of the value buffer is to small to hold the +result. Prior to this patch the implementation would just truncate +the value to size bytes. + +Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> +Closes #1408 +--- + module/zfs/zpl_xattr.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/module/zfs/zpl_xattr.c b/module/zfs/zpl_xattr.c +index c03764f..a7e38e6 100644 +--- a/module/zfs/zpl_xattr.c ++++ b/module/zfs/zpl_xattr.c +@@ -225,6 +225,11 @@ + goto out; + } + ++ if (size < i_size_read(xip)) { ++ error = -ERANGE; ++ goto out; ++ } ++ + error = zpl_read_common(xip, value, size, 0, UIO_SYSSPACE, 0, cr); + out: + if (xip) +@@ -263,9 +268,12 @@ + if (!size) + return (nv_size); + +- memcpy(value, nv_value, MIN(size, nv_size)); ++ if (size < nv_size) ++ return (-ERANGE); ++ ++ memcpy(value, nv_value, nv_size); + +- return (MIN(size, nv_size)); ++ return (nv_size); + } + + static int +-- +1.8.1.6 + diff --git a/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-xattr-behavior-2.patch b/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-xattr-behavior-2.patch new file mode 100644 index 000000000000..bb4b1c4a3a34 --- /dev/null +++ b/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-xattr-behavior-2.patch @@ -0,0 +1,37 @@ +From 0377189b884fab7db02a95088e05712c7cf336f7 Mon Sep 17 00:00:00 2001 +From: Brian Behlendorf <behlendorf1@llnl.gov> +Date: Wed, 8 May 2013 09:20:04 -0700 +Subject: [PATCH] Only check directory xattr on ENOENT + +When SA xattrs are enabled only fallback to checking the directory +xattrs when the name is not found as a SA xattr. Otherwise, the SA +error which should be returned to the caller is overwritten by the +directory xattr errors. Positive return values indicating success +will also be immediately returned. + +In the case of #1437 the ERANGE error was being correctly returned +by zpl_xattr_get_sa() only to be overridden with ENOENT which was +returned by the subsequent unnessisary call to zpl_xattr_get_dir(). + +Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> +Closes #1437 +--- + module/zfs/zpl_xattr.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/module/zfs/zpl_xattr.c b/module/zfs/zpl_xattr.c +index a7e38e6..eb2c00d 100644 +--- a/module/zfs/zpl_xattr.c ++++ b/module/zfs/zpl_xattr.c +@@ -288,7 +288,7 @@ + + if (zsb->z_use_sa && zp->z_is_sa) { + error = zpl_xattr_get_sa(ip, name, value, size); +- if (error >= 0) ++ if (error != -ENOENT) + goto out; + } + +-- +1.8.1.6 + diff --git a/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-zvol-initialization.patch b/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-zvol-initialization.patch new file mode 100644 index 000000000000..660d76c82ccf --- /dev/null +++ b/sys-fs/zfs-kmod/files/zfs-kmod-0.6.1-fix-zvol-initialization.patch @@ -0,0 +1,113 @@ +diff --git a/module/zfs/spa.c b/module/zfs/spa.c +index 82ee445..eaf05b9 100644 +--- a/module/zfs/spa.c ++++ b/module/zfs/spa.c +@@ -64,6 +64,7 @@ + #include <sys/zfs_ioctl.h> + #include <sys/dsl_scan.h> + #include <sys/zfeature.h> ++#include <sys/zvol.h> + + #ifdef _KERNEL + #include <sys/bootprops.h> +@@ -2856,6 +2857,7 @@ spa_open_common(const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy, + spa_load_state_t state = SPA_LOAD_OPEN; + int error; + int locked = B_FALSE; ++ int firstopen = B_FALSE; + + *spapp = NULL; + +@@ -2879,6 +2881,8 @@ spa_open_common(const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy, + if (spa->spa_state == POOL_STATE_UNINITIALIZED) { + zpool_rewind_policy_t policy; + ++ firstopen = B_TRUE; ++ + zpool_get_rewind_policy(nvpolicy ? nvpolicy : spa->spa_config, + &policy); + if (policy.zrp_request & ZPOOL_DO_REWIND) +@@ -2953,6 +2957,11 @@ spa_open_common(const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy, + mutex_exit(&spa_namespace_lock); + } + ++#ifdef _KERNEL ++ if (firstopen) ++ zvol_create_minors(spa->spa_name); ++#endif ++ + *spapp = spa; + + return (0); +diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c +index b41eeb2..f9387a7 100644 +--- a/module/zfs/zvol.c ++++ b/module/zfs/zvol.c +@@ -1217,6 +1217,8 @@ zvol_alloc(dev_t dev, const char *name) + if (zv == NULL) + goto out; + ++ spin_lock_init(&zv->zv_lock); ++ + zv->zv_queue = blk_init_queue(zvol_request, &zv->zv_lock); + if (zv->zv_queue == NULL) + goto out_kmem; +@@ -1250,7 +1252,6 @@ zvol_alloc(dev_t dev, const char *name) + sizeof (rl_t), offsetof(rl_t, r_node)); + zv->zv_znode.z_is_zvol = TRUE; + +- spin_lock_init(&zv->zv_lock); + list_link_init(&zv->zv_next); + + zv->zv_disk->major = zvol_major; +@@ -1563,36 +1564,40 @@ zvol_init(void) + { + int error; + ++ list_create(&zvol_state_list, sizeof (zvol_state_t), ++ offsetof(zvol_state_t, zv_next)); ++ mutex_init(&zvol_state_lock, NULL, MUTEX_DEFAULT, NULL); ++ + zvol_taskq = taskq_create(ZVOL_DRIVER, zvol_threads, maxclsyspri, + zvol_threads, INT_MAX, TASKQ_PREPOPULATE); + if (zvol_taskq == NULL) { + printk(KERN_INFO "ZFS: taskq_create() failed\n"); +- return (-ENOMEM); ++ error = -ENOMEM; ++ goto out1; + } + + error = register_blkdev(zvol_major, ZVOL_DRIVER); + if (error) { + printk(KERN_INFO "ZFS: register_blkdev() failed %d\n", error); +- taskq_destroy(zvol_taskq); +- return (error); ++ goto out2; + } + + blk_register_region(MKDEV(zvol_major, 0), 1UL << MINORBITS, + THIS_MODULE, zvol_probe, NULL, NULL); + +- mutex_init(&zvol_state_lock, NULL, MUTEX_DEFAULT, NULL); +- list_create(&zvol_state_list, sizeof (zvol_state_t), +- offsetof(zvol_state_t, zv_next)); +- +- (void) zvol_create_minors(NULL); +- + return (0); ++ ++out2: ++ taskq_destroy(zvol_taskq); ++out1: ++ mutex_destroy(&zvol_state_lock); ++ list_destroy(&zvol_state_list); ++ return (error); + } + + void + zvol_fini(void) + { +- zvol_remove_minors(NULL); + blk_unregister_region(MKDEV(zvol_major, 0), 1UL << MINORBITS); + unregister_blkdev(zvol_major, ZVOL_DRIVER); + taskq_destroy(zvol_taskq); diff --git a/sys-fs/zfs-kmod/zfs-kmod-0.6.1-r1.ebuild b/sys-fs/zfs-kmod/zfs-kmod-0.6.1-r1.ebuild new file mode 100644 index 000000000000..47a64f2cb1ef --- /dev/null +++ b/sys-fs/zfs-kmod/zfs-kmod-0.6.1-r1.ebuild @@ -0,0 +1,139 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/sys-fs/zfs-kmod/zfs-kmod-0.6.1-r1.ebuild,v 1.1 2013/05/28 13:08:52 ryao Exp $ + +EAPI="4" + +AT_M4DIR="config" +AUTOTOOLS_AUTORECONF="1" +AUTOTOOLS_IN_SOURCE_BUILD="1" + +inherit bash-completion-r1 flag-o-matic linux-info linux-mod toolchain-funcs autotools-utils + +if [ ${PV} == "9999" ] ; then + inherit git-2 + MY_PV=9999 + EGIT_REPO_URI="git://github.com/zfsonlinux/zfs.git" +else + inherit eutils versionator + MY_PV=$(replace_version_separator 3 '-') + SRC_URI="https://github.com/zfsonlinux/zfs/archive/zfs-${MY_PV}.tar.gz" + S="${WORKDIR}/zfs-zfs-${MY_PV}" + KEYWORDS="~amd64" +fi + +DESCRIPTION="Linux ZFS kernel module for sys-fs/zfs" +HOMEPAGE="http://zfsonlinux.org/" + +LICENSE="CDDL debug? ( GPL-2+ )" +SLOT="0" +IUSE="custom-cflags debug +rootfs" +RESTRICT="test" + +DEPEND=" + =sys-kernel/spl-${PV}* + dev-lang/perl + virtual/awk +" + +RDEPEND="${DEPEND} + !sys-fs/zfs-fuse +" + +pkg_setup() { + linux-info_pkg_setup + CONFIG_CHECK="!DEBUG_LOCK_ALLOC + BLK_DEV_LOOP + EFI_PARTITION + IOSCHED_NOOP + MODULES + !PAX_KERNEXEC_PLUGIN_METHOD_OR + ZLIB_DEFLATE + ZLIB_INFLATE + " + + use rootfs && \ + CONFIG_CHECK="${CONFIG_CHECK} BLK_DEV_INITRD + DEVTMPFS" + + kernel_is ge 2 6 26 || die "Linux 2.6.26 or newer required" + + [ ${PV} != "9999" ] && \ + { kernel_is le 3 9 || die "Linux 3.9 is the latest supported version."; } + + check_extra_config +} + +src_prepare() { + if [ ${PV} != "9999" ] + then + # Correctness fix for getdents + epatch "${FILESDIR}/${P}-fix-getdents.patch" + + # Prevent possible deadlock regression + epatch "${FILESDIR}/${P}-fix-txg_quiesce-deadlock.patch" + + # Correctness fixes for xattr + epatch "${FILESDIR}/${P}-fix-xattr-behavior-1.patch" + epatch "${FILESDIR}/${P}-fix-xattr-behavior-2.patch" + + # Make certain that zvols always appear + epatch "${FILESDIR}/${P}-fix-zvol-initialization.patch" + fi + + # Remove GPLv2-licensed ZPIOS unless we are debugging + use debug || sed -e 's/^subdir-m += zpios$//' -i "${S}/module/Makefile.in" + + autotools-utils_src_prepare +} + +src_configure() { + use custom-cflags || strip-flags + filter-ldflags -Wl,* + + set_arch_to_kernel + local myeconfargs=( + --bindir="${EPREFIX}/bin" + --sbindir="${EPREFIX}/sbin" + --with-config=kernel + --with-linux="${KV_DIR}" + --with-linux-obj="${KV_OUT_DIR}" + $(use_enable debug) + ) + autotools-utils_src_configure +} + +src_install() { + autotools-utils_src_install + dodoc AUTHORS COPYRIGHT DISCLAIMER README.markdown + + # Provide /usr/src/zfs symlink for lustre + dosym "$(basename $(echo "${ED}/usr/src/zfs-"*))/${KV_FULL}" /usr/src/zfs +} + +pkg_postinst() { + linux-mod_pkg_postinst + + # Remove old modules + if [ -d "${EROOT}lib/modules/${KV_FULL}/addon/zfs" ] + then + ewarn "${PN} now installs modules in ${EROOT}lib/modules/${KV_FULL}/extra/zfs" + ewarn "Old modules were detected in ${EROOT}lib/modules/${KV_FULL}/addon/zfs" + ewarn "Automatically removing old modules to avoid problems." + rm -r "${EROOT}lib/modules/${KV_FULL}/addon/zfs" || die "Cannot remove modules" + rmdir --ignore-fail-on-non-empty "${EROOT}lib/modules/${KV_FULL}/addon" + fi + + if use x86 || use arm + then + ewarn "32-bit kernels will likely require increasing vmalloc to" + ewarn "at least 256M and decreasing zfs_arc_max to some value less than that." + fi + + ewarn "This version of ZFSOnLinux includes support for features flags." + ewarn "If you upgrade your pools to make use of feature flags, you will lose" + ewarn "the ability to import them using older versions of ZFSOnLinux." + ewarn "Any new pools will be created with feature flag support and will" + ewarn "not be compatible with older versions of ZFSOnLinux. To create a new" + ewarn "pool that is backward compatible, use zpool create -o version=28 ..." +} |