~ubuntu-branches/ubuntu/precise/open-iscsi/precise-backports

« back to all changes in this revision

Viewing changes to kernel/2.6.28-32_compat.patch

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2013-09-20 09:07:42 UTC
  • mfrom: (37.1.5 quantal-proposed)
  • Revision ID: package-import@ubuntu.com-20130920090742-rv5qfxabddc9dk2h
Tags: 2.0.873-3ubuntu5~ubuntu12.04.1
No-change backport to precise (LP: #1228046)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
diff --git a/iscsi_tcp.c b/iscsi_tcp.c
 
2
index 2a401b9..197d314 100644
 
3
--- a/iscsi_tcp.c
 
4
+++ b/iscsi_tcp.c
 
5
@@ -43,6 +43,7 @@
 
6
 #include <scsi/scsi.h>
 
7
 #include "scsi_transport_iscsi.h"
 
8
 
 
9
+#include "open_iscsi_compat.h"
 
10
 #include "iscsi_tcp.h"
 
11
 
 
12
 MODULE_AUTHOR("Mike Christie <michaelc@cs.wisc.edu>, "
 
13
diff --git a/libiscsi.c b/libiscsi.c
 
14
index 59e3a5f..b79453a 100644
 
15
--- a/libiscsi.c
 
16
+++ b/libiscsi.c
 
17
@@ -518,7 +518,7 @@ static void iscsi_free_task(struct iscsi_task *task)
 
18
        if (conn->login_task == task)
 
19
                return;
 
20
 
 
21
-       kfifo_in(&session->cmdpool.queue, (void*)&task, sizeof(void*));
 
22
+       __kfifo_put(session->cmdpool.queue, (void*)&task, sizeof(void*));
 
23
 
 
24
        if (sc) {
 
25
                task->sc = NULL;
 
26
@@ -738,7 +738,7 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
 
27
                BUG_ON(conn->c_stage == ISCSI_CONN_INITIAL_STAGE);
 
28
                BUG_ON(conn->c_stage == ISCSI_CONN_STOPPED);
 
29
 
 
30
-               if (!kfifo_out(&session->cmdpool.queue,
 
31
+               if (!__kfifo_get(session->cmdpool.queue,
 
32
                                 (void*)&task, sizeof(void*)))
 
33
                        return NULL;
 
34
        }
 
35
@@ -1568,7 +1568,7 @@ static inline struct iscsi_task *iscsi_alloc_task(struct iscsi_conn *conn,
 
36
 {
 
37
        struct iscsi_task *task;
 
38
 
 
39
-       if (!kfifo_out(&conn->session->cmdpool.queue,
 
40
+       if (!__kfifo_get(conn->session->cmdpool.queue,
 
41
                         (void *) &task, sizeof(void *)))
 
42
                return NULL;
 
43
 
 
44
@@ -1738,21 +1738,9 @@ fault:
 
45
 }
 
46
 EXPORT_SYMBOL_GPL(iscsi_queuecommand);
 
47
 
 
48
-int iscsi_change_queue_depth(struct scsi_device *sdev, int depth, int reason)
 
49
+int iscsi_change_queue_depth(struct scsi_device *sdev, int depth)
 
50
 {
 
51
-       switch (reason) {
 
52
-       case SCSI_QDEPTH_DEFAULT:
 
53
-               scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth);
 
54
-               break;
 
55
-       case SCSI_QDEPTH_QFULL:
 
56
-               scsi_track_queue_full(sdev, depth);
 
57
-               break;
 
58
-       case SCSI_QDEPTH_RAMP_UP:
 
59
-               scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth);
 
60
-               break;
 
61
-       default:
 
62
-               return -EOPNOTSUPP;
 
63
-       }
 
64
+       scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth);
 
65
        return sdev->queue_depth;
 
66
 }
 
67
 EXPORT_SYMBOL_GPL(iscsi_change_queue_depth);
 
68
@@ -2524,7 +2512,12 @@ iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size)
 
69
        if (q->pool == NULL)
 
70
                return -ENOMEM;
 
71
 
 
72
-       kfifo_init(&q->queue, (void*)q->pool, max * sizeof(void*));
 
73
+       q->queue = kfifo_init((void*)q->pool, max * sizeof(void*),
 
74
+                             GFP_KERNEL, NULL);
 
75
+       if (IS_ERR(q->queue)) {
 
76
+               q->queue = NULL;
 
77
+               goto enomem;
 
78
+       }
 
79
 
 
80
        for (i = 0; i < max; i++) {
 
81
                q->pool[i] = kzalloc(item_size, GFP_KERNEL);
 
82
@@ -2532,7 +2525,7 @@ iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size)
 
83
                        q->max = i;
 
84
                        goto enomem;
 
85
                }
 
86
-               kfifo_in(&q->queue, (void*)&q->pool[i], sizeof(void*));
 
87
+               __kfifo_put(q->queue, (void*)&q->pool[i], sizeof(void*));
 
88
        }
 
89
 
 
90
        if (items) {
 
91
@@ -2555,6 +2548,7 @@ void iscsi_pool_free(struct iscsi_pool *q)
 
92
        for (i = 0; i < q->max; i++)
 
93
                kfree(q->pool[i]);
 
94
        kfree(q->pool);
 
95
+       kfree(q->queue);
 
96
 }
 
97
 EXPORT_SYMBOL_GPL(iscsi_pool_free);
 
98
 
 
99
@@ -2882,7 +2876,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
 
100
 
 
101
        /* allocate login_task used for the login/text sequences */
 
102
        spin_lock_bh(&session->lock);
 
103
-       if (!kfifo_out(&session->cmdpool.queue,
 
104
+       if (!__kfifo_get(session->cmdpool.queue,
 
105
                          (void*)&conn->login_task,
 
106
                         sizeof(void*))) {
 
107
                spin_unlock_bh(&session->lock);
 
108
@@ -2902,7 +2896,7 @@ iscsi_conn_setup(struct iscsi_cls_session *cls_session, int dd_size,
 
109
        return cls_conn;
 
110
 
 
111
 login_task_data_alloc_fail:
 
112
-       kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task,
 
113
+       __kfifo_put(session->cmdpool.queue, (void*)&conn->login_task,
 
114
                    sizeof(void*));
 
115
 login_task_alloc_fail:
 
116
        iscsi_destroy_conn(cls_conn);
 
117
@@ -2965,7 +2959,7 @@ void iscsi_conn_teardown(struct iscsi_cls_conn *cls_conn)
 
118
        free_pages((unsigned long) conn->data,
 
119
                   get_order(ISCSI_DEF_MAX_RECV_SEG_LEN));
 
120
        kfree(conn->persistent_address);
 
121
-       kfifo_in(&session->cmdpool.queue, (void*)&conn->login_task,
 
122
+       __kfifo_put(session->cmdpool.queue, (void*)&conn->login_task,
 
123
                    sizeof(void*));
 
124
        if (session->leadconn == conn)
 
125
                session->leadconn = NULL;
 
126
diff --git a/libiscsi.h b/libiscsi.h
 
127
index 0563539..4be9333 100644
 
128
--- a/libiscsi.h
 
129
+++ b/libiscsi.h
 
130
@@ -231,7 +231,7 @@ struct iscsi_conn {
 
131
 };
 
132
 
 
133
 struct iscsi_pool {
 
134
-       struct kfifo            queue;          /* FIFO Queue */
 
135
+       struct kfifo            *queue;         /* FIFO Queue */
 
136
        void                    **pool;         /* Pool of elements */
 
137
        int                     max;            /* Max number of elements */
 
138
 };
 
139
@@ -334,8 +334,7 @@ struct iscsi_host {
 
140
 /*
 
141
  * scsi host template
 
142
  */
 
143
-extern int iscsi_change_queue_depth(struct scsi_device *sdev, int depth,
 
144
-                                   int reason);
 
145
+extern int iscsi_change_queue_depth(struct scsi_device *sdev, int depth);
 
146
 extern int iscsi_eh_abort(struct scsi_cmnd *sc);
 
147
 extern int iscsi_eh_recover_target(struct scsi_cmnd *sc);
 
148
 extern int iscsi_eh_session_reset(struct scsi_cmnd *sc);
 
149
diff --git a/libiscsi_tcp.c b/libiscsi_tcp.c
 
150
index 1122de4..c3ff728 100644
 
151
--- a/libiscsi_tcp.c
 
152
+++ b/libiscsi_tcp.c
 
153
@@ -446,15 +446,15 @@ void iscsi_tcp_cleanup_task(struct iscsi_task *task)
 
154
                return;
 
155
 
 
156
        /* flush task's r2t queues */
 
157
-       while (kfifo_out(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*))) {
 
158
-               kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t,
 
159
+       while (__kfifo_get(tcp_task->r2tqueue, (void*)&r2t, sizeof(void*))) {
 
160
+               __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t,
 
161
                            sizeof(void*));
 
162
                ISCSI_DBG_TCP(task->conn, "pending r2t dropped\n");
 
163
        }
 
164
 
 
165
        r2t = tcp_task->r2t;
 
166
        if (r2t != NULL) {
 
167
-               kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t,
 
168
+               __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t,
 
169
                            sizeof(void*));
 
170
                tcp_task->r2t = NULL;
 
171
        }
 
172
@@ -542,7 +542,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
 
173
                return 0;
 
174
        }
 
175
 
 
176
-       rc = kfifo_out(&tcp_task->r2tpool.queue, (void*)&r2t, sizeof(void*));
 
177
+       rc = __kfifo_get(tcp_task->r2tpool.queue, (void*)&r2t, sizeof(void*));
 
178
        if (!rc) {
 
179
                iscsi_conn_printk(KERN_ERR, conn, "Could not allocate R2T. "
 
180
                                  "Target has sent more R2Ts than it "
 
181
@@ -555,7 +555,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
 
182
        if (r2t->data_length == 0) {
 
183
                iscsi_conn_printk(KERN_ERR, conn,
 
184
                                  "invalid R2T with zero data len\n");
 
185
-               kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t,
 
186
+               __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t,
 
187
                            sizeof(void*));
 
188
                return ISCSI_ERR_DATALEN;
 
189
        }
 
190
@@ -571,7 +571,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
 
191
                                  "invalid R2T with data len %u at offset %u "
 
192
                                  "and total length %d\n", r2t->data_length,
 
193
                                  r2t->data_offset, scsi_out(task->sc)->length);
 
194
-               kfifo_in(&tcp_task->r2tpool.queue, (void*)&r2t,
 
195
+               __kfifo_put(tcp_task->r2tpool.queue, (void*)&r2t,
 
196
                            sizeof(void*));
 
197
                return ISCSI_ERR_DATALEN;
 
198
        }
 
199
@@ -581,7 +581,7 @@ static int iscsi_tcp_r2t_rsp(struct iscsi_conn *conn, struct iscsi_task *task)
 
200
        r2t->sent = 0;
 
201
 
 
202
        tcp_task->exp_datasn = r2tsn + 1;
 
203
-       kfifo_in(&tcp_task->r2tqueue, (void*)&r2t, sizeof(void*));
 
204
+       __kfifo_put(tcp_task->r2tqueue, (void*)&r2t, sizeof(void*));
 
205
        conn->r2t_pdus_cnt++;
 
206
 
 
207
        iscsi_requeue_task(task);
 
208
@@ -952,7 +952,7 @@ int iscsi_tcp_task_init(struct iscsi_task *task)
 
209
                return conn->session->tt->init_pdu(task, 0, task->data_count);
 
210
        }
 
211
 
 
212
-       BUG_ON(kfifo_len(&tcp_task->r2tqueue));
 
213
+       BUG_ON(__kfifo_len(tcp_task->r2tqueue));
 
214
        tcp_task->exp_datasn = 0;
 
215
 
 
216
        /* Prepare PDU, optionally w/ immediate data */
 
217
@@ -983,7 +983,7 @@ static struct iscsi_r2t_info *iscsi_tcp_get_curr_r2t(struct iscsi_task *task)
 
218
                        if (r2t->data_length <= r2t->sent) {
 
219
                                ISCSI_DBG_TCP(task->conn,
 
220
                                              "  done with r2t %p\n", r2t);
 
221
-                               kfifo_in(&tcp_task->r2tpool.queue,
 
222
+                               __kfifo_put(tcp_task->r2tpool.queue,
 
223
                                            (void *)&tcp_task->r2t,
 
224
                                            sizeof(void *));
 
225
                                tcp_task->r2t = r2t = NULL;
 
226
@@ -991,12 +991,9 @@ static struct iscsi_r2t_info *iscsi_tcp_get_curr_r2t(struct iscsi_task *task)
 
227
                }
 
228
 
 
229
                if (r2t == NULL) {
 
230
-                       if (kfifo_out(&tcp_task->r2tqueue,
 
231
-                           (void *)&tcp_task->r2t, sizeof(void *)) !=
 
232
-                           sizeof(void *))
 
233
-                               r2t = NULL;
 
234
-                       else
 
235
-                               r2t = tcp_task->r2t;
 
236
+                       __kfifo_get(tcp_task->r2tqueue,
 
237
+                                   (void *)&tcp_task->r2t, sizeof(void *));
 
238
+                       r2t = tcp_task->r2t;
 
239
                }
 
240
                spin_unlock_bh(&session->lock);
 
241
        }
 
242
@@ -1131,8 +1128,9 @@ int iscsi_tcp_r2tpool_alloc(struct iscsi_session *session)
 
243
                }
 
244
 
 
245
                /* R2T xmit queue */
 
246
-               if (kfifo_alloc(&tcp_task->r2tqueue,
 
247
-                     session->max_r2t * 4 * sizeof(void*), GFP_KERNEL)) {
 
248
+               tcp_task->r2tqueue = kfifo_alloc(
 
249
+                     session->max_r2t * 4 * sizeof(void*), GFP_KERNEL, NULL);
 
250
+               if (tcp_task->r2tqueue == ERR_PTR(-ENOMEM)) {
 
251
                        iscsi_pool_free(&tcp_task->r2tpool);
 
252
                        goto r2t_alloc_fail;
 
253
                }
 
254
@@ -1145,7 +1143,7 @@ r2t_alloc_fail:
 
255
                struct iscsi_task *task = session->cmds[i];
 
256
                struct iscsi_tcp_task *tcp_task = task->dd_data;
 
257
 
 
258
-               kfifo_free(&tcp_task->r2tqueue);
 
259
+               kfifo_free(tcp_task->r2tqueue);
 
260
                iscsi_pool_free(&tcp_task->r2tpool);
 
261
        }
 
262
        return -ENOMEM;
 
263
@@ -1160,7 +1158,7 @@ void iscsi_tcp_r2tpool_free(struct iscsi_session *session)
 
264
                struct iscsi_task *task = session->cmds[i];
 
265
                struct iscsi_tcp_task *tcp_task = task->dd_data;
 
266
 
 
267
-               kfifo_free(&tcp_task->r2tqueue);
 
268
+               kfifo_free(tcp_task->r2tqueue);
 
269
                iscsi_pool_free(&tcp_task->r2tpool);
 
270
        }
 
271
 }
 
