Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp3123172ybh; Sat, 25 Jul 2020 11:44:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaaIQ/GHAbl1KxlMKuFkZN0zPQu0meSxwegXvpY7grw8LLCQ9FDUEUssux8/YlViFrZgFR X-Received: by 2002:a17:906:6847:: with SMTP id a7mr14184654ejs.306.1595702692758; Sat, 25 Jul 2020 11:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595702692; cv=none; d=google.com; s=arc-20160816; b=cYr73Y2f5XD2AnKoCakSBswKhoz6C5eUVShDLtPnDZGn0s66h5s31HmeXpR6V2CGWZ /pMgzUUqI4eN995q4x30+E+a0ls8yNi/rIyQBIk5HDw4iZYSASLkyKzQhvXyaqDpVM42 CwZwfRKS5nTbTsS2scSy490uILm5TwENO+h6UZKfyN0zP3BVozFcN2SBEFzgpsGRgDJC nZMms7dtFQ0dteK8DS0WyL2Fwsrlvb+WrDxGFg92h2tovtPbx0desoAOmbMO3ija3BnE 0kA9iuNxAjxO252LtWV3w2bHvGvG3sl/8XM2aerGiu/OEpDN19DGuY/c90DleuA6BOK/ 5qqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=eJEpSUfkla/agpQCH51QK4tTiRteg4fcYTB66EtN8tQ=; b=Z0gJzhuDrvmkdzuozFa8IZv3MRhdW+mmSh26eryjWxUtJyAFh2t2l+Sy3Ap2HOD2Xf h2EN7Dsk12j0Y+ooVZtLpCPCxznbL5rrN/00jpvVyDU/piju1Jw+PfM3XtfrurO8HEA7 w2aJo+UuZeXI4RuaqqBttCgpuls8qY4OKbCAblMKfLIswo4A1jLOHRIkDIr7T2+0sIBc nyd7fUeJ4eQ+0V34MrnZol1MZsO8p+is3lzJA6P8fSRKMu5dDcabGJ0fbf9mFyVdvX3H JTjVghRd9u/mmlNzjxfJ+S8ALJMEGEI5VZA9kYdl9SGjNg+Y/LszGetcdz5pzec2VCOd p1xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Yx8cy7p6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id p2si2726819edj.167.2020.07.25.11.44.29; Sat, 25 Jul 2020 11:44:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Yx8cy7p6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727856AbgGYSnU (ORCPT + 99 others); Sat, 25 Jul 2020 14:43:20 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:47392 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727050AbgGYSnT (ORCPT ); Sat, 25 Jul 2020 14:43:19 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06PIcTPv013083; Sat, 25 Jul 2020 18:42:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=content-type : mime-version : subject : from : in-reply-to : date : cc : content-transfer-encoding : message-id : references : to; s=corp-2020-01-29; bh=eJEpSUfkla/agpQCH51QK4tTiRteg4fcYTB66EtN8tQ=; b=Yx8cy7p67Y5KTFOgF6BIWxEauFiKJbYC5hs59KFAKYaoDXQ7q0/QJZrmXubBYVNqyj9/ +yctd08tOKOjvwNMth5YbSOPZljx5/NBNkr+WVThUqXCaB3K+1s5PEmUpGE2kzQHFhkU cweo6BAulel5xko8d1VwvdDXo2ni12KqIFskMmGf1cKNZZQ6a4o+7ZMdDTsubU8DS6Og 2Fz3t4uJECScBEr8o/X3IXFn5ioMFhjZ2aoRDMsf5v1TxLOUchi2cJOlH+bdNedfrOzm S1Jb5x/wgCAzvNQNgkp1OPFsZ10S1wGYOLqO+I1G3NYpuVctqVzoVmOeyn3Tn2/0ernd qQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 32gcpksed4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sat, 25 Jul 2020 18:42:40 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 06PIdCSi098561; Sat, 25 Jul 2020 18:42:39 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 32ghx0kp29-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 25 Jul 2020 18:42:39 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 06PIgbX8020632; Sat, 25 Jul 2020 18:42:38 GMT Received: from [20.15.0.12] (/73.88.28.6) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 25 Jul 2020 11:42:37 -0700 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] nbd: add missed destroy_workqueue when nbd_start_device fails From: Michael Christie In-Reply-To: <1595644070-26293-1-git-send-email-liheng40@huawei.com> Date: Sat, 25 Jul 2020 13:42:35 -0500 Cc: josef@toxicpanda.com, axboe@kernel.dk, linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <6A2BE179-5545-4486-81B6-5CB9020F9522@oracle.com> References: <1595644070-26293-1-git-send-email-liheng40@huawei.com> To: Li Heng X-Mailer: Apple Mail (2.3608.80.23.2.2) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9693 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 mlxlogscore=999 spamscore=0 bulkscore=0 suspectscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007250154 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9693 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxscore=0 bulkscore=0 priorityscore=1501 phishscore=0 adultscore=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 clxscore=1011 mlxlogscore=999 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007250154 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Jul 24, 2020, at 9:27 PM, Li Heng wrote: >=20 > destroy_workqueue() should be called to destroy ndev->tx_wq > when nbd_start_device init resources fails. >=20 > Reported-by: Hulk Robot > Signed-off-by: Li Heng > --- > drivers/block/nbd.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c > index ce7e9f22..45e0a9f4 100644 > --- a/drivers/block/nbd.c > +++ b/drivers/block/nbd.c > @@ -4,7 +4,7 @@ > * > * Note that you can not swap over this thing, yet. Seems to work but > * deadlocks sometimes - you can not swap over TCP in general. > - *=20 > + * > * Copyright 1997-2000, 2008 Pavel Machek > * Parts copyright 2001 Steven Whitehouse > * > @@ -1270,6 +1270,7 @@ static int nbd_start_device(struct nbd_device = *nbd) > error =3D device_create_file(disk_to_dev(nbd->disk), &pid_attr); > if (error) { > dev_err(disk_to_dev(nbd->disk), "device_create_file = failed!\n"); > + destroy_workqueue(nbd->recv_workq); > return error; > } > set_bit(NBD_RT_HAS_PID_FILE, &config->runtime_flags); > @@ -1291,6 +1292,7 @@ static int nbd_start_device(struct nbd_device = *nbd) > */ > if (i) > flush_workqueue(nbd->recv_workq); > + destroy_workqueue(nbd->recv_workq); > return -ENOMEM; > } > sk_set_memalloc(config->socks[i]->sock->sk); For the netlink error path, we end up cleaning up everything when = nbd_config_put is called in the error path. Are you seeing an issue with the ioctl interface and this code path? I = thought normally if the the NBD_DO_IT ioctl fails, then userspace closes = the device and that does the nbd_config_put that will clean this up like = is done in the netlink path. If userspace is not closing the device and is trying to maybe retry the = NBD_DO_IT ioctl or reuse the device some other way, then I think you = need to also NULL nbd->task_recv, remove pid file, NULL recv_workq after = you destroy for the cases nbd_config_put is called right after a = failure.