public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* Remove ->done from scsi_cmnd
@ 2007-09-25 16:42 Matthew Wilcox
  2007-09-25 16:42 ` [PATCH] Fix mistaken uses of ->done Matthew Wilcox
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Matthew Wilcox @ 2007-09-25 16:42 UTC (permalink / raw)
  To: linux-scsi


This series of four patches gets rid of ->done from scsi_cmnd.  It applies
on top of the patch I sent earlier today to improve gdth's abuse of
scsi_done.  Sorry, Boaz.  I'd like to thank Christoph for talking me
through some of the bits of the block layer I didn't grok.

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

* [PATCH] Fix mistaken uses of ->done
  2007-09-25 16:42 Remove ->done from scsi_cmnd Matthew Wilcox
@ 2007-09-25 16:42 ` Matthew Wilcox
  2007-09-25 16:42 ` [PATCH] pluto: Don't abuse ->done for internal commands Matthew Wilcox
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Matthew Wilcox @ 2007-09-25 16:42 UTC (permalink / raw)
  To: linux-scsi; +Cc: Matthew Wilcox, Matthew Wilcox

From: Matthew Wilcox <matthew@wil.cx>

All these drivers meant to call ->scsi_done() but got confused.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
---
 drivers/scsi/NCR5380.c       |    8 ++++----
 drivers/scsi/NCR53C9x.c      |    2 +-
 drivers/scsi/atari_NCR5380.c |    4 ++--
 drivers/scsi/sun3_NCR5380.c  |    4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index f8e449a..5b27966 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -2133,7 +2133,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) {
 				sink = 1;
 				do_abort(instance);
 				cmd->result = DID_ERROR << 16;
-				cmd->done(cmd);
+				cmd->scsi_done(cmd);
 				return;
 #endif
 				/* 
@@ -2196,7 +2196,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) {
 						sink = 1;
 						do_abort(instance);
 						cmd->result = DID_ERROR << 16;
-						cmd->done(cmd);
+						cmd->scsi_done(cmd);
 						/* XXX - need to source or sink data here, as appropriate */
 					} else
 						cmd->SCp.this_residual -= transfersize - len;
@@ -2740,7 +2740,7 @@ static int NCR5380_abort(Scsi_Cmnd * cmd) {
 			tmp->host_scribble = NULL;
 			tmp->result = DID_ABORT << 16;
 			dprintk(NDEBUG_ABORT, ("scsi%d : abort removed command from issue queue.\n", instance->host_no));
-			tmp->done(tmp);
+			tmp->scsi_done(tmp);
 			return SUCCESS;
 		}
 #if (NDEBUG  & NDEBUG_ABORT)
@@ -2805,7 +2805,7 @@ static int NCR5380_abort(Scsi_Cmnd * cmd) {
 					*prev = (Scsi_Cmnd *) tmp->host_scribble;
 					tmp->host_scribble = NULL;
 					tmp->result = DID_ABORT << 16;
-					tmp->done(tmp);
+					tmp->scsi_done(tmp);
 					return SUCCESS;
 				}
 		}
diff --git a/drivers/scsi/NCR53C9x.c b/drivers/scsi/NCR53C9x.c
index 79b4df1..96e8e29 100644
--- a/drivers/scsi/NCR53C9x.c
+++ b/drivers/scsi/NCR53C9x.c
@@ -1385,7 +1385,7 @@ int esp_abort(Scsi_Cmnd *SCptr)
 				this->host_scribble = NULL;
 				esp_release_dmabufs(esp, this);
 				this->result = DID_ABORT << 16;
-				this->done(this);
+				this->scsi_done(this);
 				if(don)
 					esp->dma_ints_on(esp);
 				return SUCCESS;
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c
index 03dbe60..743df4c 100644
--- a/drivers/scsi/atari_NCR5380.c
+++ b/drivers/scsi/atari_NCR5380.c
@@ -2041,7 +2041,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
 				sink = 1;
 				do_abort(instance);
 				cmd->result = DID_ERROR << 16;
-				cmd->done(cmd);
+				cmd->scsi_done(cmd);
 				return;
 #endif
 			case PHASE_DATAIN:
@@ -2100,7 +2100,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance)
 						sink = 1;
 						do_abort(instance);
 						cmd->result = DID_ERROR << 16;
-						cmd->done(cmd);
+						cmd->scsi_done(cmd);
 						/* XXX - need to source or sink data here, as appropriate */
 					} else {
 #ifdef REAL_DMA
diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c
index 98e3fe1..3769537 100644
--- a/drivers/scsi/sun3_NCR5380.c
+++ b/drivers/scsi/sun3_NCR5380.c
@@ -2055,7 +2055,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
 		sink = 1;
 		do_abort(instance);
 		cmd->result = DID_ERROR  << 16;
-		cmd->done(cmd);
+		cmd->scsi_done(cmd);
 		return;
 #endif
 	    case PHASE_DATAIN:
@@ -2115,7 +2115,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
 			sink = 1;
 			do_abort(instance);
 			cmd->result = DID_ERROR  << 16;
-			cmd->done(cmd);
+			cmd->scsi_done(cmd);
 			/* XXX - need to source or sink data here, as appropriate */
 		    } else {
 #ifdef REAL_DMA
-- 
1.5.3.1


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

* [PATCH] pluto: Don't abuse ->done for internal commands
  2007-09-25 16:42 Remove ->done from scsi_cmnd Matthew Wilcox
  2007-09-25 16:42 ` [PATCH] Fix mistaken uses of ->done Matthew Wilcox
@ 2007-09-25 16:42 ` Matthew Wilcox
  2007-09-25 16:42 ` [PATCH] gdth: Stop abusing " Matthew Wilcox
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Matthew Wilcox @ 2007-09-25 16:42 UTC (permalink / raw)
  To: linux-scsi; +Cc: Matthew Wilcox, Matthew Wilcox

From: Matthew Wilcox <matthew@wil.cx>

We can simply call the internal done function directly

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
---
 drivers/scsi/pluto.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/pluto.c b/drivers/scsi/pluto.c
index e221389..0363c1c 100644
--- a/drivers/scsi/pluto.c
+++ b/drivers/scsi/pluto.c
@@ -160,7 +160,6 @@ int __init pluto_detect(struct scsi_host_template *tpnt)
 	
 		SCpnt->request->cmd_flags &= ~REQ_STARTED;
 		
-		SCpnt->done = pluto_detect_done;
 		SCpnt->request_bufflen = 256;
 		SCpnt->request_buffer = fcs[i].inquiry;
 		PLD(("set up %d %08lx\n", i, (long)SCpnt))
@@ -195,7 +194,7 @@ int __init pluto_detect(struct scsi_host_template *tpnt)
 		SCpnt = &(fcs[i].cmd);
 		
 		/* Let FC mid-level free allocated resources */
