1 diff -ur lin_tape-3.0.18/intercept.c lin_tape-3.0.18-4.11/intercept.c
2 --- lin_tape-3.0.18/intercept.c 2017-02-23 19:14:41.000000000 +0100
3 +++ lin_tape-3.0.18-4.11/intercept.c 2017-05-10 00:35:27.637366919 +0200
5 #include <linux/init.h>
7 #include <scsi/scsi_driver.h>
8 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
9 +#include <scsi/scsi_transport.h>
14 @@ -1362,7 +1365,12 @@
15 if (pdev->fdev_num != -1) {
16 /* Only for fo devices */
17 /* This 'if' must match the one above in create unique */
18 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
19 + sdev->request_queue = blk_alloc_queue_node(GFP_KERNEL, NUMA_NO_NODE);
20 + __scsi_init_queue(sdev->host, sdev->request_queue);
22 sdev->request_queue = __scsi_alloc_queue(sdev->host, NULL);
26 /* set device hierachy so the new dummy dev
27 diff -ur lin_tape-3.0.18/lin_tape_ioctl_tape.c lin_tape-3.0.18-4.11/lin_tape_ioctl_tape.c
28 --- lin_tape-3.0.18/lin_tape_ioctl_tape.c 2017-05-10 00:36:01.952285733 +0200
29 +++ lin_tape-3.0.18-4.11/lin_tape_ioctl_tape.c 2017-05-09 21:45:14.236233622 +0200
30 @@ -6464,7 +6464,11 @@
33 tmp_rq = (void*)sdev->request_queue;
34 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
37 req->cmd_type = REQ_TYPE_BLOCK_PC;
39 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)
40 req->cmd_flags |= REQ_QUIET;
42 @@ -6536,17 +6540,29 @@
46 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
47 + scsi_req(req)->cmd_len = COMMAND_SIZE(cdb[0]);
48 + memset(scsi_req(req)->cmd, '\0', MAX_CDB_SIZE);
49 + memcpy(scsi_req(req)->cmd, cdb, scsi_req(req)->cmd_len);
50 + scsi_req(req)->sense = sense_data;
51 + scsi_req(req)->sense_len = 0;
53 req->cmd_len = COMMAND_SIZE(cdb[0]);
54 memset(req->cmd, '\0', MAX_CDB_SIZE);
55 memcpy(req->cmd, cdb, req->cmd_len);
56 req->sense = sense_data;
59 req->timeout = timeout;
62 blk_execute_rq(req->q, NULL, req, 1);
64 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
65 + *resid = scsi_req(req)->resid_len;
67 *resid = req->resid_len;
69 status_code = req->errors;
71 if(buf_len && !use_sg) {
72 diff -ur lin_tape-3.0.18/lin_tape_ioctl_tape.c.orig lin_tape-3.0.18-4.11/lin_tape_ioctl_tape.c.orig
73 --- lin_tape-3.0.18/lin_tape_ioctl_tape.c.orig 2017-02-23 19:14:41.000000000 +0100
74 +++ lin_tape-3.0.18-4.11/lin_tape_ioctl_tape.c.orig 2017-05-09 21:45:14.232900215 +0200
75 @@ -6465,7 +6465,11 @@
77 tmp_rq = (void*)sdev->request_queue;
78 req->cmd_type = REQ_TYPE_BLOCK_PC;
79 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)
80 req->cmd_flags |= REQ_QUIET;
82 + req->cmd_flags |= RQF_QUIET;
86 mdata = kmalloc(sizeof(struct rq_map_data), GFP_KERNEL);
87 diff -ur lin_tape-3.0.18/lin_tape_tape.h lin_tape-3.0.18-4.11/lin_tape_tape.h
88 --- lin_tape-3.0.18/lin_tape_tape.h 2017-02-23 19:14:41.000000000 +0100
89 +++ lin_tape-3.0.18-4.11/lin_tape_tape.h 2017-05-09 21:45:14.236233622 +0200
91 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9)
92 #define KOBJ_CT(kobj) ((kobj) ? atomic_read(&(kobj)->refcount) : 0)
94 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0)
95 #define KOBJ_CT(kobj) ((kobj) ? atomic_read(&(kobj)->kref.refcount) : 0)
97 +#define KOBJ_CT(kobj) ((kobj) ? kref_read(&(kobj)->kref) : 0)
101 /* global definitions */
102 diff -ur lin_tape-3.0.18/lower.c lin_tape-3.0.18-4.11/lower.c
103 --- lin_tape-3.0.18/lower.c 2017-02-23 19:14:41.000000000 +0100
104 +++ lin_tape-3.0.18-4.11/lower.c 2017-05-10 00:21:19.106042388 +0200
106 /* Local function prototypes */
107 static int lower_scsi_execute(struct scsi_device *sdev,
108 struct apfo_scsi_command *pfo_cmd,
109 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
110 + unsigned char *local_raw_sense, struct scsi_sense_hdr *sshdr);
112 unsigned char *local_raw_sense);
115 /** Look at the errors from the SCSI command,
116 * translate them to OS independent values.
117 @@ -267,11 +271,20 @@
118 /* SCSI Command from decide code */
119 result = scsi_execute(sdev, pfo_cmd->scsi_cmd,
120 pfo_cmd->data_direction, pfo_cmd->buffer,
121 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0)
122 pfo_cmd->bufflen, local_raw_sense, pfo_cmd->timeout,
123 pfo_cmd->retries, pfo_cmd->flags, &pfo_cmd->resid_len);
125 + pfo_cmd->bufflen, local_raw_sense, &local_sense_data, pfo_cmd->timeout,
126 + pfo_cmd->retries, pfo_cmd->flags, 0, &pfo_cmd->resid_len);
129 /* SCSI Command from user space */
130 +#if LINUX_VERSION_CODE < KERNEL_VERSION(4,11,0)
131 result = lower_scsi_execute(sdev, pfo_cmd, local_raw_sense);
133 + result = lower_scsi_execute(sdev, pfo_cmd, local_raw_sense, &local_sense_data);
136 /* Release this path */
137 scsi_device_put(sdev);
140 static int lower_scsi_execute(struct scsi_device *sdev,
141 struct apfo_scsi_command *pfo_cmd,
142 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
143 + unsigned char *local_raw_sense, struct scsi_sense_hdr *sshdr) {
145 unsigned char *local_raw_sense) {
151 return DRIVER_ERROR << 24;
154 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
157 rq->cmd_type = REQ_TYPE_BLOCK_PC;
159 rq->cmd_flags |= pfo_cmd->flags;
161 if ((pfo_cmd->bufflen > 0) && (pfo_cmd->data_direction != DMA_NONE)) {
162 @@ -533,11 +554,19 @@
166 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
167 + scsi_req(rq)->cmd_len = pfo_cmd->cmd_len;
168 + memset(scsi_req(rq)->cmd, 0, BLK_MAX_CDB);
169 + memcpy(scsi_req(rq)->cmd, pfo_cmd->scsi_cmd, pfo_cmd->cmd_len);
170 + scsi_req(rq)->sense = local_raw_sense;
171 + scsi_req(rq)->sense_len = 0;
173 rq->cmd_len = pfo_cmd->cmd_len;
174 memset(rq->cmd, 0, BLK_MAX_CDB);
175 memcpy(rq->cmd, pfo_cmd->scsi_cmd, pfo_cmd->cmd_len);
176 rq->sense = local_raw_sense;
179 rq->timeout = pfo_cmd->timeout;
180 rq->retries = pfo_cmd->retries;
181 rq->end_io_data = pfo_cmd;
183 DBG_ERROR("unmap returns: %d\n", err);
186 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
187 + pfo_cmd->resid_len = scsi_req(rq)->resid_len;
188 + pfo_cmd->sense_len = scsi_req(rq)->sense_len;
190 + scsi_normalize_sense(scsi_req(rq)->sense, scsi_req(rq)->sense_len, sshdr);
192 pfo_cmd->resid_len = rq->resid_len;
193 pfo_cmd->sense_len = rq->sense_len;
195 pfo_cmd->errors = rq->errors;
198 diff -ur lin_tape-3.0.18/stmp.c lin_tape-3.0.18-4.11/stmp.c
199 --- lin_tape-3.0.18/stmp.c 2017-05-10 00:36:01.955619894 +0200
200 +++ lin_tape-3.0.18-4.11/stmp.c 2017-05-09 21:45:14.236233622 +0200
203 return DRIVER_ERROR << 24;
205 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)
206 + scsi_req_init(req);
208 req->cmd_type = REQ_TYPE_BLOCK_PC;
210 #if LINUX_VERSION_CODE < KERNEL_VERSION(4,10,0)
211 req->cmd_flags |= REQ_QUIET;