#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)
/* 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;
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);
#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;
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;
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;
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;