From: Fam Zheng <famz@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, famz@redhat.com, obarenbo@redhat.com,
roliveri@redhat.com, hbrock@redhat.com, rjones@redhat.com,
armbru@redhat.com, pmyers@redhat.com, imain@redhat.com,
stefanha@redhat.com, pbonzini@redhat.com
Subject: [Qemu-devel] [PATCH 3/7] nbd: use BDS refcount
Date: Tue, 2 Jul 2013 13:59:45 +0800 [thread overview]
Message-ID: <1372744789-997-4-git-send-email-famz@redhat.com> (raw)
In-Reply-To: <1372744789-997-1-git-send-email-famz@redhat.com>
Previously, nbd call drive_get_ref on the drive of bs. A BDS doesn't
always have associated dinfo, it's more proper to use bdrv_get_ref().
Signed-off-by: Fam Zheng <famz@redhat.com>
---
blockdev-nbd.c | 9 +--------
nbd.c | 5 +++++
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 95f10c8..d8bcd6f 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -69,12 +69,6 @@ static void nbd_close_notifier(Notifier *n, void *data)
g_free(cn);
}
-static void nbd_server_put_ref(NBDExport *exp)
-{
- BlockDriverState *bs = nbd_export_get_blockdev(exp);
- drive_put_ref(drive_get_by_blockdev(bs));
-}
-
void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
Error **errp)
{
@@ -106,10 +100,9 @@ void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
}
exp = nbd_export_new(bs, 0, -1, writable ? 0 : NBD_FLAG_READ_ONLY,
- nbd_server_put_ref);
+ NULL);
nbd_export_set_name(exp, device);
- drive_get_ref(drive_get_by_blockdev(bs));
n = g_malloc0(sizeof(NBDCloseNotifier));
n->n.notify = nbd_close_notifier;
diff --git a/nbd.c b/nbd.c
index 2606403..f28b9fb 100644
--- a/nbd.c
+++ b/nbd.c
@@ -881,6 +881,7 @@ NBDExport *nbd_export_new(BlockDriverState *bs, off_t dev_offset,
exp->nbdflags = nbdflags;
exp->size = size == -1 ? bdrv_getlength(bs) : size;
exp->close = close;
+ bdrv_get_ref(bs);
return exp;
}
@@ -927,6 +928,10 @@ void nbd_export_close(NBDExport *exp)
}
nbd_export_set_name(exp, NULL);
nbd_export_put(exp);
+ if (exp->bs) {
+ bdrv_put_ref(exp->bs);
+ exp->bs = NULL;
+ }
}
void nbd_export_get(NBDExport *exp)
--
1.8.3.1
next prev parent reply other threads:[~2013-07-02 6:02 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 ` Fam Zheng [this message]
2013-07-02 10:16 ` [Qemu-devel] [PATCH 3/7] nbd: use BDS refcount 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
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=1372744789-997-4-git-send-email-famz@redhat.com \
--to=famz@redhat.com \
--cc=armbru@redhat.com \
--cc=hbrock@redhat.com \
--cc=imain@redhat.com \
--cc=kwolf@redhat.com \
--cc=obarenbo@redhat.com \
--cc=pbonzini@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).