summaryrefslogtreecommitdiffstats
path: root/meta-openembedded/meta-networking/recipes-extended/iscsitarget/files/build_with_updated_interfaces_of_linux_v4.8_and_above.patch
blob: e508a5e6cdad1a4c7242e7bfd369958f03e4f0cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
Resolve build error with linux kernel 4.8

The below changes in kernel source, triggered iscsitarget
build fail with linux kernel v4.8.

1. An extra 'flags' argument has been passed to vfs_readv/vfs_writev
   syscalls in v4.8. So, set this argument to "0" for now
   (as there is no real need for that).
   Ref: https://github.com/torvalds/linux/commit/793b80ef14af56d20c998265287648ad34239b6f
   Solves:
   -- snip --
TOPDIR/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':
TOPDIR/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'
   res = vfs_writev(file, (struct iovec __user *) iop, count, &off);
         ^~~~~~~~~~
   -- snip --

2. Redefine dropped PAGE_CACHE_* and page_cache_{get,release} definitions,
   as they have been dropped with v4.8
   Ref: https://github.com/torvalds/linux/commit/1fa64f198b9f8d6ec0f7aec7c18dc94684391140
   Solves:
   -- snip --
TOPDIR/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':
TOPDIR/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)
       (u32) ((ISCSI_CONN_IOV_MAX - 1) * PAGE_CACHE_SIZE));
                                         ^
   -- snip --

3. Replace crypto_hash interfaces with crypto_ahash interfaces,
   Ref: https://github.com/torvalds/linux/commit/896545098777564212b9e91af4c973f094649aa7
   Ref: https://www.redhat.com/archives/dm-devel/2016-January/msg00244.html
   Solves:
   -- snip --
TOPDIR/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':
TOPDIR/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]
   conn->rx_hash.tfm = crypto_alloc_hash("crc32c", 0,
                       ^~~~~~~~~~~~~~~~~
TOPDIR/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':
TOPDIR/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]
   crypto_free_hash(conn->tx_hash.tfm);
   ^~~~~~~~~~~~~~~~
   -- snip --

4. The earlier "rw" parameter has been set in "bi_rw" within
   bio structure, hence remove "rw" argument.
   Ref: https://github.com/torvalds/linux/commit/4e49ea4a3d276365bf7396c9b77b4d1d5923835a
   Solves:
-- snip --
TOPDIR/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]
   submit_bio(rw, bio);
              ^~
-- snip --

5. The 'len' argument from sk_data_ready() callback has been removed in
   linux kernel v4.3 and above.
   Ref: https://github.com/torvalds/linux/commit/676d23690fb62b5d51ba5d659935e9f7d9da9f8e
   Solves:
-- snip --
TOPDIR/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':
TOPDIR/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]
  target->nthread_info.old_data_ready = conn->sock->sk->sk_data_ready;
                                      ^
TOPDIR/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]
  conn->sock->sk->sk_data_ready = iet_data_ready;
                                ^
-- snip --

6.
   A. The "size" argument has been dropped from sock_recvmsg syscall in v4.8,
      as all callers have it equal to msg_data_left(msg).
   B. 'struct user_msghdr' is being used for userland-side msghdr instead
      of 'struct msghdr', which is used for kernel-side msghdr in linux v3.19
      and above, so typecase it while calling sock_recvmsg syscall.
   Ref: https://github.com/torvalds/linux/commit/2da62906b1e298695e1bb725927041cd59942c98
        https://github.com/torvalds/linux/commit/666547ff591cebdedc4679bf6b1b3f3383a8dea3
   Solves:
   -- snip --
TOPDIR/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 *'
 int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags);
     ^~~~~~~~~~~~
TOPDIR/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'
  res = sock_recvmsg(conn->sock, &msg, len, MSG_DONTWAIT | MSG_NOSIGNAL);
        ^~~~~~~~~~~~
   -- snip --

Detailed error log is at: http://errors.yoctoproject.org/Errors/Details/83334/

