Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp13863imn; Tue, 26 Jul 2022 20:29:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uBiJ3OeYDH7I/oiJB2BrPPcdvhnZT7TAOUHc3FDb2iNJ/a0U279hUXADXr2uRsSz4bavSn X-Received: by 2002:a17:90a:b785:b0:1f1:be59:a607 with SMTP id m5-20020a17090ab78500b001f1be59a607mr2219970pjr.84.1658892566872; Tue, 26 Jul 2022 20:29:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658892566; cv=none; d=google.com; s=arc-20160816; b=uXS21BGFsScizyvJBoqxtlSj05fARY5uUjICaZHz1o546xr5yogLmgPI0ij/Xkbt8i pFoCZ1P5s2Bk/ILbY5gZDD7n56weiZ56qVdnHTc1FbNhUBDqx6dZSCCrQzT7FLj2wr30 EWnwaGDtbiNNpzMmC25nSNZfp+tHfJRgvvAiZoaNAAkipL5QjVaXm9w9RMS2pOuaqcuz LmoAUSlxR61az2z6IS77ThehVDV+zipKQJ+QsGvTyUlom9aweTV4auduBOmIHq7OnCzT z8oo5qm+b+fpqWrrvCIYrpydpwQCw94iIBiC5DNowd5EHk3UhlyGGq1N4rnbQ/4g2DsB v0yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=32axq/VfQhSlDfqHI2UD/a9LuuHQ/A3908wmtNoQ7lo=; b=oYxKy6qRLUumP2ztp8vTKqvU/qojs0oIqkct7Xe4n7koc1Ym6W7b+03tLAmu0PKRTU UgHjCvVJOTo3mLRMIFxtk0SYuD6h+aj/9eBEYt6+0F9OI2ID17/awNo1zz/vVxTK3wYG NA0K03Sa8h2yR5jOVGNockNrwr98O03gvkN5gkg0FiidHrLJDJHCwkt4emBIFB3WJWjP lYSwj4Bq4J5cCE1hS1Gm40JDEvDpC/G1F2a7pwQrbsSyNMea71J+YhRkUayf9BM3DDQh ILVFwa/tQX0xiOKIq8B0ZoLmqFBYloNCwCZ5kH+u3b8qZYhNUMwgo7t92pxF4wZQ+enR nzXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SlPFIdOe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q124-20020a632a82000000b0041ae11d2931si10618718pgq.70.2022.07.26.20.29.09; Tue, 26 Jul 2022 20:29:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SlPFIdOe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240080AbiG0DJC (ORCPT + 99 others); Tue, 26 Jul 2022 23:09:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239918AbiG0DIz (ORCPT ); Tue, 26 Jul 2022 23:08:55 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E0F7C3C8DF for ; Tue, 26 Jul 2022 20:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658891333; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=32axq/VfQhSlDfqHI2UD/a9LuuHQ/A3908wmtNoQ7lo=; b=SlPFIdOefoa2ZV5E9vOI/11EMbtwoZWUwzKS0DwD4zx7zs2xNDG0ZoW/UAEmbC6oEgfydK Bc5r+qHcomtdnwCmQVDWXoihM9ebAkWZjB0V8ASPDaIHh0e++gIFJVJ/6AWcuLTCnf52op oxz4osYGHfKs8dW+QJ/WRErEvUqlYoQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-231-3z542prMMcGtTLhGBYgXgg-1; Tue, 26 Jul 2022 23:08:48 -0400 X-MC-Unique: 3z542prMMcGtTLhGBYgXgg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2CDAF85A581; Wed, 27 Jul 2022 03:08:48 +0000 (UTC) Received: from T590 (ovpn-8-20.pek2.redhat.com [10.72.8.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E9F87C15D4F; Wed, 27 Jul 2022 03:08:43 +0000 (UTC) Date: Wed, 27 Jul 2022 11:08:38 +0800 From: Ming Lei To: Yu Kuai Cc: axboe@kernel.dk, osandov@fb.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yi.zhang@huawei.com Subject: Re: [PATCH v3] blk-mq: fix io hung due to missing commit_rqs Message-ID: References: <20220726122224.1790882-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220726122224.1790882-1-yukuai1@huaweicloud.com> X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 26, 2022 at 08:22:24PM +0800, Yu Kuai wrote: > From: Yu Kuai > > Currently, in virtio_scsi, if 'bd->last' is not set to true while > dispatching request, such io will stay in driver's queue, and driver > will wait for block layer to dispatch more rqs. However, if block > layer failed to dispatch more rq, it should trigger commit_rqs to > inform driver. > > There is a problem in blk_mq_try_issue_list_directly() that commit_rqs > won't be called: > > // assume that queue_depth is set to 1, list contains two rq > blk_mq_try_issue_list_directly > blk_mq_request_issue_directly > // dispatch first rq > // last is false > __blk_mq_try_issue_directly > blk_mq_get_dispatch_budget > // succeed to get first budget > __blk_mq_issue_directly > scsi_queue_rq > cmd->flags |= SCMD_LAST > virtscsi_queuecommand > kick = (sc->flags & SCMD_LAST) != 0 > // kick is false, first rq won't issue to disk > queued++ > > blk_mq_request_issue_directly > // dispatch second rq > __blk_mq_try_issue_directly > blk_mq_get_dispatch_budget > // failed to get second budget > ret == BLK_STS_RESOURCE > blk_mq_request_bypass_insert > // errors is still 0 > > if (!list_empty(list) || errors && ...) > // won't pass, commit_rqs won't be called > > In this situation, first rq relied on second rq to dispatch, while > second rq relied on first rq to complete, thus they will both hung. > > Fix the problem by also treat 'BLK_STS_*RESOURCE' as 'errors' since > it means that request is not queued successfully. > > Same problem exists in blk_mq_dispatch_rq_list(), 'BLK_STS_*RESOURCE' > can't be treated as 'errors' here, fix the problem by calling > commit_rqs if queue_rq return 'BLK_STS_*RESOURCE'. > > Fixes: d666ba98f849 ("blk-mq: add mq_ops->commit_rqs()") > Signed-off-by: Yu Kuai Reviewed-by: Ming Lei Thanks, Ming