-		SCpnt->done (SCpnt);
+		pluto_detect_scsi_done(SCpnt);
 		
 		if (!SCpnt->result) {
 			struct pluto_inquiry *inq;
-- 
1.5.3.1


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

* [PATCH] gdth: Stop abusing ->done for internal commands
  2007-09-25 16:42 Remove ->done from scsi_cmnd Matthew Wilcox
  2007-09-25 16:42 ` [PATCH] Fix mistaken uses of ->done Matthew Wilcox
  2007-09-25 16:42 ` [PATCH] pluto: Don't abuse ->done for internal commands Matthew Wilcox
@ 2007-09-25 16:42 ` Matthew Wilcox
  2007-09-25 17:30   ` Boaz Harrosh
  2007-09-25 16:42 ` [PATCH] Get rid of scsi_cmnd->done Matthew Wilcox
  2007-09-26 19:54 ` Remove ->done from scsi_cmnd Christoph Hellwig
  4 siblings, 1 reply; 10+ messages in thread
From: Matthew Wilcox @ 2007-09-25 16:42 UTC (permalink / raw)
  To: linux-scsi; +Cc: Matthew Wilcox, Matthew Wilcox

From: Matthew Wilcox <matthew@wil.cx>

The ->done member was being used to mark commands as being internal.
I decided to put a magic number in ->underflow instead.  I believe this
to be safe as no current user of ->underflow has any of the bottom 9
bits set.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
---
 drivers/scsi/gdth.c      |   19 +++++++++++--------
 drivers/scsi/gdth_proc.c |    4 ++--
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 8a6a5f8..42a200f 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -691,6 +691,9 @@ static const struct file_operations gdth_fops = {
     .release = gdth_close,
 };
 
+#define GDTH_MAGIC	0xc2e7c389	/* I got it from /dev/urandom */
+#define IS_GDTH_INTERNAL_CMD(scp)	(scp->underflow == GDTH_MAGIC)
+
 #include "gdth_proc.h"
 #include "gdth_proc.c"
 
@@ -713,7 +716,7 @@ static void gdth_scsi_done(struct scsi_cmnd *scp)
 {
 	TRACE2(("gdth_scsi_done()\n"));
 
-	if (scp->done == gdth_scsi_done)
+	if (IS_GDTH_INTERNAL_CMD(scp))
 		complete((struct completion *)scp->request);
 	else 
 		scp->scsi_done(scp);
@@ -738,7 +741,7 @@ int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd,
     scp->cmd_len = 12;
     memcpy(scp->cmnd, cmnd, 12);
     scp->SCp.this_residual = IOCTL_PRI;   /* priority */
-    scp->done = gdth_scsi_done;
+    scp->underflow = GDTH_MAGIC;
     gdth_queuecommand(scp, NULL);
     wait_for_completion(&wait);
 
@@ -2319,7 +2322,7 @@ static void gdth_putq(int hanum,Scsi_Cmnd *scp,unchar priority)
     ha = HADATA(gdth_ctr_tab[hanum]);
     spin_lock_irqsave(&ha->smp_lock, flags);
 
-    if (scp->done != gdth_scsi_done) {
+    if (!IS_GDTH_INTERNAL_CMD(scp)) {
         scp->SCp.this_residual = (int)priority;
         b = virt_ctr ? NUMDATA(scp->device->host)->busnum:scp->device->channel;
         t = scp->device->id;
@@ -2382,7 +2385,7 @@ static void gdth_next(int hanum)
     for (nscp = pscp = ha->req_first; nscp; nscp = (Scsi_Cmnd *)nscp->SCp.ptr) {
         if (nscp != pscp && nscp != (Scsi_Cmnd *)pscp->SCp.ptr)
             pscp = (Scsi_Cmnd *)pscp->SCp.ptr;
-        if (nscp->done != gdth_scsi_done) {
+        if (!IS_GDTH_INTERNAL_CMD(nscp)) {
             b = virt_ctr ?
                 NUMDATA(nscp->device->host)->busnum : nscp->device->channel;
             t = nscp->device->id;
@@ -2408,7 +2411,7 @@ static void gdth_next(int hanum)
             firsttime = FALSE;
         }
 
-        if (nscp->done != gdth_scsi_done) {
+        if (!IS_GDTH_INTERNAL_CMD(nscp)) {
         if (nscp->SCp.phase == -1) {
             nscp->SCp.phase = CACHESERVICE;           /* default: cache svc. */ 
             if (nscp->cmnd[0] == TEST_UNIT_READY) {
@@ -2471,7 +2474,7 @@ static void gdth_next(int hanum)
                 else
                     gdth_scsi_done(nscp);
             }
-        } else if (nscp->done == gdth_scsi_done) {
+        } else if (IS_GDTH_INTERNAL_CMD(nscp)) {
             if (!(cmd_index=gdth_special_cmd(hanum,nscp)))
                 this_cmd = FALSE;
             next_cmd = FALSE;
@@ -3812,7 +3815,7 @@ static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp)
                     scp->sense_buffer[2] = NOT_READY;
                     scp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
                 }
-                if (scp->done != gdth_scsi_done) {
+                if (!IS_GDTH_INTERNAL_CMD(scp)) {
                     ha->dvr.size = sizeof(ha->dvr.eu.sync);
                     ha->dvr.eu.sync.ionode  = hanum;
                     ha->dvr.eu.sync.service = service;
@@ -4910,7 +4913,7 @@ static int gdth_queuecommand(struct scsi_cmnd *scp,
 #endif
 
     priority = DEFAULT_PRI;
-    if (scp->done == gdth_scsi_done)
+    if (IS_GDTH_INTERNAL_CMD(scp))
         priority = scp->SCp.this_residual;
     else
         gdth_update_timeout(hanum, scp, scp->timeout_per_command * 6);
diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
index 32982eb..1f8d9a5 100644
--- a/drivers/scsi/gdth_proc.c
+++ b/drivers/scsi/gdth_proc.c
@@ -805,7 +805,7 @@ static void gdth_stop_timeout(int hanum, int busnum, int id)
     spin_lock_irqsave(&ha->smp_lock, flags);
 
     for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
-        if (scp->done != gdth_scsi_done) {
+        if (!IS_GDTH_INTERNAL_CMD(scp)) {
             b = virt_ctr ?
                 NUMDATA(scp->device->host)->busnum : scp->device->channel;
             t = scp->device->id;
@@ -829,7 +829,7 @@ static void gdth_start_timeout(int hanum, int busnum, int id)
     spin_lock_irqsave(&ha->smp_lock, flags);
 
     for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
-        if (scp->done != gdth_scsi_done) {
+        if (!IS_GDTH_INTERNAL_CMD(scp)) {
             b = virt_ctr ?
                 NUMDATA(scp->device->host)->busnum : scp->device->channel;
             t = scp->device->id;
-- 
1.5.3.1


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

* [PATCH] Get rid of scsi_cmnd->done
  2007-09-25 16:42 Remove ->done from scsi_cmnd Matthew Wilcox
                   ` (2 preceding siblings ...)
  2007-09-25 16:42 ` [PATCH] gdth: Stop abusing " Matthew Wilcox
@ 2007-09-25 16:42 ` Matthew Wilcox
  2007-09-25 17:05   ` Boaz Harrosh
  2007-09-26 19:54 ` Remove ->done from scsi_cmnd Christoph Hellwig
  4 siblings, 1 reply; 10+ messages in thread
From: Matthew Wilcox @ 2007-09-25 16:42 UTC (permalink / raw)
  To: linux-scsi; +Cc: Matthew Wilcox, Matthew Wilcox

From: Matthew Wilcox <matthew@wil.cx>

The ULD ->done callback moves into the scsi_driver.  By moving the call
to scsi_io_completion() from scsi_blk_pc_done() to scsi_finish_command(),
we can eliminate the latter entirely.  By returning 'good_bytes' from
the ->done callback (rather than invoking scsi_io_completion()), we can
stop exporting scsi_io_completion().

Also move the prototypes from sd.h to sd.c as they're all internal anyway.
Rename sd_rw_intr to sd_done and rw_intr to sr_done.

Inspired-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
---
 drivers/scsi/scsi.c        |   20 +++++++++++++++++---
 drivers/scsi/scsi_error.c  |    1 -
 drivers/scsi/scsi_lib.c    |   14 --------------
 drivers/scsi/scsi_priv.h   |    1 +
 drivers/scsi/sd.c          |   28 ++++++++++++++++++----------
 drivers/scsi/sr.c          |   21 ++++++---------------
 include/scsi/scsi_cmnd.h   |    2 --
 include/scsi/scsi_driver.h |    1 +
 include/scsi/sd.h          |   13 -------------
 9 files changed, 43 insertions(+), 58 deletions(-)

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index a5de1a8..60799ff 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -59,6 +59,7 @@
 #include <scsi/scsi_cmnd.h>
 #include <scsi/scsi_dbg.h>
 #include <scsi/scsi_device.h>
+#include <scsi/scsi_driver.h>
 #include <scsi/scsi_eh.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_tcq.h>
@@ -367,9 +368,8 @@ void scsi_log_send(struct scsi_cmnd *cmd)
 			scsi_print_command(cmd);
 			if (level > 3) {
 				printk(KERN_INFO "buffer = 0x%p, bufflen = %d,"
-				       " done = 0x%p, queuecommand 0x%p\n",
+				       " queuecommand 0x%p\n",
 					scsi_sglist(cmd), scsi_bufflen(cmd),
-					cmd->done,
 					cmd->device->host->hostt->queuecommand);
 
 			}
@@ -658,6 +658,12 @@ void __scsi_done(struct scsi_cmnd *cmd)
 	blk_complete_request(rq);
 }
 
+/* Move this to a header if it becomes more generally useful */
+static struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
+{
+	return *(struct scsi_driver **)cmd->request->rq_disk->private_data;
+}
+
 /*
  * Function:    scsi_finish_command
  *
@@ -669,6 +675,8 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
 {
 	struct scsi_device *sdev = cmd->device;
 	struct Scsi_Host *shost = sdev->host;
+	struct scsi_driver *drv;
+	unsigned int good_bytes;
 
 	scsi_device_unbusy(sdev);
 
@@ -694,7 +702,13 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
 				"Notifying upper driver of completion "
 				"(result %x)\n", cmd->result));
 
-	cmd->done(cmd);
+	good_bytes = cmd->request_bufflen;
+        if (cmd->request->cmd_type != REQ_TYPE_BLOCK_PC) {
+		drv = scsi_cmd_to_driver(cmd);
+		if (drv->done)
+			good_bytes = drv->done(cmd);
+	}
+	scsi_io_completion(cmd, good_bytes);
 }
 EXPORT_SYMBOL(scsi_finish_command);
 
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index c05d020..10f6acc 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1671,7 +1671,6 @@ scsi_reset_provider(struct scsi_device *dev, int flag)
 	memset(&scmd->cmnd, '\0', sizeof(scmd->cmnd));
     
 	scmd->scsi_done		= scsi_reset_provider_done_command;
-	scmd->done			= NULL;
 	scmd->request_buffer		= NULL;
 	scmd->request_bufflen		= 0;
 
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 94d82cb..cb8a577 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -982,7 +982,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 	}
 	scsi_end_request(cmd, 0, this_count, !result);
 }
-EXPORT_SYMBOL(scsi_io_completion);
 
 /*
  * Function:    scsi_init_io()
@@ -1063,18 +1062,6 @@ static struct scsi_cmnd *scsi_get_cmd_from_req(struct scsi_device *sdev,
 	return cmd;
 }
 
-static void scsi_blk_pc_done(struct scsi_cmnd *cmd)
-{
-	BUG_ON(!blk_pc_request(cmd->request));
-	/*
-	 * This will complete the whole command with uptodate=1 so
-	 * as far as the block layer is concerned the command completed
-	 * successfully. Since this is a REQ_BLOCK_PC command the
-	 * caller should check the request's errors value
-	 */
-	scsi_io_completion(cmd, cmd->request_bufflen);
-}
-
 int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
 {
 	struct scsi_cmnd *cmd;
@@ -1124,7 +1111,6 @@ int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
 	cmd->transfersize = req->data_len;
 	cmd->allowed = req->retries;
 	cmd->timeout_per_command = req->timeout;
-	cmd->done = scsi_blk_pc_done;
 	return BLKPREP_OK;
 }
 EXPORT_SYMBOL(scsi_setup_blk_pc_cmnd);
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index ee8efe8..eff0059 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -68,6 +68,7 @@ extern int scsi_maybe_unblock_host(struct scsi_device *sdev);
 extern void scsi_device_unbusy(struct scsi_device *sdev);
 extern int scsi_queue_insert(struct scsi_cmnd *cmd, int reason);
 extern void scsi_next_command(struct scsi_cmnd *cmd);
+extern void scsi_io_completion(struct scsi_cmnd *, unsigned int);
 extern void scsi_run_host_queues(struct Scsi_Host *shost);
 extern struct request_queue *scsi_alloc_queue(struct scsi_device *sdev);
 extern void scsi_free_queue(struct request_queue *q);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 38a4141..0a3a528 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -86,6 +86,19 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_DISK);
 MODULE_ALIAS_SCSI_DEVICE(TYPE_MOD);
 MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC);
 
+static int  sd_revalidate_disk(struct gendisk *);
+static int  sd_probe(struct device *);
+static int  sd_remove(struct device *);
+static void sd_shutdown(struct device *);
+static int sd_suspend(struct device *, pm_message_t state);
+static int sd_resume(struct device *);
+static void sd_rescan(struct device *);
+static int sd_done(struct scsi_cmnd *);
+static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
+static void scsi_disk_release(struct class_device *cdev);
+static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
+static void sd_print_result(struct scsi_disk *, int);
+
 static DEFINE_IDR(sd_index_idr);
 static DEFINE_SPINLOCK(sd_index_lock);
 
@@ -240,6 +253,7 @@ static struct scsi_driver sd_template = {
 		.shutdown	= sd_shutdown,
 	},
 	.rescan			= sd_rescan,
+	.done			= sd_done,
 };
 
 /*
@@ -509,12 +523,6 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
 	SCpnt->timeout_per_command = timeout;
 
 	/*
-	 * This is the completion routine we use.  This is matched in terms
-	 * of capability to this function.
-	 */
-	SCpnt->done = sd_rw_intr;
-
-	/*
 	 * This indicates that the command is ready from our end to be
 	 * queued.
 	 */
@@ -908,13 +916,13 @@ static struct block_device_operations sd_fops = {
 };
 
 /**
- *	sd_rw_intr - bottom half handler: called when the lower level
+ *	sd_done - bottom half handler: called when the lower level
  *	driver has completed (successfully or otherwise) a scsi command.
  *	@SCpnt: mid-level's per command structure.
  *
  *	Note: potentially run from within an ISR. Must not block.
  **/
-static void sd_rw_intr(struct scsi_cmnd * SCpnt)
+static int sd_done(struct scsi_cmnd *SCpnt)
 {
 	int result = SCpnt->result;
  	unsigned int xfer_size = SCpnt->request_bufflen;
@@ -935,7 +943,7 @@ static void sd_rw_intr(struct scsi_cmnd * SCpnt)
 	SCSI_LOG_HLCOMPLETE(1, scsi_print_result(SCpnt));
 	if (sense_valid) {
 		SCSI_LOG_HLCOMPLETE(1, scmd_printk(KERN_INFO, SCpnt,
-						   "sd_rw_intr: sb[respc,sk,asc,"
+						   "sd_done: sb[respc,sk,asc,"
 						   "ascq]=%x,%x,%x,%x\n",
 						   sshdr.response_code,
 						   sshdr.sense_key, sshdr.asc,
@@ -1007,7 +1015,7 @@ static void sd_rw_intr(struct scsi_cmnd * SCpnt)
 		break;
 	}
  out:
-	scsi_io_completion(SCpnt, good_bytes);
+	return good_bytes;
 }
 
 static int media_not_present(struct scsi_disk *sdkp,
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index a0c4e13..c619990 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -78,6 +78,7 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_WORM);
 
 static int sr_probe(struct device *);
 static int sr_remove(struct device *);
+static int sr_done(struct scsi_cmnd *);
 
 static struct scsi_driver sr_template = {
 	.owner			= THIS_MODULE,
@@ -86,6 +87,7 @@ static struct scsi_driver sr_template = {
 		.probe		= sr_probe,
 		.remove		= sr_remove,
 	},
+	.done			= sr_done,
 };
 
 static unsigned long sr_index_bits[SR_DISKS / BITS_PER_LONG];
@@ -208,12 +210,12 @@ static int sr_media_change(struct cdrom_device_info *cdi, int slot)
 }
  
 /*
- * rw_intr is the interrupt routine for the device driver.
+ * sr_done is the interrupt routine for the device driver.
  *
- * It will be notified on the end of a SCSI read / write, and will take on
+ * It will be notified on the end of a SCSI read / write, and will take one
  * of several actions based on success or failure.
  */
-static void rw_intr(struct scsi_cmnd * SCpnt)
+static int sr_done(struct scsi_cmnd *SCpnt)
 {
 	int result = SCpnt->result;
 	int this_count = SCpnt->request_bufflen;
@@ -286,12 +288,7 @@ static void rw_intr(struct scsi_cmnd * SCpnt)
 		}
 	}
 
-	/*
-	 * This calls the generic completion function, now that we know
-	 * how many actual sectors finished, and how many sectors we need
-	 * to say have failed.
-	 */
-	scsi_io_completion(SCpnt, good_bytes);
+	return good_bytes;
 }
 
 static int sr_prep_fn(struct request_queue *q, struct request *rq)
@@ -428,12 +425,6 @@ static int sr_prep_fn(struct request_queue *q, struct request *rq)
 	SCpnt->timeout_per_command = timeout;
 
 	/*
-	 * This is the completion routine we use.  This is matched in terms
-	 * of capability to this function.
-	 */
-	SCpnt->done = rw_intr;
-
-	/*
 	 * This indicates that the command is ready from our end to be
 	 * queued.
 	 */
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 53e1705..b2888d7 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -33,7 +33,6 @@ struct scsi_cmnd {
 	struct list_head list;  /* scsi_cmnd participates in queue lists */
 	struct list_head eh_entry; /* entry for the host eh_cmd_q */
 	int eh_eflags;		/* Used by error handlr */
-	void (*done) (struct scsi_cmnd *);	/* Mid-level done function */
 
 	/*
 	 * A SCSI Command is assigned a nonzero serial_number before passed
@@ -124,7 +123,6 @@ extern struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *, gfp_t);
 extern void scsi_put_command(struct scsi_cmnd *);
 extern void __scsi_put_command(struct Scsi_Host *, struct scsi_cmnd *,
 			       struct device *);
-extern void scsi_io_completion(struct scsi_cmnd *, unsigned int);
 extern void scsi_finish_command(struct scsi_cmnd *cmd);
 extern void scsi_req_abort_cmd(struct scsi_cmnd *cmd);
 
diff --git a/include/scsi/scsi_driver.h b/include/scsi/scsi_driver.h
index 56a3047..1f5ca7f 100644
--- a/include/scsi/scsi_driver.h
+++ b/include/scsi/scsi_driver.h
@@ -15,6 +15,7 @@ struct scsi_driver {
 	struct device_driver	gendrv;
 
 	void (*rescan)(struct device *);
+	int (*done)(struct scsi_cmnd *);
 };
 #define to_scsi_driver(drv) \
 	container_of((drv), struct scsi_driver, gendrv)
diff --git a/include/scsi/sd.h b/include/scsi/sd.h
index aa1e716..f751331 100644
--- a/include/scsi/sd.h
+++ b/include/scsi/sd.h
@@ -47,19 +47,6 @@ struct scsi_disk {
 };
 #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev)
 
-static int  sd_revalidate_disk(struct gendisk *disk);
-static void sd_rw_intr(struct scsi_cmnd * SCpnt);
-static int  sd_probe(struct device *);
-static int  sd_remove(struct device *);
-static void sd_shutdown(struct device *dev);
-static int sd_suspend(struct device *dev, pm_message_t state);
-static int sd_resume(struct device *dev);
-static void sd_rescan(struct device *);
-static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
-static void scsi_disk_release(struct class_device *cdev);
-static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
-static void sd_print_result(struct scsi_disk *, int);
-
 #define sd_printk(prefix, sdsk, fmt, a...)				\
         (sdsk)->disk ?							\
 	sdev_printk(prefix, (sdsk)->device, "[%s] " fmt,		\
-- 
1.5.3.1


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

* Re: [PATCH] Get rid of scsi_cmnd->done
  2007-09-25 16:42 ` [PATCH] Get rid of scsi_cmnd->done Matthew Wilcox
@ 2007-09-25 17:05   ` Boaz Harrosh
  2007-09-25 17:09     ` Matthew Wilcox
  0 siblings, 1 reply; 10+ messages in thread
From: Boaz Harrosh @ 2007-09-25 17:05 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-scsi, Matthew Wilcox

On Tue, Sep 25 2007 at 18:42 +0200, Matthew Wilcox <willy@linux.intel.com> wrote:
> From: Matthew Wilcox <matthew@wil.cx>
> 
> The ULD ->done callback moves into the scsi_driver.  By moving the call
> to scsi_io_completion() from scsi_blk_pc_done() to scsi_finish_command(),
> we can eliminate the latter entirely.  By returning 'good_bytes' from
> the ->done callback (rather than invoking scsi_io_completion()), we can
> stop exporting scsi_io_completion().
> 
> Also move the prototypes from sd.h to sd.c as they're all internal anyway.
> Rename sd_rw_intr to sd_done and rw_intr to sr_done.
> 
> Inspired-by: Christoph Hellwig <hch@infradead.org>
> Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
> ---
>  drivers/scsi/scsi.c        |   20 +++++++++++++++++---
>  drivers/scsi/scsi_error.c  |    1 -
>  drivers/scsi/scsi_lib.c    |   14 --------------
>  drivers/scsi/scsi_priv.h   |    1 +
>  drivers/scsi/sd.c          |   28 ++++++++++++++++++----------
>  drivers/scsi/sr.c          |   21 ++++++---------------
>  include/scsi/scsi_cmnd.h   |    2 --
>  include/scsi/scsi_driver.h |    1 +
>  include/scsi/sd.h          |   13 -------------
>  9 files changed, 43 insertions(+), 58 deletions(-)
> 
> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
> index a5de1a8..60799ff 100644
> --- a/drivers/scsi/scsi.c
> +++ b/drivers/scsi/scsi.c
> @@ -59,6 +59,7 @@
>  #include <scsi/scsi_cmnd.h>
>  #include <scsi/scsi_dbg.h>
>  #include <scsi/scsi_device.h>
> +#include <scsi/scsi_driver.h>
>  #include <scsi/scsi_eh.h>
>  #include <scsi/scsi_host.h>
>  #include <scsi/scsi_tcq.h>
> @@ -367,9 +368,8 @@ void scsi_log_send(struct scsi_cmnd *cmd)
>  			scsi_print_command(cmd);
>  			if (level > 3) {
>  				printk(KERN_INFO "buffer = 0x%p, bufflen = %d,"
> -				       " done = 0x%p, queuecommand 0x%p\n",
> +				       " queuecommand 0x%p\n",
>  					scsi_sglist(cmd), scsi_bufflen(cmd),
> -					cmd->done,
>  					cmd->device->host->hostt->queuecommand);
>  
>  			}
> @@ -658,6 +658,12 @@ void __scsi_done(struct scsi_cmnd *cmd)
>  	blk_complete_request(rq);
>  }
>  
> +/* Move this to a header if it becomes more generally useful */
> +static struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
> +{
> +	return *(struct scsi_driver **)cmd->request->rq_disk->private_data;
> +}
> +
>  /*
>   * Function:    scsi_finish_command
>   *
> @@ -669,6 +675,8 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
>  {
>  	struct scsi_device *sdev = cmd->device;
>  	struct Scsi_Host *shost = sdev->host;
> +	struct scsi_driver *drv;
> +	unsigned int good_bytes;
>  
>  	scsi_device_unbusy(sdev);
>  
> @@ -694,7 +702,13 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
>  				"Notifying upper driver of completion "
>  				"(result %x)\n", cmd->result));
>  
> -	cmd->done(cmd);
> +	good_bytes = cmd->request_bufflen;
Please use scsi_bufflen(cmd) this file was already converted to
accessors.

> +        if (cmd->request->cmd_type != REQ_TYPE_BLOCK_PC) {
> +		drv = scsi_cmd_to_driver(cmd);
> +		if (drv->done)
> +			good_bytes = drv->done(cmd);
> +	}
> +	scsi_io_completion(cmd, good_bytes);
>  }
>  EXPORT_SYMBOL(scsi_finish_command);
>  
> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
> index c05d020..10f6acc 100644
> --- a/drivers/scsi/scsi_error.c
> +++ b/drivers/scsi/scsi_error.c
> @@ -1671,7 +1671,6 @@ scsi_reset_provider(struct scsi_device *dev, int flag)
>  	memset(&scmd->cmnd, '\0', sizeof(scmd->cmnd));
>      
>  	scmd->scsi_done		= scsi_reset_provider_done_command;
> -	scmd->done			= NULL;
>  	scmd->request_buffer		= NULL;
>  	scmd->request_bufflen		= 0;
>  
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 94d82cb..cb8a577 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -982,7 +982,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
>  	}
>  	scsi_end_request(cmd, 0, this_count, !result);
>  }
> -EXPORT_SYMBOL(scsi_io_completion);
>  
>  /*
>   * Function:    scsi_init_io()
> @@ -1063,18 +1062,6 @@ static struct scsi_cmnd *scsi_get_cmd_from_req(struct scsi_device *sdev,
>  	return cmd;
>  }
>  
> -static void scsi_blk_pc_done(struct scsi_cmnd *cmd)
> -{
> -	BUG_ON(!blk_pc_request(cmd->request));
> -	/*
> -	 * This will complete the whole command with uptodate=1 so
> -	 * as far as the block layer is concerned the command completed
> -	 * successfully. Since this is a REQ_BLOCK_PC command the
> -	 * caller should check the request's errors value
> -	 */
> -	scsi_io_completion(cmd, cmd->request_bufflen);
> -}
> -
>  int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
>  {
>  	struct scsi_cmnd *cmd;
> @@ -1124,7 +1111,6 @@ int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
>  	cmd->transfersize = req->data_len;
>  	cmd->allowed = req->retries;
>  	cmd->timeout_per_command = req->timeout;
> -	cmd->done = scsi_blk_pc_done;
>  	return BLKPREP_OK;
>  }
>  EXPORT_SYMBOL(scsi_setup_blk_pc_cmnd);
> diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
> index ee8efe8..eff0059 100644
> --- a/drivers/scsi/scsi_priv.h
> +++ b/drivers/scsi/scsi_priv.h
> @@ -68,6 +68,7 @@ extern int scsi_maybe_unblock_host(struct scsi_device *sdev);
>  extern void scsi_device_unbusy(struct scsi_device *sdev);
>  extern int scsi_queue_insert(struct scsi_cmnd *cmd, int reason);
>  extern void scsi_next_command(struct scsi_cmnd *cmd);
> +extern void scsi_io_completion(struct scsi_cmnd *, unsigned int);
>  extern void scsi_run_host_queues(struct Scsi_Host *shost);
>  extern struct request_queue *scsi_alloc_queue(struct scsi_device *sdev);
>  extern void scsi_free_queue(struct request_queue *q);
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 38a4141..0a3a528 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -86,6 +86,19 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_DISK);
>  MODULE_ALIAS_SCSI_DEVICE(TYPE_MOD);
>  MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC);
>  
> +static int  sd_revalidate_disk(struct gendisk *);
> +static int  sd_probe(struct device *);
> +static int  sd_remove(struct device *);
> +static void sd_shutdown(struct device *);
> +static int sd_suspend(struct device *, pm_message_t state);
> +static int sd_resume(struct device *);
> +static void sd_rescan(struct device *);
> +static int sd_done(struct scsi_cmnd *);
> +static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
> +static void scsi_disk_release(struct class_device *cdev);
> +static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
> +static void sd_print_result(struct scsi_disk *, int);
> +
>  static DEFINE_IDR(sd_index_idr);
>  static DEFINE_SPINLOCK(sd_index_lock);
>  
> @@ -240,6 +253,7 @@ static struct scsi_driver sd_template = {
>  		.shutdown	= sd_shutdown,
>  	},
>  	.rescan			= sd_rescan,
> +	.done			= sd_done,
>  };
>  
>  /*
> @@ -509,12 +523,6 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
>  	SCpnt->timeout_per_command = timeout;
>  
>  	/*
> -	 * This is the completion routine we use.  This is matched in terms
> -	 * of capability to this function.
> -	 */
> -	SCpnt->done = sd_rw_intr;
> -
> -	/*
>  	 * This indicates that the command is ready from our end to be
>  	 * queued.
>  	 */
> @@ -908,13 +916,13 @@ static struct block_device_operations sd_fops = {
>  };
>  
>  /**
> - *	sd_rw_intr - bottom half handler: called when the lower level
> + *	sd_done - bottom half handler: called when the lower level
>   *	driver has completed (successfully or otherwise) a scsi command.
>   *	@SCpnt: mid-level's per command structure.
>   *
>   *	Note: potentially run from within an ISR. Must not block.
>   **/
> -static void sd_rw_intr(struct scsi_cmnd * SCpnt)
> +static int sd_done(struct scsi_cmnd *SCpnt)
>  {
>  	int result = SCpnt->result;
>   	unsigned int xfer_size = SCpnt->request_bufflen;
> @@ -935,7 +943,7 @@ static void sd_rw_intr(struct scsi_cmnd * SCpnt)
>  	SCSI_LOG_HLCOMPLETE(1, scsi_print_result(SCpnt));
>  	if (sense_valid) {
>  		SCSI_LOG_HLCOMPLETE(1, scmd_printk(KERN_INFO, SCpnt,
> -						   "sd_rw_intr: sb[respc,sk,asc,"
> +						   "sd_done: sb[respc,sk,asc,"
>  						   "ascq]=%x,%x,%x,%x\n",
>  						   sshdr.response_code,
>  						   sshdr.sense_key, sshdr.asc,
> @@ -1007,7 +1015,7 @@ static void sd_rw_intr(struct scsi_cmnd * SCpnt)
>  		break;
>  	}
>   out:
> -	scsi_io_completion(SCpnt, good_bytes);
> +	return good_bytes;
>  }
>  
>  static int media_not_present(struct scsi_disk *sdkp,
> diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
> index a0c4e13..c619990 100644
> --- a/drivers/scsi/sr.c
> +++ b/drivers/scsi/sr.c
> @@ -78,6 +78,7 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_WORM);
>  
>  static int sr_probe(struct device *);
>  static int sr_remove(struct device *);
> +static int sr_done(struct scsi_cmnd *);
>  
>  static struct scsi_driver sr_template = {
>  	.owner			= THIS_MODULE,
> @@ -86,6 +87,7 @@ static struct scsi_driver sr_template = {
>  		.probe		= sr_probe,
>  		.remove		= sr_remove,
>  	},
> +	.done			= sr_done,
>  };
>  
>  static unsigned long sr_index_bits[SR_DISKS / BITS_PER_LONG];
> @@ -208,12 +210,12 @@ static int sr_media_change(struct cdrom_device_info *cdi, int slot)
>  }
>   
>  /*
> - * rw_intr is the interrupt routine for the device driver.
> + * sr_done is the interrupt routine for the device driver.
>   *
> - * It will be notified on the end of a SCSI read / write, and will take on
> + * It will be notified on the end of a SCSI read / write, and will take one
>   * of several actions based on success or failure.
>   */
> -static void rw_intr(struct scsi_cmnd * SCpnt)
> +static int sr_done(struct scsi_cmnd *SCpnt)
>  {
>  	int result = SCpnt->result;
>  	int this_count = SCpnt->request_bufflen;
> @@ -286,12 +288,7 @@ static void rw_intr(struct scsi_cmnd * SCpnt)
>  		}
>  	}
>  
> -	/*
> -	 * This calls the generic completion function, now that we know
> -	 * how many actual sectors finished, and how many sectors we need
> -	 * to say have failed.
> -	 */
> -	scsi_io_completion(SCpnt, good_bytes);
> +	return good_bytes;
>  }
>  
>  static int sr_prep_fn(struct request_queue *q, struct request *rq)
> @@ -428,12 +425,6 @@ static int sr_prep_fn(struct request_queue *q, struct request *rq)
>  	SCpnt->timeout_per_command = timeout;
>  
>  	/*
> -	 * This is the completion routine we use.  This is matched in terms
> -	 * of capability to this function.
> -	 */
> -	SCpnt->done = rw_intr;
> -
> -	/*
>  	 * This indicates that the command is ready from our end to be
>  	 * queued.
>  	 */
> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
> index 53e1705..b2888d7 100644
> --- a/include/scsi/scsi_cmnd.h
> +++ b/include/scsi/scsi_cmnd.h
> @@ -33,7 +33,6 @@ struct scsi_cmnd {
>  	struct list_head list;  /* scsi_cmnd participates in queue lists */
>  	struct list_head eh_entry; /* entry for the host eh_cmd_q */
>  	int eh_eflags;		/* Used by error handlr */
> -	void (*done) (struct scsi_cmnd *);	/* Mid-level done function */
>  
>  	/*
>  	 * A SCSI Command is assigned a nonzero serial_number before passed
> @@ -124,7 +123,6 @@ extern struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *, gfp_t);
>  extern void scsi_put_command(struct scsi_cmnd *);
>  extern void __scsi_put_command(struct Scsi_Host *, struct scsi_cmnd *,
>  			       struct device *);
> -extern void scsi_io_completion(struct scsi_cmnd *, unsigned int);
>  extern void scsi_finish_command(struct scsi_cmnd *cmd);
>  extern void scsi_req_abort_cmd(struct scsi_cmnd *cmd);
>  
> diff --git a/include/scsi/scsi_driver.h b/include/scsi/scsi_driver.h
> index 56a3047..1f5ca7f 100644
> --- a/include/scsi/scsi_driver.h
> +++ b/include/scsi/scsi_driver.h
> @@ -15,6 +15,7 @@ struct scsi_driver {
>  	struct device_driver	gendrv;
>  
>  	void (*rescan)(struct device *);
> +	int (*done)(struct scsi_cmnd *);
>  };
>  #define to_scsi_driver(drv) \
>  	container_of((drv), struct scsi_driver, gendrv)
> diff --git a/include/scsi/sd.h b/include/scsi/sd.h
> index aa1e716..f751331 100644
> --- a/include/scsi/sd.h
> +++ b/include/scsi/sd.h
> @@ -47,19 +47,6 @@ struct scsi_disk {
>  };
>  #define to_scsi_disk(obj) container_of(obj,struct scsi_disk,cdev)
>  
> -static int  sd_revalidate_disk(struct gendisk *disk);
> -static void sd_rw_intr(struct scsi_cmnd * SCpnt);
> -static int  sd_probe(struct device *);
> -static int  sd_remove(struct device *);
> -static void sd_shutdown(struct device *dev);
> -static int sd_suspend(struct device *dev, pm_message_t state);
> -static int sd_resume(struct device *dev);
> -static void sd_rescan(struct device *);
> -static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
> -static void scsi_disk_release(struct class_device *cdev);
> -static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);
> -static void sd_print_result(struct scsi_disk *, int);
> -
>  #define sd_printk(prefix, sdsk, fmt, a...)				\
>          (sdsk)->disk ?							\
>  	sdev_printk(prefix, (sdsk)->device, "[%s] " fmt,		\

Thanks otherwise looks very good
Boaz

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

* Re: [PATCH] Get rid of scsi_cmnd->done
  2007-09-25 17:05   ` Boaz Harrosh
@ 2007-09-25 17:09     ` Matthew Wilcox
  0 siblings, 0 replies; 10+ messages in thread
From: Matthew Wilcox @ 2007-09-25 17:09 UTC (permalink / raw)
  To: Boaz Harrosh; +Cc: Matthew Wilcox, linux-scsi

On Tue, Sep 25, 2007 at 07:05:09PM +0200, Boaz Harrosh wrote:
> > @@ -694,7 +702,13 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
> >  				"Notifying upper driver of completion "
> >  				"(result %x)\n", cmd->result));
> >  
> > -	cmd->done(cmd);
> > +	good_bytes = cmd->request_bufflen;
> Please use scsi_bufflen(cmd) this file was already converted to
> accessors.

Ah; I was basing this on linus + scsi-misc.  I guess scsi_lib hadn't
been converted because I just took the code from there.

> Thanks otherwise looks very good

Thank you for the review!

-- 
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

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

* Re: [PATCH] gdth: Stop abusing ->done for internal commands
  2007-09-25 16:42 ` [PATCH] gdth: Stop abusing " Matthew Wilcox
@ 2007-09-25 17:30   ` Boaz Harrosh
  2007-09-25 17:33     ` Matthew Wilcox
  0 siblings, 1 reply; 10+ messages in thread
From: Boaz Harrosh @ 2007-09-25 17:30 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-scsi, Matthew Wilcox

On Tue, Sep 25 2007 at 18:42 +0200, Matthew Wilcox <willy@linux.intel.com> wrote:
> From: Matthew Wilcox <matthew@wil.cx>
> 
> The ->done member was being used to mark commands as being internal.
> I decided to put a magic number in ->underflow instead.  I believe this
> to be safe as no current user of ->underflow has any of the bottom 9
> bits set.
> 
> Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
> ---
>  drivers/scsi/gdth.c      |   19 +++++++++++--------
>  drivers/scsi/gdth_proc.c |    4 ++--
>  2 files changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
> index 8a6a5f8..42a200f 100644
> --- a/drivers/scsi/gdth.c
> +++ b/drivers/scsi/gdth.c
> @@ -691,6 +691,9 @@ static const struct file_operations gdth_fops = {
>      .release = gdth_close,
>  };
>  
> +#define GDTH_MAGIC	0xc2e7c389	/* I got it from /dev/urandom */
> +#define IS_GDTH_INTERNAL_CMD(scp)	(scp->underflow == GDTH_MAGIC)
> +
>  #include "gdth_proc.h"
>  #include "gdth_proc.c"
>  
> @@ -713,7 +716,7 @@ static void gdth_scsi_done(struct scsi_cmnd *scp)
>  {
>  	TRACE2(("gdth_scsi_done()\n"));
>  
> -	if (scp->done == gdth_scsi_done)
> +	if (IS_GDTH_INTERNAL_CMD(scp))
>  		complete((struct completion *)scp->request);
>  	else 
>  		scp->scsi_done(scp);
> @@ -738,7 +741,7 @@ int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd,
>      scp->cmd_len = 12;
>      memcpy(scp->cmnd, cmnd, 12);
>      scp->SCp.this_residual = IOCTL_PRI;   /* priority */
> -    scp->done = gdth_scsi_done;
> +    scp->underflow = GDTH_MAGIC;
>      gdth_queuecommand(scp, NULL);
>      wait_for_completion(&wait);
>  
> @@ -2319,7 +2322,7 @@ static void gdth_putq(int hanum,Scsi_Cmnd *scp,unchar priority)
>      ha = HADATA(gdth_ctr_tab[hanum]);
>      spin_lock_irqsave(&ha->smp_lock, flags);
>  
> -    if (scp->done != gdth_scsi_done) {
> +    if (!IS_GDTH_INTERNAL_CMD(scp)) {
>          scp->SCp.this_residual = (int)priority;
>          b = virt_ctr ? NUMDATA(scp->device->host)->busnum:scp->device->channel;
>          t = scp->device->id;
> @@ -2382,7 +2385,7 @@ static void gdth_next(int hanum)
>      for (nscp = pscp = ha->req_first; nscp; nscp = (Scsi_Cmnd *)nscp->SCp.ptr) {
>          if (nscp != pscp && nscp != (Scsi_Cmnd *)pscp->SCp.ptr)
>              pscp = (Scsi_Cmnd *)pscp->SCp.ptr;
> -        if (nscp->done != gdth_scsi_done) {
> +        if (!IS_GDTH_INTERNAL_CMD(nscp)) {
>              b = virt_ctr ?
>                  NUMDATA(nscp->device->host)->busnum : nscp->device->channel;
>              t = nscp->device->id;
> @@ -2408,7 +2411,7 @@ static void gdth_next(int hanum)
>              firsttime = FALSE;
>          }
>  
> -        if (nscp->done != gdth_scsi_done) {
> +        if (!IS_GDTH_INTERNAL_CMD(nscp)) {
>          if (nscp->SCp.phase == -1) {
>              nscp->SCp.phase = CACHESERVICE;           /* default: cache svc. */ 
>              if (nscp->cmnd[0] == TEST_UNIT_READY) {
> @@ -2471,7 +2474,7 @@ static void gdth_next(int hanum)
>                  else
>                      gdth_scsi_done(nscp);
>              }
> -        } else if (nscp->done == gdth_scsi_done) {
> +        } else if (IS_GDTH_INTERNAL_CMD(nscp)) {
>              if (!(cmd_index=gdth_special_cmd(hanum,nscp)))
>                  this_cmd = FALSE;
>              next_cmd = FALSE;
> @@ -3812,7 +3815,7 @@ static int gdth_sync_event(int hanum,int service,unchar index,Scsi_Cmnd *scp)
>                      scp->sense_buffer[2] = NOT_READY;
>                      scp->result = (DID_OK << 16) | (CHECK_CONDITION << 1);
>                  }
> -                if (scp->done != gdth_scsi_done) {
> +                if (!IS_GDTH_INTERNAL_CMD(scp)) {
>                      ha->dvr.size = sizeof(ha->dvr.eu.sync);
>                      ha->dvr.eu.sync.ionode  = hanum;
>                      ha->dvr.eu.sync.service = service;
> @@ -4910,7 +4913,7 @@ static int gdth_queuecommand(struct scsi_cmnd *scp,
>  #endif
>  
>      priority = DEFAULT_PRI;
> -    if (scp->done == gdth_scsi_done)
> +    if (IS_GDTH_INTERNAL_CMD(scp))
>          priority = scp->SCp.this_residual;
>      else
>          gdth_update_timeout(hanum, scp, scp->timeout_per_command * 6);
> diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
> index 32982eb..1f8d9a5 100644
> --- a/drivers/scsi/gdth_proc.c
> +++ b/drivers/scsi/gdth_proc.c
> @@ -805,7 +805,7 @@ static void gdth_stop_timeout(int hanum, int busnum, int id)
>      spin_lock_irqsave(&ha->smp_lock, flags);
>  
>      for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
> -        if (scp->done != gdth_scsi_done) {
> +        if (!IS_GDTH_INTERNAL_CMD(scp)) {
>              b = virt_ctr ?
>                  NUMDATA(scp->device->host)->busnum : scp->device->channel;
>              t = scp->device->id;
> @@ -829,7 +829,7 @@ static void gdth_start_timeout(int hanum, int busnum, int id)
>      spin_lock_irqsave(&ha->smp_lock, flags);
>  
>      for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) {
> -        if (scp->done != gdth_scsi_done) {
> +        if (!IS_GDTH_INTERNAL_CMD(scp)) {
>              b = virt_ctr ?
>                  NUMDATA(scp->device->host)->busnum : scp->device->channel;
>              t = scp->device->id;

OK This is on top of the first patch that I will take care of,
right? (http://www.spinics.net/lists/linux-scsi/msg19470.html)

Here 2 it will not merge with my patchset. So I'll take it off your hands
and rebase it to mine.

In my patchset I have introduced a gdth_cmnd_priv. That is associated
with every command and is put on cmnd->host_scribble, I than moved lots
of abused Scp and other members to that new structure. I also put a 
simple boolean that states that these are Internal commands. So what
is left of this patch is the:
-    scp->done = gdth_scsi_done;
I will add that one line removal to your previous patch.

> Ah; I was basing this on linus + scsi-misc.  I guess scsi_lib hadn't
> been converted because I just took the code from there.
Yes scsi_lib was not converted, but scsi.c was.

Boaz


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

* Re: [PATCH] gdth: Stop abusing ->done for internal commands
  2007-09-25 17:30   ` Boaz Harrosh
@ 2007-09-25 17:33     ` Matthew Wilcox
  0 siblings, 0 replies; 10+ messages in thread
From: Matthew Wilcox @ 2007-09-25 17:33 UTC (permalink / raw)
  To: Boaz Harrosh; +Cc: Matthew Wilcox, linux-scsi

On Tue, Sep 25, 2007 at 07:30:29PM +0200, Boaz Harrosh wrote:
> OK This is on top of the first patch that I will take care of,
> right? (http://www.spinics.net/lists/linux-scsi/msg19470.html)

That's right.

> Here 2 it will not merge with my patchset. So I'll take it off your hands
> and rebase it to mine.

Wonderful.  Again, I don't care about this driver, just want it to not
break (more than it's already broken).

> In my patchset I have introduced a gdth_cmnd_priv. That is associated
> with every command and is put on cmnd->host_scribble, I than moved lots
> of abused Scp and other members to that new structure. I also put a 
> simple boolean that states that these are Internal commands. So what
> is left of this patch is the:
> -    scp->done = gdth_scsi_done;
> I will add that one line removal to your previous patch.

Excellent.  Makes perfect sense.

> > Ah; I was basing this on linus + scsi-misc.  I guess scsi_lib hadn't
> > been converted because I just took the code from there.
> Yes scsi_lib was not converted, but scsi.c was.

OK.  I've converted that in my tree now, and fixed a small whitespace
error I introduced.  I'll wait for more comments before posting a
replacement patch.

-- 
Intel are signing my paycheques ... these opinions are still mine
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

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

* Re: Remove ->done from scsi_cmnd
  2007-09-25 16:42 Remove ->done from scsi_cmnd Matthew Wilcox
                   ` (3 preceding siblings ...)
  2007-09-25 16:42 ` [PATCH] Get rid of scsi_cmnd->done Matthew Wilcox
@ 2007-09-26 19:54 ` Christoph Hellwig
  4 siblings, 0 replies; 10+ messages in thread
From: Christoph Hellwig @ 2007-09-26 19:54 UTC (permalink / raw)
  To: Matthew Wilcox; +Cc: linux-scsi

This whole patch series looks very nice.

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

end of thread, other threads:[~2007-09-26 19:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-25 16:42 Remove ->done from scsi_cmnd Matthew Wilcox
2007-09-25 16:42 ` [PATCH] Fix mistaken uses of ->done Matthew Wilcox
2007-09-25 16:42 ` [PATCH] pluto: Don't abuse ->done for internal commands Matthew Wilcox
2007-09-25 16:42 ` [PATCH] gdth: Stop abusing " Matthew Wilcox
2007-09-25 17:30   ` Boaz Harrosh
2007-09-25 17:33     ` Matthew Wilcox
2007-09-25 16:42 ` [PATCH] Get rid of scsi_cmnd->done Matthew Wilcox
2007-09-25 17:05   ` Boaz Harrosh
2007-09-25 17:09     ` Matthew Wilcox
2007-09-26 19:54 ` Remove ->done from scsi_cmnd Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox