Received: by 10.223.185.116 with SMTP id b49csp310560wrg; Fri, 2 Mar 2018 19:59:38 -0800 (PST) X-Google-Smtp-Source: AG47ELvX1+NxOPblz/38qfXAkKpUNMW9YjcTmXd8Tp5ldKr4G4blEH5ec7jABAfkumIPLddZ/Uac X-Received: by 10.99.167.66 with SMTP id w2mr6236394pgo.357.1520049577973; Fri, 02 Mar 2018 19:59:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520049577; cv=none; d=google.com; s=arc-20160816; b=abNS8L6PolTendorD1kWFbT63GB5UkIUOQkLvrDyOnqRRS4oyd72c8i2Co8ZMmkKS5 eXayeNErd0hMTJ7p4Onvg6ipCcOfOC3WNxHRfqFckcNDU/jbcuH2TLPKvZHsSmxTnhRx HMvjzouy1jr4XH7q3naizakGj7dZx+328JjRA5aWZa11BYbdzPDG/MCM/4qAOXw7ewZe yx1sx+Wg6foD+7Sl/AHtb/okDzSe5ANpUoTenCc5owHTrAzlIESSeDXXXSYFc0yowy1N eJcfkaTWWeQVVIuXyrXJvHyQBzgrm2UgGUOBpMZUZlvLVuNH60DE85EAtVc9dE+ONKvf qCuA== 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=8jIrbUlcX3A3EpiXlB24MTAyIGgmPfKaEGScjiSyzzc=; b=ozmgr2uXzkgNwJ6BGBH3HmdWEx0AT+c/Ef2TZYXKIhYmj+MKt/PzeDY7dVHnb1sA96 FJMS3ChP75NMTS0+qZpNwC/yfkEILH5x/lZNHN333/zw9kkr6bNVDVPeJvayffy5r+73 akiy0dWwy7OHpEt2CIicCOC21nDL6KaJ8Usa4CsdfSw8o+ajMeea/q8CuFvUAH1N6FcP ZIH/fZ6oOkxMB56NN/4b3bfja9BYCudbwHNvD5cjCpUbiw3TpyiAhwAuud6dzLahBmU+ E/DoNQiIwBIPCRZJddvqVH07aA9FNJP0BBYvP+qDYDC/TvZ1oazi4WR/yOtySvv+i7IQ ycOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=v7vnPshG; 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 c17si4957965pgn.87.2018.03.02.19.59.22; Fri, 02 Mar 2018 19:59:37 -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=v7vnPshG; 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 S965021AbeCCBlt (ORCPT + 99 others); Fri, 2 Mar 2018 20:41:49 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:59246 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964973AbeCCBlr (ORCPT ); Fri, 2 Mar 2018 20:41:47 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w231fZPJ042773; Sat, 3 Mar 2018 01:41:44 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=8jIrbUlcX3A3EpiXlB24MTAyIGgmPfKaEGScjiSyzzc=; b=v7vnPshGchi/KlC+GMH+LpctClhG5cNAkwB2MLJDqmi3CXbUv03tmN0+p3h6+2vNoJB6 iq0R8me1CpBthfXDITFs2C5z7rJtLmnecQthYILa81aKPI3Lejv7tUTeocNLZksCQXN1 79q/wEiwxV07noHWM+3kUe2IqPE5KZY0sSLuZbkI23/bnN1V0Ad3OmAPWPlraNgwQU2E ivRWXEeZAweamgthhOLg4LXFnDcVyX+mYnB5Mv5iaibCE4B7qQbOcDm8VFDQYVDyLIX1 lTJafu3sSTJVnoIeT0lfI//JaIY2pIzOIg1swDYvCPcbaBZMyKYNqrNqz3NycZgJrxAo fA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2gfh4s04tc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 03 Mar 2018 01:41:43 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w231fgJL029219 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 3 Mar 2018 01:41:43 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w231ffLR009640; Sat, 3 Mar 2018 01:41:42 GMT Received: from [10.191.8.43] (/10.191.8.43) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 02 Mar 2018 17:41:41 -0800 Subject: Re: [PATCH V3] 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: <1519961474-15236-1-git-send-email-jianchao.w.wang@oracle.com> <1520008291.2855.7.camel@wdc.com> From: "jianchao.wang" Message-ID: Date: Sat, 3 Mar 2018 09:41:40 +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: <1520008291.2855.7.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=8820 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-1803030015 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bart Thanks for your kindly response and directive. On 03/03/2018 12:31 AM, Bart Van Assche wrote: > On Fri, 2018-03-02 at 11:31 +0800, Jianchao Wang wrote: >> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c >> index a86df9c..d2f1838 100644 >> --- a/drivers/scsi/scsi_lib.c >> +++ b/drivers/scsi/scsi_lib.c >> @@ -191,7 +191,13 @@ 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); >> + /* >> + * scsi_device.sdev_gendev will be get every time in .get_budget and >> + * be put in scsi_end_request. Hence we need to put the reference >> + * here when we decide to requeue request. >> + */ >> + blk_mq_requeue_request(cmd->request, true); >> + put_device(&device->sdev_gendev); >> return; >> } >> spin_lock_irqsave(q->queue_lock, flags); > > Please consider to change the new comment into something like the following: > "Before a SCSI command is dispatched, get_device(&sdev->sdev_gendev) is called > and the host, target and device busy counters are increased. Since requeuing a > request causes these actions to be repeated and since scsi_device_unbusy() has > already been called, put_device(&device->sdev_gendev) must still be called. Call > put_device() after blk_mq_requeue_request() to avoid that removal of the SCSI > device can start before requeueing has happened." Yes, your comment is more detailed and clearly. Sincerely Jianchao