Upstream-Status: Pending

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	2017-01-19 20:19:27.400507354 -0800
+++ iscsitarget-1.4.20.3+svn502/kernel/block-io.c	2017-01-19 20:32:22.977988593 -0800
@@ -104,7 +104,11 @@ blockio_make_request(struct iet_volume *
 		/* bi_sector is ALWAYS in units of 512 bytes */
 		bio->bi_iter.bi_sector = ppos >> 9;
 		bio->bi_bdev = bio_data->bdev;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+		bio->bi_end_io = (bio_end_io_t *) blockio_bio_endio;
+#else
 		bio->bi_end_io = blockio_bio_endio;
+#endif
 		bio->bi_private = tio_work;
 
 		if (tio_bio)
@@ -139,7 +143,12 @@ blockio_make_request(struct iet_volume *
 		tio_bio = tio_bio->bi_next;
 		bio->bi_next = NULL;
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+		bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
+		submit_bio(bio);
+#else
 		submit_bio(rw, bio);
+#endif
 	}
 
 	blk_finish_plug(&plug);
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 20:19:27.400507354 -0800
+++ iscsitarget-1.4.20.3+svn502/kernel/conn.c	2017-01-19 20:32:22.978988614 -0800
@@ -148,8 +148,14 @@ static void iet_socket_bind(struct iscsi
 	target->nthread_info.old_state_change = conn->sock->sk->sk_state_change;
 	conn->sock->sk->sk_state_change = iet_state_change;
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	target->nthread_info.old_data_ready = (void (*) (struct sock *)) \
+						conn->sock->sk->sk_data_ready;
+	conn->sock->sk->sk_data_ready = (void (*) (struct sock *)) iet_data_ready;
+#else
 	target->nthread_info.old_data_ready = conn->sock->sk->sk_data_ready;
 	conn->sock->sk->sk_data_ready = iet_data_ready;
+#endif
 
 	target->nthread_info.old_write_space = conn->sock->sk->sk_write_space;
 	conn->sock->sk->sk_write_space = iet_write_space;
diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/digest.c iscsitarget-1.4.20.3+svn502/kernel/digest.c
--- iscsitarget-1.4.20.3+svn502_org/kernel/digest.c	2014-05-06 13:59:55.000000000 -0700
+++ iscsitarget-1.4.20.3+svn502/kernel/digest.c	2017-01-19 20:32:22.978988614 -0800
@@ -30,6 +30,9 @@ void digest_alg_available(unsigned int *
 int digest_init(struct iscsi_conn *conn)
 {
 	int err = 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	struct crypto_ahash *tfm;
+#endif
 
 	if (!(conn->hdigest_type & DIGEST_ALL))
 		conn->hdigest_type = DIGEST_NONE;
@@ -39,15 +42,40 @@ int digest_init(struct iscsi_conn *conn)
 
 	if (conn->hdigest_type & DIGEST_CRC32C ||
 	    conn->ddigest_type & DIGEST_CRC32C) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+		tfm = crypto_alloc_ahash("crc32c", 0, CRYPTO_ALG_ASYNC);
+		if (IS_ERR(tfm)) {
+			tfm = NULL;
+#else
 		conn->rx_hash.tfm = crypto_alloc_hash("crc32c", 0,
 						      CRYPTO_ALG_ASYNC);
 		conn->rx_hash.flags = 0;
 		if (IS_ERR(conn->rx_hash.tfm)) {
 			conn->rx_hash.tfm = NULL;
+#endif
 			err = -ENOMEM;
 			goto out;
 		}
-
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+		conn->rx_hash = ahash_request_alloc(tfm, GFP_KERNEL);
+		if (!conn->rx_hash) {
+			pr_err("ahash_request_alloc() failed for conn->rx_hash\n");
+			crypto_free_ahash(tfm);
+			err = -ENOMEM;
+			goto out;
+		}
+		ahash_request_set_callback(conn->rx_hash, 0, NULL, NULL);
+		conn->tx_hash = ahash_request_alloc(tfm, GFP_KERNEL);
+		if(!conn->tx_hash) {
+			pr_err("ahash_request_alloc() failed for conn->tx_hash\n");
+			ahash_request_free(conn->rx_hash);
+			conn->rx_hash = NULL;
+			crypto_free_ahash(tfm);
+			err = -ENOMEM;
+			goto out;
+		}
+		ahash_request_set_callback(conn->tx_hash, 0, NULL, NULL);
+#else
 		conn->tx_hash.tfm = crypto_alloc_hash("crc32c", 0,
 						      CRYPTO_ALG_ASYNC);
 		conn->tx_hash.flags = 0;
@@ -56,6 +84,7 @@ int digest_init(struct iscsi_conn *conn)
 			err = -ENOMEM;
 			goto out;
 		}
+#endif
 	}
 
 out:
@@ -73,10 +102,21 @@ out:
  */
 void digest_cleanup(struct iscsi_conn *conn)
 {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	ahash_request_free(conn->tx_hash);
+	if (conn->rx_hash) {
+		struct crypto_ahash *tfm;
+		tfm = crypto_ahash_reqtfm(conn->rx_hash);
+		ahash_request_free(conn->rx_hash);
+		crypto_free_ahash(tfm);
+	}
+
+#else
 	if (conn->tx_hash.tfm)
 		crypto_free_hash(conn->tx_hash.tfm);
 	if (conn->rx_hash.tfm)
 		crypto_free_hash(conn->rx_hash.tfm);
+#endif
 }
 
 /**
@@ -160,8 +200,13 @@ static inline void __dbg_simulate_data_d
 	}
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+static void digest_header(struct ahash_request *hash, struct iscsi_pdu *pdu,
+			  u8 *crc)
+#else
 static void digest_header(struct hash_desc *hash, struct iscsi_pdu *pdu,
 			  u8 *crc)
+#endif
 {
 	struct scatterlist sg[2];
 	unsigned int nbytes = sizeof(struct iscsi_hdr);
@@ -174,16 +219,27 @@ static void digest_header(struct hash_de
 		nbytes += pdu->ahssize;
 	}
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	crypto_ahash_init(hash);
+	ahash_request_set_crypt(hash, sg, crc, nbytes);
+	crypto_ahash_update(hash);
+	crypto_ahash_digest(hash);
+#else
 	crypto_hash_init(hash);
 	crypto_hash_update(hash, sg, nbytes);
 	crypto_hash_final(hash, crc);
+#endif
 }
 
 int digest_rx_header(struct iscsi_cmnd *cmnd)
 {
 	u32 crc;
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	digest_header(cmnd->conn->rx_hash, &cmnd->pdu, (u8 *) &crc);
+#else
 	digest_header(&cmnd->conn->rx_hash, &cmnd->pdu, (u8 *) &crc);
+#endif
 	if (crc != cmnd->hdigest)
 		return -EIO;
 
@@ -192,11 +248,20 @@ int digest_rx_header(struct iscsi_cmnd *
 
 void digest_tx_header(struct iscsi_cmnd *cmnd)
 {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	digest_header(cmnd->conn->tx_hash, &cmnd->pdu, (u8 *) &cmnd->hdigest);
+#else
 	digest_header(&cmnd->conn->tx_hash, &cmnd->pdu, (u8 *) &cmnd->hdigest);
+#endif
 }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+static void digest_data(struct ahash_request *hash, struct iscsi_cmnd *cmnd,
+			struct tio *tio, u32 offset, u8 *crc)
+#else
 static void digest_data(struct hash_desc *hash, struct iscsi_cmnd *cmnd,
 			struct tio *tio, u32 offset, u8 *crc)
+#endif
 {
 	struct scatterlist *sg = cmnd->conn->hash_sg;
 	u32 size, length, npages;
@@ -214,7 +279,11 @@ static void digest_data(struct hash_desc
 	BUG_ON(npages > ISCSI_CONN_IOV_MAX);
 
 	sg_init_table(sg, ARRAY_SIZE(cmnd->conn->hash_sg));
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	crypto_ahash_init(hash);
+#else
 	crypto_hash_init(hash);
+#endif
 
 	for (i = 0; size > 0; i++) {
 		length = min_t(u32, PAGE_CACHE_SIZE - offset, size);
@@ -225,8 +294,14 @@ static void digest_data(struct hash_desc
 
 	sg_mark_end(&sg[i - 1]);
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	ahash_request_set_crypt(hash, sg, crc, nbytes);
+	crypto_ahash_update(hash);
+	crypto_ahash_digest(hash);
+#else
 	crypto_hash_update(hash, sg, nbytes);
 	crypto_hash_final(hash, crc);
+#endif
 }
 
 int digest_rx_data(struct iscsi_cmnd *cmnd)
@@ -251,8 +326,11 @@ int digest_rx_data(struct iscsi_cmnd *cm
 		tio = cmnd->tio;
 		offset = 0;
 	}
-
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	digest_data(cmnd->conn->rx_hash, cmnd, tio, offset, (u8 *) &crc);
+#else
 	digest_data(&cmnd->conn->rx_hash, cmnd, tio, offset, (u8 *) &crc);
+#endif
 
 	if (!cmnd->conn->read_overflow &&
 	    (cmnd_opcode(cmnd) != ISCSI_OP_PDU_REJECT)) {
@@ -269,6 +347,11 @@ void digest_tx_data(struct iscsi_cmnd *c
 	struct iscsi_data_out_hdr *req = (struct iscsi_data_out_hdr *)&cmnd->pdu.bhs;
 
 	assert(tio);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	digest_data(cmnd->conn->tx_hash, cmnd, tio,
+		    be32_to_cpu(req->buffer_offset), (u8 *) &cmnd->ddigest);
+#else
 	digest_data(&cmnd->conn->tx_hash, cmnd, tio,
 		    be32_to_cpu(req->buffer_offset), (u8 *) &cmnd->ddigest);
+#endif
 }
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	2017-01-19 20:19:27.400507354 -0800
+++ iscsitarget-1.4.20.3+svn502/kernel/iscsi.h	2017-01-19 20:32:22.979988634 -0800
@@ -14,6 +14,7 @@
 #include <linux/pagemap.h>
 #include <linux/seq_file.h>
 #include <linux/mm.h>
+#include <crypto/hash.h>
 #include <linux/crypto.h>
 #include <linux/scatterlist.h>
 #include <net/sock.h>
@@ -275,8 +276,13 @@ struct iscsi_conn {
 	u32 write_offset;
 	int write_state;
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	struct ahash_request *rx_hash;
+	struct ahash_request *tx_hash;
+#else
 	struct hash_desc rx_hash;
 	struct hash_desc tx_hash;
+#endif
 	struct scatterlist hash_sg[ISCSI_CONN_IOV_MAX];
 };
 
@@ -552,4 +558,10 @@ enum cmnd_flags {
 #define PRODUCT_ID	"VIRTUAL-DISK"
 #define PRODUCT_REV	"0"
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+#define PAGE_CACHE_SHIFT	PAGE_SHIFT
+#define PAGE_CACHE_SIZE	PAGE_SIZE
+#define PAGE_CACHE_MASK	PAGE_MASK
+#endif
+
 #endif	/* __ISCSI_H__ */
diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/nthread.c iscsitarget-1.4.20.3+svn502/kernel/nthread.c
--- iscsitarget-1.4.20.3+svn502_org/kernel/nthread.c	2017-01-19 20:19:27.276504928 -0800
+++ iscsitarget-1.4.20.3+svn502/kernel/nthread.c	2017-01-19 20:32:22.979988634 -0800
@@ -155,7 +155,12 @@ static int do_recv(struct iscsi_conn *co
 
 	oldfs = get_fs();
 	set_fs(get_ds());
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	res = sock_recvmsg(conn->sock, (struct msghdr *) &msg, \
+				MSG_DONTWAIT | MSG_NOSIGNAL);
+#else
 	res = sock_recvmsg(conn->sock, &msg, len, MSG_DONTWAIT | MSG_NOSIGNAL);
+#endif
 	set_fs(oldfs);
 
 	if (res <= 0) {
@@ -376,7 +381,11 @@ static int write_data(struct iscsi_conn
 			;
 		oldfs = get_fs();
 		set_fs(KERNEL_DS);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+		res = vfs_writev(file, (struct iovec __user *) iop, count, &off, 0);
+#else
 		res = vfs_writev(file, (struct iovec __user *) iop, count, &off);
+#endif
 		set_fs(oldfs);
 		dprintk(D_DATA, "%#Lx:%u: %d(%ld)\n",
 			(unsigned long long) conn->session->sid, conn->cid,
@@ -503,7 +512,11 @@ static int tx_ddigest(struct iscsi_cmnd
 	iov.iov_base = (char *) (&cmnd->ddigest) + (sizeof(u32) - rest);
 	iov.iov_len = rest;
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	res = kernel_sendmsg(cmnd->conn->sock, (struct msghdr *) &msg, &iov, 1, rest);
+#else
 	res = kernel_sendmsg(cmnd->conn->sock, &msg, &iov, 1, rest);
+#endif
 
 	if (res > 0) {
 		cmnd->conn->write_size -= res;
@@ -702,7 +715,12 @@ static void close_conn(struct iscsi_conn
 
 	write_lock_bh(&conn->sock->sk->sk_callback_lock);
 	conn->sock->sk->sk_state_change = target->nthread_info.old_state_change;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	conn->sock->sk->sk_data_ready = (void (*) (struct sock *)) \
+					target->nthread_info.old_data_ready;
+#else
 	conn->sock->sk->sk_data_ready = target->nthread_info.old_data_ready;
+#endif
 	conn->sock->sk->sk_write_space = target->nthread_info.old_write_space;
 	write_unlock_bh(&conn->sock->sk->sk_callback_lock);
 
diff -Naurp iscsitarget-1.4.20.3+svn502_org/kernel/volume.c iscsitarget-1.4.20.3+svn502/kernel/volume.c
--- iscsitarget-1.4.20.3+svn502_org/kernel/volume.c	2017-01-19 20:19:27.276504928 -0800
+++ iscsitarget-1.4.20.3+svn502/kernel/volume.c	2017-01-19 20:32:22.979988634 -0800
@@ -84,12 +84,25 @@ static int set_scsisn(struct iet_volume
 /* Generate a MD5 hash of the target IQN and LUN number */
 static void gen_scsiid(struct iet_volume *volume)
 {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	struct ahash_request *hash;
+	struct crypto_ahash *tfm;
+#else
 	struct hash_desc hash;
+#endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	tfm = crypto_alloc_ahash("md5", 0, CRYPTO_ALG_ASYNC);
+#else
 	hash.tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC);
 	hash.flags = 0;
+#endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+	if (!IS_ERR(tfm)) {
+#else
 	if (!IS_ERR(hash.tfm)) {
+#endif
 		struct scatterlist sg[2];
 		unsigned int nbytes = 0;
 
@@ -102,11 +115,19 @@ static void gen_scsiid(struct iet_volume
 		sg_set_buf(&sg[1], &volume->lun, sizeof(volume->lun));
 		nbytes += sizeof(volume->lun);
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
+		crypto_ahash_init(hash);
+		ahash_request_set_crypt(hash, sg, volume->scsi_id, nbytes);
+		crypto_ahash_update(hash);
+		crypto_ahash_digest(hash);
+		crypto_free_ahash(tfm);
+#else
 		crypto_hash_init(&hash);
 		crypto_hash_update(&hash, sg, nbytes);
 		crypto_hash_final(&hash, volume->scsi_id);
 
 		crypto_free_hash(hash.tfm);
+#endif
 	} else {
 		/* If no MD5 available set ID to TID and LUN */
 		memcpy(volume->scsi_id, &volume->target->tid,
OpenPOWER on IntegriCloud