Received: by 10.223.185.116 with SMTP id b49csp6880527wrg; Wed, 28 Feb 2018 17:59:01 -0800 (PST) X-Google-Smtp-Source: AG47ELv0obmcobijXAOf0/SVrbyC/whZff8CEDDiggEOa/NzCXev2HY2BAlvqayU4ZDzhUF5FskP X-Received: by 10.99.8.4 with SMTP id 4mr151211pgi.289.1519869541861; Wed, 28 Feb 2018 17:59:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519869541; cv=none; d=google.com; s=arc-20160816; b=IFvfCbiWdsVm2/XAqveI8d0XWaju/AL6ZprPytWWZmsmgCzmmmmW9eFKfFf6gQMCYF /5lU3DAfqgm0qPLQrUmDHXx6ycPyNyIuzIG70Tdag9y5Ozztt7XtP0zJlPAJ/yAwvwOg EANVoe7L7A8ceosh79e8ypoVZk/YReUhTO42/eTTeYESEOuUd62X25yqEwdEnmpLLRz9 M8OxCLy+I4bIQMJT3YjuAfyYYHeTMuqskqxSmUcoUrpa0CA3d3XUyzlwUYIZ96tmRuTD BhvUxAi5rp7tcfPTOfkZ8Hb2Ya2Yt599q0EUX7oKGbll2KHhmujAVpu4oa+Qo9pdMXFM PXdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=ZI1FxFzUGv85TCEwKCPJwTJ6oSRTvp7eI6d9q/Wswtc=; b=ptSlKkqdWx7H04JEcZKvxfsFpFKp4iAOSh/yCpHe6Pw+DY1WGgcyjgj3l82MPKlVG7 n+DLWYRjzHJ80WvLhCKWusTqJH086kDpoBJpL7RGtAdACU2kUJoPHV7WTgH1K5Jg6zvq /ZapRa/qwLrWv2nM5pvW1dLEtL05+Zcyi34tAU+faEhOwNi4D7yg3pdhFAP2o1Gzc0NJ UNYb8qQsUSf8cOeNdIMjB6qYl9oWB+CZMAfP9vBACmU7d5XnbzNNAC/cg+qt31IMYW2c 3JjyJkjPyA3UkpWcLXVOG5PRLhnSUbH3qY6k1uOQvMdHdSS8kcfARVlMIZAP2ysSyOZu u+9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=gnlr9vVT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n127si1752796pga.171.2018.02.28.17.58.46; Wed, 28 Feb 2018 17:59:01 -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; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=gnlr9vVT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935708AbeCAB6E (ORCPT + 99 others); Wed, 28 Feb 2018 20:58:04 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:43610 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932134AbeCAB6C (ORCPT ); Wed, 28 Feb 2018 20:58:02 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w211vlNn063812; Thu, 1 Mar 2018 01:57:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=ZI1FxFzUGv85TCEwKCPJwTJ6oSRTvp7eI6d9q/Wswtc=; b=gnlr9vVTPmmBkH8DcUYzBxTbN8FqowJD84as9VsCQAztjs1j17/oJr7zTT1Qm+XGR1nv rC/cy+XUGFZnlQHhhyt9ssoUqmIPrGrJURJRB1yfChcrUCyzAwHf3u5/KM9BWjc/XfBW jLgM32UecOn/OBYHAbmv/Vb5UwxOKMUpcXdObcB2KMlC8G+e2bUCh9DIQOGvAU6GDBcK DwOQnyJytXMH5iMvxsT1zByj/wdsfogGO3Q4z5VxYZMnC+6sTbeVlEQd7hiK0c6f+Df5 HLe6WG7GwAARZpFgyLa2XX1sb6XZp1nIilKC7L+bPsHSpuUfLQSLbVX+hUdZSmMUl5D7 aw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2ge80081ck-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 01 Mar 2018 01:57:59 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w211vwwT031674 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Mar 2018 01:57:58 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w211vvkw020386; Thu, 1 Mar 2018 01:57:57 GMT Received: from [10.191.25.142] (/10.191.25.142) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 28 Feb 2018 17:57:57 -0800 Subject: Re: [PATCH V2] scsi: core: use blk_mq_requeue_request in __scsi_queue_insert To: Bart Van Assche , "jejb@linux.vnet.ibm.com" , "martin.petersen@oracle.com" Cc: "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "hch@lst.de" References: <1519808113-2863-1-git-send-email-jianchao.w.wang@oracle.com> <1519840355.2777.8.camel@wdc.com> From: "jianchao.wang" Message-ID: <624cedc6-9658-7b76-9c63-61c30fdfe6be@oracle.com> Date: Thu, 1 Mar 2018 09:57:54 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1519840355.2777.8.camel@wdc.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8818 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803010024 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bart Thanks for your precious time to review this and kindly detailed response. On 03/01/2018 01:52 AM, Bart Van Assche wrote: > On Wed, 2018-02-28 at 16:55 +0800, Jianchao Wang wrote: >> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c >> index a86df9c..6fa7b0c 100644 >> --- a/drivers/scsi/scsi_lib.c >> +++ b/drivers/scsi/scsi_lib.c >> @@ -191,7 +191,8 @@ static void __scsi_queue_insert(struct scsi_cmnd *cmd, int reason, bool unbusy) >> */ >> cmd->result = 0; >> if (q->mq_ops) { >> - scsi_mq_requeue_cmd(cmd); >> + blk_mq_requeue_request(cmd->request, true); >> + put_device(&device->sdev_gendev); >> return; >> } >> spin_lock_irqsave(q->queue_lock, flags); > > Anyone who sees the put_device() call that follows the blk_mq_requeue_request() > call will wonder why that call occurs there. So I think we need a comment above > that call that explains where the matching get_device() call is. Yes, I will add this. > For the legacy code path, there is a get_device() call in scsi_prep_fn() but no > put_device() call in scsi_unprep_fn() - the matching put_device() calls occur in > scsi_end_request() and after blk_requeue_request(). > > For scsi-mq however there is a get_device() call in scsi_mq_get_budget() and a > put_device() call in scsi_mq_put_budget(). So why do we need the put_device() > calls after blk_mq_requeue_request() and in the mq path for scsi_end_request()? > From the source code, we know the scsi_mq_get_budget will be invoked every time when we issue a request. But scsi_mq_put_budget is just in the fail path. scsi_queue_rq // if any error -> scsi_mq_put_budget blk_mq_dispatch_rq_list // if no driver tags -> blk_mq_put_dispatch_budget -> scsi_mq_put_budget blk_mq_do_dispatch_sched/blk_mq_do_dispatch_ctx // if no requests -> blk_mq_put_dispatch_budget -> scsi_mq_put_budget So we have to add put_device after blk_mq_requeue_request() and in scsi_end_request() to match the scsi_mq_get_budget. Thanks Jianchao