All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: famz@redhat.com
Cc: kwolf@redhat.com, rjones@redhat.com, obarenbo@redhat.com,
	roliveri@redhat.com, hbrock@redhat.com, armbru@redhat.com,
	qemu-devel@nongnu.org, pmyers@redhat.com, imain@redhat.com,
	stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 3/7] nbd: use BDS refcount
Date: Wed, 03 Jul 2013 09:28:06 +0200	[thread overview]
Message-ID: <51D3D286.8020909@redhat.com> (raw)
In-Reply-To: <20130703063030.GA1112@t430s.nay.redhat.com>

Il 03/07/2013 08:30, Fam Zheng ha scritto:
>> > The close notifier runs when the user invokes a drive_del or eject
>> > command from the monitor.  The drive_get_ref/drive_put_ref delays the
>> > bdrv_delete until after nbd.c has cleaned up all the connections.
> But drive_put_ref is called by close notifier.

Not necessarily.  nbd_export_close calls nbd_client_close, which shuts
down the socket.  However, if requests are being processed, they will
complete after nbd_export_close returns.  Completing the requests leads
to the following call chain:

   nbd_request_put (from nbd_trip)
   calls nbd_client_put
   calls nbd_export_put
   calls exp->close (if refcount goes to 0)
   calls drive_put_ref

Completion will happen as soon as the main loop runs again, because
after shutdown() the reads and writes will fail.  Still, it is
asynchronous, hence the call to drive_put_ref is also asynchronous.

> I think it can be
> omitted, registering a close notifier is enough, and close the export
> when drive_del calls it. It doesn't make more sense w/ drive_get_ref,
> does it?

I think that would cause a dangling pointer if NBD requests are being
processed at the time drive_del runs.

Paolo

  reply	other threads:[~2013-07-03  7:28 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-02  5:59 [Qemu-devel] [PATCH 0/7] Point-in-time snapshot exporting over NBD Fam Zheng
2013-07-02  5:59 ` [Qemu-devel] [PATCH 1/7] block: Convert BlockDriverState.in_use to refcount Fam Zheng
2013-07-02 10:21   ` Paolo Bonzini
2013-07-08  8:37     ` Fam Zheng
2013-07-02 19:41   ` Eric Blake
2013-07-03  0:59     ` Fam Zheng
2013-07-02  5:59 ` [Qemu-devel] [PATCH 2/7] block: use refcount to manage BlockDriverState lifecycle Fam Zheng
2013-07-02  5:59 ` [Qemu-devel] [PATCH 3/7] nbd: use BDS refcount Fam Zheng
2013-07-02 10:16   ` Paolo Bonzini
2013-07-03  1:10     ` Fam Zheng
2013-07-03  5:58       ` Paolo Bonzini
2013-07-03  6:30         ` Fam Zheng
2013-07-03  7:28           ` Paolo Bonzini [this message]
2013-07-02  5:59 ` [Qemu-devel] [PATCH 4/7] block: simplify bdrv_drop_intermediate Fam Zheng
2013-07-04 14:02   ` Stefan Hajnoczi
2013-07-05  1:00     ` Fam Zheng
2013-07-02  5:59 ` [Qemu-devel] [PATCH 5/7] block: rename bdrv_in_use to bdrv_is_shared Fam Zheng
2013-07-02  5:59 ` [Qemu-devel] [PATCH 6/7] block: add target-id option to drive-backup QMP command Fam Zheng
2013-07-02 19:59   ` Eric Blake
2013-07-02  5:59 ` [Qemu-devel] [PATCH 7/7] block: assign backing relationship in drive-backup Fam Zheng
2013-07-04 14:32   ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51D3D286.8020909@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=armbru@redhat.com \
    --cc=famz@redhat.com \
    --cc=hbrock@redhat.com \
    --cc=imain@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=obarenbo@redhat.com \
    --cc=pmyers@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    --cc=roliveri@redhat.com \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.