- Update for 2.6.28
[mirror/scst/.git] / scst / kernel / scst_exec_req_fifo-2.6.28.patch
1 diff -upr linux-2.6.28/drivers/scsi/scsi_lib.c linux-2.6.28/drivers/scsi/scsi_lib.c
2 --- linux-2.6.28/drivers/scsi/scsi_lib.c        2008-07-14 01:51:29.000000000 +0400
3 +++ linux-2.6.28/drivers/scsi/scsi_lib.c        2008-07-31 21:20:00.000000000 +0400
4 @@ -380,7 +380,7 @@ free_bios:
5  }
6  
7  /**
8 - * scsi_execute_async - insert request
9 + * __scsi_execute_async - insert request
10   * @sdev:      scsi device
11   * @cmd:       scsi command
12   * @cmd_len:   length of scsi cdb
13 @@ -393,11 +393,14 @@ free_bios:
14   * @privdata:  data passed to done()
15   * @done:      callback function when done
16   * @gfp:       memory allocation flags
17 + * @at_head:   insert request at head or tail of queue
18   */
19 -int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd,
20 +static inline int __scsi_execute_async(struct scsi_device *sdev,
21 +                      const unsigned char *cmd,
22                        int cmd_len, int data_direction, void *buffer, unsigned bufflen,
23                        int use_sg, int timeout, int retries, void *privdata,
24 -                      void (*done)(void *, char *, int, int), gfp_t gfp)
25 +                      void (*done)(void *, char *, int, int), gfp_t gfp,
26 +                      int at_head)
27  {
28         struct request *req;
29         struct scsi_io_context *sioc;
30 @@ -434,7 +439,7 @@ int scsi_execute_async(struct scsi_devic
31         sioc->data = privdata;
32         sioc->done = done;
33  
34 -       blk_execute_rq_nowait(req->q, NULL, req, 1, scsi_end_async);
35 +       blk_execute_rq_nowait(req->q, NULL, req, at_head, scsi_end_async);
36         return 0;
37  
38  free_req:
39 @@ -443,8 +446,55 @@ free_sense:
40         kmem_cache_free(scsi_io_context_cache, sioc);
41         return DRIVER_ERROR << 24;
42  }
43 +
44 +/**
45 + * scsi_execute_async - insert request
46 + * @sdev:      scsi device
47 + * @cmd:       scsi command
48 + * @cmd_len:   length of scsi cdb
49 + * @data_direction: data direction
50 + * @buffer:    data buffer (this can be a kernel buffer or scatterlist)
51 + * @bufflen:   len of buffer
52 + * @use_sg:    if buffer is a scatterlist this is the number of elements
53 + * @timeout:   request timeout in seconds
54 + * @retries:   number of times to retry request
55 + * @flags:     or into request flags
56 + **/
57 +int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd,
58 +                      int cmd_len, int data_direction, void *buffer,
59 +                      unsigned bufflen, int use_sg, int timeout,
60 +                      int retries, void *privdata,
61 +                      void (*done)(void *, char *, int, int), gfp_t gfp)
62 +{
63 +       return __scsi_execute_async(sdev, cmd, cmd_len, data_direction, buffer,
64 +               bufflen, use_sg, timeout, retries, privdata, done, gfp, 1);
65 +}
66  EXPORT_SYMBOL_GPL(scsi_execute_async);
67  
68 +/**
69 + * scsi_execute_async_fifo - insert request at tail, in FIFO order
70 + * @sdev:      scsi device
71 + * @cmd:       scsi command
72 + * @cmd_len:   length of scsi cdb
73 + * @data_direction: data direction
74 + * @buffer:    data buffer (this can be a kernel buffer or scatterlist)
75 + * @bufflen:   len of buffer
76 + * @use_sg:    if buffer is a scatterlist this is the number of elements
77 + * @timeout:   request timeout in seconds
78 + * @retries:   number of times to retry request
79 + * @flags:     or into request flags
80 + **/
81 +int scsi_execute_async_fifo(struct scsi_device *sdev, const unsigned char *cmd,
82 +                      int cmd_len, int data_direction, void *buffer,
83 +                      unsigned bufflen, int use_sg, int timeout, int retries,
84 +                      void *privdata,
85 +                      void (*done)(void *, char *, int, int), gfp_t gfp)
86 +{
87 +       return __scsi_execute_async(sdev, cmd, cmd_len, data_direction, buffer,
88 +               bufflen, use_sg, timeout, retries, privdata, done, gfp, 0);
89 +}
90 +EXPORT_SYMBOL_GPL(scsi_execute_async_fifo);
91 +
92  /*
93   * Function:    scsi_init_cmd_errh()
94   *
95 diff -upr linux-2.6.28/include/scsi/scsi_device.h linux-2.6.28/include/scsi/scsi_device.h
96 --- linux-2.6.28/include/scsi/scsi_device.h     2008-07-14 01:51:29.000000000 +0400
97 +++ linux-2.6.28/include/scsi/scsi_device.h     2008-07-31 21:20:39.000000000 +0400
98 @@ -377,6 +377,14 @@ extern int scsi_execute_async(struct scs
99                               int timeout, int retries, void *privdata,
100                               void (*done)(void *, char *, int, int),
101                               gfp_t gfp);
102 +#define SCSI_EXEC_REQ_FIFO_DEFINED
103 +extern int scsi_execute_async_fifo(struct scsi_device *sdev,
104 +                             const unsigned char *cmd, int cmd_len,
105 +                             int data_direction, void *buffer,
106 +                             unsigned bufflen, int use_sg,
107 +                             int timeout, int retries, void *privdata,
108 +                             void (*done)(void *, char *, int, int),
109 +                             gfp_t gfp);
110  
111  static inline int __must_check scsi_device_reprobe(struct scsi_device *sdev)
112  {