Stefano Stabellini
2012-Apr-24 13:07 UTC
[PATCH 0/3] qemu-xen-traditional: xen_disk backports
Hi all,
this patch series is a set of xen_disk improvements backports from
upstream QEMU:
Stefano Stabellini (3):
xen: handle backend deletion from xenstore
xen_disk: use bdrv_aio_flush instead of bdrv_flush
xen_disk: implement BLKIF_OP_FLUSH_DISKCACHE, remove
BLKIF_OP_WRITE_BARRIER
hw/xen_backend.c | 17 +++++++++--------
hw/xen_disk.c | 27 ++++++++++++++++-----------
2 files changed, 25 insertions(+), 19 deletions(-)
Cheers,
Stefano
Stefano Stabellini
2012-Apr-24 13:08 UTC
[PATCH 1/3] xen: handle backend deletion from xenstore
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
hw/xen_backend.c | 17 +++++++++--------
hw/xen_disk.c | 4 ++++
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/hw/xen_backend.c b/hw/xen_backend.c
index 64dc93a..11e09fc 100644
--- a/hw/xen_backend.c
+++ b/hw/xen_backend.c
@@ -561,7 +561,7 @@ static void xenstore_update_be(char *watch, char *type, int
dom,
struct XenDevOps *ops)
{
struct XenDevice *xendev;
- char path[XEN_BUFSIZE], *dom0;
+ char path[XEN_BUFSIZE], *dom0, *bepath;
unsigned int len, dev;
dom0 = xs_get_domain_path(xenstore, 0);
@@ -577,15 +577,16 @@ static void xenstore_update_be(char *watch, char *type,
int dom,
if (dev == -1)
return;
- if (0) {
- /* FIXME: detect devices being deleted from xenstore ... */
- xen_be_del_xendev(dom, dev);
- }
-
xendev = xen_be_get_xendev(type, dom, dev, ops);
if (xendev != NULL) {
- xen_be_backend_changed(xendev, path);
- xen_be_check_state(xendev);
+ bepath = xs_read(xenstore, 0, xendev->be, &len);
+ if (bepath == NULL) {
+ xen_be_del_xendev(dom, dev);
+ } else {
+ free(bepath);
+ xen_be_backend_changed(xendev, path);
+ xen_be_check_state(xendev);
+ }
}
}
diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index 5db58ac..f9ef062 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -758,6 +758,10 @@ static int blk_free(struct XenDevice *xendev)
struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
struct ioreq *ioreq;
+ if (blkdev->bs || blkdev->sring) {
+ blk_disconnect(xendev);
+ }
+
while (!LIST_EMPTY(&blkdev->freelist)) {
ioreq = LIST_FIRST(&blkdev->freelist);
LIST_REMOVE(ioreq, list);
--
1.7.2.5
Stefano Stabellini
2012-Apr-24 13:08 UTC
[PATCH 2/3] xen_disk: use bdrv_aio_flush instead of bdrv_flush
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
hw/xen_disk.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index f9ef062..900f456 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -382,8 +382,6 @@ static void qemu_aio_complete(void *opaque, int ret)
ioreq->aio_inflight--;
if (ioreq->aio_inflight > 0)
return;
- if (ioreq->postsync)
- bdrv_flush(ioreq->blkdev->bs);
ioreq->status = ioreq->aio_errors ? BLKIF_RSP_ERROR : BLKIF_RSP_OKAY;
ioreq_unmap(ioreq);
@@ -398,9 +396,10 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
if (ioreq->req.nr_segments && ioreq_map(ioreq) == -1)
goto err;
- ioreq->aio_inflight++;
- if (ioreq->presync)
- bdrv_flush(blkdev->bs); /* FIXME: aio_flush() ??? */
+ if (ioreq->presync) {
+ ioreq->aio_inflight++;
+ bdrv_aio_flush(ioreq->blkdev->bs, qemu_aio_complete, ioreq);
+ }
switch (ioreq->req.operation) {
case BLKIF_OP_READ:
@@ -422,8 +421,10 @@ static int ioreq_runio_qemu_aio(struct ioreq *ioreq)
/* unknown operation (shouldn''t happen -- parse catches this) */
goto err;
}
-
- qemu_aio_complete(ioreq, 0);
+ if (ioreq->postsync) {
+ ioreq->aio_inflight++;
+ bdrv_aio_flush(ioreq->blkdev->bs, qemu_aio_complete, ioreq);
+ }
return 0;
--
1.7.2.5
Stefano Stabellini
2012-Apr-24 13:08 UTC
[PATCH 3/3] xen_disk: implement BLKIF_OP_FLUSH_DISKCACHE, remove BLKIF_OP_WRITE_BARRIER
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
hw/xen_disk.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index 900f456..8181af9 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -181,13 +181,13 @@ static int ioreq_parse(struct ioreq *ioreq)
case BLKIF_OP_READ:
ioreq->prot = PROT_WRITE; /* to memory */
break;
- case BLKIF_OP_WRITE_BARRIER:
+ case BLKIF_OP_FLUSH_DISKCACHE:
if (!ioreq->req.nr_segments) {
ioreq->presync = 1;
return 0;
}
if (!syncwrite)
- ioreq->presync = ioreq->postsync = 1;
+ ioreq->postsync = 1;
/* fall through */
case BLKIF_OP_WRITE:
ioreq->prot = PROT_READ; /* from memory */
@@ -333,7 +333,7 @@ static int ioreq_runio_qemu_sync(struct ioreq *ioreq)
}
break;
case BLKIF_OP_WRITE:
- case BLKIF_OP_WRITE_BARRIER:
+ case BLKIF_OP_FLUSH_DISKCACHE:
if (!ioreq->req.nr_segments)
break;
pos = ioreq->start;
@@ -669,7 +669,7 @@ static int blk_init(struct XenDevice *xendev)
blkdev->file_size, blkdev->file_size >> 20);
/* fill info */
- xenstore_write_be_int(&blkdev->xendev, "feature-barrier",
have_barriers);
+ xenstore_write_be_int(&blkdev->xendev,
"feature-flush-cache", 1);
xenstore_write_be_int(&blkdev->xendev, "info",
info);
xenstore_write_be_int(&blkdev->xendev, "sector-size",
blkdev->file_blk);
xenstore_write_be_int(&blkdev->xendev, "sectors",
--
1.7.2.5
Ian Jackson
2012-Apr-24 15:53 UTC
Re: [PATCH 0/3] qemu-xen-traditional: xen_disk backports
Stefano Stabellini writes ("[Xen-devel] [PATCH 0/3] qemu-xen-traditional:
xen_disk backports"):> Stefano Stabellini (3):
> xen: handle backend deletion from xenstore
> xen_disk: use bdrv_aio_flush instead of bdrv_flush
> xen_disk: implement BLKIF_OP_FLUSH_DISKCACHE, remove
BLKIF_OP_WRITE_BARRIER
Thanks, they all look sensible, and you can put my ack on them:
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
But can you please repost with some commit messages which contain a
reference to the corresponding upstream commit for each one ? That
will make future archaeology much much easier.
Ian.