272
diff --git a/libiscsi_tcp.h b/libiscsi_tcp.h
 
273
index c020eee..3bacef5 100644
 
274
--- a/libiscsi_tcp.h
 
275
+++ b/libiscsi_tcp.h
 
276
@@ -80,7 +80,7 @@ struct iscsi_tcp_task {
 
277
        int                     data_offset;
 
278
        struct iscsi_r2t_info   *r2t;           /* in progress solict R2T */
 
279
        struct iscsi_pool       r2tpool;
 
280
-       struct kfifo            r2tqueue;
 
281
+       struct kfifo            *r2tqueue;
 
282
        void                    *dd_data;
 
283
 };
 
284
 
 
285
diff --git a/open_iscsi_compat.h b/open_iscsi_compat.h
 
286
new file mode 100644
 
287
index 0000000..50ab84d
 
288
--- /dev/null
 
289
+++ b/open_iscsi_compat.h
 
290
@@ -0,0 +1,276 @@
 
291
+#include <linux/version.h>
 
292
+#include <linux/kernel.h>
 
293
+#include <scsi/scsi.h>
 
294
+#include <scsi/scsi_cmnd.h>
 
295
+
 
296
+#ifndef OPEN_ISCSI_COMPAT
 
297
+#define OPEN_ISCSI_COMPAT
 
