[PATCH][BIONIC] UBUNTU: SAUCE: add workarounds to enable ZFS for 4.14
Colin King
colin.king at canonical.com
Mon Nov 6 17:23:55 UTC 2017
From: Colin Ian King <colin.king at canonical.com>
Currently there are no upstream compat workarounds for 4.14 so for
the moment use some workarounds that enable ZFS to build on 4.14.
I added pre-v4.14 #ifdefs so these patches are compatible with the
userspace dkms ZFS/SPL source. Passes the ZFS kernel team autotest
regression tests.
This should all be superceeded once 7.3.0 lands in Bionic and we
have the official 4.14 compat fixes.
Also enable ZFS in debian/rules
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
debian/rules | 2 --
spl/include/sys/vmsystm.h | 8 ++++++++
zfs/module/zfs/vdev_disk.c | 8 ++++++++
zfs/module/zfs/zvol.c | 13 +++++++++++++
4 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/debian/rules b/debian/rules
index 5a68364bc310..6c8855f2b3a9 100755
--- a/debian/rules
+++ b/debian/rules
@@ -75,8 +75,6 @@ ifneq ($(do_tools),true)
do_tools_common=
endif
-do_zfs=false
-
# Either tools package needs the common source preparation
do_any_tools=$(sort $(filter-out false,$(do_linux_tools) $(do_cloud_tools)))
diff --git a/spl/include/sys/vmsystm.h b/spl/include/sys/vmsystm.h
index 9d334fe0a16e..edc0b38249b2 100644
--- a/spl/include/sys/vmsystm.h
+++ b/spl/include/sys/vmsystm.h
@@ -30,15 +30,23 @@
#include <linux/swap.h>
#include <linux/highmem.h>
#include <linux/vmalloc.h>
+#include <linux/version.h>
#include <sys/types.h>
#include <asm/uaccess.h>
#define membar_producer() smp_wmb()
#define physmem totalram_pages
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0)
#define freemem (nr_free_pages() + \
global_page_state(NR_INACTIVE_FILE) + \
global_page_state(NR_INACTIVE_ANON) + \
global_page_state(NR_SLAB_RECLAIMABLE))
+#else
+#define freemem (nr_free_pages() + \
+ global_zone_page_state(NR_INACTIVE_FILE) + \
+ global_zone_page_state(NR_INACTIVE_ANON) + \
+ global_zone_page_state(NR_SLAB_RECLAIMABLE))
+#endif
#define xcopyin(from, to, size) copy_from_user(to, from, size)
#define xcopyout(from, to, size) copy_to_user(to, from, size)
diff --git a/zfs/module/zfs/vdev_disk.c b/zfs/module/zfs/vdev_disk.c
index 33eba20a4a15..9968b0379cf5 100644
--- a/zfs/module/zfs/vdev_disk.c
+++ b/zfs/module/zfs/vdev_disk.c
@@ -574,7 +574,11 @@ __vdev_disk_physio(struct block_device *bdev, zio_t *zio, caddr_t kbuf_ptr,
/* Matching put called by vdev_disk_physio_completion */
vdev_disk_dio_get(dr);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0)
dr->dr_bio[i]->bi_bdev = bdev;
+#else
+ bio_set_dev(dr->dr_bio[i], bdev);
+#endif
BIO_BI_SECTOR(dr->dr_bio[i]) = bio_offset >> 9;
dr->dr_bio[i]->bi_end_io = vdev_disk_physio_completion;
dr->dr_bio[i]->bi_private = dr;
@@ -650,7 +654,11 @@ vdev_disk_io_flush(struct block_device *bdev, zio_t *zio)
bio->bi_end_io = vdev_disk_io_flush_completion;
bio->bi_private = zio;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0)
bio->bi_bdev = bdev;
+#else
+ bio_set_dev(bio, bdev);
+#endif
zio->io_delay = jiffies_64;
bio_set_flush(bio);
vdev_submit_bio(bio);
diff --git a/zfs/module/zfs/zvol.c b/zfs/module/zfs/zvol.c
index cfdc709864ef..e03130cfaa90 100644
--- a/zfs/module/zfs/zvol.c
+++ b/zfs/module/zfs/zvol.c
@@ -52,6 +52,7 @@
#include <sys/spa_impl.h>
#include <sys/zvol.h>
#include <linux/blkdev_compat.h>
+#include <linux/version.h>
unsigned int zvol_inhibit_dev = 0;
unsigned int zvol_major = ZVOL_MAJOR;
@@ -614,7 +615,11 @@ zvol_log_write(zvol_state_t *zv, dmu_tx_t *tx, uint64_t offset,
static int
zvol_write(struct bio *bio)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0)
zvol_state_t *zv = bio->bi_bdev->bd_disk->private_data;
+#else
+ zvol_state_t *zv = bio->bi_disk->private_data;
+#endif
uint64_t offset = BIO_BI_SECTOR(bio) << 9;
uint64_t size = BIO_BI_SIZE(bio);
int error = 0;
@@ -664,7 +669,11 @@ zvol_write(struct bio *bio)
static int
zvol_discard(struct bio *bio)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0)
zvol_state_t *zv = bio->bi_bdev->bd_disk->private_data;
+#else
+ zvol_state_t *zv = bio->bi_disk->private_data;
+#endif
uint64_t start = BIO_BI_SECTOR(bio) << 9;
uint64_t size = BIO_BI_SIZE(bio);
uint64_t end = start + size;
@@ -706,7 +715,11 @@ zvol_discard(struct bio *bio)
static int
zvol_read(struct bio *bio)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,14,0)
zvol_state_t *zv = bio->bi_bdev->bd_disk->private_data;
+#else
+ zvol_state_t *zv = bio->bi_disk->private_data;
+#endif
uint64_t offset = BIO_BI_SECTOR(bio) << 9;
uint64_t len = BIO_BI_SIZE(bio);
int error;
--
2.14.1
More information about the kernel-team
mailing list