Revision 8b3b7206 block/qcow2-refcount.c
b/block/qcow2-refcount.c | ||
---|---|---|
44 | 44 |
} |
45 | 45 |
|
46 | 46 |
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_UPDATE); |
47 |
if (bdrv_pwrite(bs->file, s->refcount_block_cache_offset, |
|
48 |
s->refcount_block_cache, size) != size)
|
|
47 |
if (bdrv_pwrite_sync(bs->file, s->refcount_block_cache_offset,
|
|
48 |
s->refcount_block_cache, size) < 0)
|
|
49 | 49 |
{ |
50 | 50 |
return -EIO; |
51 | 51 |
} |
... | ... | |
269 | 269 |
|
270 | 270 |
/* Now the new refcount block needs to be written to disk */ |
271 | 271 |
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE); |
272 |
ret = bdrv_pwrite(bs->file, new_block, s->refcount_block_cache, |
|
272 |
ret = bdrv_pwrite_sync(bs->file, new_block, s->refcount_block_cache,
|
|
273 | 273 |
s->cluster_size); |
274 | 274 |
if (ret < 0) { |
275 | 275 |
goto fail_block; |
... | ... | |
279 | 279 |
if (refcount_table_index < s->refcount_table_size) { |
280 | 280 |
uint64_t data64 = cpu_to_be64(new_block); |
281 | 281 |
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_HOOKUP); |
282 |
ret = bdrv_pwrite(bs->file, |
|
282 |
ret = bdrv_pwrite_sync(bs->file,
|
|
283 | 283 |
s->refcount_table_offset + refcount_table_index * sizeof(uint64_t), |
284 | 284 |
&data64, sizeof(data64)); |
285 | 285 |
if (ret < 0) { |
... | ... | |
359 | 359 |
|
360 | 360 |
/* Write refcount blocks to disk */ |
361 | 361 |
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_BLOCKS); |
362 |
ret = bdrv_pwrite(bs->file, meta_offset, new_blocks, |
|
362 |
ret = bdrv_pwrite_sync(bs->file, meta_offset, new_blocks,
|
|
363 | 363 |
blocks_clusters * s->cluster_size); |
364 | 364 |
qemu_free(new_blocks); |
365 | 365 |
if (ret < 0) { |
... | ... | |
372 | 372 |
} |
373 | 373 |
|
374 | 374 |
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE_TABLE); |
375 |
ret = bdrv_pwrite(bs->file, table_offset, new_table, |
|
375 |
ret = bdrv_pwrite_sync(bs->file, table_offset, new_table,
|
|
376 | 376 |
table_size * sizeof(uint64_t)); |
377 | 377 |
if (ret < 0) { |
378 | 378 |
goto fail_table; |
... | ... | |
387 | 387 |
cpu_to_be64w((uint64_t*)data, table_offset); |
388 | 388 |
cpu_to_be32w((uint32_t*)(data + 8), table_clusters); |
389 | 389 |
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_SWITCH_TABLE); |
390 |
ret = bdrv_pwrite(bs->file, offsetof(QCowHeader, refcount_table_offset), |
|
390 |
ret = bdrv_pwrite_sync(bs->file, offsetof(QCowHeader, refcount_table_offset),
|
|
391 | 391 |
data, sizeof(data)); |
392 | 392 |
if (ret < 0) { |
393 | 393 |
goto fail_table; |
... | ... | |
444 | 444 |
size = (last_index - first_index) << REFCOUNT_SHIFT; |
445 | 445 |
|
446 | 446 |
BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_UPDATE_PART); |
447 |
ret = bdrv_pwrite(bs->file, |
|
447 |
ret = bdrv_pwrite_sync(bs->file,
|
|
448 | 448 |
refcount_block_offset + (first_index << REFCOUNT_SHIFT), |
449 | 449 |
&s->refcount_block_cache[first_index], size); |
450 | 450 |
if (ret < 0) { |
... | ... | |
826 | 826 |
} |
827 | 827 |
} |
828 | 828 |
if (l2_modified) { |
829 |
if (bdrv_pwrite(bs->file, |
|
830 |
l2_offset, l2_table, l2_size) != l2_size)
|
|
829 |
if (bdrv_pwrite_sync(bs->file,
|
|
830 |
l2_offset, l2_table, l2_size) < 0)
|
|
831 | 831 |
goto fail; |
832 | 832 |
} |
833 | 833 |
|
... | ... | |
850 | 850 |
if (l1_modified) { |
851 | 851 |
for(i = 0; i < l1_size; i++) |
852 | 852 |
cpu_to_be64s(&l1_table[i]); |
853 |
if (bdrv_pwrite(bs->file, l1_table_offset, l1_table, |
|
854 |
l1_size2) != l1_size2)
|
|
853 |
if (bdrv_pwrite_sync(bs->file, l1_table_offset, l1_table,
|
|
854 |
l1_size2) < 0)
|
|
855 | 855 |
goto fail; |
856 | 856 |
for(i = 0; i < l1_size; i++) |
857 | 857 |
be64_to_cpus(&l1_table[i]); |
Also available in: Unified diff