298
+
 
299
+#ifndef SCAN_WILD_CARD
 
300
+#define SCAN_WILD_CARD  ~0
 
301
+#endif
 
302
+
 
303
+#ifndef NIPQUAD_FMT
 
304
+#define NIPQUAD_FMT "%u.%u.%u.%u"
 
305
+#endif
 
306
+
 
307
+#ifndef NIP6_FMT
 
308
+#define NIP6_FMT "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x"
 
309
+#endif
 
310
+
 
311
+#ifndef DEFINE_MUTEX
 
312
+
 
313
+/* mutex changes from 2.6.16-rc1 and up */
 
314
+#define DEFINE_MUTEX DECLARE_MUTEX
 
315
+#define mutex_lock down
 
316
+#define mutex_unlock up
 
317
+#define mutex semaphore
 
318
+#define mutex_init init_MUTEX
 
319
+#endif
 
320
+
 
321
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,12)
 
322
+
 
323
+void int_to_scsilun(unsigned int lun, struct scsi_lun *scsilun)
 
324
+{
 
325
+       int i;
 
326
+
 
327
+       memset(scsilun->scsi_lun, 0, sizeof(scsilun->scsi_lun));
 
328
+
 
329
+       for (i = 0; i < sizeof(lun); i += 2) {
 
330
+               scsilun->scsi_lun[i] = (lun >> 8) & 0xFF;
 
331
+               scsilun->scsi_lun[i+1] = lun & 0xFF;
 
332
+               lun = lun >> 16;
 
333
+       }
 
334
+}
 
