|
|
9ae3a8 |
From e81a83acac1f44ade1e28879203ca95466dad805 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Date: Fri, 17 Jan 2014 03:07:50 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 07/34] xen_disk: simplify blk_disconnect with refcnt
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1389928083-8921-6-git-send-email-famz@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 56767
|
|
|
9ae3a8 |
O-Subject: [RHEL-7 qemu-kvm PATCH 05/18] xen_disk: simplify blk_disconnect with refcnt
|
|
|
9ae3a8 |
Bugzilla: 1041301
|
|
|
9ae3a8 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
We call bdrv_attach_dev when initializing whether or not bs is created
|
|
|
9ae3a8 |
locally, so call bdrv_detach_dev and let the refcnt handle the
|
|
|
9ae3a8 |
lifecycle.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit c0777fe18b08c3a6de0c53325d6b9b75ebb9de9a)
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
hw/block/xen_disk.c
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Contextual conflict because of backport of 4f8a066b.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/block/xen_disk.c | 11 +++++------
|
|
|
9ae3a8 |
1 file changed, 5 insertions(+), 6 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/block/xen_disk.c | 11 +++++------
|
|
|
9ae3a8 |
1 files changed, 5 insertions(+), 6 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
|
|
|
9ae3a8 |
index 138ab94..a2653b2 100644
|
|
|
9ae3a8 |
--- a/hw/block/xen_disk.c
|
|
|
9ae3a8 |
+++ b/hw/block/xen_disk.c
|
|
|
9ae3a8 |
@@ -822,6 +822,9 @@ static int blk_connect(struct XenDevice *xendev)
|
|
|
9ae3a8 |
blkdev->bs = NULL;
|
|
|
9ae3a8 |
return -1;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
+ /* blkdev->bs is not create by us, we get a reference
|
|
|
9ae3a8 |
+ * so we can bdrv_unref() unconditionally */
|
|
|
9ae3a8 |
+ bdrv_ref(blkdev->bs);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
bdrv_attach_dev_nofail(blkdev->bs, blkdev);
|
|
|
9ae3a8 |
blkdev->file_size = bdrv_getlength(blkdev->bs);
|
|
|
9ae3a8 |
@@ -920,12 +923,8 @@ static void blk_disconnect(struct XenDevice *xendev)
|
|
|
9ae3a8 |
struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (blkdev->bs) {
|
|
|
9ae3a8 |
- if (!blkdev->dinfo) {
|
|
|
9ae3a8 |
- /* close/delete only if we created it ourself */
|
|
|
9ae3a8 |
- bdrv_close(blkdev->bs);
|
|
|
9ae3a8 |
- bdrv_detach_dev(blkdev->bs, blkdev);
|
|
|
9ae3a8 |
- bdrv_unref(blkdev->bs);
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
+ bdrv_detach_dev(blkdev->bs, blkdev);
|
|
|
9ae3a8 |
+ bdrv_unref(blkdev->bs);
|
|
|
9ae3a8 |
blkdev->bs = NULL;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
xen_be_unbind_evtchn(&blkdev->xendev);
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|