Re: Kernel panic w/ message request_threaded_irq -> qla2x00_request_irqs -> qla2x00_probe_one -> mod_timer

2019-04-28 Thread TomK
On 4/15/2019 10:26 PM, TomK wrote: On 4/15/2019 3:35 PM, Laurence Oberman wrote: On Mon, 2019-04-15 at 08:39 -0700, Bart Van Assche wrote: On Mon, 2019-04-15 at 08:55 -0400, Laurence Oberman wrote: On Sun, 2019-04-14 at 23:25 -0400, TomK wrote: Hey All, I'm getting a kernel panic on an Gigab

[PATCH V4 0/3] scsi: core: avoid big pre-allocation for sg list

2019-04-28 Thread Ming Lei
Hi, Since supporting to blk-mq, big pre-allocation for sg list is introduced, this way is very unfriendly wrt. memory consumption. There were Red Hat internal reports that some scsi_debug based tests can't be run any more because of too big pre-allocation. Also lpfc users commplained that 1GB+ r

[PATCH V4 1/3] lib/sg_pool.c: improve APIs for allocating sg pool

2019-04-28 Thread Ming Lei
Now sg_alloc_table_chained() allows user to provide one preallocated SGL, and returns simply if the requested number isn't bigger than size of that SGL. This way is nice for inline small SGL to small IO request. However, scattergather code only allows that size of the 1st preallocated SGL is SG_CH

Re: [PATCH V4 1/3] lib/sg_pool.c: improve APIs for allocating sg pool

2019-04-28 Thread Christoph Hellwig
Looks good: Reviewed-by: Christoph Hellwig

[PATCH V4 2/3] scsi: core: avoid to pre-allocate big chunk for protection meta data

2019-04-28 Thread Ming Lei
Now scsi_mq_setup_tags() pre-allocates a big buffer for protection sg entries, and the buffer size is scsi_mq_sgl_size(). This way isn't correct, scsi_mq_sgl_size() is used to pre-allocate sg entries for IO data. And the protection data buffer is much less, for example, one 512byte sector needs 8b

[PATCH V4 3/3] scsi: core: avoid to pre-allocate big chunk for sg list

2019-04-28 Thread Ming Lei
Now scsi_mq_setup_tags() pre-allocates a big buffer for IO sg list, and the buffer size is scsi_mq_sgl_size() which depends on smaller value between shost->sg_tablesize and SG_CHUNK_SIZE. Modern HBA's DMA is often capable of deadling with very big segment number, so scsi_mq_sgl_size() is often big

[PATCH V8 2/7] blk-mq: move cancel of requeue_work into blk_mq_release

2019-04-28 Thread Ming Lei
With holding queue's kobject refcount, it is safe for driver to schedule requeue. However, blk_mq_kick_requeue_list() may be called after blk_sync_queue() is done because of concurrent requeue activities, then requeue work may not be completed when freeing queue, and kernel oops is triggered. So m

[PATCH V8 1/7] blk-mq: grab .q_usage_counter when queuing request from plug code path

2019-04-28 Thread Ming Lei
Just like aio/io_uring, we need to grab 2 refcount for queuing one request, one is for submission, another is for completion. If the request isn't queued from plug code path, the refcount grabbed in generic_make_request() serves for submission. In theroy, this refcount should have been released af

[PATCH V8 5/7] blk-mq: always free hctx after request queue is freed

2019-04-28 Thread Ming Lei
In normal queue cleanup path, hctx is released after request queue is freed, see blk_mq_release(). However, in __blk_mq_update_nr_hw_queues(), hctx may be freed because of hw queues shrinking. This way is easy to cause use-after-free, because: one implicit rule is that it is safe to call almost al

[PATCH V8 4/7] blk-mq: split blk_mq_alloc_and_init_hctx into two parts

2019-04-28 Thread Ming Lei
Split blk_mq_alloc_and_init_hctx into two parts, and one is blk_mq_alloc_hctx() for allocating all hctx resources, another is blk_mq_init_hctx() for initializing hctx, which serves as counter-part of blk_mq_exit_hctx(). Cc: Dongli Zhang Cc: James Smart Cc: Bart Van Assche Cc: linux-scsi@vger.ke

[PATCH V8 3/7] blk-mq: free hw queue's resource in hctx's release handler

2019-04-28 Thread Ming Lei
Once blk_cleanup_queue() returns, tags shouldn't be used any more, because blk_mq_free_tag_set() may be called. Commit 45a9c9d909b2 ("blk-mq: Fix a use-after-free") fixes this issue exactly. However, that commit introduces another issue. Before 45a9c9d909b2, we are allowed to run queue during clea

[PATCH V8 0/7] blk-mq: fix races related with freeing queue

2019-04-28 Thread Ming Lei
Hi, Since 45a9c9d909b2 ("blk-mq: Fix a use-after-free"), run queue isn't allowed during cleanup queue even though queue refcount is held. This change has caused lots of kernel oops triggered in run queue path, turns out it isn't easy to fix them all. So move freeing of hw queue resources into hc

[PATCH V8 7/7] block: don't drain in-progress dispatch in blk_cleanup_queue()

