Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1 | Description: 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. |
| 11 | Author: Stefan Bader <stefan.bader@canonical.com> |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 12 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 13 | The original patch is at http://launchpadlibrarian.net/227478885/iscsitarget_1.4.20.3+svn502-2ubuntu2_1.4.20.3+svn502-2ubuntu3.diff.gz, |
| 14 | those changes were taken using #ifs to allow compilation of iscsitarget |
| 15 | package with kernel versions < 4.3. |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 16 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 17 | Upstream-Status: Submitted [http://launchpadlibrarian.net/227478885/iscsitarget_1.4.20.3+svn502-2ubuntu2_1.4.20.3+svn502-2ubuntu3.diff.gz] |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 18 | |
| 19 | Signed-off-by: Jagadeesh Krishnanjanappa <jkrishnanjanappa@mvista.com> |
| 20 | |
| 21 | diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/block-io.c iscsitarget-1.4.20.3+svn502/kernel/block-io.c |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 22 | --- 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 Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 33 | { |
| 34 | struct tio_work *tio_work = bio->bi_private; |
| 35 | |
| 36 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 37 | + if (bio->bi_error) |
| 38 | + atomic_set(&tio_work->error, bio->bi_error); |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 39 | +#else |
| 40 | error = test_bit(BIO_UPTODATE, &bio->bi_flags) ? error : -EIO; |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 41 | |
| 42 | if (error) |
| 43 | atomic_set(&tio_work->error, error); |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 44 | +#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 Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 49 | u32 size = tio->size; |
| 50 | u32 tio_index = 0; |
| 51 | |
| 52 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 53 | + int max_pages = bdev_q ? BIO_MAX_PAGES : 1; |
| 54 | +#else |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 55 | int max_pages = 1; |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 56 | +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */ |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 57 | int err = 0; |
| 58 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 59 | loff_t ppos = tio->offset; |
| 60 | |
| 61 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 62 | /* Calculate max_pages for bio_alloc (memory saver) */ |
| 63 | if (bdev_q) |
| 64 | max_pages = bio_get_nr_vecs(bio_data->bdev); |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 65 | +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) */ |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 66 | |
| 67 | tio_work = kzalloc(sizeof (*tio_work), GFP_KERNEL); |
| 68 | if (!tio_work) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 69 | diff -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 Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 75 | |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 76 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 77 | +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 | /* |
| 94 | diff -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 | |