From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VC7or-0006XE-0X for qemu-devel@nongnu.org; Wed, 21 Aug 2013 08:47:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VC7oi-0001Gn-Jx for qemu-devel@nongnu.org; Wed, 21 Aug 2013 08:47:24 -0400 Received: from mail-we0-x236.google.com ([2a00:1450:400c:c03::236]:56948) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VC7oi-0001Gj-EB for qemu-devel@nongnu.org; Wed, 21 Aug 2013 08:47:16 -0400 Received: by mail-we0-f182.google.com with SMTP id q59so380895wes.27 for ; Wed, 21 Aug 2013 05:47:15 -0700 (PDT) Date: Wed, 21 Aug 2013 14:47:12 +0200 From: Stefan Hajnoczi Message-ID: <20130821124712.GA11975@stefanha-thinkpad.redhat.com> References: <1375071932-31627-1-git-send-email-famz@redhat.com> <1375071932-31627-3-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1375071932-31627-3-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [RFC PATCH 2/4] nbd: call drive_put_ref() only if dinfo exists List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: kwolf@redhat.com, pbonzini@redhat.com, imain@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On Mon, Jul 29, 2013 at 12:25:30PM +0800, Fam Zheng wrote: > Signed-off-by: Fam Zheng > --- > blockdev-nbd.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/blockdev-nbd.c b/blockdev-nbd.c > index 95f10c8..c75df19 100644 > --- a/blockdev-nbd.c > +++ b/blockdev-nbd.c > @@ -72,7 +72,10 @@ static void nbd_close_notifier(Notifier *n, void *data) > static void nbd_server_put_ref(NBDExport *exp) > { > BlockDriverState *bs = nbd_export_get_blockdev(exp); > - drive_put_ref(drive_get_by_blockdev(bs)); > + DriveInfo *dinfo = drive_get_by_blockdev(bs); > + if (dinfo) { > + drive_put_ref(dinfo); > + } This doesn't make sense to me. If we hold a reference, we must release it. Once your refcount series is applied, NBD should be able to hold just the BDS refcount. Then we don't care about DriveInfo at all anymore besides looking up the BDS when the user creates an export. Stefan