2019-04-28 Thread Ming Lei
Now freeing hw queue resource is moved to hctx's release handler, we don't need to worry about the race between blk_cleanup_queue and run queue any more. So don't drain in-progress dispatch in blk_cleanup_queue(). This is basically revert of c2856ae2f315 ("blk-mq: quiesce queue before freeing que

[PATCH V8 6/7] blk-mq: move cancel of hctx->run_work into blk_mq_hw_sysfs_release

2019-04-28 Thread Ming Lei
hctx is always released after requeue is freed. With holding queue's kobject refcount, it is safe for driver to run queue, so one run queue might be scheduled after blk_sync_queue() is done. So moving the cancel of hctx->run_work into blk_mq_hw_sysfs_release() for avoiding run released queue. Cc

Re: [PATCH V8 1/7] blk-mq: grab .q_usage_counter when queuing request from plug code path

2019-04-28 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig

Re: [PATCH V8 4/7] blk-mq: split blk_mq_alloc_and_init_hctx into two parts

2019-04-28 Thread Christoph Hellwig
> +static struct blk_mq_hw_ctx * > +blk_mq_alloc_hctx(struct request_queue *q, > + struct blk_mq_tag_set *set, Nit: The second paramter would easily fit on the first line. > + unsigned hctx_idx, int node) > +{ > + struct blk_mq_hw_ctx *hctx; > + > + hctx = kzalloc_

Re: [PATCH V8 5/7] blk-mq: always free hctx after request queue is freed

2019-04-28 Thread Christoph Hellwig
On Sun, Apr 28, 2019 at 04:14:06PM +0800, Ming Lei wrote: > In normal queue cleanup path, hctx is released after request queue > is freed, see blk_mq_release(). > > However, in __blk_mq_update_nr_hw_queues(), hctx may be freed because > of hw queues shrinking. This way is easy to cause use-after-f

Re: [PATCH V8 5/7] blk-mq: always free hctx after request queue is freed

2019-04-28 Thread Ming Lei
On Sun, Apr 28, 2019 at 02:14:26PM +0200, Christoph Hellwig wrote: > On Sun, Apr 28, 2019 at 04:14:06PM +0800, Ming Lei wrote: > > In normal queue cleanup path, hctx is released after request queue > > is freed, see blk_mq_release(). > > > > However, in __blk_mq_update_nr_hw_queues(), hctx may be

Re: [RFC PATCH 1/4] fdomain: Resurrect driver (core)

2019-04-28 Thread Ondrej Zary
On Wednesday 24 April 2019 08:02:12 Christoph Hellwig wrote: > > +static void fdomain_work(struct work_struct *work) > > +{ > > + struct fdomain *fd = container_of(work, struct fdomain, work); > > + struct Scsi_Host *sh = container_of((void *)fd, struct Scsi_Host, > > +

[PATCH 0/4] fdomain: Resurrect driver (modular version)

2019-04-28 Thread Ondrej Zary
Resurrect previously removed fdomain driver, in modern style. Initialization is rewritten completely, with support for multiple cards, no more global state variables. Most of the code from interrupt handler is moved to a workqueue. This is a modularized version with core separated from bus-speci

[PATCH 3/4] fdomain: Resurrect driver (ISA support)

2019-04-28 Thread Ondrej Zary
Future Domain 16xx ISA SCSI support card support. Currently untested. Signed-off-by: Ondrej Zary --- drivers/scsi/Kconfig | 14 +++ drivers/scsi/Makefile | 1 + drivers/scsi/fdomain_isa.c | 231 + 3 files changed, 246 insertions(+) crea

[PATCH 1/4] fdomain: Resurrect driver (core)

2019-04-28 Thread Ondrej Zary
Future Domain TMC-16xx/TMC-3260 SCSI driver. This is the core driver, common for PCI, ISA and PCMCIA cards. Signed-off-by: Ondrej Zary --- drivers/scsi/Kconfig | 4 + drivers/scsi/Makefile | 1 + drivers/scsi/fdomain.c | 600 + drivers/scsi

[PATCH 4/4] fdomain: Resurrect driver (PCMCIA support)

2019-04-28 Thread Ondrej Zary
Future Domain PCMCIA SCSI support card support. Currently untested. Signed-off-by: Ondrej Zary --- drivers/scsi/pcmcia/Kconfig | 10 + drivers/scsi/pcmcia/Makefile | 1 + drivers/scsi/pcmcia/fdomain_cs.c | 89 3 files changed, 100 insertion

[PATCH 2/4] fdomain: Resurrect driver (PCI support)

2019-04-28 Thread Ondrej Zary
Future Domain TMC-3260/AHA-2920A PCI card support. Tested on Adaptec AHA-2920A PCI card. Signed-off-by: Ondrej Zary --- drivers/scsi/Kconfig | 17 drivers/scsi/Makefile | 1 + drivers/scsi/fdomain_pci.c | 68 ++ 3 files change

Re: [PATCH V8 4/7] blk-mq: split blk_mq_alloc_and_init_hctx into two parts

2019-04-28 Thread Hannes Reinecke
On 4/28/19 10:14 AM, Ming Lei wrote: Split blk_mq_alloc_and_init_hctx into two parts, and one is blk_mq_alloc_hctx() for allocating all hctx resources, another is blk_mq_init_hctx() for initializing hctx, which serves as counter-part of blk_mq_exit_hctx(). Cc: Dongli Zhang Cc: James Smart Cc: