Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp314686img; Wed, 20 Mar 2019 00:58:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxr5m9N46OE+tbMZTiWtFl1OB5mWo7rZdphbJ7fjCKYa2LAJ+hNs256OFX6hcyBKC2EYukp X-Received: by 2002:a17:902:681:: with SMTP id 1mr6613517plh.31.1553068726905; Wed, 20 Mar 2019 00:58:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553068726; cv=none; d=google.com; s=arc-20160816; b=Pqm7TG036LTg8Gy0VquKodYHnJrQQNKh+X8THEpDV+bUltka39et83vPnQ8p5iLZd8 yIfpjI3FsOazfdOMVg47OutTAusfhVnWoM0SAtoALARSWye/CvAdywHbRn6LEvv0Swvx t4Tt/1eQ6jnvny6DZ4PCw6J6RbGuKzPHin8hCQXWzlI6FVq7vfnkiyHMIhi3lZftUSdz dXB3mV3/AuyuSohnHKR/r6IzuHSluHjsfWVgTy4P8lz4FLSbtIVUBhiyRBZcL7l/nNxB OrTuianM5qxB2H3FPg7m08rcANUhdm3nQtXTG0CkGVo23GlW9wPahUN8KqdB6DHMrOQH 0/HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=4PEyKQjfPYJgGD0UC3khKlPiqP9T+4bAUrh5JYMvkl8=; b=riY/YM3eXngRcN7sxw3/R0xHl6TuCOXfKg/WmuaGHIJmy5ous2u52SbaudQ7tXoBL5 KJH705RijVBdyU3vSpFp7xf41e60+RhDqNiLK7LA+LR4/GIKiOLiTyofECLoEPex+Gy7 jhis19Gr7+Ejb8HdMMGeU6IdeKtNufea2H3ADoKT3uw/lB1Ku6aB0dqbyMZi+E/JkwVx NlRA4Nj9bkv8U9NlSEVQFUE5ll1woZTzYJP58T2EPagWf2mY2DVuqegqnw5HvDJ6aBwu /c5kghboRAgjnt1ooyMDsvnnsM9PQtByTIBiRUCO+PDw57NueDDY0Gr+1/wIEqeW9bmh TjRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d11si1243142pls.255.2019.03.20.00.58.31; Wed, 20 Mar 2019 00:58:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727640AbfCTH5w (ORCPT + 99 others); Wed, 20 Mar 2019 03:57:52 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:5711 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725942AbfCTH5w (ORCPT ); Wed, 20 Mar 2019 03:57:52 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id B2E404FAF7B91349BC93; Wed, 20 Mar 2019 15:57:49 +0800 (CST) Received: from huawei.com (10.90.53.225) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.408.0; Wed, 20 Mar 2019 15:57:39 +0800 From: zhengbin To: , , , , CC: , , Subject: [PATCH] blk-mq: fix a hung issue when set device state to blocked and restore running Date: Wed, 20 Mar 2019 16:02:01 +0800 Message-ID: <1553068921-6605-1-git-send-email-zhengbin13@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When I use dd test a SCSI device which use blk-mq in the following steps: 1.echo "blocked" >/sys/block/sda/device/state 2.dd if=/dev/sda of=/mnt/t.log bs=1M count=10 3.echo "running" >/sys/block/sda/device/state dd should finish this work after step 3, unfortunately, still hung. After step2, the key code process is like this: blk_mq_dispatch_rq_list-->scsi_queue_rq-->prep_to_mq -->if ret is BLK_STS_RESOURCE, delay run hw queue prep_to_mq will return BLK_STS_RESOURCE, and scsi_queue_rq will transter it to BLK_STS_DEV_RESOURCE. In this situtation, we should delay run hw queue. This patch fixes that. Fixes: 86ff7c2a80cd ("blk-mq: introduce BLK_STS_DEV_RESOURCE") Signed-off-by: zhengbin --- block/blk-mq.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index a9c1816..556d606 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1309,15 +1309,17 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list, * returning BLK_STS_RESOURCE. Two exceptions are scsi-mq * and dm-rq. * - * If driver returns BLK_STS_RESOURCE and SCHED_RESTART - * bit is set, run queue after a delay to avoid IO stalls - * that could otherwise occur if the queue is idle. + * If driver returns BLK_STS_RESOURCE or BLK_STS_DEV_RESOURCE + * and SCHED_RESTART bit is set, run queue after a delay to + * avoid IO stalls that could otherwise occur if the queue + * is idle. */ needs_restart = blk_mq_sched_needs_restart(hctx); if (!needs_restart || (no_tag && list_empty_careful(&hctx->dispatch_wait.entry))) blk_mq_run_hw_queue(hctx, true); - else if (needs_restart && (ret == BLK_STS_RESOURCE)) + else if (needs_restart && ((ret == BLK_STS_RESOURCE) || + (ret == BLK_STS_DEV_RESOURCE))) blk_mq_delay_run_hw_queue(hctx, BLK_MQ_RESOURCE_DELAY); blk_mq_update_dispatch_busy(hctx, true); -- 2.7.4