[pve-devel] [PATCH zfsonlinux 1/3] update/rebase to spl-0.7.10 with patches from ZOL

Stoiko Ivanov s.ivanov at proxmox.com
Tue Sep 11 11:43:40 CEST 2018


Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 ...nux-4.18-compat-inode-timespec-timespec64.patch | 178 +++++++++++++++++++++
 ...pool-state-proc-entry-SUSPENDED-pools-SPL.patch |  69 ++++++++
 ...sem_tryupgrade-for-4.9.20-rt16-kernel-SPL.patch | 136 ++++++++++++++++
 spl-patches/0005-Tag-spl-0.7.10.patch              |  59 +++++++
 spl-patches/series                                 |   4 +
 5 files changed, 446 insertions(+)
 create mode 100644 spl-patches/0002-Linux-4.18-compat-inode-timespec-timespec64.patch
 create mode 100644 spl-patches/0003-Add-pool-state-proc-entry-SUSPENDED-pools-SPL.patch
 create mode 100644 spl-patches/0004-Add-rwsem_tryupgrade-for-4.9.20-rt16-kernel-SPL.patch
 create mode 100644 spl-patches/0005-Tag-spl-0.7.10.patch

diff --git a/spl-patches/0002-Linux-4.18-compat-inode-timespec-timespec64.patch b/spl-patches/0002-Linux-4.18-compat-inode-timespec-timespec64.patch
new file mode 100644
index 0000000..eb7828e
--- /dev/null
+++ b/spl-patches/0002-Linux-4.18-compat-inode-timespec-timespec64.patch
@@ -0,0 +1,178 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Brian Behlendorf <behlendorf1 at llnl.gov>
+Date: Sun, 12 Aug 2018 18:22:54 -0400
+Subject: [PATCH] Linux 4.18 compat: inode timespec -> timespec64
+
+Commit torvalds/linux at 95582b0 changes the inode i_atime, i_mtime,
+and i_ctime members form timespec's to timespec64's to make them
+2038 safe.  As part of this change the current_time() function was
+also updated to return the timespec64 type.
+
+Resolve this issue by introducing a new inode_timespec_t type which
+is defined to match the timespec type used by the inode.  It should
+be used when working with inode timestamps to ensure matching types.
+
+The timestruc_t type under Illumos was used in a similar fashion but
+was specified to always be a timespec_t.  Rather than incorrectly
+define this type all timespec_t types have been replaced by the new
+inode_timespec_t type.
+
+Finally, the kernel and user space 'sys/time.h' headers were aligned
+with each other.  They define as appropriate for the context several
+constants as macros and include static inline implementation of
+gethrestime(), gethrestime_sec(), and gethrtime().
+
+Reviewed-by: Chunwei Chen <tuxoko at gmail.com>
+Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
+Closes #7643
+Backported-by: Richard Yao <ryao at gentoo.org>
+
+Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
+---
+ config/kernel-inode-times.m4 | 25 +++++++++++++++++++++++++
+ config/spl-build.m4          |  1 +
+ include/sys/condvar.h        |  1 +
+ include/sys/time.h           | 25 +++++++++++++++++++------
+ include/sys/types.h          |  3 ---
+ include/sys/vnode.h          |  6 +++---
+ 6 files changed, 49 insertions(+), 12 deletions(-)
+ create mode 100644 config/kernel-inode-times.m4
+
+diff --git a/config/kernel-inode-times.m4 b/config/kernel-inode-times.m4
+new file mode 100644
+index 0000000..3a6acd8
+--- /dev/null
++++ b/config/kernel-inode-times.m4
+@@ -0,0 +1,25 @@
++dnl #
++dnl # 4.18 API change
++dnl # i_atime, i_mtime, and i_ctime changed from timespec to timespec64.
++dnl #
++AC_DEFUN([SPL_AC_KERNEL_INODE_TIMES], [
++	AC_MSG_CHECKING([whether inode->i_*time's are timespec64])
++	tmp_flags="$EXTRA_KCFLAGS"
++	EXTRA_KCFLAGS="-Werror"
++	SPL_LINUX_TRY_COMPILE([
++		#include <linux/fs.h>
++	],[
++		struct inode ip;
++		struct timespec ts;
++
++		memset(&ip, 0, sizeof(ip));
++		ts = ip.i_mtime;
++	],[
++		AC_MSG_RESULT(no)
++	],[
++		AC_MSG_RESULT(yes)
++		AC_DEFINE(HAVE_INODE_TIMESPEC64_TIMES, 1,
++		    [inode->i_*time's are timespec64])
++	])
++	EXTRA_KCFLAGS="$tmp_flags"
++])
+diff --git a/config/spl-build.m4 b/config/spl-build.m4
+index 5c6c02a..0dc5be8 100644
+--- a/config/spl-build.m4
++++ b/config/spl-build.m4
+@@ -43,6 +43,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
+ 	SPL_AC_2ARGS_VFS_GETATTR
+ 	SPL_AC_USLEEP_RANGE
+ 	SPL_AC_KMEM_CACHE_ALLOCFLAGS
++	SPL_AC_KERNEL_INODE_TIMES
+ 	SPL_AC_WAIT_ON_BIT
+ 	SPL_AC_INODE_LOCK
+ 	SPL_AC_GROUP_INFO_GID
+diff --git a/include/sys/condvar.h b/include/sys/condvar.h
+index 5fcc906..ce3149a 100644
+--- a/include/sys/condvar.h
++++ b/include/sys/condvar.h
+@@ -31,6 +31,7 @@
+ #include <sys/kmem.h>
+ #include <sys/mutex.h>
+ #include <sys/callo.h>
++#include <sys/time.h>
+ 
+ /*
+  * The kcondvar_t struct is protected by mutex taken externally before
+diff --git a/include/sys/time.h b/include/sys/time.h
+index ddda6de..59557af 100644
+--- a/include/sys/time.h
++++ b/include/sys/time.h
+@@ -52,15 +52,28 @@
+ #define	NSEC2SEC(n)	((n) / (NANOSEC / SEC))
+ #define	SEC2NSEC(m)	((hrtime_t)(m) * (NANOSEC / SEC))
+ 
++typedef longlong_t		hrtime_t;
++typedef struct timespec		timespec_t;
++
+ static const int hz = HZ;
+ 
+ #define	TIMESPEC_OVERFLOW(ts)		\
+ 	((ts)->tv_sec < TIME_MIN || (ts)->tv_sec > TIME_MAX)
+ 
++#if defined(HAVE_INODE_TIMESPEC64_TIMES)
++typedef struct timespec64	inode_timespec_t;
++#else
++typedef struct timespec		inode_timespec_t;
++#endif
++
+ static inline void
+-gethrestime(timestruc_t *now)
+-{
+-	*now = current_kernel_time();
++gethrestime(inode_timespec_t *ts)
++ {
++#if defined(HAVE_INODE_TIMESPEC64_TIMES)
++	*ts = current_kernel_time64();
++#else
++	*ts = current_kernel_time();
++#endif
+ }
+ 
+ static inline time_t
+@@ -74,9 +87,9 @@ gethrestime_sec(void)
+ static inline hrtime_t
+ gethrtime(void)
+ {
+-	struct timespec now;
+-	getrawmonotonic(&now);
+-	return (((hrtime_t)now.tv_sec * NSEC_PER_SEC) + now.tv_nsec);
++	struct timespec ts;
++	getrawmonotonic(&ts);
++	return (((hrtime_t)ts.tv_sec * NSEC_PER_SEC) + ts.tv_nsec);
+ }
+ 
+ #endif  /* _SPL_TIME_H */
+diff --git a/include/sys/types.h b/include/sys/types.h
+index 2fe63b7..b958462 100644
+--- a/include/sys/types.h
++++ b/include/sys/types.h
+@@ -49,9 +49,6 @@ typedef long long			offset_t;
+ typedef struct task_struct		kthread_t;
+ typedef struct task_struct		proc_t;
+ typedef short				pri_t;
+-typedef struct timespec			timestruc_t; /* definition per SVr4 */
+-typedef struct timespec			timespec_t;
+-typedef longlong_t			hrtime_t;
+ typedef unsigned short			ushort_t;
+ typedef u_longlong_t			len_t;
+ typedef longlong_t			diskaddr_t;
+diff --git a/include/sys/vnode.h b/include/sys/vnode.h
+index 0ed4794..87f12d6 100644
+--- a/include/sys/vnode.h
++++ b/include/sys/vnode.h
+@@ -129,9 +129,9 @@ typedef struct vattr {
+ 	long		va_nodeid;	/* node # */
+ 	uint32_t	va_nlink;	/* # links */
+ 	uint64_t	va_size;	/* file size */
+-	struct timespec	va_atime;	/* last acc */
+-	struct timespec	va_mtime;	/* last mod */
+-	struct timespec	va_ctime;	/* last chg */
++	inode_timespec_t va_atime;	/* last acc */
++	inode_timespec_t va_mtime;	/* last mod */
++	inode_timespec_t va_ctime;	/* last chg */
+ 	dev_t		va_rdev;	/* dev */
+ 	uint64_t	va_nblocks;	/* space used */
+ 	uint32_t	va_blksize;	/* block size */
+-- 
+2.11.0
+
diff --git a/spl-patches/0003-Add-pool-state-proc-entry-SUSPENDED-pools-SPL.patch b/spl-patches/0003-Add-pool-state-proc-entry-SUSPENDED-pools-SPL.patch
new file mode 100644
index 0000000..b728794
--- /dev/null
+++ b/spl-patches/0003-Add-pool-state-proc-entry-SUSPENDED-pools-SPL.patch
@@ -0,0 +1,69 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tony Hutter <hutter2 at llnl.gov>
+Date: Wed, 15 Aug 2018 09:39:55 -0700
+Subject: [PATCH] Add pool state /proc entry, "SUSPENDED" pools (SPL)
+
+(This is the SPL backported code from f0ed6c744)
+
+1. Add a proc entry to display the pool's state:
+
+$ cat /proc/spl/kstat/zfs/tank/state
+ONLINE
+
+This is done without using the spa config locks, so it will
+never hang.
+
+2. Fix 'zpool status' and 'zpool list -o health' output to print
+"SUSPENDED" instead of "ONLINE" for suspended pools.
+
+Reviewed-by: Olaf Faaland <faaland1 at llnl.gov>
+Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
+Reviewed by: Richard Elling <Richard.Elling at RichardElling.com>
+Signed-off-by: Tony Hutter <hutter2 at llnl.gov>
+Closes #7331
+Closes #7563
+
+Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
+---
+ include/sys/kstat.h    | 2 +-
+ module/spl/spl-kstat.c | 4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/include/sys/kstat.h b/include/sys/kstat.h
+index 2018019..b8aa7ed 100644
+--- a/include/sys/kstat.h
++++ b/include/sys/kstat.h
+@@ -72,7 +72,7 @@
+ #define	KSTAT_FLAG_UNSUPPORTED	\
+ 	(KSTAT_FLAG_VAR_SIZE | KSTAT_FLAG_WRITABLE | \
+ 	KSTAT_FLAG_PERSISTENT | KSTAT_FLAG_DORMANT)
+-
++#define	KSTAT_FLAG_NO_HEADERS	0x80
+ 
+ #define	KS_MAGIC		0x9d9d9d9d
+ 
+diff --git a/module/spl/spl-kstat.c b/module/spl/spl-kstat.c
+index 6970fcc..f9b9015 100644
+--- a/module/spl/spl-kstat.c
++++ b/module/spl/spl-kstat.c
+@@ -388,7 +388,8 @@ kstat_seq_start(struct seq_file *f, loff_t *pos)
+ 
+ 	ksp->ks_snaptime = gethrtime();
+ 
+-	if (!n && kstat_seq_show_headers(f))
++	if (!(ksp->ks_flags & KSTAT_FLAG_NO_HEADERS) && !n &&
++	    kstat_seq_show_headers(f))
+ 		return (NULL);
+ 
+ 	if (n >= ksp->ks_ndata)
+@@ -538,7 +539,6 @@ __kstat_create(const char *ks_module, int ks_instance, const char *ks_name,
+ 	ASSERT(ks_module);
+ 	ASSERT(ks_instance == 0);
+ 	ASSERT(ks_name);
+-	ASSERT(!(ks_flags & KSTAT_FLAG_UNSUPPORTED));
+ 
+ 	if ((ks_type == KSTAT_TYPE_INTR) || (ks_type == KSTAT_TYPE_IO))
+ 		ASSERT(ks_ndata == 1);
+-- 
+2.11.0
+
diff --git a/spl-patches/0004-Add-rwsem_tryupgrade-for-4.9.20-rt16-kernel-SPL.patch b/spl-patches/0004-Add-rwsem_tryupgrade-for-4.9.20-rt16-kernel-SPL.patch
new file mode 100644
index 0000000..8aeed22
--- /dev/null
+++ b/spl-patches/0004-Add-rwsem_tryupgrade-for-4.9.20-rt16-kernel-SPL.patch
@@ -0,0 +1,136 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tony Hutter <hutter2 at llnl.gov>
+Date: Wed, 15 Aug 2018 11:58:54 -0700
+Subject: [PATCH] Add rwsem_tryupgrade for 4.9.20-rt16 kernel (SPL)
+
+(This is the SPL backported code from 11d0525cb)
+
+The RT rwsem implementation was changed to allow multiple readers
+as of the 4.9.20-rt16 patch set.  This results in a build failure
+because the existing implementation was forced to directly access
+the rwsem structure which has changed.
+
+While this could be accommodated by adding additional compatibility
+code.  This patch resolves the build issue by simply assuming the
+rwsem can never be upgraded.  This functionality is a performance
+optimization and all callers must already handle this case.
+
+Converting the last remaining use of __SPIN_LOCK_UNLOCKED to
+spin_lock_init() was additionally required to get a clean build.
+
+Signed-off-by: Brian Behlendorf <behlendorf1 at llnl.gov>
+Closes #7589
+
+Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
+---
+ include/sys/isa_defs.h  |  8 ++++++++
+ include/sys/rwlock.h    | 10 +++++-----
+ module/spl/spl-rwlock.c | 19 ++++++++++++++-----
+ module/spl/spl-vnode.c  |  2 ++
+ 4 files changed, 29 insertions(+), 10 deletions(-)
+
+diff --git a/include/sys/isa_defs.h b/include/sys/isa_defs.h
+index 5559782..13dcb35 100644
+--- a/include/sys/isa_defs.h
++++ b/include/sys/isa_defs.h
+@@ -210,6 +210,14 @@
+ 
+ #include <sys/byteorder.h>
+ 
++/*
++ * CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS will be defined by the Linux
++ * kernel for architectures which support efficient unaligned access.
++ */
++#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
++#define        HAVE_EFFICIENT_UNALIGNED_ACCESS
++#endif
++
+ #if defined(__LITTLE_ENDIAN) && !defined(_LITTLE_ENDIAN)
+ #define	_LITTLE_ENDIAN __LITTLE_ENDIAN
+ #endif
+diff --git a/include/sys/rwlock.h b/include/sys/rwlock.h
+index 325dfc4..2699229 100644
+--- a/include/sys/rwlock.h
++++ b/include/sys/rwlock.h
+@@ -135,7 +135,7 @@ RW_LOCK_HELD(krwlock_t *rwp)
+ }
+ 
+ /*
+- * The following functions must be a #define	and not static inline.
++ * The following functions must be a #define and not static inline.
+  * This ensures that the native linux semaphore functions (down/up)
+  * will be correctly located in the users code which is important
+  * for the built in kernel lock analysis tools
+@@ -151,10 +151,10 @@ RW_LOCK_HELD(krwlock_t *rwp)
+ 	spl_rw_set_type(rwp, type);					\
+ })
+ 
+-#define	rw_destroy(rwp)							\
+-({									\
+-	VERIFY(!RW_LOCK_HELD(rwp));					\
+-})
++/*
++ * The Linux rwsem implementation does not require a matching destroy.
++ */
++#define	rw_destroy(rwp)		((void) 0)
+ 
+ #define	rw_tryenter(rwp, rw)						\
+ ({									\
+diff --git a/module/spl/spl-rwlock.c b/module/spl/spl-rwlock.c
+index bf7ee2f..ac28c91 100644
+--- a/module/spl/spl-rwlock.c
++++ b/module/spl/spl-rwlock.c
+@@ -34,16 +34,24 @@
+ static int
+ __rwsem_tryupgrade(struct rw_semaphore *rwsem)
+ {
+-
++#if defined(READER_BIAS) && defined(WRITER_BIAS)
++	/*
++	 * After the 4.9.20-rt16 kernel the realtime patch series lifted the
++	 * single reader restriction.  While this could be accommodated by
++	 * adding additional compatibility code assume the rwsem can never
++	 * be upgraded.  All caller must already cleanly handle this case.
++	 */
++	return (0);
++#else
+ 	ASSERT((struct task_struct *)
+ 	    ((unsigned long)rwsem->lock.owner & ~RT_MUTEX_OWNER_MASKALL) ==
+ 	    current);
+ 
+ 	/*
+-	 * Under the realtime patch series, rwsem is implemented as a
+-	 * single mutex held by readers and writers alike. However,
+-	 * this implementation would prevent a thread from taking a
+-	 * read lock twice, as the mutex would already be locked on
++	 * Prior to 4.9.20-rt16 kernel the realtime patch series, rwsem is
++	 * implemented as a single mutex held by readers and writers alike.
++	 * However, this implementation would prevent a thread from taking
++	 * a read lock twice, as the mutex would already be locked on
+ 	 * the second attempt. Therefore the implementation allows a
+ 	 * single thread to take a rwsem as read lock multiple times
+ 	 * tracking that nesting as read_depth counter.
+@@ -59,6 +67,7 @@ __rwsem_tryupgrade(struct rw_semaphore *rwsem)
+ 		return (1);
+ 	}
+ 	return (0);
++#endif
+ }
+ #elif defined(CONFIG_RWSEM_GENERIC_SPINLOCK)
+ static int
+diff --git a/module/spl/spl-vnode.c b/module/spl/spl-vnode.c
+index 74ae8fe..cd0015f 100644
+--- a/module/spl/spl-vnode.c
++++ b/module/spl/spl-vnode.c
+@@ -670,6 +670,8 @@ vn_file_cache_destructor(void *buf, void *cdrarg)
+ int
+ spl_vn_init(void)
+ {
++	spin_lock_init(&vn_file_lock);
++
+ 	vn_cache = kmem_cache_create("spl_vn_cache",
+ 	    sizeof (struct vnode), 64, vn_cache_constructor,
+ 	    vn_cache_destructor, NULL, NULL, NULL, 0);
+-- 
+2.11.0
+
diff --git a/spl-patches/0005-Tag-spl-0.7.10.patch b/spl-patches/0005-Tag-spl-0.7.10.patch
new file mode 100644
index 0000000..e25bad4
--- /dev/null
+++ b/spl-patches/0005-Tag-spl-0.7.10.patch
@@ -0,0 +1,59 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tony Hutter <hutter2 at llnl.gov>
+Date: Wed, 5 Sep 2018 10:36:46 -0700
+Subject: [PATCH] Tag spl-0.7.10
+
+META file and changelog updated.
+
+Signed-off-by: Tony Hutter <hutter2 at llnl.gov>
+Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
+---
+ META                         | 2 +-
+ rpm/generic/spl-kmod.spec.in | 3 +++
+ rpm/generic/spl.spec.in      | 3 +++
+ 3 files changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/META b/META
+index 95c9368..7818d34 100644
+--- a/META
++++ b/META
+@@ -1,7 +1,7 @@
+ Meta:         1
+ Name:         spl
+ Branch:       1.0
+-Version:      0.7.9
++Version:      0.7.10
+ Release:      1
+ Release-Tags: relext
+ License:      GPL
+diff --git a/rpm/generic/spl-kmod.spec.in b/rpm/generic/spl-kmod.spec.in
+index 9cd2225..f31e31e 100644
+--- a/rpm/generic/spl-kmod.spec.in
++++ b/rpm/generic/spl-kmod.spec.in
+@@ -167,6 +167,9 @@ chmod u+x ${RPM_BUILD_ROOT}%{kmodinstdir_prefix}/*/extra/*/*/*
+ rm -rf $RPM_BUILD_ROOT
+ 
+ %changelog
++* Wed Sep 05 2018 Tony Hutter <hutter2 at llnl.gov> - 0.7.10-1
++- Released 0.7.10-1, detailed release notes are available at:
++- https://github.com/zfsonlinux/zfs/releases/tag/zfs-0.7.10
+ * Tue May 08 2018 Tony Hutter <hutter2 at llnl.gov> - 0.7.9-1
+ - Released 0.7.9-1, detailed release notes are available at:
+ - https://github.com/zfsonlinux/zfs/releases/tag/zfs-0.7.9
+diff --git a/rpm/generic/spl.spec.in b/rpm/generic/spl.spec.in
+index 39c6411..7e9ee12 100644
+--- a/rpm/generic/spl.spec.in
++++ b/rpm/generic/spl.spec.in
+@@ -44,6 +44,9 @@ make install DESTDIR=%{?buildroot}
+ %{_mandir}/man5/*
+ 
+ %changelog
++* Wed Sep 05 2018 Tony Hutter <hutter2 at llnl.gov> - 0.7.10-1
++- Released 0.7.10-1, detailed release notes are available at:
++- https://github.com/zfsonlinux/zfs/releases/tag/zfs-0.7.10
+ * Tue May 08 2018 Tony Hutter <hutter2 at llnl.gov> - 0.7.9-1
+ - Released 0.7.9-1, detailed release notes are available at:
+ - https://github.com/zfsonlinux/zfs/releases/tag/zfs-0.7.9
+-- 
+2.11.0
+
diff --git a/spl-patches/series b/spl-patches/series
index 20724b7..d97e0b1 100644
--- a/spl-patches/series
+++ b/spl-patches/series
@@ -1 +1,5 @@
 0001-remove-DKMS-and-module-build.patch
+0002-Linux-4.18-compat-inode-timespec-timespec64.patch
+0003-Add-pool-state-proc-entry-SUSPENDED-pools-SPL.patch
+0004-Add-rwsem_tryupgrade-for-4.9.20-rt16-kernel-SPL.patch
+0005-Tag-spl-0.7.10.patch
-- 
2.11.0





More information about the pve-devel mailing list