linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: jejb@steeleye.com
Cc: linux-scsi@vger.kernel.org
Subject: [PATCH] scsi_execute_async should take a struct scatterlist *
Date: Sat, 4 Nov 2006 20:14:40 +0100	[thread overview]
Message-ID: <20061104191440.GD23477@lst.de> (raw)

Crrently scsi_execute_async takes a void *buffer argument that can
be either interpreted as a kernel buffer or scatterlist pointer
depending on what the use_sg argument is set to.  There is no user
of the use_sg == 0 kernel buffer case and we should remove it in
favour of type safety.

And yes, long-term we should get rid of the current scsi_execute_async
interface entirely, struct scatterlist * doesn't make sense as a data
structure above the block layer.


Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: scsi-misc-2.6/drivers/scsi/scsi_lib.c
===================================================================
--- scsi-misc-2.6.orig/drivers/scsi/scsi_lib.c	2006-11-02 15:31:51.000000000 +0100
+++ scsi-misc-2.6/drivers/scsi/scsi_lib.c	2006-11-02 17:05:34.000000000 +0100
@@ -368,21 +368,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
+ * scsi_execute_async - execute SCSI command asynchronously
+ * @sdev:		scsi device
+ * @cmd:		scsi command block
+ * @cmd_len:		length of scsi command block
+ * @data_direction:	data direction
+ * @sg:			data buffer in form of a scatterlist
+ * @data_length:	total data length
+ * @use_sg:		number of elements in the scatterlist
+ * @timeout:		request timeout in seconds
+ * @retries:		number of times to retry request
+ * @privdata:		private data passed back to the done callback
+ * @done:		I/O completion callback
+ * @gfp:		memory allocation 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,
+		       int cmd_len, int data_direction, struct scatterlist *sg,
+		       unsigned data_length, int use_sg, int timeout,
+		       int retries, void *privdata,
 		       void (*done)(void *, char *, int, int), gfp_t gfp)
 {
 	struct request *req;
@@ -390,6 +393,8 @@
 	int err = 0;
 	int write = (data_direction == DMA_TO_DEVICE);
 
+	BUG_ON(data_length && !use_sg);
+
 	sioc = kmem_cache_alloc(scsi_io_context_cache, gfp);
 	if (!sioc)
 		return DRIVER_ERROR << 24;
@@ -401,13 +406,11 @@
 	req->cmd_type = REQ_TYPE_BLOCK_PC;
 	req->cmd_flags |= REQ_QUIET;
 
-	if (use_sg)
-		err = scsi_req_map_sg(req, buffer, use_sg, bufflen, gfp);
-	else if (bufflen)
-		err = blk_rq_map_kern(req->q, req, buffer, bufflen, gfp);
-
-	if (err)
-		goto free_req;
+	if (use_sg) {
+		err = scsi_req_map_sg(req, sg, use_sg, data_length, gfp);
+		if (err)
+			goto free_req;
+	}
 
 	req->cmd_len = cmd_len;
 	memcpy(req->cmd, cmd, req->cmd_len);
Index: scsi-misc-2.6/include/scsi/scsi_device.h
===================================================================
--- scsi-misc-2.6.orig/include/scsi/scsi_device.h	2006-10-30 17:00:35.000000000 +0100
+++ scsi-misc-2.6/include/scsi/scsi_device.h	2006-11-02 17:05:49.000000000 +0100
@@ -293,7 +293,7 @@
 			    struct scsi_sense_hdr *, int timeout, int retries);
 extern 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,
+			      struct scatterlist *sg, unsigned data_length, int use_sg,
 			      int timeout, int retries, void *privdata,
 			      void (*done)(void *, char *, int, int),
 			      gfp_t gfp);

             reply	other threads:[~2006-11-04 19:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-04 19:14 Christoph Hellwig [this message]
2006-11-07 17:43 ` [PATCH] scsi_execute_async should take a struct scatterlist * Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061104191440.GD23477@lst.de \
    --to=hch@lst.de \
    --cc=jejb@steeleye.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).