335
+
 
336
+#define __nlmsg_put(skb, daemon_pid, seq, type, len, flags) \
 
337
+       __nlmsg_put(skb, daemon_pid, 0, 0, len)
 
338
+
 
339
+#endif
 
340
+
 
341
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)
 
342
+
 
343
+#define gfp_t unsigned
 
344
+
 
345
+void *kzalloc(size_t size, gfp_t flags)
 
346
+{
 
347
+       void *ret = kmalloc(size, flags);
 
348
+       if (ret)
 
349
+               memset(ret, 0, size);
 
350
+}
 
351
+
 
352
+#endif
 
353
+
 
354
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
 
355
+
 
356
+#include "linux/crypto.h"
 
357
+
 
358
+#define CRYPTO_ALG_ASYNC               0x00000080
 
359
+struct hash_desc
 
360
+{
 
361
+       struct crypto_tfm *tfm;
 
362
+       u32 flags;
 
363
+};
 
364
+
 
365
+static inline int crypto_hash_init(struct hash_desc *desc)
 
366
+{
 
367
+       crypto_digest_init(desc->tfm);
 
368
+       return 0;
 
369
+}
 
370
+
 
371
+static inline int crypto_hash_digest(struct hash_desc *desc,
 
372
+                                    struct scatterlist *sg,
 
373
+                                    unsigned int nbytes, u8 *out)
 
