Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp949727img; Mon, 18 Mar 2019 19:03:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyyzRQzGI06WmwE8hCzulvuYzx+Wm7DvgRmUzReLPz1DOxXJYHS9tRJXQ/UjbFfYU9Sl+C5 X-Received: by 2002:a63:4e4e:: with SMTP id o14mr20811786pgl.254.1552960994523; Mon, 18 Mar 2019 19:03:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552960994; cv=none; d=google.com; s=arc-20160816; b=ma8e+lpRH7jNIyzixtPbkd3eHPPXCoTg/a9xsH2uGKc3a6E/H16fFopihXwk8eAMT4 rm8UatUgWM9jdM4KO8QHm1/UOGAZHRrohfO4fdHvXTbJtH69pVNKyuTfESvAmk2bsdAv mXF2gAlGD2Hp3+ouovzSy0nKSTRuSrCZxZxxjO+lr6dUbdLnRxDz5GZGFyGTsaX2Tpv7 pXxhSvf4e3CKoToxlyGhM4KpaZGKRBElcFGi3PJX2x41J08VnLTvdd1G0bIjhdgv9x8N Z7J5P1ipeg0kiuEnvxyIwOq0ipoaI+xPTmx2TSAb08qmau9i9h6zLtrQxeIPGzbtFq22 9T2g== 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; bh=qRP0v67g8qqW9Dregqsi0hYaw1mJNAEkd/RTyV5Yy0A=; b=Dzx3CYyVS+EnJtM3F9DBg6l5N1aDSqk3TazHQSLUc+a47IPNVKVEcJmjbZ1PBP/3Ss u+JUmadEhI8hf/CA7F6ryKV8iT+BLh0D4RJXnWUE/P1XZV9owF8OM50GiK+Tn0j+K4Bj qN8zRAqL+z9NAT8JcF5VOyb0FkMZ3BhdQkFBlBKWihaxbCM9hUq3iCLtCkOUdBZS5DfI mVzNnIEMFXr0648I14nDiAl63XkBDG+p4KMrrvoBV3g+lCbl6pMpy9GJgUr4DqfO0g+i QPwS7VoUpJbeiAC/bxVTfzLq3vLHh7Zx3DtHwIpO1PnEEGEvC1J0mtkkC0M1UusY629R VA5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=rcXx8oqn; 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 s14si10192050pgs.98.2019.03.18.19.02.58; Mon, 18 Mar 2019 19:03:14 -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; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=rcXx8oqn; 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 S1727439AbfCSCBu (ORCPT + 99 others); Mon, 18 Mar 2019 22:01:50 -0400 Received: from aserp2130.oracle.com ([141.146.126.79]:60354 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726788AbfCSCBu (ORCPT ); Mon, 18 Mar 2019 22:01:50 -0400 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2J1xD5N052089; Tue, 19 Mar 2019 02:01:19 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-2018-07-02; bh=qRP0v67g8qqW9Dregqsi0hYaw1mJNAEkd/RTyV5Yy0A=; b=rcXx8oqnOVAjOEgVsFFwn4AuqaK0hMSrKWkJaiHFgvnzmZvmUi21+P0L3qqmSziqotoh byrJRWeWFpBTQOwYj7mAXitZ0k9yRLd6wYkKgkoiFZHve7ljb0BeuM6O6MiFfXZfjSZf XHuVqt6TdGIEPcH0iFXP05CZmro/D/vLCBCjIZYZB2Lqd2o5vxCXiqLiW9c8CI+W6JKz HqovSOpBk/kSWRbqdH0QIIKtR+yjTvsCgAx+PUxNZqXn8o7JPX56hy2EkdfQnotSfM+B apEdKGvGBzhOQczj9x2Nxecz+0mulKvjF1eGMV17OEpcSL92oezQnCx69YouDuEUmnVq 0A== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2r8pnej2wn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Mar 2019 02:01:18 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x2J21GvF009205 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Mar 2019 02:01:16 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x2J21Fjx002656; Tue, 19 Mar 2019 02:01:15 GMT Received: from [10.182.69.118] (/10.182.69.118) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 18 Mar 2019 19:01:15 -0700 Subject: Re: [PATCH 5/8] nbd: use blk_mq_queue_tag_busy_iter To: Bart Van Assche , axboe@kernel.dk Cc: linux-block@vger.kernel.org, jsmart2021@gmail.com, sagi@grimberg.me, josef@toxicpanda.com, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, keith.busch@intel.com, hare@suse.de, jthumshirn@suse.de, hch@lst.de References: <1552640264-26101-1-git-send-email-jianchao.w.wang@oracle.com> <1552640264-26101-6-git-send-email-jianchao.w.wang@oracle.com> <1552929384.152266.27.camel@acm.org> From: "jianchao.wang" Message-ID: <6447c549-d531-58a7-57f7-00480ec2d128@oracle.com> Date: Tue, 19 Mar 2019 10:04:23 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <1552929384.152266.27.camel@acm.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9199 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903190013 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bart Thanks for your comment on this. On 3/19/19 1:16 AM, Bart Van Assche wrote: > On Fri, 2019-03-15 at 16:57 +0800, Jianchao Wang wrote: >> blk_mq_tagset_busy_iter is not safe that it could get stale request >> in tags->rqs[]. Use blk_mq_queue_tag_busy_iter here. >> >> Signed-off-by: Jianchao Wang >> --- >> drivers/block/nbd.c | 2 + >> 1 file changed, 1 insertion(), 1 deletion(-) >> >> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c >> index 7c9a949..9e7e828 100644 >> --- a/drivers/block/nbd.c >> +++ b/drivers/block/nbd.c >> @@ -747,7 +747,7 @@ static bool nbd_clear_req(struct request *req, void *data, bool reserved) >> static void nbd_clear_que(struct nbd_device *nbd) >> { >> blk_mq_quiesce_queue(nbd->disk->queue); >> - blk_mq_tagset_busy_iter(&nbd->tag_set, nbd_clear_req, NULL); >> + blk_mq_queue_tag_busy_iter(nbd->disk->queue, nbd_clear_req, NULL, true); >> blk_mq_unquiesce_queue(nbd->disk->queue); >> dev_dbg(disk_to_dev(nbd->disk), "queue cleared\n"); >> } > > Hi Jianchao, > > The nbd driver calls nbd_clear_que() after having called sock_shutdown(). So > what makes you think that it's not safe to call blk_mq_tagset_busy_iter() > from nbd_clear_que()? > The request_queue is not frozen, so there still could be someone enters and get request. If no io scheduler attached, the driver tag could be allocated and tags->rqs[] would be set. During this, blk_mq_tagset_busy_iter could get some stale requests in tags->rqs[] which maybe freed due to switching io scheduler to none. Thanks Jianchao