Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp897910imu; Thu, 13 Dec 2018 06:19:32 -0800 (PST) X-Google-Smtp-Source: AFSGD/V00d5EV/vNxdGh698II2wI1vR6HM8EflaYR6kgIiiH40IvgVU60qbsGRj3XHtxCKzp+t2T X-Received: by 2002:a62:16d6:: with SMTP id 205mr24211546pfw.256.1544710772380; Thu, 13 Dec 2018 06:19:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544710772; cv=none; d=google.com; s=arc-20160816; b=JptYGMQ+TYNbkJmE+pwJRzoQb78dNNvlo3NaT7bdyztILc4DWOtMWMDf2VBk1BBUl1 LOdDxwrXiV3ajOiTaeb2TKlUxsmfDHTVwgvDSeVCEDRZlM6E3efvymI12Q5Hurt81D+m prfAUAniIY8OMWCwoo2wUGEIamnZ7oC/cMIRcC1IhSb5lLQ24Uaoguo4L3Re0PBiZOtf fDInbAkv/gwzsmOU2ROqjt8hpNYd+QmtXW3CfHjGf7Oco8H5d7IjdvK8l2WImaUUjCNb DyDN06X8A8+XdZWvGf4YtIlZH4Ggf+i6ZirfbVwifyZhu5fPjwt89qlCrW8t+Na5O+IX DaOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version; bh=je8vVL1vFJs3gVCTxmmp71AipZwjakbocWVc4zE1L9I=; b=SaQUOrklnEC2OiKAJxEjn/YjjpIgJ4NWmowYgGg+tAtNOV5qGr0kB05/0MZF2gY2F6 qRHZ9dEMAjrefUYSgouLhDyFihJrxBHpGL32I19HzFUTjCazeSwm5yofjnRGHLcsk39a JhCUZhn9BlFNGt4h79xE4lOnd/DIB6ohZjG440zfYMtr9uyscTCpmvgOzgAmo9rBMRH0 BFsGLuCWxBz4I+avSDrGwNiTuVs9W4iQAmkbRnvEXyatPThXtW6w/NPFEtSNBXVKuK+H HU9F+XB3hiXcLoHQXuZONlAi4uiCZ0Lo266fuQse0/3VoKA10bl51cUto98dEPxBA24V 9nIw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i23si1589184pgb.116.2018.12.13.06.18.50; Thu, 13 Dec 2018 06:19:32 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728515AbeLMORq (ORCPT + 99 others); Thu, 13 Dec 2018 09:17:46 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34426 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727856AbeLMORq (ORCPT ); Thu, 13 Dec 2018 09:17:46 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wBDEDw3t134586 for ; Thu, 13 Dec 2018 09:17:45 -0500 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0a-001b2d01.pphosted.com with ESMTP id 2pbrxqrbh1-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 13 Dec 2018 09:17:45 -0500 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 13 Dec 2018 14:17:44 -0000 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 13 Dec 2018 14:17:41 -0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wBDEHeXQ15728658 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 13 Dec 2018 14:17:40 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3A38A28058; Thu, 13 Dec 2018 14:17:40 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D106B28064; Thu, 13 Dec 2018 14:17:38 +0000 (GMT) Received: from ltc.linux.ibm.com (unknown [9.16.170.189]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 13 Dec 2018 14:17:38 +0000 (GMT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 13 Dec 2018 08:21:49 -0600 From: Adriana Kobylak To: medadyoung@gmail.com, joel@jms.id.au, jk@ozlabs.org Cc: jbacik@fb.com, axboe@kernel.dk, linux-block@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, nbd@other.debian.org, openbmc Subject: Re: [PATCH] nbd:clear NBD_BOUND flag when NBD connection is closed In-Reply-To: <1544509023-18923-1-git-send-email-medadyoung@gmail.com> References: <1544509023-18923-1-git-send-email-medadyoung@gmail.com> X-Sender: anoo@linux.ibm.com User-Agent: Roundcube Webmail/1.0.1 X-TM-AS-GCONF: 00 x-cbid: 18121314-0060-0000-0000-000002E36DA7 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010219; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000271; SDB=6.01131193; UDB=6.00587859; IPR=6.00911325; MB=3.00024681; MTD=3.00000008; XFM=3.00000015; UTC=2018-12-13 14:17:43 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18121314-0061-0000-0000-000047863A82 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-12-13_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 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-1812130124 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-12-11 00:17, medadyoung@gmail.com wrote: > From: Medad > > If we do NOT clear NBD_BOUND flag when NBD connection is closed, > then the original NBD device could not be used again. > > Signed-off-by: Medad Tested on Witherspoon (OpenPOWER P9 with AST2500) and verified with this patch that the NBD device could be disconnected/reconnected. Tested by: Adriana Kobylak > --- > drivers/block/nbd.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c > index 64278f4..5c88490 100644 > --- a/drivers/block/nbd.c > +++ b/drivers/block/nbd.c > @@ -277,10 +277,14 @@ static void sock_shutdown(struct nbd_device *nbd) > struct nbd_config *config = nbd->config; > int i; > > - if (config->num_connections == 0) > + if (config->num_connections == 0) { > + clear_bit(NBD_BOUND, &config->runtime_flags); > return; > - if (test_and_set_bit(NBD_DISCONNECTED, &config->runtime_flags)) > + } > + if (test_and_set_bit(NBD_DISCONNECTED, &config->runtime_flags)) { > + clear_bit(NBD_BOUND, &config->runtime_flags); > return; > + } > > for (i = 0; i < config->num_connections; i++) { > struct nbd_sock *nsock = config->socks[i]; > @@ -944,7 +948,7 @@ static int nbd_reconnect_socket(struct nbd_device > *nbd, unsigned long arg) > sockfd_put(old); > > clear_bit(NBD_DISCONNECTED, &config->runtime_flags); > - > + clear_bit(NBD_BOUND, &config->runtime_flags); > /* We take the tx_mutex in an error path in the recv_work, so we > * need to queue_work outside of the tx_mutex. > */ > @@ -1020,6 +1024,7 @@ static int nbd_disconnect(struct nbd_device *nbd) > dev_info(disk_to_dev(nbd->disk), "NBD_DISCONNECT\n"); > set_bit(NBD_DISCONNECT_REQUESTED, &config->runtime_flags); > send_disconnects(nbd); > + clear_bit(NBD_BOUND, &config->runtime_flags); > return 0; > }