blob: bce38baee51520d21ff7e3d2f7d17fffd4d39764 [file] [log] [blame]
Brad Bishop6e60e8b2018-02-01 10:27:11 -05001Description: Fix source to compile with 4.3+ kernels
2 commit 4246a0b63bd8f56a1469b12eafeb875b1041a451
3 block: add a bi_error field to struct bio
4 -> Removes BIO_UPTODATE and error argument to bio_endio.
5 commit b54ffb73cadcdcff9cc1ae0e11f502407e3e2e4c
6 block: remove bio_get_nr_vecs()
7 -> Removed that call (always use BIO_MAX_PAGES)
8 commit 676d23690fb62b5d51ba5d659935e9f7d9da9f8e
9 net: Fix use after free by removing length arg from sk_data_ready callbacks.
10 -> Removes len argument from sk_data_ready() callback.
11Author: Stefan Bader <stefan.bader@canonical.com>
Patrick Williamsb48b7b42016-08-17 15:04:38 -050012
Brad Bishop6e60e8b2018-02-01 10:27:11 -050013The original patch is at http://launchpadlibrarian.net/227478885/iscsitarget_1.4.20.3+svn502-2ubuntu2_1.4.20.3+svn502-2ubuntu3.diff.gz,
14those changes were taken using #ifs to allow compilation of iscsitarget
15package with kernel versions < 4.3.
Patrick Williamsb48b7b42016-08-17 15:04:38 -050016
Brad Bishop6e60e8b2018-02-01 10:27:11 -050017Upstream-Status: Submitted [http://launchpadlibrarian.net/227478885/iscsitarget_1.4.20.3+svn502-2ubuntu2_1.4.20.3+svn502-2ubuntu3.diff.gz]
Patrick Williamsb48b7b42016-08-17 15:04:38 -050018
19Signed-off-by: Jagadeesh Krishnanjanappa <jkrishnanjanappa@mvista.com>
20
21diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/block-io.c iscsitarget-1.4.20.3+svn502/kernel/block-io.c
Brad Bishop6e60e8b2018-02-01 10:27:11 -050022--- iscsitarget-1.4.20.3+svn502_org/kernel/block-io.c 2014-05-06 13:59:55.000000000 -0700
23+++ iscsitarget-1.4.20.3+svn502/kernel/block-io.c 2017-01-19 00:46:28.263951115 -0800
24@@ -29,14 +29,23 @@ struct tio_work {
25 struct completion tio_complete;
26 };
27
28+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
29+static void blockio_bio_endio(struct bio *bio)
30+#else
31 static void blockio_bio_endio(struct bio *bio, int error)
32+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */
Patrick Williamsb48b7b42016-08-17 15:04:38 -050033 {
34 struct tio_work *tio_work = bio->bi_private;
35
36+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050037+ if (bio->bi_error)
38+ atomic_set(&tio_work->error, bio->bi_error);
Patrick Williamsb48b7b42016-08-17 15:04:38 -050039+#else
40 error = test_bit(BIO_UPTODATE, &bio->bi_flags) ? error : -EIO;
Patrick Williamsb48b7b42016-08-17 15:04:38 -050041
42 if (error)
43 atomic_set(&tio_work->error, error);
Brad Bishop6e60e8b2018-02-01 10:27:11 -050044+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */
45
46 /* If last bio signal completion */
47 if (atomic_dec_and_test(&tio_work->bios_remaining))
48@@ -61,14 +70,20 @@ blockio_make_request(struct iet_volume *
Patrick Williamsb48b7b42016-08-17 15:04:38 -050049 u32 size = tio->size;
50 u32 tio_index = 0;
51
52+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050053+ int max_pages = bdev_q ? BIO_MAX_PAGES : 1;
54+#else
Patrick Williamsb48b7b42016-08-17 15:04:38 -050055 int max_pages = 1;
Brad Bishop6e60e8b2018-02-01 10:27:11 -050056+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */
Patrick Williamsb48b7b42016-08-17 15:04:38 -050057 int err = 0;
58
Brad Bishop6e60e8b2018-02-01 10:27:11 -050059 loff_t ppos = tio->offset;
60
61+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
Patrick Williamsb48b7b42016-08-17 15:04:38 -050062 /* Calculate max_pages for bio_alloc (memory saver) */
63 if (bdev_q)
64 max_pages = bio_get_nr_vecs(bio_data->bdev);
Brad Bishop6e60e8b2018-02-01 10:27:11 -050065+#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) */
Patrick Williamsb48b7b42016-08-17 15:04:38 -050066
67 tio_work = kzalloc(sizeof (*tio_work), GFP_KERNEL);
68 if (!tio_work)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050069diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/conn.c iscsitarget-1.4.20.3+svn502/kernel/conn.c
70--- iscsitarget-1.4.20.3+svn502_org/kernel/conn.c 2017-01-19 00:39:09.737117778 -0800
71+++ iscsitarget-1.4.20.3+svn502/kernel/conn.c 2017-01-19 00:52:30.037223901 -0800
72@@ -89,13 +89,21 @@ static void iet_state_change(struct sock
73 target->nthread_info.old_state_change(sk);
74 }
Patrick Williamsb48b7b42016-08-17 15:04:38 -050075
Patrick Williamsb48b7b42016-08-17 15:04:38 -050076+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050077+static void iet_data_ready(struct sock *sk)
78+#else
79 static void iet_data_ready(struct sock *sk, int len)
80+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */
81 {
82 struct iscsi_conn *conn = sk->sk_user_data;
83 struct iscsi_target *target = conn->session->target;
84
85 nthread_wakeup(target);
86+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
87+ target->nthread_info.old_data_ready(sk);
88+#else
89 target->nthread_info.old_data_ready(sk, len);
90+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */
91 }
92
93 /*
94diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/iscsi.h iscsitarget-1.4.20.3+svn502/kernel/iscsi.h
95--- iscsitarget-1.4.20.3+svn502_org/kernel/iscsi.h 2014-05-06 13:59:55.000000000 -0700
96+++ iscsitarget-1.4.20.3+svn502/kernel/iscsi.h 2017-01-19 00:48:02.102837260 -0800
97@@ -81,7 +81,11 @@ struct network_thread_info {
98 spinlock_t nthread_lock;
99
100 void (*old_state_change)(struct sock *);
101+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
102+ void (*old_data_ready)(struct sock *);
103+#else
104 void (*old_data_ready)(struct sock *, int);
105+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */
106 void (*old_write_space)(struct sock *);
107 };
108