aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2012-05-08 09:38:41 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2012-05-08 09:38:41 -0500
commit7c652c1eaf20b9271ebcc92b788d1fe656b3a774 (patch)
treeb82120a0cecc99af4261329bd01e8e914e01a9db /block
parente45bca682ca1b63cdfba9c8a6b164d1838a2eda4 (diff)
parent21fcf36095939a97fc3df578e12821c3e6c3ba78 (diff)
downloadqemu-7c652c1eaf20b9271ebcc92b788d1fe656b3a774.zip
qemu-7c652c1eaf20b9271ebcc92b788d1fe656b3a774.tar.gz
qemu-7c652c1eaf20b9271ebcc92b788d1fe656b3a774.tar.bz2
Merge remote-tracking branch 'kwolf/for-anthony' into staging
* kwolf/for-anthony: fdc: simplify media change handling qcow2: lock on prealloc block: make bdrv_create adopt coroutine qcow2: Limit COW to where it's needed sheepdog: switch to writethrough mode if cluster doesn't support flush
Diffstat (limited to 'block')
-rw-r--r--block/qcow2-cluster.c14
-rw-r--r--block/qcow2.c3
-rw-r--r--block/sheepdog.c8
3 files changed, 20 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;
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;
}
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;