From: Matthew Wilcox <willy@linux.intel.com>
To: linux-scsi@vger.kernel.org
Subject: [PATCH 1/3] SCSI: Make cmd_serial_number an atomic
Date: Fri, 1 Apr 2011 16:20:51 -0400 [thread overview]
Message-ID: <20110401202051.GL4183@linux.intel.com> (raw)
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;
next reply other threads:[~2011-04-01 20:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-01 20:20 Matthew Wilcox [this message]
2011-04-02 13:36 ` [PATCH 1/3] SCSI: Make cmd_serial_number an atomic 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
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=20110401202051.GL4183@linux.intel.com \
--to=willy@linux.intel.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).