Revision 3de0a294
b/block/qcow2-cache.c | ||
---|---|---|
38 | 38 |
int size; |
39 | 39 |
Qcow2CachedTable* entries; |
40 | 40 |
struct Qcow2Cache* depends; |
41 |
bool depends_on_flush; |
|
41 | 42 |
bool writethrough; |
42 | 43 |
}; |
43 | 44 |
|
... | ... | |
85 | 86 |
} |
86 | 87 |
|
87 | 88 |
c->depends = NULL; |
89 |
c->depends_on_flush = false; |
|
90 |
|
|
88 | 91 |
return 0; |
89 | 92 |
} |
90 | 93 |
|
91 | 94 |
static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i) |
92 | 95 |
{ |
93 | 96 |
BDRVQcowState *s = bs->opaque; |
94 |
int ret; |
|
97 |
int ret = 0;
|
|
95 | 98 |
|
96 | 99 |
if (!c->entries[i].dirty || !c->entries[i].offset) { |
97 | 100 |
return 0; |
... | ... | |
99 | 102 |
|
100 | 103 |
if (c->depends) { |
101 | 104 |
ret = qcow2_cache_flush_dependency(bs, c); |
102 |
if (ret < 0) { |
|
103 |
return ret; |
|
105 |
} else if (c->depends_on_flush) { |
|
106 |
ret = bdrv_flush(bs->file); |
|
107 |
if (ret >= 0) { |
|
108 |
c->depends_on_flush = false; |
|
104 | 109 |
} |
105 | 110 |
} |
106 | 111 |
|
112 |
if (ret < 0) { |
|
113 |
return ret; |
|
114 |
} |
|
115 |
|
|
107 | 116 |
if (c == s->refcount_block_cache) { |
108 | 117 |
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_UPDATE_PART); |
109 | 118 |
} else if (c == s->l2_table_cache) { |
... | ... | |
167 | 176 |
return 0; |
168 | 177 |
} |
169 | 178 |
|
179 |
void qcow2_cache_depends_on_flush(Qcow2Cache *c) |
|
180 |
{ |
|
181 |
c->depends_on_flush = true; |
|
182 |
} |
|
183 |
|
|
170 | 184 |
static int qcow2_cache_find_entry_to_replace(Qcow2Cache *c) |
171 | 185 |
{ |
172 | 186 |
int i; |
b/block/qcow2-cluster.c | ||
---|---|---|
637 | 637 |
* handled. |
638 | 638 |
*/ |
639 | 639 |
if (cow) { |
640 |
bdrv_flush(bs->file);
|
|
640 |
qcow2_cache_depends_on_flush(s->l2_table_cache);
|
|
641 | 641 |
} |
642 | 642 |
|
643 | 643 |
qcow2_cache_set_dependency(bs, s->l2_table_cache, s->refcount_block_cache); |
b/block/qcow2.h | ||
---|---|---|
229 | 229 |
int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c); |
230 | 230 |
int qcow2_cache_set_dependency(BlockDriverState *bs, Qcow2Cache *c, |
231 | 231 |
Qcow2Cache *dependency); |
232 |
void qcow2_cache_depends_on_flush(Qcow2Cache *c); |
|
232 | 233 |
|
233 | 234 |
int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset, |
234 | 235 |
void **table); |
Also available in: Unified diff