Patchwork [isci,v2,12/18] libata: make ata_print_id atomic

login
register
mail settings
Submitter Dan Williams
Date March 11, 2012, 7:28 a.m.
Message ID <20120311072845.6320.68461.stgit@dwillia2-linux.jf.intel.com>
Download mbox | patch
Permalink /patch/145957/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Dan Williams - March 11, 2012, 7:28 a.m.
This variable is incremented from multiple contexts (module_init via
libata-lldds and the libsas discovery thread).  Make it atomic to head
off any chance of libsas and libata creating duplicate ids.

Acked-by: Jacek Danecki <jacek.danecki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/ata/libata-core.c |    4 ++--
 drivers/ata/libata-scsi.c |    4 ++--
 drivers/ata/libata.h      |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dan Williams - April 11, 2012, 2:21 a.m.
Ping? I assume this fairly uncontroversial and can be 3.4-rc material.

On Sat, Mar 10, 2012 at 11:28 PM, Dan Williams <dan.j.williams@intel.com> wrote:
> This variable is incremented from multiple contexts (module_init via
> libata-lldds and the libsas discovery thread).  Make it atomic to head
> off any chance of libsas and libata creating duplicate ids.
>
> Acked-by: Jacek Danecki <jacek.danecki@intel.com>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
>  drivers/ata/libata-core.c |    4 ++--
>  drivers/ata/libata-scsi.c |    4 ++--
>  drivers/ata/libata.h      |    2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> index ea8444e..bd79c8b 100644
> --- a/drivers/ata/libata-core.c
> +++ b/drivers/ata/libata-core.c
> @@ -97,7 +97,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
>  static void ata_dev_xfermask(struct ata_device *dev);
>  static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
>
> -unsigned int ata_print_id = 1;
> +atomic_t ata_print_id = ATOMIC_INIT(1);
>
>  struct ata_force_param {
>        const char      *name;
> @@ -6031,7 +6031,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
>
>        /* give ports names and add SCSI hosts */
>        for (i = 0; i < host->n_ports; i++)
> -               host->ports[i]->print_id = ata_print_id++;
> +               host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
>
>
>        /* Create associated sysfs transport objects  */
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index 1ee00c8..93dabdc 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -3843,7 +3843,7 @@ int ata_sas_async_port_init(struct ata_port *ap)
>        int rc = ap->ops->port_start(ap);
>
>        if (!rc) {
> -               ap->print_id = ata_print_id++;
> +               ap->print_id = atomic_inc_return(&ata_print_id);
>                __ata_port_probe(ap);
>        }
>
> @@ -3867,7 +3867,7 @@ int ata_sas_port_init(struct ata_port *ap)
>        int rc = ap->ops->port_start(ap);
>
>        if (!rc) {
> -               ap->print_id = ata_print_id++;
> +               ap->print_id = atomic_inc_return(&ata_print_id);
>                rc = ata_port_probe(ap);
>        }
>
> diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
> index 2e26fca..9d0fd0b 100644
> --- a/drivers/ata/libata.h
> +++ b/drivers/ata/libata.h
> @@ -53,7 +53,7 @@ enum {
>        ATA_DNXFER_QUIET        = (1 << 31),
>  };
>
> -extern unsigned int ata_print_id;
> +extern atomic_t ata_print_id;
>  extern int atapi_passthru16;
>  extern int libata_fua;
>  extern int libata_noacpi;
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jacek Danecki - April 11, 2012, 11:42 a.m.
On 04/11/12 04:21, Dan Williams wrote:
> Ping? I assume this fairly uncontroversial and can be 3.4-rc material.
>

Acked-by: Jacek Danecki <jacek.danecki@intel.com>
Jack Wang - April 11, 2012, 1:42 p.m.
Acked-by: Jack Wang <jack_wang@usish.com>




--------------
jack_wang
>On 04/11/12 04:21, Dan Williams wrote:

>> Ping? I assume this fairly uncontroversial and can be 3.4-rc material.

>>

>

>Acked-by: Jacek Danecki <jacek.danecki@intel.com>

>-- 

>Jacek

>--

>To unsubscribe from this list: send the line "unsubscribe linux-scsi" in

>the body of a message to majordomo@vger.kernel.org

>More majordomo info at  http://vger.kernel.org/majordomo-info.html

>

>__________ Information from ESET NOD32 Antivirus, version of virus signature database 5659 (20101129) __________

>

>The message was checked by ESET NOD32 Antivirus.

>

>http://www.eset.com

>

>

>
Jeff Garzik - April 12, 2012, 7:58 p.m.
On 03/11/2012 03:28 AM, Dan Williams wrote:
> This variable is incremented from multiple contexts (module_init via
> libata-lldds and the libsas discovery thread).  Make it atomic to head
> off any chance of libsas and libata creating duplicate ids.
>
> Acked-by: Jacek Danecki<jacek.danecki@intel.com>
> Signed-off-by: Dan Williams<dan.j.williams@intel.com>
> ---
>   drivers/ata/libata-core.c |    4 ++--
>   drivers/ata/libata-scsi.c |    4 ++--
>   drivers/ata/libata.h      |    2 +-
>   3 files changed, 5 insertions(+), 5 deletions(-)

applied



--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index ea8444e..bd79c8b 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -97,7 +97,7 @@  static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
 static void ata_dev_xfermask(struct ata_device *dev);
 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
 
-unsigned int ata_print_id = 1;
+atomic_t ata_print_id = ATOMIC_INIT(1);
 
 struct ata_force_param {
 	const char	*name;
@@ -6031,7 +6031,7 @@  int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
 
 	/* give ports names and add SCSI hosts */
 	for (i = 0; i < host->n_ports; i++)
-		host->ports[i]->print_id = ata_print_id++;
+		host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
 
 
 	/* Create associated sysfs transport objects  */
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 1ee00c8..93dabdc 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3843,7 +3843,7 @@  int ata_sas_async_port_init(struct ata_port *ap)
 	int rc = ap->ops->port_start(ap);
 
 	if (!rc) {
-		ap->print_id = ata_print_id++;
+		ap->print_id = atomic_inc_return(&ata_print_id);
 		__ata_port_probe(ap);
 	}
 
@@ -3867,7 +3867,7 @@  int ata_sas_port_init(struct ata_port *ap)
 	int rc = ap->ops->port_start(ap);
 
 	if (!rc) {
-		ap->print_id = ata_print_id++;
+		ap->print_id = atomic_inc_return(&ata_print_id);
 		rc = ata_port_probe(ap);
 	}
 
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 2e26fca..9d0fd0b 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -53,7 +53,7 @@  enum {
 	ATA_DNXFER_QUIET	= (1 << 31),
 };
 
-extern unsigned int ata_print_id;
+extern atomic_t ata_print_id;
 extern int atapi_passthru16;
 extern int libata_fua;
 extern int libata_noacpi;