linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] SCSI: Make cmd_serial_number an atomic
@ 2011-04-01 20:20 Matthew Wilcox
  2011-04-02 13:36 ` Christoph Hellwig
  0 siblings, 1 reply; 10+ messages in thread
From: Matthew Wilcox @ 2011-04-01 20:20 UTC (permalink / raw)
  To: linux-scsi


In preparation for moving some drivers out from under the host_lock,
make cmd_serial_number an atomic.

Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 2aeb2e9..13a3bf0 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -631,14 +631,15 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
  * @host: the scsi host
  * @cmd: command to assign serial number to
  *
- * Description: a serial number identifies a request for error recovery
- * and debugging purposes.  Protected by the Host_Lock of host.
+ * A serial number identifies a request for error recovery and debugging
+ * purposes.
  */
 void scsi_cmd_get_serial(struct Scsi_Host *host, struct scsi_cmnd *cmd)
 {
-	cmd->serial_number = host->cmd_serial_number++;
+ again:
+	cmd->serial_number = atomic_inc_return(&host->cmd_serial_number);
 	if (cmd->serial_number == 0) 
-		cmd->serial_number = host->cmd_serial_number++;
+		goto again;
 }
 EXPORT_SYMBOL(scsi_cmd_get_serial);
 
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index e7e3858..69dfabb 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -621,11 +621,9 @@ struct Scsi_Host {
 	short unsigned int sg_prot_tablesize;
 	short unsigned int max_sectors;
 	unsigned long dma_boundary;
-	/* 
-	 * Used to assign serial numbers to the cmds.
-	 * Protected by the host lock.
-	 */
-	unsigned long cmd_serial_number;
+
+	/* Used to assign serial numbers to the cmds.  */
+	atomic_t cmd_serial_number;
 	
 	unsigned active_mode:2;
 	unsigned unchecked_isa_dma:1;

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

end of thread, other threads:[~2011-04-03 19:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-01 20:20 [PATCH 1/3] SCSI: Make cmd_serial_number an atomic Matthew Wilcox
2011-04-02 13:36 ` Christoph Hellwig
2011-04-02 13:51   ` James Bottomley
2011-04-02 18:10   ` Jeff Garzik
2011-04-02 21:02   ` Matthew Wilcox
2011-04-03 11:00     ` Christoph Hellwig
2011-04-03 12:14       ` James Bottomley
2011-04-03 13:15       ` Matthew Wilcox
2011-04-03 13:33         ` Christoph Hellwig
2011-04-03 19:54           ` James Bottomley

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).