Re: RFC: Allow block drivers to poll for I/O instead of sleeping
On 06/25/13 05:18, Matthew Wilcox wrote: On Mon, Jun 24, 2013 at 10:07:51AM +0200, Ingo Molnar wrote: I'm wondering, how will this scheme work if the IO completion latency is a lot more than the 5 usecs in the testcase? What if it takes 20 usecs or 100 usecs or more? There's clearly a threshold at which it stops making sense, and our current NAND-based SSDs are almost certainly on the wrong side of that threshold! I can't wait for one of the "post-NAND" technologies to make it to market in some form that makes it economical to use in an SSD. The problem is that some of the people who are looking at those technologies are crazy. They want to "bypass the kernel" and "do user space I/O" because "the kernel is too slow". This patch is part of an effort to show them how crazy they are. And even if it doesn't convince them, at least users who refuse to rewrite their applications to take advantage of magical userspace I/O libraries will see real performance benefits. Recently I attended an interesting talk about this subject in which it was proposed not only to bypass the kernel for access to high-IOPS devices but also to allow byte-addressability for block devices. The slides that accompanied that talk can be found here (includes a performance comparison with the traditional block driver API): Bernard Metzler, On Suitability of High-Performance Networking API for Storage, OFA Int'l Developer Workshop, April 24, 2013 (http://www.openfabrics.org/ofa-documents/presentations/doc_download/559-on-suitability-of-high-performance-networking-api-for-storage.html). This approach leaves the choice of whether to use polling or an interrupt-based completion notification to the user of the new API, something the Linux InfiniBand RDMA verbs API already allows today. Bart. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v11 3/9] Avoid calling __scsi_remove_device() twice
On 06/24/13 19:38, James Bottomley wrote: > On Wed, 2013-06-12 at 14:52 +0200, Bart Van Assche wrote: >> SCSI devices are added to the shost->__devices list from inside >> scsi_alloc_sdev(). If something goes wrong during LUN scanning, >> e.g. a transport layer failure occurs, then __scsi_remove_device() >> can get invoked by the LUN scanning code for a SCSI device in >> state SDEV_CREATED_BLOCK or SDEV_BLOCKED. If this happens then >> the SCSI device has not yet been added to sysfs (is_visible == 0). >> Make sure that if this happens these devices are transitioned >> into state SDEV_DEL. This avoids that __scsi_remove_device() >> gets invoked a second time by scsi_forget_host(). > > The current principle is that scsi_remove_device can fail, so the > condition you're avoiding is expected. If you want to make it always > succeed, we have to worry about any device state racing with an > asynchronous remove, which looks like a whole nasty can of worms. > > The change log makes it sound like what you actually want to enable is > the ability to remove devices which fail probing but which are in the > blocked state, so why not just respin with only that, which is just > adding the blocked states to the ->SDEV_DEL state transitions? If what you had in mind is the patch below, I think we agree: diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index e3d6276..eaea242 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2185,6 +2185,8 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) case SDEV_OFFLINE: case SDEV_TRANSPORT_OFFLINE: case SDEV_CANCEL: + case SDEV_BLOCK: + case SDEV_CREATED_BLOCK: break; default: goto illegal; -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v11 4/9] Disallow changing the device state via sysfs into "deleted"
On 06/24/13 19:59, James Bottomley wrote: On Wed, 2013-06-12 at 14:53 +0200, Bart Van Assche wrote: Changing the state of a SCSI device via sysfs into "cancel" or "deleted" prevents removal of these devices by scsi_remove_host(). Hence do not allow this. Also, introduce the symbolic name INVALID_SDEV_STATE, representing a value different from any valid SCSI device state. Update scsi_device_set_state() such that gcc does not issue a warning about an enumeration value not being handled inside a switch statement. zero is the invalid state, that's why the SDEV_ states start at 1. Using a bare zero also means that gcc doesn't have to consider it in the switch statement, so there's no need to introduce a new one. If we want to try to babysit user initiated state changes, then it looks like OFFLINE<->RUNNING might be the only useful ones? How about the BLOCKED<>RUNNING and QUIESCE<>RUNNING transitions ? I think it may be useful for a user to trigger these as well. Bart. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v11 6/9] Make scsi_remove_host() wait until error handling finished
On 06/25/13 00:27, James Bottomley wrote: On Mon, 2013-06-24 at 15:04 -0500, Mike Christie wrote: On 06/24/2013 02:19 PM, James Bottomley wrote: On Wed, 2013-06-12 at 14:55 +0200, Bart Van Assche wrote: A SCSI LLD may start cleaning up host resources as soon as scsi_remove_host() returns. These host resources may be needed by the LLD in an implementation of one of the eh_* functions. So if one of the eh_* functions is in progress when scsi_remove_host() is invoked, wait until the eh_* function has finished. Also, do not invoke any of the eh_* functions after scsi_remove_host() has started. We already have state guards for this, don't we? That's the SHOST_*_RECOVERY ones. When eh functions are active, the host transitions to a recovery state, so the wait could just wait on that state rather than implement an open coded counting semaphore. That seems better. For the sg_reset_provider case we just would have to also wait on the tmf_in_progress bit. The simplest way is may just be to move the kthread_stop() from release to remove. That synchronously waits for the outstanding error handling to complete and the eh thread to stop. Perhaps the eh thread should also wait for tmf in progress before it dies? Regarding TMF that are in progress: my preference is to leave it to the LLD to wait for any TMF in progress if necessary. At least with SRP over RDMA it is possible to prevent receiving further TMF completion notifications by closing the connection over which these TMF were sent. There is a difference though between moving the EH kthread_stop() call and the patch at the start of this thread: moving the EH kthread_stop() call does not prevent that an ioctl like SG_SCSI_RESET triggers an eh_* callback after scsi_remove_host() has finished. However, the scsi_begin_eh() / scsi_end_eh() functions do prevent that an ioctl can cause an eh_* callback to be invoked after scsi_remove_device() finished. Bart. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v11 6/9] Make scsi_remove_host() wait until error handling finished
On 06/25/13 00:27, James Bottomley wrote: For a variety of reasons this patch set is incredibly hard to review: Almost every patch touches pieces in the mid layer where you have to be sure in minute detail you know what's going on (and what should be going on), so usually it's a couple of hours with the source code just making sure you do know this. Plus it's code where the underlying usage model has evolved over the years meaning the original guarantees might have been violated silently somewhere and the ramifications spread out like tentacles everywhere. Finally, it's not clear from the change logs why the changes are actually being made: for instance sentence one of this change log says "A SCSI LLD may start cleaning up host resources as soon as scsi_remove_host() returns." which causes my sanity checker to go off immediately because in a refcounted model, like we use for dev, target and host, nothing essential is supposed to be freed until the last put which may or may not happen in the remove function. If the invocations of the eh_* callback functions would be visible to the block layer then blk_cleanup_queue() would wait until any such eh_* invocations have finished. Such an approach could simplify device removal in the SCSI mid-layer significantly. It also would avoid that an eh_* callback can be invoked via an ioctl after scsi_remove_device() has finished. Bart. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 8/9] scsi/pm8001: use pdev->pm_cap instead of pci_find_capability(..,PCI_CAP_ID_PM)
Hi, Any comments? On 2013/6/18 16:23, Yijing Wang wrote: > Pci core has been saved pm cap register offset by pdev->pm_cap in > pci_pm_init() > in init path. So we can use pdev->pm_cap instead of using > pci_find_capability(pdev, PCI_CAP_ID_PM) for better performance and > simplified code. > > Signed-off-by: Yijing Wang > Cc: xjtu...@gmail.com > Cc: lindar_...@usish.com > Cc: "James E.J. Bottomley" > Cc: linux-scsi@vger.kernel.org > Cc: linux-ker...@vger.kernel.org > --- > drivers/scsi/pm8001/pm8001_init.c |7 +++ > 1 files changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/scsi/pm8001/pm8001_init.c > b/drivers/scsi/pm8001/pm8001_init.c > index e4b9bc7..3861aa1 100644 > --- a/drivers/scsi/pm8001/pm8001_init.c > +++ b/drivers/scsi/pm8001/pm8001_init.c > @@ -912,14 +912,13 @@ static int pm8001_pci_suspend(struct pci_dev *pdev, > pm_message_t state) > { > struct sas_ha_struct *sha = pci_get_drvdata(pdev); > struct pm8001_hba_info *pm8001_ha; > - int i , pos; > + int i; > u32 device_state; > pm8001_ha = sha->lldd_ha; > flush_workqueue(pm8001_wq); > scsi_block_requests(pm8001_ha->shost); > - pos = pci_find_capability(pdev, PCI_CAP_ID_PM); > - if (pos == 0) { > - printk(KERN_ERR " PCI PM not supported\n"); > + if (!pdev->pm_cap) { > + dev_err(&pdev->dev, " PCI PM not supported\n"); > return -ENODEV; > } > PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF); > -- Thanks! Yijing -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v11 4/9] Disallow changing the device state via sysfs into "deleted"
On Tue, 2013-06-25 at 10:41 +0200, Bart Van Assche wrote: > On 06/24/13 19:59, James Bottomley wrote: > > On Wed, 2013-06-12 at 14:53 +0200, Bart Van Assche wrote: > >> Changing the state of a SCSI device via sysfs into "cancel" or > >> "deleted" prevents removal of these devices by scsi_remove_host(). > >> Hence do not allow this. Also, introduce the symbolic name > >> INVALID_SDEV_STATE, representing a value different from any valid > >> SCSI device state. Update scsi_device_set_state() such that gcc > >> does not issue a warning about an enumeration value not being > >> handled inside a switch statement. > > > > zero is the invalid state, that's why the SDEV_ states start at 1. > > Using a bare zero also means that gcc doesn't have to consider it in the > > switch statement, so there's no need to introduce a new one. > > > > If we want to try to babysit user initiated state changes, then it looks > > like OFFLINE<->RUNNING might be the only useful ones? > > How about the BLOCKED<>RUNNING and QUIESCE<>RUNNING transitions ? I > think it may be useful for a user to trigger these as well. They're part of paired state, so the user would tamper with assumptions the HBA is making ... also, just changing the state doesn't help, the queue needs to be restarted for these transitions which it currently isn't. James -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v11 3/9] Avoid calling __scsi_remove_device() twice
On Tue, 2013-06-25 at 10:37 +0200, Bart Van Assche wrote: > On 06/24/13 19:38, James Bottomley wrote: > > On Wed, 2013-06-12 at 14:52 +0200, Bart Van Assche wrote: > >> SCSI devices are added to the shost->__devices list from inside > >> scsi_alloc_sdev(). If something goes wrong during LUN scanning, > >> e.g. a transport layer failure occurs, then __scsi_remove_device() > >> can get invoked by the LUN scanning code for a SCSI device in > >> state SDEV_CREATED_BLOCK or SDEV_BLOCKED. If this happens then > >> the SCSI device has not yet been added to sysfs (is_visible == 0). > >> Make sure that if this happens these devices are transitioned > >> into state SDEV_DEL. This avoids that __scsi_remove_device() > >> gets invoked a second time by scsi_forget_host(). > > > > The current principle is that scsi_remove_device can fail, so the > > condition you're avoiding is expected. If you want to make it always > > succeed, we have to worry about any device state racing with an > > asynchronous remove, which looks like a whole nasty can of worms. > > > > The change log makes it sound like what you actually want to enable is > > the ability to remove devices which fail probing but which are in the > > blocked state, so why not just respin with only that, which is just > > adding the blocked states to the ->SDEV_DEL state transitions? > > If what you had in mind is the patch below, I think we agree: > > diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c > index e3d6276..eaea242 100644 > --- a/drivers/scsi/scsi_lib.c > +++ b/drivers/scsi/scsi_lib.c > @@ -2185,6 +2185,8 @@ scsi_device_set_state(struct scsi_device *sdev, enum > scsi_device_state state) > case SDEV_OFFLINE: > case SDEV_TRANSPORT_OFFLINE: > case SDEV_CANCEL: > + case SDEV_BLOCK: > + case SDEV_CREATED_BLOCK: Something like this, yes. For the probe lun case, we have to be in CREATED, so any block action transitions only to CREATED_BLOCK. The BLOCK->DEL transition can only be a result of an async remove racing with bringup, can't it? Which is something I think we still want to forbid. James -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v11 6/9] Make scsi_remove_host() wait until error handling finished
On Tue, 2013-06-25 at 11:01 +0200, Bart Van Assche wrote: > On 06/25/13 00:27, James Bottomley wrote: > > On Mon, 2013-06-24 at 15:04 -0500, Mike Christie wrote: > >> On 06/24/2013 02:19 PM, James Bottomley wrote: > >>> On Wed, 2013-06-12 at 14:55 +0200, Bart Van Assche wrote: > A SCSI LLD may start cleaning up host resources as soon as > scsi_remove_host() returns. These host resources may be needed by > the LLD in an implementation of one of the eh_* functions. So if > one of the eh_* functions is in progress when scsi_remove_host() > is invoked, wait until the eh_* function has finished. Also, do > not invoke any of the eh_* functions after scsi_remove_host() has > started. > >>> > >>> We already have state guards for this, don't we? That's the > >>> SHOST_*_RECOVERY ones. When eh functions are active, the host > >>> transitions to a recovery state, so the wait could just wait on that > >>> state rather than implement an open coded counting semaphore. > >> > >> That seems better. For the sg_reset_provider case we just would have to > >> also wait on the tmf_in_progress bit. > > > > The simplest way is may just be to move the kthread_stop() from release > > to remove. That synchronously waits for the outstanding error handling > > to complete and the eh thread to stop. Perhaps the eh thread should > > also wait for tmf in progress before it dies? > > Regarding TMF that are in progress: my preference is to leave it to the > LLD to wait for any TMF in progress if necessary. At least with SRP over > RDMA it is possible to prevent receiving further TMF completion > notifications by closing the connection over which these TMF were sent. > > There is a difference though between moving the EH kthread_stop() call > and the patch at the start of this thread: moving the EH kthread_stop() > call does not prevent that an ioctl like SG_SCSI_RESET triggers an eh_* > callback after scsi_remove_host() has finished. However, the > scsi_begin_eh() / scsi_end_eh() functions do prevent that an ioctl can > cause an eh_* callback to be invoked after scsi_remove_device() finished. OK, but this doesn't tell me what you're trying to achieve. An eh function is allowable as long as the host hadn't had the release callback executed. That means you must have to have a reference to the device/host to execute the eh function, which is currently guaranteed for all invocations. James -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: RFC: Allow block drivers to poll for I/O instead of sleeping
On Mon, 2013-06-24 at 23:07 -0400, Matthew Wilcox wrote: > On Mon, Jun 24, 2013 at 08:11:02PM -0400, Steven Rostedt wrote: > > What about hooking into the idle_balance code? That happens if we are > > about to go to idle but before the full schedule switch to the idle > > task. > > > > > > In __schedule(void): > > > > if (unlikely(!rq->nr_running)) > > idle_balance(cpu, rq); > > That may be a great place to try it from the PoV of the scheduler, but are > you OK with me threading a struct backing_dev_info * all the way through > the scheduler to idle_balance()? :-) Well, there's other ways to pass data down besides parameters. You could attach something to the task itself. -- Steve -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: RFC: Allow block drivers to poll for I/O instead of sleeping
On Mon, Jun 24 2013, Matthew Wilcox wrote: > On Mon, Jun 24, 2013 at 09:15:45AM +0200, Jens Axboe wrote: > > Willy, I think the general design is fine, hooking in via the bdi is the > > only way to get back to the right place from where you need to sleep. > > Some thoughts: > > > > - This should be hooked in via blk-iopoll, both of them should call into > > the same driver hook for polling completions. > > I actually started working on this, then I realised that it's actually > a bad idea. blk-iopoll's poll function is to poll the single I/O queue > closest to this CPU. The iowait poll function is to poll all queues > that the I/O for this address_space might complete on. blk_iopoll can be tied to "whatever". It was originally designed to be tied to the queue, which would make it driver-wide. So there's no intent for it to poll only a subset of the device, though if you tie it to a completion queue (which would be most natural), then it'd only find completions there. I didn't look at your nvme end of the implementation - if you could reliably map to the right completion queue, then it would have the same mapping as iopoll on a per-completion queue basis. If you can't, then you have to poll all of them. That doesn't seem like it would scale well for having more than a few applications banging on a device. > I'm reluctant to ask drivers to define two poll functions, but I'm even > more reluctant to ask them to define one function with two purposes. > > > - It needs to be more intelligent in when you want to poll and when you > > want regular irq driven IO. > > Oh yeah, absolutely. While the example patch didn't show it, I wouldn't > enable it for all NVMe devices; only ones with sufficiently low latency. > There's also the ability for the driver to look at the number of > outstanding I/Os and return an error (eg -EBUSY) to stop spinning. There might also be read vs write differences. Say some devices complete writes very quickly, but reads are slower. Or vice versa. And then there's the inevitable "some IOs are slow, but usually very fast". But that can't really be handled except giving up on the polling at some point. > > - With the former note, the app either needs to opt in (and hence > > willingly sacrifice CPU cycles of its scheduling slice) or it needs to > > be nicer in when it gives up and goes back to irq driven IO. > > Yup. I like the way you framed it. If the task *wants* to spend its > CPU cycles on polling for I/O instead of giving up the remainder of its > time slice, then it should be able to do that. After all, it already can; > it can submit an I/O request via AIO, and then call io_getevents in a > tight loop. Exactly, that was my point. Or it can busy loop just checking the aio ring, at which point it's really stupid to be IRQ driven at all. It'd be much better to have the app reap the completion directly. > So maybe the right way to do this is with a task flag? If we go that > route, I'd like to further develop this option to allow I/Os to be > designated as "low latency" vs "normal". Taking a page fault would be > "low latency" for all tasks, not just ones that choose to spin for I/O. Not sure, I'd have to think about it some more. It's a mix of what the application decides to do, but also what the underlying device can do. And there might be fs implications, etc. -- Jens Axboe -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: RFC: Allow block drivers to poll for I/O instead of sleeping
On Mon, Jun 24 2013, Steven Rostedt wrote: > On Mon, Jun 24, 2013 at 09:17:18AM +0200, Jens Axboe wrote: > > On Sun, Jun 23 2013, Linus Torvalds wrote: > > > > > > You could try to do that either *in* the idle thread (which would take > > > the context switch overhead - maybe negating some of the advantages), > > > or alternatively hook into the scheduler idle logic before actually > > > doing the switch. > > > > It can't happen in the idle thread. If you need to take the context > > switch, then you've negated pretty much all of the gain of the polled > > approach. > > What about hooking into the idle_balance code? That happens if we are > about to go to idle but before the full schedule switch to the idle > task. > > > In __schedule(void): > > if (unlikely(!rq->nr_running)) > idle_balance(cpu, rq); If you can avoid the switch (sleep/wakeup), then that's what matters. If you end up sleeping, you've lost that latency game and polling is mostly useful in the blk_iopoll designed fashion for high iops scenarios. Besides, you need the task + page context to be able to find out what to poll for (and when to stop). -- Jens Axboe -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: RFC: Allow block drivers to poll for I/O instead of sleeping
On Mon, Jun 24 2013, Matthew Wilcox wrote: > On Mon, Jun 24, 2013 at 10:07:51AM +0200, Ingo Molnar wrote: > > I'm wondering, how will this scheme work if the IO completion latency is a > > lot more than the 5 usecs in the testcase? What if it takes 20 usecs or > > 100 usecs or more? > > There's clearly a threshold at which it stops making sense, and our > current NAND-based SSDs are almost certainly on the wrong side of that > threshold! I can't wait for one of the "post-NAND" technologies to make > it to market in some form that makes it economical to use in an SSD. > > The problem is that some of the people who are looking at those > technologies are crazy. They want to "bypass the kernel" and "do user > space I/O" because "the kernel is too slow". This patch is part of an > effort to show them how crazy they are. And even if it doesn't convince > them, at least users who refuse to rewrite their applications to take > advantage of magical userspace I/O libraries will see real performance > benefits. Fully concur with that. At least on the read side, nand is just getting crappier and polled completions is usually not going to be great. On the write side, however, there are definite gains. Completions in the 10-15usec range aren't unusual. And once we hit PCM, well, it'll be fun. On the write side, there are plenty of super latency customers out there who would LOVE to poll when/if it's useful. Most often also the same kind of people who talk the crazy of putting everything in user space. Which is why I like the polling. If we can get sufficiently close, then we can shut some of that up. -- Jens Axboe -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v11 3/9] Avoid calling __scsi_remove_device() twice
On 06/25/13 15:44, James Bottomley wrote: On Tue, 2013-06-25 at 10:37 +0200, Bart Van Assche wrote: On 06/24/13 19:38, James Bottomley wrote: On Wed, 2013-06-12 at 14:52 +0200, Bart Van Assche wrote: SCSI devices are added to the shost->__devices list from inside scsi_alloc_sdev(). If something goes wrong during LUN scanning, e.g. a transport layer failure occurs, then __scsi_remove_device() can get invoked by the LUN scanning code for a SCSI device in state SDEV_CREATED_BLOCK or SDEV_BLOCKED. If this happens then the SCSI device has not yet been added to sysfs (is_visible == 0). Make sure that if this happens these devices are transitioned into state SDEV_DEL. This avoids that __scsi_remove_device() gets invoked a second time by scsi_forget_host(). The current principle is that scsi_remove_device can fail, so the condition you're avoiding is expected. If you want to make it always succeed, we have to worry about any device state racing with an asynchronous remove, which looks like a whole nasty can of worms. The change log makes it sound like what you actually want to enable is the ability to remove devices which fail probing but which are in the blocked state, so why not just respin with only that, which is just adding the blocked states to the ->SDEV_DEL state transitions? If what you had in mind is the patch below, I think we agree: diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index e3d6276..eaea242 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2185,6 +2185,8 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) case SDEV_OFFLINE: case SDEV_TRANSPORT_OFFLINE: case SDEV_CANCEL: + case SDEV_BLOCK: + case SDEV_CREATED_BLOCK: Something like this, yes. For the probe lun case, we have to be in CREATED, so any block action transitions only to CREATED_BLOCK. The BLOCK->DEL transition can only be a result of an async remove racing with bringup, can't it? Which is something I think we still want to forbid. OK, I will leave the BLOCK->DEL transition out. Bart. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v11 6/9] Make scsi_remove_host() wait until error handling finished
On 06/25/13 15:45, James Bottomley wrote: On Tue, 2013-06-25 at 11:01 +0200, Bart Van Assche wrote: There is a difference though between moving the EH kthread_stop() call and the patch at the start of this thread: moving the EH kthread_stop() call does not prevent that an ioctl like SG_SCSI_RESET triggers an eh_* callback after scsi_remove_host() has finished. However, the scsi_begin_eh() / scsi_end_eh() functions do prevent that an ioctl can cause an eh_* callback to be invoked after scsi_remove_device() finished. OK, but this doesn't tell me what you're trying to achieve. An eh function is allowable as long as the host hadn't had the release callback executed. That means you must have to have a reference to the device/host to execute the eh function, which is currently guaranteed for all invocations. That raises a new question: how is an LLD expected to clean up resources without triggering a race condition ? What you wrote means that it's not safe for an LLD to start cleaning up the resources needed by the eh_* callbacks immediately after scsi_remove_device() returns since it it not guaranteed that at that time all references to the device have already been dropped. Bart. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 09/16] qla2xxx: Remove dead code in qla2x00_configure_hba()
From: Bart Van Assche At the end of qla2x00_configure_hba() we know that rval == QLA_SUCCESS. Hence remove the dead code. Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap --- drivers/scsi/qla2xxx/qla_dbg.c |1 + drivers/scsi/qla2xxx/qla_init.c |8 2 files changed, 1 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index 74a2121..91dbd81 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -15,6 +15,7 @@ * | Mailbox commands | 0x117a | 0x111a-0x111b | * | || 0x1155-0x1158 | * | Device Discovery | 0x2095 | 0x2020-0x2022, | + * | || 0x2011-0x2012, | * | || 0x2016 | * | Queue Command and IO tracing | 0x3058 | 0x3006-0x300b | * | || 0x3027-0x3028 | diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 3565dfd..f2216ed 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -2309,14 +2309,6 @@ qla2x00_configure_hba(scsi_qla_host_t *vha) "Topology - %s, Host Loop address 0x%x.\n", connect_type, vha->loop_id); - if (rval) { - ql_log(ql_log_warn, vha, 0x2011, - "%s FAILED\n", __func__); - } else { - ql_dbg(ql_dbg_disc, vha, 0x2012, - "%s success\n", __func__); - } - return(rval); } -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 06/16] qla2xxx: Fix sparse warning from qla_mr.c and qla_iocb.c.
Signed-off-by: Giridhar Malavali Signed-off-by: Saurav Kashyap --- drivers/scsi/qla2xxx/qla_def.h| 34 drivers/scsi/qla2xxx/qla_gbl.h|2 +- drivers/scsi/qla2xxx/qla_inline.h |2 +- drivers/scsi/qla2xxx/qla_iocb.c |4 +- drivers/scsi/qla2xxx/qla_mr.c | 167 +++-- drivers/scsi/qla2xxx/qla_mr.h | 98 +++--- 6 files changed, 157 insertions(+), 150 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h index c32efc7..95ca32a 100644 --- a/drivers/scsi/qla2xxx/qla_def.h +++ b/drivers/scsi/qla2xxx/qla_def.h @@ -323,7 +323,7 @@ struct srb_iocb { uint32_t lun; uint32_t data; struct completion comp; - uint32_t comp_status; + __le16 comp_status; } tmf; struct { #define SRB_FXDISC_REQ_DMA_VALID BIT_0 @@ -338,21 +338,21 @@ struct srb_iocb { void *rsp_addr; dma_addr_t req_dma_handle; dma_addr_t rsp_dma_handle; - uint32_t adapter_id; - uint32_t adapter_id_hi; - uint32_t req_func_type; - uint32_t req_data; - uint32_t req_data_extra; - uint32_t result; - uint32_t seq_number; - uint32_t fw_flags; + __le32 adapter_id; + __le32 adapter_id_hi; + __le16 req_func_type; + __le32 req_data; + __le32 req_data_extra; + __le32 result; + __le32 seq_number; + __le16 fw_flags; struct completion fxiocb_comp; - uint32_t reserved_0; + __le32 reserved_0; uint8_t reserved_1; } fxiocb; struct { uint32_t cmd_hndl; - uint32_t comp_status; + __le16 comp_status; struct completion comp; } abt; } u; @@ -1196,14 +1196,14 @@ typedef struct { struct init_cb_fx { uint16_tversion; uint16_treserved_1[13]; - uint16_trequest_q_outpointer; - uint16_tresponse_q_inpointer; + __le16 request_q_outpointer; + __le16 response_q_inpointer; uint16_treserved_2[2]; - uint16_tresponse_q_length; - uint16_trequest_q_length; + __le16 response_q_length; + __le16 request_q_length; uint16_treserved_3[2]; - uint32_trequest_q_address[2]; - uint32_tresponse_q_address[2]; + __le32 request_q_address[2]; + __le32 response_q_address[2]; uint16_treserved_4[4]; uint8_t response_q_msivec; uint8_t reserved_5[19]; diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h index 026bfde..2d98232 100644 --- a/drivers/scsi/qla2xxx/qla_gbl.h +++ b/drivers/scsi/qla2xxx/qla_gbl.h @@ -587,7 +587,7 @@ extern int qlafx00_init_firmware(scsi_qla_host_t *, uint16_t); extern int qlafx00_fw_ready(scsi_qla_host_t *); extern int qlafx00_configure_devices(scsi_qla_host_t *); extern int qlafx00_reset_initialize(scsi_qla_host_t *); -extern int qlafx00_fx_disc(scsi_qla_host_t *, fc_port_t *, uint8_t); +extern int qlafx00_fx_disc(scsi_qla_host_t *, fc_port_t *, uint16_t); extern int qlafx00_process_aen(struct scsi_qla_host *, struct qla_work_evt *); extern int qlafx00_post_aenfx_work(struct scsi_qla_host *, uint32_t, uint32_t *, int); diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h index 0a5c895..28c38b4 100644 --- a/drivers/scsi/qla2xxx/qla_inline.h +++ b/drivers/scsi/qla2xxx/qla_inline.h @@ -83,7 +83,7 @@ static inline void host_to_adap(uint8_t *src, uint8_t *dst, uint32_t bsize) { uint32_t *isrc = (uint32_t *) src; - uint32_t *odest = (uint32_t *) dst; + __le32 *odest = (__le32 *) dst; uint32_t iter = bsize >> 2; for (; iter ; iter--) diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 15e4080..9de372f 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -1863,8 +1863,8 @@ skip_cmd_array: pkt = req->ring_ptr; memset(pkt, 0, REQUEST_ENTRY_SIZE); if (IS_QLAFX00(ha)) { - WRT_REG_BYTE(&pkt->entry_count, req_cnt); - WRT_REG_WORD(&pkt->handle, handle); + WRT_REG_BYTE((void __iomem *)&pkt->entry_count, req_cnt); + WRT_REG_W
[PATCH 04/16] qla2xxx: Do not query FC statistics during chip reset.
From: Chad Dupuis During a chip reset, the mailbox call to get FC statistics from the ISP will not work resulting in needless mailbox accesses and errors printing out: qla2xxx [:05:00.0]-00af:11: Performing ISP error recovery - ha=881fad044800. qla2xxx [:05:00.0]-1020:11: Failed mbx[0]=4001, mb[1]=4953, mb[2]=5020, mb[3]=b100, cmd=6d . qla2xxx [:05:00.0]-1020:11: Failed mbx[0]=4001, mb[1]=4953, mb[2]=5020, mb[3]=b100, cmd=6d . qla2xxx [:05:00.0]-1020:11: Failed mbx[0]=4001, mb[1]=4953, mb[2]=5020, mb[3]=b100, cmd=6d . qla2xxx [:05:00.0]-1020:11: Failed mbx[0]=4001, mb[1]=4953, mb[2]=5020, mb[3]=b100, cmd=6d . qla2xxx [:05:00.0]-1020:11: Failed mbx[0]=4001, mb[1]=4953, mb[2]=5020, mb[3]=b100, cmd=6d . To prevent this, check for a chip reset when an application queries for FC stats and return immediately if a chip reset is occurring. Signed-off-by: Chad Dupuis Signed-off-by: Saurav Kashyap --- drivers/scsi/qla2xxx/qla_attr.c |5 - 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c index bf60c63..d7a99ae 100644 --- a/drivers/scsi/qla2xxx/qla_attr.c +++ b/drivers/scsi/qla2xxx/qla_attr.c @@ -1691,6 +1691,9 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost) if (unlikely(pci_channel_offline(ha->pdev))) goto done; + if (qla2x00_reset_active(vha)) + goto done; + stats = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &stats_dma); if (stats == NULL) { ql_log(ql_log_warn, vha, 0x707d, @@ -1703,7 +1706,7 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost) if (IS_FWI2_CAPABLE(ha)) { rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma); } else if (atomic_read(&base_vha->loop_state) == LOOP_READY && - !qla2x00_reset_active(vha) && !ha->dpc_active) { + !ha->dpc_active) { /* Must be in a 'READY' state for statistics retrieval. */ rval = qla2x00_get_link_status(base_vha, base_vha->loop_id, stats, stats_dma); -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 12/16] qla2xxx: Remove redundant assignments.
From: Bart Van Assche The value of the pointer called "nxt" is not used after the "nxt = qla24xx_copy_eft(ha, nxt)" statement. Hence keep the function call but remove the assignment. Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap --- drivers/scsi/qla2xxx/qla_dbg.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index 91dbd81..df132fe 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -1470,7 +1470,7 @@ qla25xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked) nxt = qla2xxx_copy_queues(ha, nxt); - nxt = qla24xx_copy_eft(ha, nxt); + qla24xx_copy_eft(ha, nxt); /* Chain entries -- started with MQ. */ nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain); @@ -1789,7 +1789,7 @@ qla81xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked) nxt = qla2xxx_copy_queues(ha, nxt); - nxt = qla24xx_copy_eft(ha, nxt); + qla24xx_copy_eft(ha, nxt); /* Chain entries -- started with MQ. */ nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain); @@ -2291,7 +2291,7 @@ qla83xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked) copy_queue: nxt = qla2xxx_copy_queues(ha, nxt); - nxt = qla24xx_copy_eft(ha, nxt); + qla24xx_copy_eft(ha, nxt); /* Chain entries -- started with MQ. */ nxt_chain = qla25xx_copy_fce(ha, nxt_chain, &last_chain); -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 01/16] qla2xxx: Clear the MBX_INTR_WAIT flag when the mailbox time-out happens.
From: Giridhar Malavali Signed-off-by: Giridhar Malavali Signed-off-by: Saurav Kashyap --- drivers/scsi/qla2xxx/qla_dbg.c |2 +- drivers/scsi/qla2xxx/qla_mbx.c | 10 -- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index cfa2a20..3cc2105 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -12,7 +12,7 @@ * | Level| Last Value Used | Holes | * -- * | Module Init and Probe| 0x014f | 0x4b,0xba,0xfa | - * | Mailbox commands | 0x1179 | 0x111a-0x111b | + * | Mailbox commands | 0x117a | 0x111a-0x111b | * | || 0x1155-0x1158 | * | Device Discovery | 0x2095 | 0x2020-0x2022, | * | || 0x2016 | diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 3587ec2..144effd 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -177,8 +177,14 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) WRT_REG_WORD(®->isp.hccr, HCCR_SET_HOST_INT); spin_unlock_irqrestore(&ha->hardware_lock, flags); - wait_for_completion_timeout(&ha->mbx_intr_comp, mcp->tov * HZ); - + if (!wait_for_completion_timeout(&ha->mbx_intr_comp, + mcp->tov * HZ)) { + ql_dbg(ql_dbg_mbx, vha, 0x117a, + "cmd=%x Timeout.\n", command); + spin_lock_irqsave(&ha->hardware_lock, flags); + clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); + spin_unlock_irqrestore(&ha->hardware_lock, flags); + } } else { ql_dbg(ql_dbg_mbx, vha, 0x1011, "Cmd=%x Polling Mode.\n", command); -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 03/16] qla2xxx: Move qla2x00_free_device to the correct location.
Signed-off-by: Giridhar Malavali Signed-off-by: Saurav Kashyap --- drivers/scsi/qla2xxx/qla_os.c |3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index ad72c1d..c2e2e20 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -104,8 +104,6 @@ MODULE_PARM_DESC(ql2xshiftctondsd, "Set to control shifting of command type processing " "based on total number of SG elements."); -static void qla2x00_free_device(scsi_qla_host_t *); - int ql2xfdmienable=1; module_param(ql2xfdmienable, int, S_IRUGO); MODULE_PARM_DESC(ql2xfdmienable, @@ -237,6 +235,7 @@ static int qla2xxx_eh_host_reset(struct scsi_cmnd *); static int qla2x00_change_queue_depth(struct scsi_device *, int, int); static int qla2x00_change_queue_type(struct scsi_device *, int); +static void qla2x00_free_device(scsi_qla_host_t *); struct scsi_host_template qla2xxx_driver_template = { .module = THIS_MODULE, -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 08/16] qla2xxx: Clean up qla84xx_mgmt_cmd()
From: Bart Van Assche Remove dead code, simplify a pointer computation and move the ql84_mgmt assignment to just before its first use. Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap --- drivers/scsi/qla2xxx/qla_bsg.c | 10 +- drivers/scsi/qla2xxx/qla_dbg.c |2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index 9a30b69..b85f002 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -1084,14 +1084,6 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job) return -EINVAL; } - ql84_mgmt = (struct qla_bsg_a84_mgmt *)((char *)bsg_job->request + - sizeof(struct fc_bsg_request)); - if (!ql84_mgmt) { - ql_log(ql_log_warn, vha, 0x703b, - "MGMT header not provided, exiting.\n"); - return -EINVAL; - } - mn = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &mn_dma); if (!mn) { ql_log(ql_log_warn, vha, 0x703c, @@ -1102,7 +1094,7 @@ qla84xx_mgmt_cmd(struct fc_bsg_job *bsg_job) memset(mn, 0, sizeof(struct access_chip_84xx)); mn->entry_type = ACCESS_CHIP_IOCB_TYPE; mn->entry_count = 1; - + ql84_mgmt = (void *)bsg_job->request + sizeof(struct fc_bsg_request); switch (ql84_mgmt->mgmt.cmd) { case QLA84_MGMT_READ_MEM: case QLA84_MGMT_GET_INFO: diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index 91a1166..74a2121 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -36,7 +36,7 @@ * | || 0x70a8,0x70ab, | * | || 0x70ad-0x70ae, | * | || 0x70d1-0x70da, | - * | || 0x7047 | + * | || 0x7047,0x703b | * | Task Management | 0x803c | 0x8025-0x8026 | * | || 0x800b,0x8039 | * | AER/EEH | 0x9011 | | -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 05/16] qla2xxx: Do not take a second firmware dump when intentionally generating one.
From: Chad Dupuis When we are intentionally generating a firmware dump by executing the MBC_GEN_SYSTEM_ERROR command, the command actually times out. The normal course of action when a mailbox command times out is to take a firmware dump. However, in this special case we do not want to do this since the MBA_SYSTEM_ERR AEN already generates a firmware dump. Signed-off-by: Chad Dupuis Signed-off-by: Saurav Kashyap --- drivers/scsi/qla2xxx/qla_mbx.c |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 144effd..7257c3c 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -281,9 +281,11 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) /* * Attempt to capture a firmware dump for further analysis -* of the current firmware state +* of the current firmware state. We do not need to do this +* if we are intentionally generating a dump. */ - ha->isp_ops->fw_dump(vha, 0); + if (mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) + ha->isp_ops->fw_dump(vha, 0); rval = QLA_FUNCTION_TIMEOUT; } -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 15/16] qla2xxx: Remove an unused variable from qla2x00_remove_one().
From: Bart Van Assche Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap --- drivers/scsi/qla2xxx/qla_os.c |4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 6df5223..3e21e9f 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -2979,14 +2979,12 @@ qla2x00_remove_one(struct pci_dev *pdev) set_bit(UNLOADING, &base_vha->dpc_flags); mutex_lock(&ha->vport_lock); while (ha->cur_vport_count) { - struct Scsi_Host *scsi_host; - spin_lock_irqsave(&ha->vport_slock, flags); BUG_ON(base_vha->list.next == &ha->vp_list); /* This assumes first entry in ha->vp_list is always base vha */ vha = list_first_entry(&base_vha->list, scsi_qla_host_t, list); - scsi_host = scsi_host_get(vha->host); + scsi_host_get(vha->host); spin_unlock_irqrestore(&ha->vport_slock, flags); mutex_unlock(&ha->vport_lock); -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 14/16] qla2xxx: Fix qla2xxx_check_risc_status().
From: Bart Van Assche Change the 'rval' variable from QLA_FUNCTION_TIMEOUT into QLA_SUCCESS before starting a loop that is only executed if rval is initialized to QLA_SUCCESS. Coverity reported that loop as "dead code". Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap --- drivers/scsi/qla2xxx/qla_isr.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index d2a4c75..2d8e7b8 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c @@ -2485,6 +2485,7 @@ qla2xxx_check_risc_status(scsi_qla_host_t *vha) if (rval == QLA_SUCCESS) goto next_test; + rval = QLA_SUCCESS; WRT_REG_DWORD(®->iobase_window, 0x0003); for (cnt = 100; (RD_REG_DWORD(®->iobase_window) & BIT_0) == 0 && rval == QLA_SUCCESS; cnt--) { -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 11/16] qla2xxx: Remove a dead assignment in qla24xx_build_scsi_crc_2_iocbs().
From: Bart Van Assche Since the value of cur_seg is not used and since scsi_prot_sglist() has no side effects it is safe to remove the statement "cur_seg = scsi_port_sglist(cmd)". Detected by Coverity. Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap --- drivers/scsi/qla2xxx/qla_iocb.c |2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c index 9de372f..42ef481 100644 --- a/drivers/scsi/qla2xxx/qla_iocb.c +++ b/drivers/scsi/qla2xxx/qla_iocb.c @@ -1189,7 +1189,6 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, uint32_t*cur_dsd, *fcp_dl; scsi_qla_host_t *vha; struct scsi_cmnd*cmd; - struct scatterlist *cur_seg; int sgc; uint32_ttotal_bytes = 0; uint32_tdata_bytes; @@ -1396,7 +1395,6 @@ qla24xx_build_scsi_crc_2_iocbs(srb_t *sp, struct cmd_type_crc_2 *cmd_pkt, if (bundling && tot_prot_dsds) { /* Walks dif segments */ - cur_seg = scsi_prot_sglist(cmd); cmd_pkt->control_flags |= __constant_cpu_to_le16(CF_DIF_SEG_DESCR_ENABLE); cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.dif_address; -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 07/16] qla2xxx: Clean up qla24xx_iidma()
From: Bart Van Assche Remove dead code and simplify a pointer computation. Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap --- drivers/scsi/qla2xxx/qla_bsg.c |9 + drivers/scsi/qla2xxx/qla_dbg.c |3 ++- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index 5ba0cc1..9a30b69 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -1282,14 +1282,7 @@ qla24xx_iidma(struct fc_bsg_job *bsg_job) return -EINVAL; } - port_param = (struct qla_port_param *)((char *)bsg_job->request + - sizeof(struct fc_bsg_request)); - if (!port_param) { - ql_log(ql_log_warn, vha, 0x7047, - "port_param header not provided.\n"); - return -EINVAL; - } - + port_param = (void *)bsg_job->request + sizeof(struct fc_bsg_request); if (port_param->fc_scsi_addr.dest_type != EXT_DEF_TYPE_WWPN) { ql_log(ql_log_warn, vha, 0x7048, "Invalid destination type.\n"); diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c index 3cc2105..91a1166 100644 --- a/drivers/scsi/qla2xxx/qla_dbg.c +++ b/drivers/scsi/qla2xxx/qla_dbg.c @@ -35,7 +35,8 @@ * | || 0x70a5,0x70a6, | * | || 0x70a8,0x70ab, | * | || 0x70ad-0x70ae, | - * | || 0x70d1-0x70da | + * | || 0x70d1-0x70da, | + * | || 0x7047 | * | Task Management | 0x803c | 0x8025-0x8026 | * | || 0x800b,0x8039 | * | AER/EEH | 0x9011 | | -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 16/16] qla2xxx: Fix a memory leak in an error path of qla2x00_process_els()
From: Bart Van Assche Avoid that the fcport structure gets leaked if bsg_job->request->msgcode == FC_BSG_HST_ELS_NOLOGIN, the fcport allocation succeeds and the !vha->flags.online branch is taken. This was detected by Coverity. However, Coverity does not recognize that all qla2x00_process_els() callers specify either FC_BSG_RPT_ELS or FC_BSG_HST_ELS_NOLOGIN in the field bsg_job->request->msgcode and that the value of that field is not modified inside that function. This results in a false positive report about a possible memory leak in an error path for bsg_job->request->msgcode values other than the two mentioned values. Make it easy for Coverity (and for humans) to recognize that there is no fcport leak in the error path by changing the bsg_job->request->msgcode == FC_BSG_HST_ELS_NOLOGIN test into bsg_job->request->msgcode != FC_BSG_RPT_ELS. Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap --- drivers/scsi/qla2xxx/qla_bsg.c | 14 +++--- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index b85f002..417eaad 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -269,6 +269,12 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job) type = "FC_BSG_HST_ELS_NOLOGIN"; } + if (!vha->flags.online) { + ql_log(ql_log_warn, vha, 0x7005, "Host not online.\n"); + rval = -EIO; + goto done; + } + /* pass through is supported only for ISP 4Gb or higher */ if (!IS_FWI2_CAPABLE(ha)) { ql_dbg(ql_dbg_user, vha, 0x7001, @@ -326,12 +332,6 @@ qla2x00_process_els(struct fc_bsg_job *bsg_job) NPH_FABRIC_CONTROLLER : NPH_F_PORT; } - if (!vha->flags.online) { - ql_log(ql_log_warn, vha, 0x7005, "Host not online.\n"); - rval = -EIO; - goto done; - } - req_sg_cnt = dma_map_sg(&ha->pdev->dev, bsg_job->request_payload.sg_list, bsg_job->request_payload.sg_cnt, DMA_TO_DEVICE); @@ -399,7 +399,7 @@ done_unmap_sg: goto done_free_fcport; done_free_fcport: - if (bsg_job->request->msgcode == FC_BSG_HST_ELS_NOLOGIN) + if (bsg_job->request->msgcode == FC_BSG_RPT_ELS) kfree(fcport); done: return rval; -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 10/16] qla2xxx: Remove two superfluous tests.
From: Bart Van Assche Since ha->model_desc is an array comparing it against NULL is superfluous. Hence remove these tests. Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap --- drivers/scsi/qla2xxx/qla_gs.c |3 +-- drivers/scsi/qla2xxx/qla_os.c |3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index d0ea8b9..f26442a 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -1370,8 +1370,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *vha) /* Model description. */ eiter = (struct ct_fdmi_hba_attr *) (entries + size); eiter->type = __constant_cpu_to_be16(FDMI_HBA_MODEL_DESCRIPTION); - if (ha->model_desc) - strncpy(eiter->a.model_desc, ha->model_desc, 80); + strncpy(eiter->a.model_desc, ha->model_desc, 80); alen = strlen(eiter->a.model_desc); alen += (alen & 3) ? (4 - (alen & 3)) : 4; eiter->len = cpu_to_be16(4 + alen); diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index c2e2e20..6df5223 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -2839,8 +2839,7 @@ skip_dpc: qla2x00_dfs_setup(base_vha); ql_log(ql_log_info, base_vha, 0x00fb, - "QLogic %s - %s.\n", - ha->model_number, ha->model_desc ? ha->model_desc : ""); + "QLogic %s - %s.\n", ha->model_number, ha->model_desc); ql_log(ql_log_info, base_vha, 0x00fc, "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 13/16] qla2xxx: Help Coverity with analyzing ct_sns_pkt initialization.
From: Bart Van Assche Coverity reports "Overrunning struct type ct_sns_req of 1228 bytes by passing it to a function which accesses it at byte offset 8207" for each qla2x00_prep_ct_req(), qla2x00_prep_ct_fdmi_req() and qla24xx_prep_ct_fm_req() call. Help Coverity to recognize that these calls do not trigger a buffer overflow by making it explicit that these three functions initializes both the request and reply structures. This patch does not change any functionality. Signed-off-by: Bart Van Assche Signed-off-by: Saurav Kashyap --- drivers/scsi/qla2xxx/qla_gs.c | 83 +++- 1 files changed, 39 insertions(+), 44 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c index f26442a..0926451 100644 --- a/drivers/scsi/qla2xxx/qla_gs.c +++ b/drivers/scsi/qla2xxx/qla_gs.c @@ -99,17 +99,17 @@ qla24xx_prep_ms_iocb(scsi_qla_host_t *vha, uint32_t req_size, uint32_t rsp_size) * Returns a pointer to the intitialized @ct_req. */ static inline struct ct_sns_req * -qla2x00_prep_ct_req(struct ct_sns_req *ct_req, uint16_t cmd, uint16_t rsp_size) +qla2x00_prep_ct_req(struct ct_sns_pkt *p, uint16_t cmd, uint16_t rsp_size) { - memset(ct_req, 0, sizeof(struct ct_sns_pkt)); + memset(p, 0, sizeof(struct ct_sns_pkt)); - ct_req->header.revision = 0x01; - ct_req->header.gs_type = 0xFC; - ct_req->header.gs_subtype = 0x02; - ct_req->command = cpu_to_be16(cmd); - ct_req->max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); + p->p.req.header.revision = 0x01; + p->p.req.header.gs_type = 0xFC; + p->p.req.header.gs_subtype = 0x02; + p->p.req.command = cpu_to_be16(cmd); + p->p.req.max_rsp_size = cpu_to_be16((rsp_size - 16) / 4); - return (ct_req); + return &p->p.req; } static int @@ -188,7 +188,7 @@ qla2x00_ga_nxt(scsi_qla_host_t *vha, fc_port_t *fcport) GA_NXT_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GA_NXT_CMD, + ct_req = qla2x00_prep_ct_req(ha->ct_sns, GA_NXT_CMD, GA_NXT_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; @@ -284,8 +284,7 @@ qla2x00_gid_pt(scsi_qla_host_t *vha, sw_info_t *list) gid_pt_rsp_size); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GID_PT_CMD, - gid_pt_rsp_size); + ct_req = qla2x00_prep_ct_req(ha->ct_sns, GID_PT_CMD, gid_pt_rsp_size); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- port_type */ @@ -359,7 +358,7 @@ qla2x00_gpn_id(scsi_qla_host_t *vha, sw_info_t *list) GPN_ID_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GPN_ID_CMD, + ct_req = qla2x00_prep_ct_req(ha->ct_sns, GPN_ID_CMD, GPN_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; @@ -421,7 +420,7 @@ qla2x00_gnn_id(scsi_qla_host_t *vha, sw_info_t *list) GNN_ID_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GNN_ID_CMD, + ct_req = qla2x00_prep_ct_req(ha->ct_sns, GNN_ID_CMD, GNN_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; @@ -495,7 +494,7 @@ qla2x00_rft_id(scsi_qla_host_t *vha) RFT_ID_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFT_ID_CMD, + ct_req = qla2x00_prep_ct_req(ha->ct_sns, RFT_ID_CMD, RFT_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; @@ -551,7 +550,7 @@ qla2x00_rff_id(scsi_qla_host_t *vha) RFF_ID_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFF_ID_CMD, + ct_req = qla2x00_prep_ct_req(ha->ct_sns, RFF_ID_CMD, RFF_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; @@ -606,8 +605,7 @@ qla2x00_rnn_id(scsi_qla_host_t *vha) RNN_ID_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RNN_ID_CMD, - RNN_ID_RSP_SIZE); + ct_req = qla2x00_prep_ct_req(ha->ct_sns, RNN_ID_CMD, RNN_ID_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; /* Prepare CT arguments -- port_id, node_name */ @@ -676,7 +674,7 @@ qla2x00_rsnn_nn(scsi_qla_host_t *vha) ms_pkt = ha->isp_ops->prep_ms_iocb(vha, 0, RSNN_NN_RSP_SIZE); /* Prepare CT request */ - ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD, + ct_req = qla2x00_prep_ct_req(ha->ct_sns, RSNN_NN_CMD, RSNN_NN_RSP_SIZE); ct_rsp = &ha->ct_sns->p.rsp; @@ -1262,18 +1260,18 @@ qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t *vha, uint32_t req_size) * Returns a pointer to the intitialized @ct_req. */ static inline struct ct_sns_req * -qla2x00_prep_ct_fdmi_req(struct ct_sns_req *ct_re
MAINTAINERS: Add myself as the maintainer for BusLogic SCSI driver
MAINTAINERS: Add myself as the maintainer for BusLogic SCSI driver I ported BusLogic driver to 64-bit. There is no current maintainer for this driver and since I made significant changes to the driver for 64-bit porting work, I will continue to maintain it. Signed-off-by: Khalid Aziz Cc: Khalid Aziz --- MAINTAINERS |7 +++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 5be702c..83cd4e4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1858,6 +1858,13 @@ S: Odd fixes F: Documentation/video4linux/bttv/ F: drivers/media/pci/bt8xx/bttv* +BUSLOGIC SCSI DRIVER +M: Khalid Aziz +L: linux-scsi@vger.kernel.org +S: Maintained +F: drivers/scsi/BusLogic.* +F: drivers/scsi/FlashPoint.* + C-MEDIA CMI8788 DRIVER M: Clemens Ladisch L: alsa-de...@alsa-project.org (moderated for non-subscribers) -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 00/16] qla2xxx: Patches for scsi "misc" branch.
Hi James, Please apply the following patches to the scsi tree at your earliest convenience for inclusion in the next mainline merge window. Thanks, ~Saurav Bart Van Assche (10): qla2xxx: Clean up qla24xx_iidma() qla2xxx: Clean up qla84xx_mgmt_cmd() qla2xxx: Remove dead code in qla2x00_configure_hba() qla2xxx: Remove two superfluous tests. qla2xxx: Remove a dead assignment in qla24xx_build_scsi_crc_2_iocbs(). qla2xxx: Remove redundant assignments. qla2xxx: Help Coverity with analyzing ct_sns_pkt initialization. qla2xxx: Fix qla2xxx_check_risc_status(). qla2xxx: Remove an unused variable from qla2x00_remove_one(). qla2xxx: Fix a memory leak in an error path of qla2x00_process_els() Chad Dupuis (2): qla2xxx: Do not query FC statistics during chip reset. qla2xxx: Do not take a second firmware dump when intentionally generating one. Giridhar Malavali (2): qla2xxx: Clear the MBX_INTR_WAIT flag when the mailbox time-out happens. qla2xxx: Set the index in outstanding command array to NULL when cmd is aborted when the request timeout. Saurav Kashyap (2): qla2xxx: Move qla2x00_free_device to the correct location. qla2xxx: Fix sparse warning from qla_mr.c and qla_iocb.c. drivers/scsi/qla2xxx/qla_attr.c |5 +- drivers/scsi/qla2xxx/qla_bsg.c| 38 +++-- drivers/scsi/qla2xxx/qla_dbg.c| 12 ++- drivers/scsi/qla2xxx/qla_def.h| 34 drivers/scsi/qla2xxx/qla_gbl.h|2 +- drivers/scsi/qla2xxx/qla_gs.c | 86 +-- drivers/scsi/qla2xxx/qla_init.c |8 -- drivers/scsi/qla2xxx/qla_inline.h |2 +- drivers/scsi/qla2xxx/qla_iocb.c |6 +- drivers/scsi/qla2xxx/qla_isr.c|1 + drivers/scsi/qla2xxx/qla_mbx.c| 16 +++- drivers/scsi/qla2xxx/qla_mr.c | 167 +++-- drivers/scsi/qla2xxx/qla_mr.h | 98 +++--- drivers/scsi/qla2xxx/qla_os.c | 10 +-- 14 files changed, 235 insertions(+), 250 deletions(-) -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 02/16] qla2xxx: Set the index in outstanding command array to NULL when cmd is aborted when the request timeout.
From: Giridhar Malavali Call the generic BSG free routine to unmap the DMA buffers. Signed-off-by: Giridhar Malavali Signed-off-by: Saurav Kashyap --- drivers/scsi/qla2xxx/qla_bsg.c |5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c index 39719f8..5ba0cc1 100644 --- a/drivers/scsi/qla2xxx/qla_bsg.c +++ b/drivers/scsi/qla2xxx/qla_bsg.c @@ -2153,6 +2153,7 @@ qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job) (sp->type == SRB_ELS_CMD_HST) || (sp->type == SRB_FXIOCB_BCMD)) && (sp->u.bsg_job == bsg_job)) { + req->outstanding_cmds[cnt] = NULL; spin_unlock_irqrestore(&ha->hardware_lock, flags); if (ha->isp_ops->abort_command(sp)) { ql_log(ql_log_warn, vha, 0x7089, @@ -2180,8 +2181,6 @@ qla24xx_bsg_timeout(struct fc_bsg_job *bsg_job) done: spin_unlock_irqrestore(&ha->hardware_lock, flags); - if (bsg_job->request->msgcode == FC_BSG_HST_CT) - kfree(sp->fcport); - qla2x00_rel_sp(vha, sp); + sp->free(vha, sp); return 0; } -- 1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v11 6/9] Make scsi_remove_host() wait until error handling finished
On Jun 25, 2013, at 10:31 AM, Bart Van Assche wrote: > On 06/25/13 15:45, James Bottomley wrote: >> On Tue, 2013-06-25 at 11:01 +0200, Bart Van Assche wrote: >>> There is a difference though between moving the EH kthread_stop() call >>> and the patch at the start of this thread: moving the EH kthread_stop() >>> call does not prevent that an ioctl like SG_SCSI_RESET triggers an eh_* >>> callback after scsi_remove_host() has finished. However, the >>> scsi_begin_eh() / scsi_end_eh() functions do prevent that an ioctl can >>> cause an eh_* callback to be invoked after scsi_remove_device() finished. >> >> OK, but this doesn't tell me what you're trying to achieve. >> >> An eh function is allowable as long as the host hadn't had the release >> callback executed. That means you must have to have a reference to the >> device/host to execute the eh function, which is currently guaranteed >> for all invocations. > > That raises a new question: how is an LLD expected to clean up resources > without triggering a race condition ? What you wrote means that it's not safe > for an LLD to start cleaning up the resources needed by the eh_* callbacks > immediately after scsi_remove_device() returns since it it not guaranteed > that at that time all references to the device have already been dropped. > A callback in the device/target/host (whatever is needed) release function would do this right? If I understand James right, I think he suggested something like this in another mail. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v11 6/9] Make scsi_remove_host() wait until error handling finished
On Tue, 2013-06-25 at 11:13 -0500, Michael Christie wrote: > On Jun 25, 2013, at 10:31 AM, Bart Van Assche wrote: > > > On 06/25/13 15:45, James Bottomley wrote: > >> On Tue, 2013-06-25 at 11:01 +0200, Bart Van Assche wrote: > >>> There is a difference though between moving the EH kthread_stop() call > >>> and the patch at the start of this thread: moving the EH kthread_stop() > >>> call does not prevent that an ioctl like SG_SCSI_RESET triggers an eh_* > >>> callback after scsi_remove_host() has finished. However, the > >>> scsi_begin_eh() / scsi_end_eh() functions do prevent that an ioctl can > >>> cause an eh_* callback to be invoked after scsi_remove_device() finished. > >> > >> OK, but this doesn't tell me what you're trying to achieve. > >> > >> An eh function is allowable as long as the host hadn't had the release > >> callback executed. That means you must have to have a reference to the > >> device/host to execute the eh function, which is currently guaranteed > >> for all invocations. > > > > That raises a new question: how is an LLD expected to clean up resources > > without triggering a race condition ? What you wrote means that it's not > > safe for an LLD to start cleaning up the resources needed by the eh_* > > callbacks immediately after scsi_remove_device() returns since it it not > > guaranteed that at that time all references to the device have already been > > dropped. > > > > > A callback in the device/target/host (whatever is needed) release > function would do this right? If I understand James right, I think he > suggested something like this in another mail. Exactly ... at least that's what we should do. If I look at what we actually do: all the HBAs treat scsi_remove_host as a waited for transition. The reason this works is the loop over __scsi_remove_device() in scsi_forget_host(). By the time that loop returns, every scsi_device is gone (and so is every target). Because blk_cleanup_queue() induces a synchronous wait for the queue to die in __scsi_remove_device(), there can be no outstanding I/O and no eh activity for the device when it returns (and no possibility of starting any). Thus at the end of scsi_forget_host, we have no devices to start I/O and no eh activity, so the final put will be the last. James -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v11 6/9] Make scsi_remove_host() wait until error handling finished
On 06/25/13 19:40, James Bottomley wrote: If I look at what we actually do: all the HBAs treat scsi_remove_host as a waited for transition. The reason this works is the loop over __scsi_remove_device() in scsi_forget_host(). By the time that loop returns, every scsi_device is gone (and so is every target). Because blk_cleanup_queue() induces a synchronous wait for the queue to die in __scsi_remove_device(), there can be no outstanding I/O and no eh activity for the device when it returns (and no possibility of starting any). Thus at the end of scsi_forget_host, we have no devices to start I/O and no eh activity, so the final put will be the last. With the patch at the start of this thread everything works like you described above. However, without that patch EH activity can continue after scsi_remove_device() has returned. I have seen that occurring several times while testing SCSI LLD patches. Bart. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 24/45] [SCSI] fcoe: Use get/put_online_cpus_atomic() to prevent CPU offline
Once stop_machine() is gone from the CPU offline path, we won't be able to depend on disabling preemption to prevent CPUs from going offline from under us. Use the get/put_online_cpus_atomic() APIs to prevent CPUs from going offline, while invoking from atomic context. Cc: Robert Love Cc: "James E.J. Bottomley" Cc: de...@open-fcoe.org Cc: linux-scsi@vger.kernel.org Signed-off-by: Srivatsa S. Bhat --- drivers/scsi/fcoe/fcoe.c |7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 292b24f..a107d3c 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -1484,6 +1484,7 @@ static int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, * was originated, otherwise select cpu using rx exchange id * or fcoe_select_cpu(). */ + get_online_cpus_atomic(); if (ntoh24(fh->fh_f_ctl) & FC_FC_EX_CTX) cpu = ntohs(fh->fh_ox_id) & fc_cpu_mask; else { @@ -1493,8 +1494,10 @@ static int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, cpu = ntohs(fh->fh_rx_id) & fc_cpu_mask; } - if (cpu >= nr_cpu_ids) + if (cpu >= nr_cpu_ids) { + put_online_cpus_atomic(); goto err; + } fps = &per_cpu(fcoe_percpu, cpu); spin_lock(&fps->fcoe_rx_list.lock); @@ -1514,6 +1517,7 @@ static int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, spin_lock(&fps->fcoe_rx_list.lock); if (!fps->thread) { spin_unlock(&fps->fcoe_rx_list.lock); + put_online_cpus_atomic(); goto err; } } @@ -1535,6 +1539,7 @@ static int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev, if (fps->thread->state == TASK_INTERRUPTIBLE) wake_up_process(fps->thread); spin_unlock(&fps->fcoe_rx_list.lock); + put_online_cpus_atomic(); return 0; err: -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
fcoe pull request for 3.9-rc
The following changes since commit 1e876e3b1a9df25bb04682b0d48aaa7e8ae1fc82: Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux (2013-06-25 09:08:07 -1000) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/rwlove/fcoe.git tags/critical_fix_for_3.9 for you to fetch changes up to 2884d4230867c8a46cf701214051e923301e7429: fcoe: Use correct API to set vlan tag for FCoE Ethertype skbs (2013-06-25 12:23:19 -0700) This patch fixes a critical bug that was introduced in 3.9 related to VLAN tagging FCoE frames. Robert Love (1): fcoe: Use correct API to set vlan tag for FCoE Ethertype skbs drivers/scsi/fcoe/fcoe.c |7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c index 292b24f..32ae6c6 100644 --- a/drivers/scsi/fcoe/fcoe.c +++ b/drivers/scsi/fcoe/fcoe.c @@ -1656,9 +1656,12 @@ static int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp) if (fcoe->netdev->priv_flags & IFF_802_1Q_VLAN && fcoe->realdev->features & NETIF_F_HW_VLAN_CTAG_TX) { -skb->vlan_tci = VLAN_TAG_PRESENT | -vlan_dev_vlan_id(fcoe->netdev); +/* must set skb->dev before calling vlan_put_tag */ skb->dev = fcoe->realdev; +skb = __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), + vlan_dev_vlan_id(fcoe->netdev)); +if (!skb) +return -ENOMEM; } else skb->dev = fcoe->netdev; -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 0/4] SG_IO filtering via sysfs and minimal whitelist
Il 27/05/2013 15:50, Paolo Bonzini ha scritto: > > We've been running in circles for nine months now. Let's restart from > the maintainer's suggestion, which was probably dismissed too quickly. > > This is still not a complete solution, because /dev/sgN does not have > access to its queue object. Still, it can be a base for discussion. > > If accepted (in a complete form with access to the queue object for > non-block devices), this series removes the need to fix the opcode > conflicts as far as I'm concerned. We could just consider that a > feature of CONFIG_BLK_DEV_SG_FILTER_MMC. > > Previously posted at https://lkml.org/lkml/2012/9/25/397 (short thread). > Rebased just fine, this one is compile-tested only. > > Paolo RFC didn't get many Cs. Paolo -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 8/9] scsi/pm8001: use pdev->pm_cap instead of pci_find_capability(..,PCI_CAP_ID_PM)
Pci core has been saved pm cap register offset by pdev->pm_cap in pci_pm_init() in init path. So we can use pdev->pm_cap instead of using pci_find_capability(pdev, PCI_CAP_ID_PM) for better performance and simplified code. Signed-off-by: Yijing Wang Cc: xjtu...@gmail.com Cc: lindar_...@usish.com Cc: "James E.J. Bottomley" Cc: linux-scsi@vger.kernel.org Cc: linux-ker...@vger.kernel.org --- drivers/scsi/pm8001/pm8001_init.c |7 +++ 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c index e4b9bc7..3861aa1 100644 --- a/drivers/scsi/pm8001/pm8001_init.c +++ b/drivers/scsi/pm8001/pm8001_init.c @@ -912,14 +912,13 @@ static int pm8001_pci_suspend(struct pci_dev *pdev, pm_message_t state) { struct sas_ha_struct *sha = pci_get_drvdata(pdev); struct pm8001_hba_info *pm8001_ha; - int i , pos; + int i; u32 device_state; pm8001_ha = sha->lldd_ha; flush_workqueue(pm8001_wq); scsi_block_requests(pm8001_ha->shost); - pos = pci_find_capability(pdev, PCI_CAP_ID_PM); - if (pos == 0) { - printk(KERN_ERR " PCI PM not supported\n"); + if (!pdev->pm_cap) { + dev_err(&pdev->dev, " PCI PM not supported\n"); return -ENODEV; } PM8001_CHIP_DISP->interrupt_disable(pm8001_ha, 0xFF); -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/1] [SCSI] sg: fix race condition when do exclusive open
Hi Jörn Engel, Ping. How about this one? I found my lat patch hasn't fix the issue, so I modified it a little more. Last thread is: Subject: Re: [PATCH] sg: atomize check and set sdp->exclude in sg_open Message-ID: <20130605154106.ga2...@logfs.org> Regards, Vaughan 于 2013年06月17日 21:10, vaughan 写道: > Rewrite the last patch. > Add a new field 'toopen' in sg_device to count ongoing sg_open's. By checking > both 'toopen' and 'exclude' marks when do exclusive open, old race conditions > can be avoided. > Replace global sg_open_exclusive_lock with a per device lock - sfd_lock. > Since sfds list is now protected by the lock owned by the same sg_device, > sg_index_lock becomes a real global lock to only protect sg devices lookup. > Also did some cleanup, such as remove get_exclude() and rename set_exclude() > to clear_exclude(). > > Signed-off-by: Vaughan Cao > --- > drivers/scsi/sg.c | 152 > -- > 1 file changed, 90 insertions(+), 62 deletions(-) > > diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c > index 25b5455..b0ea73f 100644 > --- a/drivers/scsi/sg.c > +++ b/drivers/scsi/sg.c > @@ -103,11 +103,8 @@ static int scatter_elem_sz_prev = SG_SCATTER_SZ; > static int sg_add(struct device *, struct class_interface *); > static void sg_remove(struct device *, struct class_interface *); > > -static DEFINE_SPINLOCK(sg_open_exclusive_lock); > - > static DEFINE_IDR(sg_index_idr); > -static DEFINE_RWLOCK(sg_index_lock); /* Also used to lock > -file descriptor list > for device */ > +static DEFINE_RWLOCK(sg_index_lock); /* protect sg index */ > > static struct class_interface sg_interface = { > .add_dev= sg_add, > @@ -144,7 +141,7 @@ typedef struct sg_request { /* SG_MAX_QUEUE > requests outstanding per file */ > } Sg_request; > > typedef struct sg_fd { /* holds the state of a file descriptor > */ > - /* sfd_siblings is protected by sg_index_lock */ > + /* sfd_siblings is protected by sfd_lock of sg_device */ > struct list_head sfd_siblings; > struct sg_device *parentdp; /* owning device */ > wait_queue_head_t read_wait;/* queue read until command done */ > @@ -171,10 +168,10 @@ typedef struct sg_device { /* holds the state of each > scsi generic device */ > wait_queue_head_t o_excl_wait; /* queue open() when O_EXCL in use */ > int sg_tablesize; /* adapter's max scatter-gather table size */ > u32 index; /* device index number */ > - /* sfds is protected by sg_index_lock */ > + spinlock_t sfd_lock;/* protect sfds, exclude, toopen */ > struct list_head sfds; > + int toopen; /* number of who are ready to open sg */ > volatile char detached; /* 0->attached, 1->detached pending removal */ > - /* exclude protected by sg_open_exclusive_lock */ > char exclude; /* opened for exclusive access */ > char sgdebug; /* 0->off, 1->sense, 9->dump dev, 10-> all devs > */ > struct gendisk *disk; > @@ -224,25 +221,44 @@ static int sg_allow_access(struct file *filp, unsigned > char *cmd) > return blk_verify_command(q, cmd, filp->f_mode & FMODE_WRITE); > } > > -static int get_exclude(Sg_device *sdp) > +static void clear_exclude(Sg_device *sdp) > { > unsigned long flags; > - int ret; > > - spin_lock_irqsave(&sg_open_exclusive_lock, flags); > - ret = sdp->exclude; > - spin_unlock_irqrestore(&sg_open_exclusive_lock, flags); > + spin_lock_irqsave(&sdp->sfd_lock, flags); > + sdp->exclude = 0; > + spin_unlock_irqrestore(&sdp->sfd_lock, flags); > + return; > +} > + > +/* we can add exclusively only when no other addition is going on */ > +static int try_add_exclude(Sg_device *sdp) > +{ > + unsigned long flags; > + int ret = 0; > + > + spin_lock_irqsave(&sdp->sfd_lock, flags); > + if (list_empty(&sdp->sfds) && !sdp->toopen) { > + sdp->exclude = 1; > + sdp->toopen++; > + ret = 1; > + } > + spin_unlock_irqrestore(&sdp->sfd_lock, flags); > return ret; > } > > -static int set_exclude(Sg_device *sdp, char val) > +static int try_add_shareable(Sg_device *sdp) > { > unsigned long flags; > + int ret = 0; > > - spin_lock_irqsave(&sg_open_exclusive_lock, flags); > - sdp->exclude = val; > - spin_unlock_irqrestore(&sg_open_exclusive_lock, flags); > - return val; > + spin_lock_irqsave(&sdp->sfd_lock, flags); > + if (!sdp->exclude && sdp->toopen != INT_MAX) { > + sdp->toopen++; > + ret = 1; > + } > + spin_unlock_irqrestore(&sdp->sfd_lock, flags); > + return ret; > } > > static int sfds_list_empty(Sg_device *sdp) > @@ -250,9 +266,9 @@ static int sfds_list_empty(Sg_device *sdp) > unsigned long flags; > int ret; > > - read_lock_irqsave(&s