Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp504189ybv; Thu, 13 Feb 2020 04:39:35 -0800 (PST) X-Google-Smtp-Source: APXvYqxhiXiyKm7iIa0w7O3i2wA0QWewvQ3KA9dkSgui9MxCHMNEHojrGSu9QzaTqzDEzm4dJHQ9 X-Received: by 2002:a54:4f14:: with SMTP id e20mr2662105oiy.84.1581597575662; Thu, 13 Feb 2020 04:39:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581597575; cv=none; d=google.com; s=arc-20160816; b=BYaEw4/PTwELL0LPapv/edP5iudzGeouJ0/pmUMKF0/2rT1Z4p7fi4unCChJh4h4Hv s6ZIvRXSgbCO+IoujsdY202iadMPBaCY7YqNGmlcSA0uUGOkY4oJGjIXdh9F7rKbWaZi DL+XYbWinhGU12LliXelrw6YtQWHtS8QI8PS36ivaIubsOYhPa782K2K+oEhlv/Rm7ww OlrxyU76perFfFiHOJK4ub0Vq+Egx/WBmjAbZGjynC5AMlB4ZDKmGWc4vk0El+jYoFUj eOhnVfDQsZMrdhP5BAmjqPpam4S5w6+Ab1FeZMFEalTqFtDQdH6sVQQVgaORF0Y2QsCh 5iJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from; bh=ey+Wq36TNl7vY3UhisXi3jGB0IVf3dYwbjm+92dQ0rY=; b=EmBpKgxQ50P15IxTTDBDT0q8acP/dPBKWMSBFRin9RuuzQeqrabH0smUqsovxyyxGh T7F3TWE0fWhy2g9d4c4WgbIxuyyWxgdwcH8TWvNHeXGG8aBKecrAnL89btBqIoe3+J96 2p3ZAV+/4f9m0nt+bMOoeToakodgFFbNETo/KxZtQcLCZxUG3CFy5BoaDmtpGkfEp9XM iWy5aD3I3PcGHBRF66bY72mQ6V8fSp+1QMkdv+c5O7pYy0BCNOr6/D4VG3/apawLE8d2 LVDwvwAh6X6mqKpc6s9vwHcqh6Y9B68GpGWGvfTRRu6pqf+f3iSXMEOQw1AwGU5ZFXYA HHcA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si1167632oic.140.2020.02.13.04.39.23; Thu, 13 Feb 2020 04:39:35 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729952AbgBMMiN (ORCPT + 99 others); Thu, 13 Feb 2020 07:38:13 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:30156 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729673AbgBMMiN (ORCPT ); Thu, 13 Feb 2020 07:38:13 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01DCaUIZ133130 for ; Thu, 13 Feb 2020 07:38:11 -0500 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2y4wutsgws-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 13 Feb 2020 07:38:11 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 13 Feb 2020 12:38:09 -0000 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 13 Feb 2020 12:38:05 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01DCb9Cr43778406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 13 Feb 2020 12:37:09 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 277075204E; Thu, 13 Feb 2020 12:38:04 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id A8B1452051; Thu, 13 Feb 2020 12:38:03 +0000 (GMT) From: Halil Pasic To: "Michael S. Tsirkin" , Jason Wang Cc: Halil Pasic , Jens Axboe , Paolo Bonzini , Stefan Hajnoczi , virtualization@lists.linux-foundation.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, Christian Borntraeger , Viktor Mihajlovski , Cornelia Huck , Ram Pai , Thiago Jung Bauermann , "Lendacky, Thomas" Subject: [PATCH 1/2] virtio-blk: fix hw_queue stopped on arbitrary error Date: Thu, 13 Feb 2020 13:37:27 +0100 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200213123728.61216-1-pasic@linux.ibm.com> References: <20200213123728.61216-1-pasic@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 20021312-0020-0000-0000-000003A9C690 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20021312-0021-0000-0000-00002201B136 Message-Id: <20200213123728.61216-2-pasic@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-13_04:2020-02-12,2020-02-13 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 spamscore=0 mlxscore=0 impostorscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002130098 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since nobody else is going to restart our hw_queue for us, the blk_mq_start_stopped_hw_queues() is in virtblk_done() is not sufficient necessarily sufficient to ensure that the queue will get started again. In case of global resource outage (-ENOMEM because mapping failure, because of swiotlb full) our virtqueue may be empty and we can get stuck with a stopped hw_queue. Let us not stop the queue on arbitrary errors, but only on -EONSPC which indicates a full virtqueue, where the hw_queue is guaranteed to get started by virtblk_done() before when it makes sense to carry on submitting requests. Let us also remove a stale comment. Signed-off-by: Halil Pasic Cc: Jens Axboe Fixes: f7728002c1c7 ("virtio_ring: fix return code on DMA mapping fails") --- I'm in doubt with regards to the Fixes tag. The thing is, virtio-blk probably made an assumption on virtqueue_add: the failure is either because the virtqueue is full, or the failure is fatal. In both cases it seems acceptable to stop the queue, although the fatal case is arguable. Since commit f7728002c1c7 it the dma mapping has failed returns -ENOMEM and not -EIO, and thus we have a recoverable failure that ain't virtqueue full. So I lean towards to a fixes tag that references that commit, although it ain't broken. Alternatively one could say 'Fixes: e467cde23818 ("Block driver using virtio.")', if the aforementioned assumption shouldn't have made in the first place. --- drivers/block/virtio_blk.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 54158766334b..adfe43f5ffe4 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c @@ -245,10 +245,12 @@ static blk_status_t virtio_queue_rq(struct blk_mq_hw_ctx *hctx, err = virtblk_add_req(vblk->vqs[qid].vq, vbr, vbr->sg, num); if (err) { virtqueue_kick(vblk->vqs[qid].vq); - blk_mq_stop_hw_queue(hctx); + /* Don't stop the queue if -ENOMEM: we may have failed to + * bounce the buffer due to global resource outage. + */ + if (err == -ENOSPC) + blk_mq_stop_hw_queue(hctx); spin_unlock_irqrestore(&vblk->vqs[qid].lock, flags); - /* Out of mem doesn't actually happen, since we fall back - * to direct descriptors */ if (err == -ENOMEM || err == -ENOSPC) return BLK_STS_DEV_RESOURCE; return BLK_STS_IOERR; -- 2.17.1