* [Qemu-devel] [PULL 0/5] Block patches for 1.1
@ 2012-05-07 17:55 Kevin Wolf
2012-05-07 17:55 ` [Qemu-devel] [PATCH 1/5] sheepdog: switch to writethrough mode if cluster doesn't support flush Kevin Wolf
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Kevin Wolf @ 2012-05-07 17:55 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
The following changes since commit 847c25d01cbe8e4fe457a7426f82daaaf3287aae:
hw/ac97: Mask out the EAPD bit on Powerdown Ctrl/Stat writes (2012-05-07 16:31:40 +0400)
are available in the git repository at:
git://repo.or.cz/qemu/kevin.git for-anthony
Hervé Poussineau (1):
fdc: simplify media change handling
Kevin Wolf (1):
qcow2: Limit COW to where it's needed
MORITA Kazutaka (1):
sheepdog: switch to writethrough mode if cluster doesn't support flush
Zhi Yong Wu (2):
block: make bdrv_create adopt coroutine
qcow2: lock on prealloc
block.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
block/qcow2-cluster.c | 14 +++++++++-----
block/qcow2.c | 3 +++
block/sheepdog.c | 8 ++++++++
hw/fdc.c | 29 +++++++++++------------------
5 files changed, 73 insertions(+), 25 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 1/5] sheepdog: switch to writethrough mode if cluster doesn't support flush
2012-05-07 17:55 [Qemu-devel] [PULL 0/5] Block patches for 1.1 Kevin Wolf
@ 2012-05-07 17:55 ` Kevin Wolf
2012-05-07 17:55 ` [Qemu-devel] [PATCH 2/5] qcow2: Limit COW to where it's needed Kevin Wolf
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2012-05-07 17:55 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
From: MORITA Kazutaka <morita.kazutaka@gmail.com>
This is necessary for qemu to work with the older version of Sheepdog
which doesn't support SD_OP_FLUSH_VDI.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/sheepdog.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 0ed6b19..e01d371 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -1678,6 +1678,14 @@ static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs)
return ret;
}
+ if (rsp->result == SD_RES_INVALID_PARMS) {
+ dprintf("disable write cache since the server doesn't support it\n");
+
+ s->cache_enabled = 0;
+ closesocket(s->flush_fd);
+ return 0;
+ }
+
if (rsp->result != SD_RES_SUCCESS) {
error_report("%s", sd_strerror(rsp->result));
return -EIO;
--
1.7.6.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 2/5] qcow2: Limit COW to where it's needed
2012-05-07 17:55 [Qemu-devel] [PULL 0/5] Block patches for 1.1 Kevin Wolf
2012-05-07 17:55 ` [Qemu-devel] [PATCH 1/5] sheepdog: switch to writethrough mode if cluster doesn't support flush Kevin Wolf
@ 2012-05-07 17:55 ` Kevin Wolf
2012-05-07 17:55 ` [Qemu-devel] [PATCH 3/5] block: make bdrv_create adopt coroutine Kevin Wolf
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2012-05-07 17:55 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
This fixes a regression introduced in commit 250196f1. The bug leads to
data corruption, found during an Autotest run with a Fedora 8 guest.
Consider a write request whose first part is covered by an already
allocated cluster, but additional clusters need to be newly allocated.
When counting the number of clusters to allocate, the qcow2 code would
decide to do COW for all remaining clusters of the write request, even
if some of them are already allocated.
If during this COW operation another write request is issued that touches
the same cluster, it will still refer to the old cluster. When the COW
completes, the first request will update the L2 table and the second
write request will be lost. Note that the requests need not overlap, it's
enough for them to touch the same cluster.
This patch ensures that only clusters that really require COW are
considered for allocation. In this case any other request writing to the
same cluster will be an allocating write and gets serialised.
Reported-by: Marcelo Tosatti <mtosatti@redhat.com>
Tested-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/qcow2-cluster.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 353889d..10c22fe 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -883,15 +883,19 @@ again:
assert(keep_clusters <= nb_clusters);
nb_clusters -= keep_clusters;
} else {
+ keep_clusters = 0;
+ cluster_offset = 0;
+ }
+
+ if (nb_clusters > 0) {
/* For the moment, overwrite compressed clusters one by one */
- if (cluster_offset & QCOW_OFLAG_COMPRESSED) {
+ uint64_t entry = be64_to_cpu(l2_table[l2_index + keep_clusters]);
+ if (entry & QCOW_OFLAG_COMPRESSED) {
nb_clusters = 1;
} else {
- nb_clusters = count_cow_clusters(s, nb_clusters, l2_table, l2_index);
+ nb_clusters = count_cow_clusters(s, nb_clusters, l2_table,
+ l2_index + keep_clusters);
}
-
- keep_clusters = 0;
- cluster_offset = 0;
}
cluster_offset &= L2E_OFFSET_MASK;
--
1.7.6.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 3/5] block: make bdrv_create adopt coroutine
2012-05-07 17:55 [Qemu-devel] [PULL 0/5] Block patches for 1.1 Kevin Wolf
2012-05-07 17:55 ` [Qemu-devel] [PATCH 1/5] sheepdog: switch to writethrough mode if cluster doesn't support flush Kevin Wolf
2012-05-07 17:55 ` [Qemu-devel] [PATCH 2/5] qcow2: Limit COW to where it's needed Kevin Wolf
@ 2012-05-07 17:55 ` Kevin Wolf
2012-05-07 17:55 ` [Qemu-devel] [PATCH 4/5] qcow2: lock on prealloc Kevin Wolf
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2012-05-07 17:55 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
The current qemu.git introduces failure with preallocation and some
sizes:
qemu-img create -f qcow2 new.img 976563K -o preallocation=metadata
qemu-img: qemu-coroutine-lock.c:111: qemu_co_mutex_unlock: Assertion
`mutex->locked == 1' failed.
And lock needs to work in coroutine context. So to fix this issue, we
need to make bdrv_create adopt coroutine at first.
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/block.c b/block.c
index 43c794c..ee7d8f2 100644
--- a/block.c
+++ b/block.c
@@ -341,13 +341,53 @@ BlockDriver *bdrv_find_whitelisted_format(const char *format_name)
return drv && bdrv_is_whitelisted(drv) ? drv : NULL;
}
+typedef struct CreateCo {
+ BlockDriver *drv;
+ char *filename;
+ QEMUOptionParameter *options;
+ int ret;
+} CreateCo;
+
+static void coroutine_fn bdrv_create_co_entry(void *opaque)
+{
+ CreateCo *cco = opaque;
+ assert(cco->drv);
+
+ cco->ret = cco->drv->bdrv_create(cco->filename, cco->options);
+}
+
int bdrv_create(BlockDriver *drv, const char* filename,
QEMUOptionParameter *options)
{
- if (!drv->bdrv_create)
+ int ret;
+
+ Coroutine *co;
+ CreateCo cco = {
+ .drv = drv,
+ .filename = g_strdup(filename),
+ .options = options,
+ .ret = NOT_DONE,
+ };
+
+ if (!drv->bdrv_create) {
return -ENOTSUP;
+ }
- return drv->bdrv_create(filename, options);
+ if (qemu_in_coroutine()) {
+ /* Fast-path if already in coroutine context */
+ bdrv_create_co_entry(&cco);
+ } else {
+ co = qemu_coroutine_create(bdrv_create_co_entry);
+ qemu_coroutine_enter(co, &cco);
+ while (cco.ret == NOT_DONE) {
+ qemu_aio_wait();
+ }
+ }
+
+ ret = cco.ret;
+ g_free(cco.filename);
+
+ return ret;
}
int bdrv_create_file(const char* filename, QEMUOptionParameter *options)
--
1.7.6.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 4/5] qcow2: lock on prealloc
2012-05-07 17:55 [Qemu-devel] [PULL 0/5] Block patches for 1.1 Kevin Wolf
` (2 preceding siblings ...)
2012-05-07 17:55 ` [Qemu-devel] [PATCH 3/5] block: make bdrv_create adopt coroutine Kevin Wolf
@ 2012-05-07 17:55 ` Kevin Wolf
2012-05-07 17:55 ` [Qemu-devel] [PATCH 5/5] fdc: simplify media change handling Kevin Wolf
2012-05-08 16:11 ` [Qemu-devel] [PULL 0/5] Block patches for 1.1 Anthony Liguori
5 siblings, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2012-05-07 17:55 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
preallocate() will be locked. This is required because
qcow2_alloc_cluster_link_l2() assumes that it runs under a lock that it
can drop while COW is being performed.
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/qcow2.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index 8c60a6f..ee4678f 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1192,7 +1192,10 @@ static int qcow2_create2(const char *filename, int64_t total_size,
/* And if we're supposed to preallocate metadata, do that now */
if (prealloc) {
+ BDRVQcowState *s = bs->opaque;
+ qemu_co_mutex_lock(&s->lock);
ret = preallocate(bs);
+ qemu_co_mutex_unlock(&s->lock);
if (ret < 0) {
goto out;
}
--
1.7.6.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH 5/5] fdc: simplify media change handling
2012-05-07 17:55 [Qemu-devel] [PULL 0/5] Block patches for 1.1 Kevin Wolf
` (3 preceding siblings ...)
2012-05-07 17:55 ` [Qemu-devel] [PATCH 4/5] qcow2: lock on prealloc Kevin Wolf
@ 2012-05-07 17:55 ` Kevin Wolf
2012-05-08 16:11 ` [Qemu-devel] [PULL 0/5] Block patches for 1.1 Anthony Liguori
5 siblings, 0 replies; 7+ messages in thread
From: Kevin Wolf @ 2012-05-07 17:55 UTC (permalink / raw)
To: anthony; +Cc: kwolf, qemu-devel
From: Hervé Poussineau <hpoussin@reactos.org>
This also (partly) fixes IBM OS/2 Warp 4.0 floppy installation, where
not all floppies have the same format (2x80x18 for the first ones,
2x80x23 for the next ones).
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
hw/fdc.c | 29 +++++++++++------------------
1 files changed, 11 insertions(+), 18 deletions(-)
diff --git a/hw/fdc.c b/hw/fdc.c
index 756d4ce..cb4cd25 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -705,6 +705,15 @@ static void fdctrl_raise_irq(FDCtrl *fdctrl, uint8_t status0)
qemu_set_irq(fdctrl->irq, 1);
fdctrl->sra |= FD_SRA_INTPEND;
}
+ if (status0 & FD_SR0_SEEK) {
+ FDrive *cur_drv;
+ /* A seek clears the disk change line (if a disk is inserted) */
+ cur_drv = get_cur_drv(fdctrl);
+ if (cur_drv->max_track) {
+ cur_drv->media_changed = 0;
+ }
+ }
+
fdctrl->reset_sensei = 0;
fdctrl->status0 = status0;
FLOPPY_DPRINTF("Set interrupt status to 0x%02x\n", fdctrl->status0);
@@ -936,23 +945,7 @@ static void fdctrl_write_ccr(FDCtrl *fdctrl, uint32_t value)
static int fdctrl_media_changed(FDrive *drv)
{
- int ret;
-
- if (!drv->bs)
- return 0;
- if (drv->media_changed) {
- drv->media_changed = 0;
- ret = 1;
- } else {
- ret = bdrv_media_changed(drv->bs);
- if (ret < 0) {
- ret = 0; /* we don't know, assume no */
- }
- }
- if (ret) {
- fd_revalidate(drv);
- }
- return ret;
+ return drv->media_changed;
}
/* Digital input register : 0x07 (read-only) */
@@ -1856,6 +1849,7 @@ static void fdctrl_change_cb(void *opaque, bool load)
FDrive *drive = opaque;
drive->media_changed = 1;
+ fd_revalidate(drive);
}
static const BlockDevOps fdctrl_block_ops = {
@@ -1886,7 +1880,6 @@ static int fdctrl_connect_drives(FDCtrl *fdctrl)
fd_init(drive);
fd_revalidate(drive);
if (drive->bs) {
- drive->media_changed = 1;
bdrv_set_dev_ops(drive->bs, &fdctrl_block_ops, drive);
}
}
--
1.7.6.5
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PULL 0/5] Block patches for 1.1
2012-05-07 17:55 [Qemu-devel] [PULL 0/5] Block patches for 1.1 Kevin Wolf
` (4 preceding siblings ...)
2012-05-07 17:55 ` [Qemu-devel] [PATCH 5/5] fdc: simplify media change handling Kevin Wolf
@ 2012-05-08 16:11 ` Anthony Liguori
5 siblings, 0 replies; 7+ messages in thread
From: Anthony Liguori @ 2012-05-08 16:11 UTC (permalink / raw)
To: Kevin Wolf; +Cc: qemu-devel
On 05/07/2012 12:55 PM, Kevin Wolf wrote:
> The following changes since commit 847c25d01cbe8e4fe457a7426f82daaaf3287aae:
>
> hw/ac97: Mask out the EAPD bit on Powerdown Ctrl/Stat writes (2012-05-07 16:31:40 +0400)
>
> are available in the git repository at:
> git://repo.or.cz/qemu/kevin.git for-anthony
Pulled. Thanks.
Regards,
Anthony Liguori
>
> Hervé Poussineau (1):
> fdc: simplify media change handling
>
> Kevin Wolf (1):
> qcow2: Limit COW to where it's needed
>
> MORITA Kazutaka (1):
> sheepdog: switch to writethrough mode if cluster doesn't support flush
>
> Zhi Yong Wu (2):
> block: make bdrv_create adopt coroutine
> qcow2: lock on prealloc
>
> block.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
> block/qcow2-cluster.c | 14 +++++++++-----
> block/qcow2.c | 3 +++
> block/sheepdog.c | 8 ++++++++
> hw/fdc.c | 29 +++++++++++------------------
> 5 files changed, 73 insertions(+), 25 deletions(-)
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-05-08 16:11 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-07 17:55 [Qemu-devel] [PULL 0/5] Block patches for 1.1 Kevin Wolf
2012-05-07 17:55 ` [Qemu-devel] [PATCH 1/5] sheepdog: switch to writethrough mode if cluster doesn't support flush Kevin Wolf
2012-05-07 17:55 ` [Qemu-devel] [PATCH 2/5] qcow2: Limit COW to where it's needed Kevin Wolf
2012-05-07 17:55 ` [Qemu-devel] [PATCH 3/5] block: make bdrv_create adopt coroutine Kevin Wolf
2012-05-07 17:55 ` [Qemu-devel] [PATCH 4/5] qcow2: lock on prealloc Kevin Wolf
2012-05-07 17:55 ` [Qemu-devel] [PATCH 5/5] fdc: simplify media change handling Kevin Wolf
2012-05-08 16:11 ` [Qemu-devel] [PULL 0/5] Block patches for 1.1 Anthony Liguori
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).