blob: bce38baee51520d21ff7e3d2f7d17fffd4d39764 [file] [log] [blame]
Description: Fix source to compile with 4.3+ kernels
commit 4246a0b63bd8f56a1469b12eafeb875b1041a451
block: add a bi_error field to struct bio
-> Removes BIO_UPTODATE and error argument to bio_endio.
commit b54ffb73cadcdcff9cc1ae0e11f502407e3e2e4c
block: remove bio_get_nr_vecs()
-> Removed that call (always use BIO_MAX_PAGES)
commit 676d23690fb62b5d51ba5d659935e9f7d9da9f8e
net: Fix use after free by removing length arg from sk_data_ready callbacks.
-> Removes len argument from sk_data_ready() callback.
Author: Stefan Bader <stefan.bader@canonical.com>
The original patch is at http://launchpadlibrarian.net/227478885/iscsitarget_1.4.20.3+svn502-2ubuntu2_1.4.20.3+svn502-2ubuntu3.diff.gz,
those changes were taken using #ifs to allow compilation of iscsitarget
package with kernel versions < 4.3.
Upstream-Status: Submitted [http://launchpadlibrarian.net/227478885/iscsitarget_1.4.20.3+svn502-2ubuntu2_1.4.20.3+svn502-2ubuntu3.diff.gz]
Signed-off-by: Jagadeesh Krishnanjanappa <jkrishnanjanappa@mvista.com>
diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/block-io.c iscsitarget-1.4.20.3+svn502/kernel/block-io.c
--- iscsitarget-1.4.20.3+svn502_org/kernel/block-io.c 2014-05-06 13:59:55.000000000 -0700
+++ iscsitarget-1.4.20.3+svn502/kernel/block-io.c 2017-01-19 00:46:28.263951115 -0800
@@ -29,14 +29,23 @@ struct tio_work {
struct completion tio_complete;
};
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
+static void blockio_bio_endio(struct bio *bio)
+#else
static void blockio_bio_endio(struct bio *bio, int error)
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */
{
struct tio_work *tio_work = bio->bi_private;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
+ if (bio->bi_error)
+ atomic_set(&tio_work->error, bio->bi_error);
+#else
error = test_bit(BIO_UPTODATE, &bio->bi_flags) ? error : -EIO;
if (error)
atomic_set(&tio_work->error, error);
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */
/* If last bio signal completion */
if (atomic_dec_and_test(&tio_work->bios_remaining))
@@ -61,14 +70,20 @@ blockio_make_request(struct iet_volume *
u32 size = tio->size;
u32 tio_index = 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
+ int max_pages = bdev_q ? BIO_MAX_PAGES : 1;
+#else
int max_pages = 1;
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */
int err = 0;
loff_t ppos = tio->offset;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
/* Calculate max_pages for bio_alloc (memory saver) */
if (bdev_q)
max_pages = bio_get_nr_vecs(bio_data->bdev);
+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) */
tio_work = kzalloc(sizeof (*tio_work), GFP_KERNEL);
if (!tio_work)
diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/conn.c iscsitarget-1.4.20.3+svn502/kernel/conn.c
--- iscsitarget-1.4.20.3+svn502_org/kernel/conn.c 2017-01-19 00:39:09.737117778 -0800
+++ iscsitarget-1.4.20.3+svn502/kernel/conn.c 2017-01-19 00:52:30.037223901 -0800
@@ -89,13 +89,21 @@ static void iet_state_change(struct sock
target->nthread_info.old_state_change(sk);
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
+static void iet_data_ready(struct sock *sk)
+#else
static void iet_data_ready(struct sock *sk, int len)
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */
{
struct iscsi_conn *conn = sk->sk_user_data;
struct iscsi_target *target = conn->session->target;
nthread_wakeup(target);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
+ target->nthread_info.old_data_ready(sk);
+#else
target->nthread_info.old_data_ready(sk, len);
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */
}
/*
diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/iscsi.h iscsitarget-1.4.20.3+svn502/kernel/iscsi.h
--- iscsitarget-1.4.20.3+svn502_org/kernel/iscsi.h 2014-05-06 13:59:55.000000000 -0700
+++ iscsitarget-1.4.20.3+svn502/kernel/iscsi.h 2017-01-19 00:48:02.102837260 -0800
@@ -81,7 +81,11 @@ struct network_thread_info {
spinlock_t nthread_lock;
void (*old_state_change)(struct sock *);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
+ void (*old_data_ready)(struct sock *);
+#else
void (*old_data_ready)(struct sock *, int);
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */
void (*old_write_space)(struct sock *);
};