Commit 095a23c2 authored by Colin Ian King's avatar Colin Ian King Committed by Mo Zhou

Add Linux 4.20 and 5.0 compat fixes. (0.7.12-1ubuntu{3,4,5})

 + 3204-Add-4.20-timespec-compat-fix.patch
 + 3300-Add-check-for-totalram-pages.patch
 + 3301-Add-check-for-ktime_get_coarse_real_ts64.patch
 + 3302-linux-5-0-disable-vector-instructions-on-5-0-kernels.patch
 + 3303-linux-5-0-convert-ms-macros-to-sb.patch
 + 3304-linux-5-0-fix-bio-set-dev.patch

Gbp-Dch: Full
parent 95c6b1b6
Pipeline #34623 failed with stages
in 23 minutes and 19 seconds
Add 4.20 timespec compat fix
This adds a compat fix for zpios-ctl.h to cater for the new 64 bit
times.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Index: zfs-linux-0.7.12/include/zpios-ctl.h
===================================================================
--- zfs-linux-0.7.12.orig/include/zpios-ctl.h
+++ zfs-linux-0.7.12/include/zpios-ctl.h
@@ -181,9 +181,13 @@ zpios_timespec_t
zpios_timespec_now(void)
{
zpios_timespec_t zts_now;
- struct timespec ts_now;
+ inode_timespec_t ts_now;
+#if defined(HAVE_INODE_TIMESPEC64_TIMES)
+ ts_now = current_kernel_time64();
+#else
ts_now = current_kernel_time();
+#endif
zts_now.ts_sec = ts_now.tv_sec;
zts_now.ts_nsec = ts_now.tv_nsec;
check if totamram-pages is a function
Linux 5.0 totalram_pages is now a function, so check for this
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
Index: zfs-linux-0.7.12/config/kernel-totalram-pages.m4
===================================================================
--- /dev/null
+++ zfs-linux-0.7.12/config/kernel-totalram-pages.m4
@@ -0,0 +1,20 @@
+dnl #
+dnl # 5.0 API change
+dnl # check if totalram_pages is a function
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_TOTALRAM_PAGES_FUNCTION], [
+ AC_MSG_CHECKING([whether totalram_pages is a function])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/mm.h>
+ ],[
+ unsigned long t;
+
+ t = totalram_pages();
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_TOTALRAM_PAGES_FUNCTION, 1,
+ [totalram_pages is a function])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
Index: zfs-linux-0.7.12/module/zfs/arc.c
===================================================================
--- zfs-linux-0.7.12.orig/module/zfs/arc.c
+++ zfs-linux-0.7.12/module/zfs/arc.c
@@ -4004,9 +4004,17 @@ arc_all_memory(void)
{
#ifdef _KERNEL
#ifdef CONFIG_HIGHMEM
+#ifdef HAVE_TOTALRAM_PAGES_FUNCTION
+ return (ptob(totalram_pages() - totalhigh_pages));
+#else
return (ptob(totalram_pages - totalhigh_pages));
+#endif /* HAVE_TOTALRAM_PAGES_FUNCTION */
+#else
+#ifdef HAVE_TOTALRAM_PAGES_FUNCTION
+ return (ptob(totalram_pages()));
#else
return (ptob(totalram_pages));
+#endif /* HAVE_TOTALRAM_PAGES_FUNCTION */
#endif /* CONFIG_HIGHMEM */
#else
return (ptob(physmem) / 2);
check if ktime_get_coarse_real_ts64 is supported
Linux 5.0 now uses ktime_get_coarse_real_ts64 check and use this
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
Index: zfs-linux-0.7.12/config/kernel-ktime.m4
===================================================================
--- /dev/null
+++ zfs-linux-0.7.12/config/kernel-ktime.m4
@@ -0,0 +1,20 @@
+dnl #
+dnl # 5.0 API change
+dnl # current_kernel_time64 to ktime_get_coarse_real_ts64 timespec64
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_KTIME_GET_COARSE_REAL_TS64], [
+ AC_MSG_CHECKING([whether ktime_get_coarse_real_ts64 exists])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/ktime.h>
+ ],[
+ struct timespec64 ts;
+
+ ktime_get_coarse_real_ts64(&ts);
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_KTIME_GET_COARSE_REAL_TS64, 1,
+ [ktime_get_coarse_real_ts64 is provided])
+ ],[
+ AC_MSG_RESULT(no)
+ ])
+])
Index: zfs-linux-0.7.12/include/zpios-ctl.h
===================================================================
--- zfs-linux-0.7.12.orig/include/zpios-ctl.h
+++ zfs-linux-0.7.12/include/zpios-ctl.h
@@ -184,7 +184,11 @@ zpios_timespec_now(void)
inode_timespec_t ts_now;
#if defined(HAVE_INODE_TIMESPEC64_TIMES)
+#if defined(HAVE_KTIME_GET_COARSE_REAL_TS64)
+ ktime_get_coarse_real_ts64(&ts_now);
+#else
ts_now = current_kernel_time64();
+#endif
#else
ts_now = current_kernel_time();
#endif
Linux 5.0: Convert MS_* macros to SB_*
In the 5.0 kernel, only the mount namespace code should use the MS_*
macos. Filesystems should use the SB_* ones.
https://patchwork.kernel.org/patch/10552493/
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes zfsonlinux#8264
(cherry picked from commit https://github.com/tonyhutter/zfs/commit/bdb806d742d90805bf23f19b9092d03e74ec6cc7)
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
Index: zfs-linux-0.7.12/module/zfs/vdev_disk.c
===================================================================
--- zfs-linux-0.7.12.orig/module/zfs/vdev_disk.c
+++ zfs-linux-0.7.12/module/zfs/vdev_disk.c
@@ -35,6 +35,7 @@
#include <sys/zio.h>
#include <sys/sunldi.h>
#include <linux/mod_compat.h>
+#include <linux/vfs_compat.h>
char *zfs_vdev_scheduler = VDEV_SCHEDULER;
static void *zfs_vdev_holder = VDEV_HOLDER;
@@ -76,7 +77,7 @@ vdev_bdev_mode(int smode)
ASSERT3S(smode & (FREAD | FWRITE), !=, 0);
if ((smode & FREAD) && !(smode & FWRITE))
- mode = MS_RDONLY;
+ mode = SB_RDONLY;
return (mode);
}
Index: zfs-linux-0.7.12/module/zfs/zfs_vfsops.c
===================================================================
--- zfs-linux-0.7.12.orig/module/zfs/zfs_vfsops.c
+++ zfs-linux-0.7.12/module/zfs/zfs_vfsops.c
@@ -66,6 +66,7 @@
#include <sys/dmu_objset.h>
#include <sys/spa_boot.h>
#include <sys/zpl.h>
+#include <linux/vfs_compat.h>
#include "zfs_comutil.h"
enum {
@@ -259,7 +260,7 @@ zfsvfs_parse_options(char *mntopts, vfs_
boolean_t
zfs_is_readonly(zfsvfs_t *zfsvfs)
{
- return (!!(zfsvfs->z_sb->s_flags & MS_RDONLY));
+ return (!!(zfsvfs->z_sb->s_flags & SB_RDONLY));
}
/*ARGSUSED*/
@@ -353,15 +354,15 @@ acltype_changed_cb(void *arg, uint64_t n
switch (newval) {
case ZFS_ACLTYPE_OFF:
zfsvfs->z_acl_type = ZFS_ACLTYPE_OFF;
- zfsvfs->z_sb->s_flags &= ~MS_POSIXACL;
+ zfsvfs->z_sb->s_flags &= ~SB_POSIXACL;
break;
case ZFS_ACLTYPE_POSIXACL:
#ifdef CONFIG_FS_POSIX_ACL
zfsvfs->z_acl_type = ZFS_ACLTYPE_POSIXACL;
- zfsvfs->z_sb->s_flags |= MS_POSIXACL;
+ zfsvfs->z_sb->s_flags |= SB_POSIXACL;
#else
zfsvfs->z_acl_type = ZFS_ACLTYPE_OFF;
- zfsvfs->z_sb->s_flags &= ~MS_POSIXACL;
+ zfsvfs->z_sb->s_flags &= ~SB_POSIXACL;
#endif /* CONFIG_FS_POSIX_ACL */
break;
default:
@@ -390,9 +391,9 @@ readonly_changed_cb(void *arg, uint64_t
return;
if (newval)
- sb->s_flags |= MS_RDONLY;
+ sb->s_flags |= SB_RDONLY;
else
- sb->s_flags &= ~MS_RDONLY;
+ sb->s_flags &= ~SB_RDONLY;
}
static void
@@ -420,9 +421,9 @@ nbmand_changed_cb(void *arg, uint64_t ne
return;
if (newval == TRUE)
- sb->s_flags |= MS_MANDLOCK;
+ sb->s_flags |= SB_MANDLOCK;
else
- sb->s_flags &= ~MS_MANDLOCK;
+ sb->s_flags &= ~SB_MANDLOCK;
}
static void
@@ -1763,8 +1764,8 @@ zfs_remount(struct super_block *sb, int
int error;
if ((issnap || !spa_writeable(dmu_objset_spa(zfsvfs->z_os))) &&
- !(*flags & MS_RDONLY)) {
- *flags |= MS_RDONLY;
+ !(*flags & SB_RDONLY)) {
+ *flags |= SB_RDONLY;
return (EROFS);
}
Linux 5.0: Fix bio_set_dev()
The Linux 5.0 kernel updated the bio_set_dev() macro so it calls the
GPL-only bio_associate_blkg() symbol thus inadvertently converting
the entire macro. Provide a minimal version which always assigns the
request queue's root_blkg to the bio.
[Colin Ian King]
Fix check, include linux/module.h and set MODULE_LICENSE macro
correctly.
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes: zfsonlinux#8287
(based on commit https://github.com/tonyhutter/zfs/commit/b94a2e437c24c26d4725fa7159fd0525ff0889e1)
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
Index: zfs-linux-0.7.12/config/kernel-bio_set_dev.m4
===================================================================
--- zfs-linux-0.7.12.orig/config/kernel-bio_set_dev.m4
+++ zfs-linux-0.7.12/config/kernel-bio_set_dev.m4
@@ -1,10 +1,10 @@
dnl #
dnl # Linux 4.14 API,
dnl #
-dnl # The bio_set_dev() helper was introduced as part of the transition
+dnl # The bio_set_dev() helper macro was introduced as part of the transition
dnl # to have struct gendisk in struct bio.
dnl #
-AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_DEV], [
+AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_DEV_MACRO], [
AC_MSG_CHECKING([whether bio_set_dev() exists])
ZFS_LINUX_TRY_COMPILE([
#include <linux/bio.h>
@@ -20,3 +20,35 @@ AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_DEV], [
AC_MSG_RESULT(no)
])
])
+
+dnl #
+dnl # Linux 5.0 API,
+dnl #
+dnl # The bio_set_dev() helper macro was updated to internally depend on
+dnl # bio_associate_blkg() symbol which is exported GPL-only.
+dnl #
+AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_DEV_GPL_ONLY], [
+ AC_MSG_CHECKING([whether bio_set_dev() is GPL-only])
+ ZFS_LINUX_TRY_COMPILE([
+ #include <linux/module.h>
+ #include <linux/bio.h>
+ #include <linux/fs.h>
+
+ MODULE_LICENSE("$ZFS_META_LICENSE");
+ ],[
+ struct block_device *bdev = NULL;
+ struct bio *bio = NULL;
+ bio_set_dev(bio, bdev);
+ ],[
+ AC_MSG_RESULT(no)
+ ],[
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_BIO_SET_DEV_GPL_ONLY, 1,
+ [bio_set_dev() GPL-only])
+ ])
+])
+
+AC_DEFUN([ZFS_AC_KERNEL_BIO_SET_DEV], [
+ ZFS_AC_KERNEL_BIO_SET_DEV_MACRO
+ ZFS_AC_KERNEL_BIO_SET_DEV_GPL_ONLY
+])
Index: zfs-linux-0.7.12/module/zfs/vdev_disk.c
===================================================================
--- zfs-linux-0.7.12.orig/module/zfs/vdev_disk.c
+++ zfs-linux-0.7.12/module/zfs/vdev_disk.c
@@ -502,13 +502,38 @@ vdev_submit_bio_impl(struct bio *bio)
#endif
}
-#ifndef HAVE_BIO_SET_DEV
+#ifdef HAVE_BIO_SET_DEV
+#if defined(CONFIG_BLK_CGROUP) && defined(HAVE_BIO_SET_DEV_GPL_ONLY)
+/*
+ * The Linux 5.0 kernel updated the bio_set_dev() macro so it calls the
+ * GPL-only bio_associate_blkg() symbol thus inadvertently converting
+ * the entire macro. Provide a minimal version which always assigns the
+ * request queue's root_blkg to the bio.
+ */
+static inline void
+vdev_bio_associate_blkg(struct bio *bio)
+{
+ struct request_queue *q = bio->bi_disk->queue;
+
+ ASSERT3P(q, !=, NULL);
+ ASSERT3P(q->root_blkg, !=, NULL);
+ ASSERT3P(bio->bi_blkg, ==, NULL);
+
+ if (blkg_tryget(q->root_blkg))
+ bio->bi_blkg = q->root_blkg;
+}
+#define bio_associate_blkg vdev_bio_associate_blkg
+#endif
+#else
+/*
+ * Provide a bio_set_dev() helper macro for pre-Linux 4.14 kernels.
+ */
static inline void
bio_set_dev(struct bio *bio, struct block_device *bdev)
{
bio->bi_bdev = bdev;
}
-#endif /* !HAVE_BIO_SET_DEV */
+#endif /* HAVE_BIO_SET_DEV */
static inline void
vdev_submit_bio(struct bio *bio)
......@@ -34,3 +34,9 @@ init-debian-openrc-workaround.patch
2339-Prevent-zdb-8-from-occasionally-hanging-on-I-O.patch
2341-Change-movaps-to-movups-in-AES-NI-code.patch
3203-Fix-zpool-create-t-tempname.patch
3204-Add-4.20-timespec-compat-fix.patch
3300-Add-check-for-totalram-pages.patch
3301-Add-check-for-ktime_get_coarse_real_ts64.patch
3302-linux-5-0-disable-vector-instructions-on-5-0-kernels.patch
3303-linux-5-0-convert-ms-macros-to-sb.patch
3304-linux-5-0-fix-bio-set-dev.patch
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment