qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH 12/22] nbd/server: Simplify export shutdown


From: Eric Blake
Subject: Re: [RFC PATCH 12/22] nbd/server: Simplify export shutdown
Date: Wed, 19 Aug 2020 15:45:36 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0

On 8/13/20 11:29 AM, Kevin Wolf wrote:
Closing export is somewhat convoluted because nbd_export_close() and
nbd_export_put() call each other and the ways they actually end up being
nested is not necessarily obvious.

You are in a maze of twisty little passages, all alike.

Yes, I've always hated that part of the code; thanks for tackling a cleanup.


However, it is not really necessary to call nbd_export_close() from
nbd_export_put() when putting the last reference because it only does
three things:

1. Close all clients. We're going to refcount 0 and all clients hold a
    reference, so we know there is no active client any more.

2. Close the user reference (represented by exp->name being non-NULL).
    The same argument applies: If the export were still named, we would
    still have a reference.

3. Freeing exp->description. This is really cleanup work to be done when
    the export is finally freed. There is no reason to already clear it
    while clients are still in the process of shutting down.

So after moving the cleanup of exp->description, the code can be
simplified so that only nbd_export_close() calls nbd_export_put(), but
never the other way around.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
  nbd/server.c | 17 ++++-------------
  1 file changed, 4 insertions(+), 13 deletions(-)


Reviewed-by: Eric Blake <eblake@redhat.com>

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]