linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tomas Henzl <thenzl@redhat.com>
To: Don Brace <don.brace@pmcs.com>,
	scott.teel@pmcs.com, Kevin.Barnett@pmcs.com,
	scott.benesh@pmcs.com, james.bottomley@parallels.com,
	hch@infradead.org, Justin.Lindley@pmcs.com, elliott@hpe.com
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 05/21] hpsa: fix hpsa_adjust_hpsa_scsi_table
Date: Mon, 26 Oct 2015 15:55:43 +0100	[thread overview]
Message-ID: <562E3EEF.1090301@redhat.com> (raw)
In-Reply-To: <20151024195256.17127.93962.stgit@brunhilda>

On 24.10.2015 21:52, Don Brace wrote:
> Fix a NULL pointer issue in the driver when devices are removed
> during a reset.
>
> Signed-off-by: Don Brace <don.brace@pmcs.com>
> ---
>  drivers/block/cciss.h |    1 +
>  drivers/scsi/hpsa.c   |   16 ++++++++++++++++
>  drivers/scsi/hpsa.h   |    1 +
>  3 files changed, 18 insertions(+)
>
> diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
> index 7fda30e..036fb0f 100644
> --- a/drivers/block/cciss.h
> +++ b/drivers/block/cciss.h
> @@ -155,6 +155,7 @@ struct ctlr_info
>  	size_t reply_pool_size;
>  	unsigned char reply_pool_wraparound;
>  	u32 *blockFetchTable;
> +	atomic_t reset_in_progress;
>  };
>  
>  /*  Defining the diffent access_methods
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 3520d75..714bb76 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -1656,6 +1656,11 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>  	int nadded, nremoved;
>  	struct Scsi_Host *sh = NULL;
>  
> +	if (atomic_read(&h->reset_in_progress)) {
> +		h->drv_req_rescan = 1;
> +		return;
> +	}

Is it safe, what happens when a reset is invoked at this point?
Is it possible to somehow reuse the scan_lock or scan_finished
and change the logic and wait with the reset?
(maybe break and reschedule the scan)

Btw. why is an atomic variable needed here?

--tm


> +
>  	added = kzalloc(sizeof(*added) * HPSA_MAX_DEVICES, GFP_KERNEL);
>  	removed = kzalloc(sizeof(*removed) * HPSA_MAX_DEVICES, GFP_KERNEL);
>  
> @@ -1764,8 +1769,14 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>  		goto free_and_out;
>  
>  	sh = h->scsi_host;
> +	if (sh == NULL) {
> +		dev_warn(&h->pdev->dev, "%s: scsi_host is null\n", __func__);
> +		return;
> +	}
>  	/* Notify scsi mid layer of any removed devices */
>  	for (i = 0; i < nremoved; i++) {
> +		if (!removed[i])
> +			continue;
>  		if (removed[i]->expose_state & HPSA_SCSI_ADD) {
>  			struct scsi_device *sdev =
>  				scsi_device_lookup(sh, removed[i]->bus,
> @@ -1790,6 +1801,8 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int hostno,
>  
>  	/* Notify scsi mid layer of any added devices */
>  	for (i = 0; i < nadded; i++) {
> +		if (!added[i])
> +			continue;
>  		if (!(added[i]->expose_state & HPSA_SCSI_ADD))
>  			continue;
>  		if (scsi_add_device(sh, added[i]->bus,
> @@ -5227,12 +5240,15 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
>  
>  	hpsa_show_dev_msg(__stringify(KERN_WARNING), h, dev, "resetting");
>  
> +	atomic_set(&h->reset_in_progress, 1);
> +
>  	/* send a reset to the SCSI LUN which the command was sent to */
>  	rc = hpsa_do_reset(h, dev, dev->scsi3addr, HPSA_RESET_TYPE_LUN,
>  			   DEFAULT_REPLY_QUEUE);
>  	snprintf(msg, sizeof(msg), "reset %s",
>  		 rc == 0 ? "completed successfully" : "failed");
>  	hpsa_show_dev_msg(__stringify(KERN_WARNING), h, dev, msg);
> +	atomic_set(&h->reset_in_progress, 0);
>  	return rc == 0 ? SUCCESS : FAILED;
>  }
>  
> diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
> index 642c8ce..c7c1697 100644
> --- a/drivers/scsi/hpsa.h
> +++ b/drivers/scsi/hpsa.h
> @@ -271,6 +271,7 @@ struct ctlr_info {
>  	wait_queue_head_t abort_cmd_wait_queue;
>  	wait_queue_head_t event_sync_wait_queue;
>  	struct mutex reset_mutex;
> +	atomic_t reset_in_progress;
>  };
>  
>  struct offline_device_entry {
>
> --
> 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


  reply	other threads:[~2015-10-26 14:55 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-24 19:52 [PATCH 00/21] hpsa updates Don Brace
2015-10-24 19:52 ` [PATCH 01/21] hpsa: correct calls to dev_printk Don Brace
2015-10-26 12:52   ` Tomas Henzl
2015-10-26 13:41     ` Don Brace
2015-10-24 19:52 ` [PATCH 02/21] hpsa: allow driver requested rescans Don Brace
2015-10-26 14:36   ` Tomas Henzl
2015-10-24 19:52 ` [PATCH 03/21] hpsa: abandon rescans on memory alloaction failures Don Brace
2015-10-26 14:24   ` Tomas Henzl
2015-10-26 14:29     ` Don Brace
2015-10-26 14:32       ` Tomas Henzl
2015-10-26 14:36         ` Tomas Henzl
2015-10-24 19:52 ` [PATCH 04/21] hpsa: correct transfer length for 6 byte read/write commands Don Brace
2015-10-26 14:37   ` Tomas Henzl
2015-10-24 19:52 ` [PATCH 05/21] hpsa: fix hpsa_adjust_hpsa_scsi_table Don Brace
2015-10-26 14:55   ` Tomas Henzl [this message]
2015-10-26 15:22     ` Don Brace
2015-10-24 19:53 ` [PATCH 06/21] hpsa: fix physical target reset Don Brace
2015-10-24 19:53 ` [PATCH 07/21] hpsa: correct check for non-disk devices Don Brace
2015-10-24 19:53 ` [PATCH 08/21] hpsa: correct ioaccel2 sg chain len Don Brace
2015-10-24 19:53 ` [PATCH 09/21] hpsa: simplify check for device exposure Don Brace
2015-10-24 19:53 ` [PATCH 10/21] hpsa: simplify update scsi devices Don Brace
2015-10-24 19:53 ` [PATCH 11/21] hpsa: add function is_logical_device Don Brace
2015-10-24 19:53 ` [PATCH 12/21] hpsa: enhance hpsa_get_device_id Don Brace
2015-10-24 19:53 ` [PATCH 13/21] hpsa: refactor hpsa_figure_bus_target_lun Don Brace
2015-10-24 19:53 ` [PATCH 14/21] hpsa: move scsi_add_device and scsi_remove_device calls to new function Don Brace
2015-10-24 19:53 ` [PATCH 15/21] External array LUNs must use target and lun numbers assigned by the Don Brace
2015-10-24 19:54 ` [PATCH 16/21] hpsa: eliminate fake lun0 enclosures Don Brace
2015-10-24 19:54 ` [PATCH 17/21] hpsa: add discovery polling for PT RAID devices Don Brace
2015-10-24 19:54 ` [PATCH 18/21] hpsa: disable report lun data caching Don Brace
2015-10-24 19:54 ` [PATCH 19/21] hpsa: enhance device messages Don Brace
2015-10-24 20:19   ` kbuild test robot
2015-10-26 13:36     ` Don Brace
2015-10-24 19:54 ` [PATCH 20/21] hpsa: add in sas transport class Don Brace
2015-10-24 19:54 ` [PATCH 21/21] hpsa: bump the driver version Don Brace

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=562E3EEF.1090301@redhat.com \
    --to=thenzl@redhat.com \
    --cc=Justin.Lindley@pmcs.com \
    --cc=Kevin.Barnett@pmcs.com \
    --cc=don.brace@pmcs.com \
    --cc=elliott@hpe.com \
    --cc=hch@infradead.org \
    --cc=james.bottomley@parallels.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=scott.benesh@pmcs.com \
    --cc=scott.teel@pmcs.com \
    /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).