diff options
| author | Jagadeesh Krishnanjanappa <jkrishnanjanappa@mvista.com> | 2017-01-20 13:54:36 +0530 |
|---|---|---|
| committer | Joe MacDonald <joe_macdonald@mentor.com> | 2017-02-22 08:31:58 -0500 |
| commit | 8e068c2022f3e3c27af31b6d400b6572f999ce75 (patch) | |
| tree | c41f2d3d02f93a2873e0ee932ec81521f7c5f5e7 | |
| parent | 67acc01098e69823b7eb0ee942179cafae204697 (diff) | |
| download | meta-openembedded-8e068c2022f3e3c27af31b6d400b6572f999ce75.tar.gz | |
iscsitarget: use upstream to build with linux kernel >= 4.3
1. 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.
2. It helps to maintain the patches in future, when iscsitarget is updated.
Signed-off-by: Jagadeesh Krishnanjanappa <jkrishnanjanappa@mvista.com>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
| -rw-r--r-- | meta-networking/recipes-extended/iscsitarget/files/build_with_updated_bio_struct_of_linux_v4.3_and_above.patch | 123 |
1 files changed, 78 insertions, 45 deletions
diff --git a/meta-networking/recipes-extended/iscsitarget/files/build_with_updated_bio_struct_of_linux_v4.3_and_above.patch b/meta-networking/recipes-extended/iscsitarget/files/build_with_updated_bio_struct_of_linux_v4.3_and_above.patch index 0e8b792af8..bce38baee5 100644 --- a/meta-networking/recipes-extended/iscsitarget/files/build_with_updated_bio_struct_of_linux_v4.3_and_above.patch +++ b/meta-networking/recipes-extended/iscsitarget/files/build_with_updated_bio_struct_of_linux_v4.3_and_above.patch | |||
| @@ -1,75 +1,108 @@ | |||
| 1 | 1. test_bit was used to return true boolean value, if | 1 | Description: Fix source to compile with 4.3+ kernels |
| 2 | BIO_UPTODATE bit of bio->bi_flags is set. But the same | 2 | commit 4246a0b63bd8f56a1469b12eafeb875b1041a451 |
| 3 | job can be done by checking bio->bi_error, implemented in | 3 | block: add a bi_error field to struct bio |
| 4 | linux kernel 4.3 and above. If bio->bi_error is set, then | 4 | -> Removes BIO_UPTODATE and error argument to bio_endio. |
| 5 | it denotes error. | 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> | ||
| 6 | 12 | ||
| 7 | Ref: https://github.com/torvalds/linux/commit/4246a0b63bd8f56a1469b12eafeb875b1041a451 | 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. | ||
| 8 | 16 | ||
| 9 | It solves below build error: | 17 | Upstream-Status: Submitted [http://launchpadlibrarian.net/227478885/iscsitarget_1.4.20.3+svn502-2ubuntu2_1.4.20.3+svn502-2ubuntu3.diff.gz] |
| 10 | -- snip -- | ||
| 11 | iscsitarget-1.4.20.3+svn502/kernel/block-io.c:40:19: error: 'BIO_UPTODATE' undeclared (first use in this function) | ||
| 12 | error = test_bit(BIO_UPTODATE, &bio->bi_flags) ? error : -EIO; | ||
| 13 | -- CUT -- | ||
| 14 | |||
| 15 | 2. bio can always be filled to a maximum value of BIO_MAX_PAGES, | ||
| 16 | so no need to check for min value for linux kernel 4.3 and above. | ||
| 17 | |||
| 18 | Ref: https://github.com/torvalds/linux/commit/b54ffb73cadcdcff9cc1ae0e11f502407e3e2e4c | ||
| 19 | |||
| 20 | It solves below build error: | ||
| 21 | -- snip -- | ||
| 22 | iscsitarget-1.4.20.3+svn502/kernel/block-io.c:80:15: error: implicit declaration of function 'bio_get_nr_vecs' [-Werror=implicit-function-declaration] | ||
| 23 | max_pages = bio_get_nr_vecs(bio_data->bdev); | ||
| 24 | -- CUT -- | ||
| 25 | |||
| 26 | Upstream-Status: Pending | ||
| 27 | 18 | ||
| 28 | Signed-off-by: Jagadeesh Krishnanjanappa <jkrishnanjanappa@mvista.com> | 19 | Signed-off-by: Jagadeesh Krishnanjanappa <jkrishnanjanappa@mvista.com> |
| 29 | 20 | ||
| 30 | diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/block-io.c iscsitarget-1.4.20.3+svn502/kernel/block-io.c | 21 | diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/block-io.c iscsitarget-1.4.20.3+svn502/kernel/block-io.c |
| 31 | --- iscsitarget-1.4.20.3+svn502_org/kernel/block-io.c 2016-04-01 09:07:12.891810059 +0530 | 22 | --- iscsitarget-1.4.20.3+svn502_org/kernel/block-io.c 2014-05-06 13:59:55.000000000 -0700 |
| 32 | +++ iscsitarget-1.4.20.3+svn502/kernel/block-io.c 2016-04-01 09:15:59.076469313 +0530 | 23 | +++ iscsitarget-1.4.20.3+svn502/kernel/block-io.c 2017-01-19 00:46:28.263951115 -0800 |
| 33 | @@ -33,7 +33,11 @@ static void blockio_bio_endio(struct bio | 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) */ | ||
| 34 | { | 33 | { |
| 35 | struct tio_work *tio_work = bio->bi_private; | 34 | struct tio_work *tio_work = bio->bi_private; |
| 36 | 35 | ||
| 37 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) | 36 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) |
| 38 | + error = bio->bi_error ? -EIO : error; | 37 | + if (bio->bi_error) |
| 38 | + atomic_set(&tio_work->error, bio->bi_error); | ||
| 39 | +#else | 39 | +#else |
| 40 | error = test_bit(BIO_UPTODATE, &bio->bi_flags) ? error : -EIO; | 40 | error = test_bit(BIO_UPTODATE, &bio->bi_flags) ? error : -EIO; |
| 41 | +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */ | ||
| 42 | 41 | ||
| 43 | if (error) | 42 | if (error) |
| 44 | atomic_set(&tio_work->error, error); | 43 | atomic_set(&tio_work->error, error); |
| 45 | @@ -61,6 +65,10 @@ blockio_make_request(struct iet_volume * | 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 * | ||
| 46 | u32 size = tio->size; | 49 | u32 size = tio->size; |
| 47 | u32 tio_index = 0; | 50 | u32 tio_index = 0; |
| 48 | 51 | ||
| 49 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) | 52 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) |
| 50 | + int err = 0; | 53 | + int max_pages = bdev_q ? BIO_MAX_PAGES : 1; |
| 51 | + loff_t ppos = tio->offset; | 54 | +#else |
| 52 | +#else | ||
| 53 | int max_pages = 1; | 55 | int max_pages = 1; |
| 56 | +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */ | ||
| 54 | int err = 0; | 57 | int err = 0; |
| 55 | 58 | ||
| 56 | @@ -69,6 +77,7 @@ blockio_make_request(struct iet_volume * | 59 | loff_t ppos = tio->offset; |
| 60 | |||
| 61 | +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) | ||
| 57 | /* Calculate max_pages for bio_alloc (memory saver) */ | 62 | /* Calculate max_pages for bio_alloc (memory saver) */ |
| 58 | if (bdev_q) | 63 | if (bdev_q) |
| 59 | max_pages = bio_get_nr_vecs(bio_data->bdev); | 64 | max_pages = bio_get_nr_vecs(bio_data->bdev); |
| 60 | +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */ | 65 | +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0) */ |
| 61 | 66 | ||
| 62 | tio_work = kzalloc(sizeof (*tio_work), GFP_KERNEL); | 67 | tio_work = kzalloc(sizeof (*tio_work), GFP_KERNEL); |
| 63 | if (!tio_work) | 68 | if (!tio_work) |
| 64 | @@ -80,7 +89,11 @@ blockio_make_request(struct iet_volume * | 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 | } | ||
| 65 | 75 | ||
| 66 | /* Main processing loop, allocate and fill all bios */ | ||
| 67 | while (size && tio_index < tio->pg_cnt) { | ||
| 68 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) | 76 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) |
| 69 | + bio = bio_alloc(GFP_KERNEL, BIO_MAX_PAGES); | 77 | +static void iet_data_ready(struct sock *sk) |
| 70 | +#else | 78 | +#else |
| 71 | bio = bio_alloc(GFP_KERNEL, min(max_pages, BIO_MAX_PAGES)); | 79 | static void iet_data_ready(struct sock *sk, int len) |
| 72 | +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */ | 80 | +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0) */ |
| 73 | if (!bio) { | 81 | { |
| 74 | err = -ENOMEM; | 82 | struct iscsi_conn *conn = sk->sk_user_data; |
| 75 | goto out; | 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 | |||
