Commit ade406775d3795141927bdd581edee2cb44da864
Committed by
Anthony Liguori
1 parent
cab3c825
qcow/qcow2: Drop synchronous qcow_write()
There is only one (internal) user left and it can be switched to the normal emulation provided in block.c Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
2 changed files
with
2 additions
and
77 deletions
block/qcow.c
| ... | ... | @@ -488,41 +488,6 @@ static int qcow_read(BlockDriverState *bs, int64_t sector_num, |
| 488 | 488 | } |
| 489 | 489 | #endif |
| 490 | 490 | |
| 491 | -static int qcow_write(BlockDriverState *bs, int64_t sector_num, | |
| 492 | - const uint8_t *buf, int nb_sectors) | |
| 493 | -{ | |
| 494 | - BDRVQcowState *s = bs->opaque; | |
| 495 | - int ret, index_in_cluster, n; | |
| 496 | - uint64_t cluster_offset; | |
| 497 | - | |
| 498 | - while (nb_sectors > 0) { | |
| 499 | - index_in_cluster = sector_num & (s->cluster_sectors - 1); | |
| 500 | - n = s->cluster_sectors - index_in_cluster; | |
| 501 | - if (n > nb_sectors) | |
| 502 | - n = nb_sectors; | |
| 503 | - cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0, | |
| 504 | - index_in_cluster, | |
| 505 | - index_in_cluster + n); | |
| 506 | - if (!cluster_offset) | |
| 507 | - return -1; | |
| 508 | - if (s->crypt_method) { | |
| 509 | - encrypt_sectors(s, sector_num, s->cluster_data, buf, n, 1, | |
| 510 | - &s->aes_encrypt_key); | |
| 511 | - ret = bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512, | |
| 512 | - s->cluster_data, n * 512); | |
| 513 | - } else { | |
| 514 | - ret = bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512); | |
| 515 | - } | |
| 516 | - if (ret != n * 512) | |
| 517 | - return -1; | |
| 518 | - nb_sectors -= n; | |
| 519 | - sector_num += n; | |
| 520 | - buf += n * 512; | |
| 521 | - } | |
| 522 | - s->cluster_cache_offset = -1; /* disable compressed cache */ | |
| 523 | - return 0; | |
| 524 | -} | |
| 525 | - | |
| 526 | 491 | typedef struct QCowAIOCB { |
| 527 | 492 | BlockDriverAIOCB common; |
| 528 | 493 | int64_t sector_num; |
| ... | ... | @@ -904,7 +869,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num, |
| 904 | 869 | |
| 905 | 870 | if (ret != Z_STREAM_END || out_len >= s->cluster_size) { |
| 906 | 871 | /* could not compress: write normal cluster */ |
| 907 | - qcow_write(bs, sector_num, buf, s->cluster_sectors); | |
| 872 | + bdrv_write(bs, sector_num, buf, s->cluster_sectors); | |
| 908 | 873 | } else { |
| 909 | 874 | cluster_offset = get_cluster_offset(bs, sector_num << 9, 2, |
| 910 | 875 | out_len, 0, 0); | ... | ... |
block/qcow2.c
| ... | ... | @@ -1229,46 +1229,6 @@ static int qcow_read(BlockDriverState *bs, int64_t sector_num, |
| 1229 | 1229 | return 0; |
| 1230 | 1230 | } |
| 1231 | 1231 | |
| 1232 | -static int qcow_write(BlockDriverState *bs, int64_t sector_num, | |
| 1233 | - const uint8_t *buf, int nb_sectors) | |
| 1234 | -{ | |
| 1235 | - BDRVQcowState *s = bs->opaque; | |
| 1236 | - int ret, index_in_cluster, n; | |
| 1237 | - uint64_t cluster_offset; | |
| 1238 | - int n_end; | |
| 1239 | - QCowL2Meta l2meta; | |
| 1240 | - | |
| 1241 | - while (nb_sectors > 0) { | |
| 1242 | - index_in_cluster = sector_num & (s->cluster_sectors - 1); | |
| 1243 | - n_end = index_in_cluster + nb_sectors; | |
| 1244 | - if (s->crypt_method && | |
| 1245 | - n_end > QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors) | |
| 1246 | - n_end = QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors; | |
| 1247 | - cluster_offset = alloc_cluster_offset(bs, sector_num << 9, | |
| 1248 | - index_in_cluster, | |
| 1249 | - n_end, &n, &l2meta); | |
| 1250 | - if (!cluster_offset) | |
| 1251 | - return -1; | |
| 1252 | - if (s->crypt_method) { | |
| 1253 | - encrypt_sectors(s, sector_num, s->cluster_data, buf, n, 1, | |
| 1254 | - &s->aes_encrypt_key); | |
| 1255 | - ret = bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512, | |
| 1256 | - s->cluster_data, n * 512); | |
| 1257 | - } else { | |
| 1258 | - ret = bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512); | |
| 1259 | - } | |
| 1260 | - if (ret != n * 512 || alloc_cluster_link_l2(bs, cluster_offset, &l2meta) < 0) { | |
| 1261 | - free_any_clusters(bs, cluster_offset, l2meta.nb_clusters); | |
| 1262 | - return -1; | |
| 1263 | - } | |
| 1264 | - nb_sectors -= n; | |
| 1265 | - sector_num += n; | |
| 1266 | - buf += n * 512; | |
| 1267 | - } | |
| 1268 | - s->cluster_cache_offset = -1; /* disable compressed cache */ | |
| 1269 | - return 0; | |
| 1270 | -} | |
| 1271 | - | |
| 1272 | 1232 | typedef struct QCowAIOCB { |
| 1273 | 1233 | BlockDriverAIOCB common; |
| 1274 | 1234 | int64_t sector_num; |
| ... | ... | @@ -1834,7 +1794,7 @@ static int qcow_write_compressed(BlockDriverState *bs, int64_t sector_num, |
| 1834 | 1794 | |
| 1835 | 1795 | if (ret != Z_STREAM_END || out_len >= s->cluster_size) { |
| 1836 | 1796 | /* could not compress: write normal cluster */ |
| 1837 | - qcow_write(bs, sector_num, buf, s->cluster_sectors); | |
| 1797 | + bdrv_write(bs, sector_num, buf, s->cluster_sectors); | |
| 1838 | 1798 | } else { |
| 1839 | 1799 | cluster_offset = alloc_compressed_cluster_offset(bs, sector_num << 9, |
| 1840 | 1800 | out_len); | ... | ... |