qcow2: reindent and use while before the big jump

prepare to remove read/write callbacks

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Frediano Ziglio 2011-08-23 15:21:18 +02:00 committed by Kevin Wolf
parent e78c69b89c
commit 5ebaa27e9a

View File

@ -399,10 +399,7 @@ static int qcow2_aio_read_cb(QCowAIOCB *acb)
int cur_nr_sectors; /* number of sectors in current iteration */
uint64_t cluster_offset = 0;
if (acb->remaining_sectors == 0) {
/* request completed */
return 0;
}
while (acb->remaining_sectors != 0) {
/* prepare next request */
cur_nr_sectors = acb->remaining_sectors;
@ -498,8 +495,9 @@ static int qcow2_aio_read_cb(QCowAIOCB *acb)
acb->remaining_sectors -= cur_nr_sectors;
acb->sector_num += cur_nr_sectors;
acb->bytes_done += cur_nr_sectors * 512;
}
return 1;
return 0;
}
static QCowAIOCB *qcow2_aio_setup(BlockDriverState *bs, int64_t sector_num,
@ -572,16 +570,14 @@ static int qcow2_aio_write_cb(QCowAIOCB *acb)
l2meta.nb_clusters = 0;
qemu_co_queue_init(&l2meta.dependent_requests);
if (acb->remaining_sectors == 0) {
/* request completed */
return 0;
}
while (acb->remaining_sectors != 0) {
index_in_cluster = acb->sector_num & (s->cluster_sectors - 1);
n_end = index_in_cluster + acb->remaining_sectors;
if (s->crypt_method &&
n_end > QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors)
n_end > QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors) {
n_end = QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors;
}
ret = qcow2_alloc_cluster_offset(bs, acb->sector_num << 9,
index_in_cluster, n_end, &cur_nr_sectors, &l2meta);
@ -602,7 +598,8 @@ static int qcow2_aio_write_cb(QCowAIOCB *acb)
s->cluster_size);
}
assert(acb->hd_qiov.size <= QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size);
assert(acb->hd_qiov.size <=
QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size);
qemu_iovec_to_buffer(&acb->hd_qiov, acb->cluster_data);
qcow2_encrypt_sectors(s, acb->sector_num, acb->cluster_data,
@ -634,8 +631,9 @@ static int qcow2_aio_write_cb(QCowAIOCB *acb)
acb->remaining_sectors -= cur_nr_sectors;
acb->sector_num += cur_nr_sectors;
acb->bytes_done += cur_nr_sectors * 512;
}
return 1;
return 0;
}
static int qcow2_co_writev(BlockDriverState *bs,