blob: e508a5e6cdad1a4c7242e7bfd369958f03e4f0cf [file] [log] [blame]
Patrick Williamsddad1a12017-02-23 20:36:32 -06001Resolve build error with linux kernel 4.8
2
3The below changes in kernel source, triggered iscsitarget
4build fail with linux kernel v4.8.
5
61. An extra 'flags' argument has been passed to vfs_readv/vfs_writev
7 syscalls in v4.8. So, set this argument to "0" for now
8 (as there is no real need for that).
9 Ref: https://github.com/torvalds/linux/commit/793b80ef14af56d20c998265287648ad34239b6f
10 Solves:
11 -- snip --
12TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/nthread.c: In function 'write_data':
13TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/nthread.c:350:9: error: too few arguments to function 'vfs_writev'
14 res = vfs_writev(file, (struct iovec __user *) iop, count, &off);
15 ^~~~~~~~~~
16 -- snip --
17
182. Redefine dropped PAGE_CACHE_* and page_cache_{get,release} definitions,
19 as they have been dropped with v4.8
20 Ref: https://github.com/torvalds/linux/commit/1fa64f198b9f8d6ec0f7aec7c18dc94684391140
21 Solves:
22 -- snip --
23TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/param.c: In function 'sess_param_check':
24TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/param.c:48:41: error: 'PAGE_CACHE_SIZE' undeclared (first use in this function)
25 (u32) ((ISCSI_CONN_IOV_MAX - 1) * PAGE_CACHE_SIZE));
26 ^
27 -- snip --
28
293. Replace crypto_hash interfaces with crypto_ahash interfaces,
30 Ref: https://github.com/torvalds/linux/commit/896545098777564212b9e91af4c973f094649aa7
31 Ref: https://www.redhat.com/archives/dm-devel/2016-January/msg00244.html
32 Solves:
33 -- snip --
34TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/digest.c: In function 'digest_init':
35TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/digest.c:42:23: error: implicit declaration of function 'crypto_alloc_hash' [-Werror=implicit-function-declaration]
36 conn->rx_hash.tfm = crypto_alloc_hash("crc32c", 0,
37 ^~~~~~~~~~~~~~~~~
38TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/digest.c: In function 'digest_cleanup':
39TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/digest.c:77:3: error: implicit declaration of function 'crypto_free_hash' [-Werror=implicit-function-declaration]
40 crypto_free_hash(conn->tx_hash.tfm);
41 ^~~~~~~~~~~~~~~~
42 -- snip --
43
444. The earlier "rw" parameter has been set in "bi_rw" within
45 bio structure, hence remove "rw" argument.
46 Ref: https://github.com/torvalds/linux/commit/4e49ea4a3d276365bf7396c9b77b4d1d5923835a
47 Solves:
48-- snip --
49TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/block-io.c:140:14: warning: passing argument 1 of 'submit_bio' makes pointer from integer without a cast [-Wint-conversion]
50 submit_bio(rw, bio);
51 ^~
52-- snip --
53
545. The 'len' argument from sk_data_ready() callback has been removed in
55 linux kernel v4.3 and above.
56 Ref: https://github.com/torvalds/linux/commit/676d23690fb62b5d51ba5d659935e9f7d9da9f8e
57 Solves:
58-- snip --
59TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/conn.c: In function 'iet_socket_bind':
60TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/conn.c:143:38: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
61 target->nthread_info.old_data_ready = conn->sock->sk->sk_data_ready;
62 ^
63TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/conn.c:144:32: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
64 conn->sock->sk->sk_data_ready = iet_data_ready;
65 ^
66-- snip --
67
686.
69 A. The "size" argument has been dropped from sock_recvmsg syscall in v4.8,
70 as all callers have it equal to msg_data_left(msg).
71 B. 'struct user_msghdr' is being used for userland-side msghdr instead
72 of 'struct msghdr', which is used for kernel-side msghdr in linux v3.19
73 and above, so typecase it while calling sock_recvmsg syscall.
74 Ref: https://github.com/torvalds/linux/commit/2da62906b1e298695e1bb725927041cd59942c98
75 https://github.com/torvalds/linux/commit/666547ff591cebdedc4679bf6b1b3f3383a8dea3
76 Solves:
77 -- snip --
78TOPDIR/tmp-glibc/work-shared/qemux86/kernel-source/include/linux/net.h:222:5: note: expected 'struct msghdr *' but argument is of type 'struct user_msghdr *'
79 int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags);
80 ^~~~~~~~~~~~
81TOPDIR/tmp-glibc/work/qemux86-oe-linux/iscsitarget/1.4.20.3+svn502-r0/iscsitarget-1.4.20.3+svn502/kernel/nthread.c:129:8: error: too many arguments to function 'sock_recvmsg'
82 res = sock_recvmsg(conn->sock, &msg, len, MSG_DONTWAIT | MSG_NOSIGNAL);
83 ^~~~~~~~~~~~
84 -- snip --
85
86Detailed error log is at: http://errors.yoctoproject.org/Errors/Details/83334/
87
88Upstream-Status: Pending
89
90Signed-off-by: Jagadeesh Krishnanjanappa <jkrishnanjanappa@mvista.com>
91
92diff -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 -050093--- iscsitarget-1.4.20.3+svn502_org/kernel/block-io.c 2017-01-19 20:19:27.400507354 -0800
94+++ iscsitarget-1.4.20.3+svn502/kernel/block-io.c 2017-01-19 20:32:22.977988593 -0800
95@@ -104,7 +104,11 @@ blockio_make_request(struct iet_volume *
Patrick Williamsddad1a12017-02-23 20:36:32 -060096 /* bi_sector is ALWAYS in units of 512 bytes */
97 bio->bi_iter.bi_sector = ppos >> 9;
98 bio->bi_bdev = bio_data->bdev;
99+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
100+ bio->bi_end_io = (bio_end_io_t *) blockio_bio_endio;
101+#else
102 bio->bi_end_io = blockio_bio_endio;
103+#endif
104 bio->bi_private = tio_work;
105
106 if (tio_bio)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500107@@ -139,7 +143,12 @@ blockio_make_request(struct iet_volume *
Patrick Williamsddad1a12017-02-23 20:36:32 -0600108 tio_bio = tio_bio->bi_next;
109 bio->bi_next = NULL;
110
111+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
112+ bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
113+ submit_bio(bio);
114+#else
115 submit_bio(rw, bio);
116+#endif
117 }
118
119 blk_finish_plug(&plug);
120diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/conn.c iscsitarget-1.4.20.3+svn502/kernel/conn.c
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500121--- iscsitarget-1.4.20.3+svn502_org/kernel/conn.c 2017-01-19 20:19:27.400507354 -0800
122+++ iscsitarget-1.4.20.3+svn502/kernel/conn.c 2017-01-19 20:32:22.978988614 -0800
123@@ -148,8 +148,14 @@ static void iet_socket_bind(struct iscsi
Patrick Williamsddad1a12017-02-23 20:36:32 -0600124 target->nthread_info.old_state_change = conn->sock->sk->sk_state_change;
125 conn->sock->sk->sk_state_change = iet_state_change;
126
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500127+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
128+ target->nthread_info.old_data_ready = (void (*) (struct sock *)) \
Patrick Williamsddad1a12017-02-23 20:36:32 -0600129+ conn->sock->sk->sk_data_ready;
130+ conn->sock->sk->sk_data_ready = (void (*) (struct sock *)) iet_data_ready;
131+#else
132 target->nthread_info.old_data_ready = conn->sock->sk->sk_data_ready;
133 conn->sock->sk->sk_data_ready = iet_data_ready;
134+#endif
135
136 target->nthread_info.old_write_space = conn->sock->sk->sk_write_space;
137 conn->sock->sk->sk_write_space = iet_write_space;
138diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/digest.c iscsitarget-1.4.20.3+svn502/kernel/digest.c
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500139--- iscsitarget-1.4.20.3+svn502_org/kernel/digest.c 2014-05-06 13:59:55.000000000 -0700
140+++ iscsitarget-1.4.20.3+svn502/kernel/digest.c 2017-01-19 20:32:22.978988614 -0800
Patrick Williamsddad1a12017-02-23 20:36:32 -0600141@@ -30,6 +30,9 @@ void digest_alg_available(unsigned int *
142 int digest_init(struct iscsi_conn *conn)
143 {
144 int err = 0;
145+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
146+ struct crypto_ahash *tfm;
147+#endif
148
149 if (!(conn->hdigest_type & DIGEST_ALL))
150 conn->hdigest_type = DIGEST_NONE;
151@@ -39,15 +42,40 @@ int digest_init(struct iscsi_conn *conn)
152
153 if (conn->hdigest_type & DIGEST_CRC32C ||
154 conn->ddigest_type & DIGEST_CRC32C) {
155+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
156+ tfm = crypto_alloc_ahash("crc32c", 0, CRYPTO_ALG_ASYNC);
157+ if (IS_ERR(tfm)) {
158+ tfm = NULL;
159+#else
160 conn->rx_hash.tfm = crypto_alloc_hash("crc32c", 0,
161 CRYPTO_ALG_ASYNC);
162 conn->rx_hash.flags = 0;
163 if (IS_ERR(conn->rx_hash.tfm)) {
164 conn->rx_hash.tfm = NULL;
165+#endif
166 err = -ENOMEM;
167 goto out;
168 }
169-
170+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
171+ conn->rx_hash = ahash_request_alloc(tfm, GFP_KERNEL);
172+ if (!conn->rx_hash) {
173+ pr_err("ahash_request_alloc() failed for conn->rx_hash\n");
174+ crypto_free_ahash(tfm);
175+ err = -ENOMEM;
176+ goto out;
177+ }
178+ ahash_request_set_callback(conn->rx_hash, 0, NULL, NULL);
179+ conn->tx_hash = ahash_request_alloc(tfm, GFP_KERNEL);
180+ if(!conn->tx_hash) {
181+ pr_err("ahash_request_alloc() failed for conn->tx_hash\n");
182+ ahash_request_free(conn->rx_hash);
183+ conn->rx_hash = NULL;
184+ crypto_free_ahash(tfm);
185+ err = -ENOMEM;
186+ goto out;
187+ }
188+ ahash_request_set_callback(conn->tx_hash, 0, NULL, NULL);
189+#else
190 conn->tx_hash.tfm = crypto_alloc_hash("crc32c", 0,
191 CRYPTO_ALG_ASYNC);
192 conn->tx_hash.flags = 0;
193@@ -56,6 +84,7 @@ int digest_init(struct iscsi_conn *conn)
194 err = -ENOMEM;
195 goto out;
196 }
197+#endif
198 }
199
200 out:
201@@ -73,10 +102,21 @@ out:
202 */
203 void digest_cleanup(struct iscsi_conn *conn)
204 {
205+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
206+ ahash_request_free(conn->tx_hash);
207+ if (conn->rx_hash) {
208+ struct crypto_ahash *tfm;
209+ tfm = crypto_ahash_reqtfm(conn->rx_hash);
210+ ahash_request_free(conn->rx_hash);
211+ crypto_free_ahash(tfm);
212+ }
213+
214+#else
215 if (conn->tx_hash.tfm)
216 crypto_free_hash(conn->tx_hash.tfm);
217 if (conn->rx_hash.tfm)
218 crypto_free_hash(conn->rx_hash.tfm);
219+#endif
220 }
221
222 /**
223@@ -160,8 +200,13 @@ static inline void __dbg_simulate_data_d
224 }
225 }
226
227+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
228+static void digest_header(struct ahash_request *hash, struct iscsi_pdu *pdu,
229+ u8 *crc)
230+#else
231 static void digest_header(struct hash_desc *hash, struct iscsi_pdu *pdu,
232 u8 *crc)
233+#endif
234 {
235 struct scatterlist sg[2];
236 unsigned int nbytes = sizeof(struct iscsi_hdr);
237@@ -174,16 +219,27 @@ static void digest_header(struct hash_de
238 nbytes += pdu->ahssize;
239 }
240
241+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
242+ crypto_ahash_init(hash);
243+ ahash_request_set_crypt(hash, sg, crc, nbytes);
244+ crypto_ahash_update(hash);
245+ crypto_ahash_digest(hash);
246+#else
247 crypto_hash_init(hash);
248 crypto_hash_update(hash, sg, nbytes);
249 crypto_hash_final(hash, crc);
250+#endif
251 }
252
253 int digest_rx_header(struct iscsi_cmnd *cmnd)
254 {
255 u32 crc;
256
257+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
258+ digest_header(cmnd->conn->rx_hash, &cmnd->pdu, (u8 *) &crc);
259+#else
260 digest_header(&cmnd->conn->rx_hash, &cmnd->pdu, (u8 *) &crc);
261+#endif
262 if (crc != cmnd->hdigest)
263 return -EIO;
264
265@@ -192,11 +248,20 @@ int digest_rx_header(struct iscsi_cmnd *
266
267 void digest_tx_header(struct iscsi_cmnd *cmnd)
268 {
269+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
270+ digest_header(cmnd->conn->tx_hash, &cmnd->pdu, (u8 *) &cmnd->hdigest);
271+#else
272 digest_header(&cmnd->conn->tx_hash, &cmnd->pdu, (u8 *) &cmnd->hdigest);
273+#endif
274 }
275
276+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
277+static void digest_data(struct ahash_request *hash, struct iscsi_cmnd *cmnd,
278+ struct tio *tio, u32 offset, u8 *crc)
279+#else
280 static void digest_data(struct hash_desc *hash, struct iscsi_cmnd *cmnd,
281 struct tio *tio, u32 offset, u8 *crc)
282+#endif
283 {
284 struct scatterlist *sg = cmnd->conn->hash_sg;
285 u32 size, length, npages;
286@@ -214,7 +279,11 @@ static void digest_data(struct hash_desc
287 BUG_ON(npages > ISCSI_CONN_IOV_MAX);
288
289 sg_init_table(sg, ARRAY_SIZE(cmnd->conn->hash_sg));
290+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
291+ crypto_ahash_init(hash);
292+#else
293 crypto_hash_init(hash);
294+#endif
295
296 for (i = 0; size > 0; i++) {
297 length = min_t(u32, PAGE_CACHE_SIZE - offset, size);
298@@ -225,8 +294,14 @@ static void digest_data(struct hash_desc
299
300 sg_mark_end(&sg[i - 1]);
301
302+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
303+ ahash_request_set_crypt(hash, sg, crc, nbytes);
304+ crypto_ahash_update(hash);
305+ crypto_ahash_digest(hash);
306+#else
307 crypto_hash_update(hash, sg, nbytes);
308 crypto_hash_final(hash, crc);
309+#endif
310 }
311
312 int digest_rx_data(struct iscsi_cmnd *cmnd)
313@@ -251,8 +326,11 @@ int digest_rx_data(struct iscsi_cmnd *cm
314 tio = cmnd->tio;
315 offset = 0;
316 }
317-
318+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
319+ digest_data(cmnd->conn->rx_hash, cmnd, tio, offset, (u8 *) &crc);
320+#else
321 digest_data(&cmnd->conn->rx_hash, cmnd, tio, offset, (u8 *) &crc);
322+#endif
323
324 if (!cmnd->conn->read_overflow &&
325 (cmnd_opcode(cmnd) != ISCSI_OP_PDU_REJECT)) {
326@@ -269,6 +347,11 @@ void digest_tx_data(struct iscsi_cmnd *c
327 struct iscsi_data_out_hdr *req = (struct iscsi_data_out_hdr *)&cmnd->pdu.bhs;
328
329 assert(tio);
330+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
331+ digest_data(cmnd->conn->tx_hash, cmnd, tio,
332+ be32_to_cpu(req->buffer_offset), (u8 *) &cmnd->ddigest);
333+#else
334 digest_data(&cmnd->conn->tx_hash, cmnd, tio,
335 be32_to_cpu(req->buffer_offset), (u8 *) &cmnd->ddigest);
336+#endif
337 }
338diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/iscsi.h iscsitarget-1.4.20.3+svn502/kernel/iscsi.h
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500339--- iscsitarget-1.4.20.3+svn502_org/kernel/iscsi.h 2017-01-19 20:19:27.400507354 -0800
340+++ iscsitarget-1.4.20.3+svn502/kernel/iscsi.h 2017-01-19 20:32:22.979988634 -0800
Patrick Williamsddad1a12017-02-23 20:36:32 -0600341@@ -14,6 +14,7 @@
342 #include <linux/pagemap.h>
343 #include <linux/seq_file.h>
344 #include <linux/mm.h>
345+#include <crypto/hash.h>
346 #include <linux/crypto.h>
347 #include <linux/scatterlist.h>
348 #include <net/sock.h>
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500349@@ -275,8 +276,13 @@ struct iscsi_conn {
Patrick Williamsddad1a12017-02-23 20:36:32 -0600350 u32 write_offset;
351 int write_state;
352
353+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
354+ struct ahash_request *rx_hash;
355+ struct ahash_request *tx_hash;
356+#else
357 struct hash_desc rx_hash;
358 struct hash_desc tx_hash;
359+#endif
360 struct scatterlist hash_sg[ISCSI_CONN_IOV_MAX];
361 };
362
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500363@@ -552,4 +558,10 @@ enum cmnd_flags {
Patrick Williamsddad1a12017-02-23 20:36:32 -0600364 #define PRODUCT_ID "VIRTUAL-DISK"
365 #define PRODUCT_REV "0"
366
367+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
368+#define PAGE_CACHE_SHIFT PAGE_SHIFT
369+#define PAGE_CACHE_SIZE PAGE_SIZE
370+#define PAGE_CACHE_MASK PAGE_MASK
371+#endif
372+
373 #endif /* __ISCSI_H__ */
374diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/nthread.c iscsitarget-1.4.20.3+svn502/kernel/nthread.c
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500375--- iscsitarget-1.4.20.3+svn502_org/kernel/nthread.c 2017-01-19 20:19:27.276504928 -0800
376+++ iscsitarget-1.4.20.3+svn502/kernel/nthread.c 2017-01-19 20:32:22.979988634 -0800
377@@ -155,7 +155,12 @@ static int do_recv(struct iscsi_conn *co
Patrick Williamsddad1a12017-02-23 20:36:32 -0600378
379 oldfs = get_fs();
380 set_fs(get_ds());
381+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
382+ res = sock_recvmsg(conn->sock, (struct msghdr *) &msg, \
383+ MSG_DONTWAIT | MSG_NOSIGNAL);
384+#else
385 res = sock_recvmsg(conn->sock, &msg, len, MSG_DONTWAIT | MSG_NOSIGNAL);
386+#endif
387 set_fs(oldfs);
388
389 if (res <= 0) {
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500390@@ -376,7 +381,11 @@ static int write_data(struct iscsi_conn
Patrick Williamsddad1a12017-02-23 20:36:32 -0600391 ;
392 oldfs = get_fs();
393 set_fs(KERNEL_DS);
394+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
395+ res = vfs_writev(file, (struct iovec __user *) iop, count, &off, 0);
396+#else
397 res = vfs_writev(file, (struct iovec __user *) iop, count, &off);
398+#endif
399 set_fs(oldfs);
400 dprintk(D_DATA, "%#Lx:%u: %d(%ld)\n",
401 (unsigned long long) conn->session->sid, conn->cid,
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500402@@ -503,7 +512,11 @@ static int tx_ddigest(struct iscsi_cmnd
Patrick Williamsddad1a12017-02-23 20:36:32 -0600403 iov.iov_base = (char *) (&cmnd->ddigest) + (sizeof(u32) - rest);
404 iov.iov_len = rest;
405
406+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
407+ res = kernel_sendmsg(cmnd->conn->sock, (struct msghdr *) &msg, &iov, 1, rest);
408+#else
409 res = kernel_sendmsg(cmnd->conn->sock, &msg, &iov, 1, rest);
410+#endif
411
412 if (res > 0) {
413 cmnd->conn->write_size -= res;
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500414@@ -702,7 +715,12 @@ static void close_conn(struct iscsi_conn
Patrick Williamsddad1a12017-02-23 20:36:32 -0600415
416 write_lock_bh(&conn->sock->sk->sk_callback_lock);
417 conn->sock->sk->sk_state_change = target->nthread_info.old_state_change;
418+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
419+ conn->sock->sk->sk_data_ready = (void (*) (struct sock *)) \
420+ target->nthread_info.old_data_ready;
421+#else
422 conn->sock->sk->sk_data_ready = target->nthread_info.old_data_ready;
423+#endif
424 conn->sock->sk->sk_write_space = target->nthread_info.old_write_space;
425 write_unlock_bh(&conn->sock->sk->sk_callback_lock);
426
427diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/volume.c iscsitarget-1.4.20.3+svn502/kernel/volume.c
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500428--- iscsitarget-1.4.20.3+svn502_org/kernel/volume.c 2017-01-19 20:19:27.276504928 -0800
429+++ iscsitarget-1.4.20.3+svn502/kernel/volume.c 2017-01-19 20:32:22.979988634 -0800
Patrick Williamsddad1a12017-02-23 20:36:32 -0600430@@ -84,12 +84,25 @@ static int set_scsisn(struct iet_volume
431 /* Generate a MD5 hash of the target IQN and LUN number */
432 static void gen_scsiid(struct iet_volume *volume)
433 {
434+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
435+ struct ahash_request *hash;
436+ struct crypto_ahash *tfm;
437+#else
438 struct hash_desc hash;
439+#endif
440
441+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
442+ tfm = crypto_alloc_ahash("md5", 0, CRYPTO_ALG_ASYNC);
443+#else
444 hash.tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC);
445 hash.flags = 0;
446+#endif
447
448+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
449+ if (!IS_ERR(tfm)) {
450+#else
451 if (!IS_ERR(hash.tfm)) {
452+#endif
453 struct scatterlist sg[2];
454 unsigned int nbytes = 0;
455
456@@ -102,11 +115,19 @@ static void gen_scsiid(struct iet_volume
457 sg_set_buf(&sg[1], &volume->lun, sizeof(volume->lun));
458 nbytes += sizeof(volume->lun);
459
460+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
461+ crypto_ahash_init(hash);
462+ ahash_request_set_crypt(hash, sg, volume->scsi_id, nbytes);
463+ crypto_ahash_update(hash);
464+ crypto_ahash_digest(hash);
465+ crypto_free_ahash(tfm);
466+#else
467 crypto_hash_init(&hash);
468 crypto_hash_update(&hash, sg, nbytes);
469 crypto_hash_final(&hash, volume->scsi_id);
470
471 crypto_free_hash(hash.tfm);
472+#endif
473 } else {
474 /* If no MD5 available set ID to TID and LUN */
475 memcpy(volume->scsi_id, &volume->target->tid,