diff options
author | Anthony Liguori <aliguori@us.ibm.com> | 2012-05-08 09:38:41 -0500 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-05-08 09:38:41 -0500 |
commit | 7c652c1eaf20b9271ebcc92b788d1fe656b3a774 (patch) | |
tree | b82120a0cecc99af4261329bd01e8e914e01a9db /block | |
parent | e45bca682ca1b63cdfba9c8a6b164d1838a2eda4 (diff) | |
parent | 21fcf36095939a97fc3df578e12821c3e6c3ba78 (diff) |
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.c | 14 | ||||
-rw-r--r-- | block/qcow2.c | 3 | ||||
-rw-r--r-- | block/sheepdog.c | 8 |
3 files changed, 20 insertions, 5 deletions
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 353889d41b..10c22fe12b 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 8c60a6f061..ee4678f6ed 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 0ed6b193c9..e01d371680 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; |