OSDN Git Service

blk-mq: move cancel of hctx->run_work into blk_mq_hw_sysfs_release
authorMing Lei <ming.lei@redhat.com>
Tue, 30 Apr 2019 01:52:28 +0000 (09:52 +0800)
committerJens Axboe <axboe@kernel.dk>
Sat, 4 May 2019 13:24:09 +0000 (07:24 -0600)
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: Dongli Zhang <dongli.zhang@oracle.com>
Cc: James Smart <james.smart@broadcom.com>
Cc: Bart Van Assche <bart.vanassche@wdc.com>
Cc: linux-scsi@vger.kernel.org,
Cc: Martin K . Petersen <martin.petersen@oracle.com>,
Cc: Christoph Hellwig <hch@lst.de>,
Cc: James E . J . Bottomley <jejb@linux.vnet.ibm.com>,
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Tested-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-core.c
block/blk-mq-sysfs.c

index 81d2095..6722b24 100644 (file)
@@ -233,14 +233,6 @@ void blk_sync_queue(struct request_queue *q)
 {
        del_timer_sync(&q->timeout);
        cancel_work_sync(&q->timeout_work);
-
-       if (queue_is_mq(q)) {
-               struct blk_mq_hw_ctx *hctx;
-               int i;
-
-               queue_for_each_hw_ctx(q, hctx, i)
-                       cancel_delayed_work_sync(&hctx->run_work);
-       }
 }
 EXPORT_SYMBOL(blk_sync_queue);
 
index 7593c4c..2280d3c 100644 (file)
@@ -36,6 +36,8 @@ static void blk_mq_hw_sysfs_release(struct kobject *kobj)
        struct blk_mq_hw_ctx *hctx = container_of(kobj, struct blk_mq_hw_ctx,
                                                  kobj);
 
+       cancel_delayed_work_sync(&hctx->run_work);
+
        if (hctx->flags & BLK_MQ_F_BLOCKING)
                cleanup_srcu_struct(hctx->srcu);
        blk_free_flush_queue(hctx->fq);