374
+{
 
375
+       crypto_digest_digest(desc->tfm, sg, 1, out);
 
376
+       return nbytes;
 
377
+}
 
378
+
 
379
+static inline int crypto_hash_update(struct hash_desc *desc,
 
380
+                                    struct scatterlist *sg,
 
381
+                                    unsigned int nbytes)
 
382
+{
 
383
+       crypto_digest_update(desc->tfm, sg, 1);
 
384
+       return nbytes;
 
385
+}
 
386
+
 
387
+static inline int crypto_hash_final(struct hash_desc *desc, u8 *out)
 
388
+{
 
389
+       crypto_digest_final(desc->tfm, out);
 
390
+       return 0;
 
391
+}
 
392
+
 
393
+static inline struct crypto_tfm *crypto_alloc_hash(const char *alg_name,
 
394
+                                                   u32 type, u32 mask)
 
395
+{
 
396
+       struct crypto_tfm *ret = crypto_alloc_tfm(alg_name ,type);
 
397
+       return ret ? ret : ERR_PTR(-ENOMEM);
 
398
+}
 
399
+
 
400
+static inline void crypto_free_hash(struct crypto_tfm *tfm)
 
401
+{
 
402
+       crypto_free_tfm(tfm);
 
403
+}
 
404
+
 
405
+int kernel_getsockname(struct socket *sock, struct sockaddr *addr,
 
406
+                       int *addrlen)
 
407
+{
 
408
+       return sock->ops->getname(sock, addr, addrlen, 0);
 
409
+}
 
410
+
 
411
+int kernel_getpeername(struct socket *sock, struct sockaddr *addr,
 
412
+                       int *addrlen)
 
413
+{
 
414
+       return sock->ops->getname(sock, addr, addrlen, 1);
 
415
+}
 
416
+
 
417
+#endif
 
418
+
 
419
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,20)
 
420
+
 
421
+static inline int is_power_of_2(unsigned long n)
 
422
+{
 
423
+       return (n != 0 && ((n & (n - 1)) == 0));
 
424
+}
 
425
+#endif
 
426
+
 
427
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21)
 
428
+
 
429
+static inline struct nlmsghdr *nlmsg_hdr(const struct sk_buff *skb)
 
430
+{
 
431
+       return (struct nlmsghdr *)skb->data;
 
432
+}
 
433
+
 
434
+#endif
 
435
+
 
436
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,22)
 
437
+
 
438
+static inline void *shost_priv(struct Scsi_Host *shost)
 
439
+{
 
440
+       return (void *)shost->hostdata;
 
441
+}
 
442
+
 
443
+/*
 
444
+ * Note: We do not support bidi for the compat modules if the kernel
 
445
+ * does not have support.
 
446
+ */
 
447
+#define scsi_sg_count(cmd) ((cmd)->use_sg)
 
448
+#define scsi_sglist(cmd) ((struct scatterlist *)(cmd)->request_buffer)
 
449
+#define scsi_bufflen(cmd) ((cmd)->request_bufflen)
 
450
+
 
451
+static inline void scsi_set_resid(struct scsi_cmnd *cmd, int resid)
 
452
+{
 
453
+       cmd->resid = resid;
 
454
+}
 
455
+
 
456
+static inline int scsi_get_resid(struct scsi_cmnd *cmd)
 
457
+{
 
458
+       return cmd->resid;
 
459
+}
 
460
+
 
461
+#endif
 
462
+
 
463
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)
 
464
+
 
465
+static inline unsigned long rounddown_pow_of_two(unsigned long n)
 
466
+{
 
467
+       return 1UL << (fls_long(n) - 1);
 
468
+}
 
469
+
 
470
+
 
471
+static inline struct scatterlist *sg_next(struct scatterlist *sg)
 
472
+{
 
473
+       if (!sg) {
 
474
+               BUG();
 
475
+               return NULL;
 
476
+       }
 
477
+       return sg + 1;
 
478
+}
 
479
+
 
480
+#define for_each_sg(sglist, sg, nr, __i)        \
 
481
+       for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg))
 
482
+
 
483
+#define sg_page(_sg) _sg->page
 
484
+
 
485
+static inline void sg_set_page(struct scatterlist *sg, struct page *page,
 
486
+                               unsigned int len, unsigned int offset)
 
487
+{
 
488
+       sg->page = page;
 
489
+       sg->offset = offset;
 
490
+       sg->length = len;
 
491
+}
 
492
+
 
493
+static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents)
 
494
+{
 
495
+       memset(sgl, 0, sizeof(*sgl) * nents);
 
496
+}
 
497
+#endif
 
498
+
 
499
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,24)
 
500
+
 
501
+static inline int scsi_bidi_cmnd(struct scsi_cmnd *cmd)
 
502
+{
 
503
+       return 0;
 
504
+}
 
505
+
 
506
+#define netlink_kernel_release(_nls) \
 
507
+       sock_release(_nls->sk_socket)
 
508
+
 
509
+
 
510
+#endif
 
511
+
 
512
+
 
513
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,13)
 
514
+
 
515
+#define netlink_kernel_create(net, uint, groups, input, cb_mutex, mod) \
 
516
+       netlink_kernel_create(uint, input)
 
517
+
 
518
+#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21)
 
519
+
 
520
+#define netlink_kernel_create(net, uint, groups, input, cb_mutex, mod) \
 
521
+       netlink_kernel_create(uint, groups, input, mod)
 
522
+
 
523
+#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,22)
 
524
+
 
525
+#define netlink_kernel_create(net, uint, groups, input, cb_mutex, mod) \
 
526
+       netlink_kernel_create(uint, groups, input, cb_mutex, mod)
 
527
+
 
528
+#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)
 
529
+
 
530
+#define netlink_kernel_create(net, uint, groups, input, cb_mutex, mod) \
 
531
+       netlink_kernel_create(uint, groups, input, cb_mutex, mod)
 
532
+
 
533
+#endif
 
534
+
 
535
+#ifndef DID_TRANSPORT_DISRUPTED
 
536
+#define DID_TRANSPORT_DISRUPTED DID_BUS_BUSY
 
537
+#endif
 
538
+
 
539
+#ifndef DID_TRANSPORT_FAILFAST
 
540
+#define DID_TRANSPORT_FAILFAST DID_NO_CONNECT
 
541
+#endif
 
542
+
 
543
+#ifndef SCSI_MLQUEUE_TARGET_BUSY
 
544
+#define SCSI_MLQUEUE_TARGET_BUSY SCSI_MLQUEUE_HOST_BUSY
 
545
+#endif
 
546
+
 
547
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27)
 
548
+
 
549
+#define BLK_EH_NOT_HANDLED EH_NOT_HANDLED
 
550
+#define BLK_EH_RESET_TIMER EH_RESET_TIMER
 
551
+
 
552
+#define blk_eh_timer_return scsi_eh_timer_return
 
553
+
 
554
+#endif
 
555
+
 
556
+
 
557
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34)
 
558
+
 
559
+static inline wait_queue_head_t *sk_sleep(struct sock *sk)
 
560
+{
 
561
+       return sk->sk_sleep;
 
562
+}
 
563
+
 
564
+#endif
 
565
+
 
566
+#endif
 
567
-- 
 
568
1.6.6.1
 
569