@@ -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)))
@@ -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)
@@ -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);
@@ -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;