linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6.25.1] Add scsi_execute_async_fifo()
@ 2008-05-02 14:38 Bart Van Assche
  2008-05-02 15:33 ` Christoph Hellwig
  0 siblings, 1 reply; 36+ messages in thread
From: Bart Van Assche @ 2008-05-02 14:38 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, Vladislav Bolkhovitin, scst-devel

The patch below implements the following:
* Defines a new internal function __scsi_execute_async(). The only difference
  with the existing function scsi_execute_async() is that this new function
  has an extra parameter, at_head, which allows to specify whether to insert
  the new request at the head or at the tail of the queue.
* Replaces the implementation of scsi_execute_async() by a call to the new
  function __scsi_execute_async(). The behavior of this function is not
  changed.
* Defines a new function scsi_execute_async_fifo() which inserts a request at
  the tail, in FIFO order.
* Adds #define SCSI_EXEC_REQ_FIFO_DEFINED such that out-of-tree kernel
  modules can easily find out whether or not the new function
  scsi_execute_async_fifo() is present.

Signed-off-by: bart.vanassche@gmail.com


diff -uprN -X linux-2.6.25.1/Documentation/dontdiff 
orig/linux-2.6.25.1/drivers/scsi/scsi_lib.c 
linux-2.6.25.1/drivers/scsi/scsi_lib.c
--- orig/linux-2.6.25.1/drivers/scsi/scsi_lib.c	2008-05-01 23:45:25.000000000 
+0200
+++ linux-2.6.25.1/drivers/scsi/scsi_lib.c	2008-05-02 15:26:46.000000000 +0200
@@ -363,7 +363,7 @@ free_bios:
 }
 
 /**
- * scsi_execute_async - insert request
+ * __scsi_execute_async - insert request
  * @sdev:	scsi device
  * @cmd:	scsi command
  * @cmd_len:	length of scsi cdb
@@ -376,11 +376,14 @@ free_bios:
  * @privdata:	data passed to done()
  * @done:	callback function when done
  * @gfp:	memory allocation flags
+ * @at_head:	insert request at head or tail of queue
  */
-int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd,
+static inline int __scsi_execute_async(struct scsi_device *sdev,
+		       const unsigned char *cmd,
 		       int cmd_len, int data_direction, void *buffer, unsigned bufflen,
 		       int use_sg, int timeout, int retries, void *privdata,
-		       void (*done)(void *, char *, int, int), gfp_t gfp)
+		       void (*done)(void *, char *, int, int), gfp_t gfp,
+		       int at_head)
 {
 	struct request *req;
 	struct scsi_io_context *sioc;
@@ -417,7 +420,7 @@ int scsi_execute_async(struct scsi_devic
 	sioc->data = privdata;
 	sioc->done = done;
 
-	blk_execute_rq_nowait(req->q, NULL, req, 1, scsi_end_async);
+	blk_execute_rq_nowait(req->q, NULL, req, at_head, scsi_end_async);
 	return 0;
 
 free_req:
@@ -426,8 +429,57 @@ free_sense:
 	kmem_cache_free(scsi_io_context_cache, sioc);
 	return DRIVER_ERROR << 24;
 }
+
+/**
+ * scsi_execute_async - insert request
+ * @sdev:	scsi device
+ * @cmd:	scsi command
+ * @cmd_len:	length of scsi cdb
+ * @data_direction: data direction
+ * @buffer:	data buffer (this can be a kernel buffer or scatterlist)
+ * @bufflen:	len of buffer
+ * @use_sg:	if buffer is a scatterlist this is the number of elements
+ * @timeout:	request timeout in seconds
+ * @retries:	number of times to retry request
+ * @flags:	or into request flags
+ **/
+int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd,
+		       int cmd_len, int data_direction, void *buffer,
+		       unsigned bufflen, int use_sg, int timeout, int retries,
+		       void *privdata, void (*done)(void *, char *, int, int),
+		       gfp_t gfp)
+{
+	return __scsi_execute_async(sdev, cmd, cmd_len, data_direction, buffer,
+				    bufflen, use_sg, timeout, retries, privdata,
+				    done, gfp, 1);
+}
 EXPORT_SYMBOL_GPL(scsi_execute_async);
 
+/**
+ * scsi_execute_async_fifo - insert request at tail, in FIFO order
+ * @sdev:	scsi device
+ * @cmd:	scsi command
+ * @cmd_len:	length of scsi cdb
+ * @data_direction: data direction
+ * @buffer:	data buffer (this can be a kernel buffer or scatterlist)
+ * @bufflen:	len of buffer
+ * @use_sg:	if buffer is a scatterlist this is the number of elements
+ * @timeout:	request timeout in seconds
+ * @retries:	number of times to retry request
+ * @flags:	or into request flags
+ **/
+int scsi_execute_async_fifo(struct scsi_device *sdev, const unsigned char 
*cmd,
+			    int cmd_len, int data_direction, void *buffer,
+			    unsigned bufflen, int use_sg, int timeout,
+			    int retries, void *privdata,
+			    void (*done)(void *, char *, int, int), gfp_t gfp)
+{
+	return __scsi_execute_async(sdev, cmd, cmd_len, data_direction, buffer,
+				    bufflen, use_sg, timeout, retries, privdata,
+				    done, gfp, 0);
+}
+EXPORT_SYMBOL_GPL(scsi_execute_async_fifo);
+
 /*
  * Function:    scsi_init_cmd_errh()
  *
diff -uprN -X linux-2.6.25.1/Documentation/dontdiff 
orig/linux-2.6.25.1/include/scsi/scsi_device.h 
linux-2.6.25.1/include/scsi/scsi_device.h
--- orig/linux-2.6.25.1/include/scsi/scsi_device.h	2008-05-01 
23:45:25.000000000 +0200
+++ linux-2.6.25.1/include/scsi/scsi_device.h	2008-05-02 15:28:29.000000000 
+0200
@@ -332,6 +332,14 @@ extern int scsi_execute_async(struct scs
 			      int timeout, int retries, void *privdata,
 			      void (*done)(void *, char *, int, int),
 			      gfp_t gfp);
+#define SCSI_EXEC_REQ_FIFO_DEFINED
+extern int scsi_execute_async_fifo(struct scsi_device *sdev,
+				   const unsigned char *cmd, int cmd_len,
+				   int data_direction, void *buffer,
+				   unsigned bufflen, int use_sg,
+				   int timeout, int retries, void *privdata,
+				   void (*done)(void *, char *, int, int),
+				   gfp_t gfp);
 
 static inline int __must_check scsi_device_reprobe(struct scsi_device *sdev)
 {

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2008-05-14 16:49 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-02 14:38 [PATCH 2.6.25.1] Add scsi_execute_async_fifo() Bart Van Assche
2008-05-02 15:33 ` Christoph Hellwig
2008-05-02 15:53   ` Bart Van Assche
2008-05-02 15:55     ` Christoph Hellwig
2008-05-02 16:06       ` Bart Van Assche
2008-05-02 16:16         ` Matthew Wilcox
2008-05-02 16:23           ` Bart Van Assche
2008-05-02 16:30             ` James Bottomley
2008-05-02 16:43               ` Bart Van Assche
2008-05-02 16:49             ` Matthew Wilcox
2008-05-02 16:57               ` Bart Van Assche
2008-05-02 17:02                 ` Matthew Wilcox
2008-05-02 18:21                   ` Vladislav Bolkhovitin
2008-05-02 16:18         ` James Bottomley
2008-05-02 16:39           ` Bart Van Assche
2008-05-02 18:09           ` Vladislav Bolkhovitin
2008-05-02 18:17           ` SCSI target subsystem Vladislav Bolkhovitin
2008-05-03  9:41             ` Bart Van Assche
2008-05-03  9:53               ` Matthew Wilcox
2008-05-03 10:39                 ` Bart Van Assche
2008-05-03 13:28                   ` Matthew Wilcox
2008-05-03 14:48                     ` Bart Van Assche
2008-05-04 15:53                   ` Bart Van Assche
2008-05-04 11:35                 ` Vladislav Bolkhovitin
2008-05-04 15:23             ` Vladislav Bolkhovitin
2008-05-04 11:48       ` [PATCH 2.6.25.1] Add scsi_execute_async_fifo() Vladislav Bolkhovitin
2008-05-04 17:53         ` Boaz Harrosh
2008-05-13 16:48           ` Vladislav Bolkhovitin
2008-05-13 17:35             ` Boaz Harrosh
2008-05-14 15:58               ` [Scst-devel] " Vladislav Bolkhovitin
2008-05-14 16:38                 ` Boaz Harrosh
2008-05-14 16:49                   ` Vladislav Bolkhovitin
2008-05-04 15:30       ` Bart Van Assche
2008-05-08 15:02         ` Bart Van Assche
2008-05-08 15:54           ` [Scst-devel] " Arne Redlich
2008-05-13 16:47             ` Vladislav Bolkhovitin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).