From 9b644b883d214635921f0849bdd7be4f7762b6ea Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Tue, 14 Feb 2012 11:13:50 +0100 Subject: [PATCH 25/99] Cleanup: Be consistent and use BDRV_SECTOR_SIZE instead of 512 RH-Author: Kevin Wolf Message-id: <1329218101-24213-26-git-send-email-kwolf@redhat.com> Patchwork-id: 37216 O-Subject: [RHEL-6.3 qemu-kvm PATCH v2 25/96] Cleanup: Be consistent and use BDRV_SECTOR_SIZE instead of 512 Bugzilla: 783950 RH-Acked-by: Paolo Bonzini RH-Acked-by: Marcelo Tosatti RH-Acked-by: Laszlo Ersek From: Jes Sorensen Bugzilla: 783950 Clean up block.c and use BDRV_SECTOR_SIZE rather than hard coded numbers (512) when referring to sector size throughout the code. Signed-off-by: Jes Sorensen Signed-off-by: Kevin Wolf (cherry picked from commit eb5a316514144bc1def4cb9b88fb996420ca80cc) Conflicts: block.c Signed-off-by: Kevin Wolf --- block.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) Signed-off-by: Michal Novotny --- block.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index 92d3ce3..3be1ca5 100644 --- a/block.c +++ b/block.c @@ -955,7 +955,8 @@ static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset, static int bdrv_check_request(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { - return bdrv_check_byte_request(bs, sector_num * 512, nb_sectors * 512); + return bdrv_check_byte_request(bs, sector_num * BDRV_SECTOR_SIZE, + nb_sectors * BDRV_SECTOR_SIZE); } /* return < 0 if error. See bdrv_write() for the return codes */ @@ -1209,7 +1210,7 @@ struct partition { static int guess_disk_lchs(BlockDriverState *bs, int *pcylinders, int *pheads, int *psectors) { - uint8_t buf[512]; + uint8_t buf[BDRV_SECTOR_SIZE]; int ret, i, heads, sectors, cylinders; struct partition *p; uint32_t nr_sects; @@ -1758,7 +1759,7 @@ static QObject* bdrv_info_stats_bs(BlockDriverState *bs) bs->nr_bytes[BDRV_ACCT_WRITE], bs->nr_ops[BDRV_ACCT_READ], bs->nr_ops[BDRV_ACCT_WRITE], - bs->wr_highest_sector * 512, + bs->wr_highest_sector * (long)BDRV_SECTOR_SIZE, bs->nr_ops[BDRV_ACCT_FLUSH], bs->total_time_ns[BDRV_ACCT_WRITE], bs->total_time_ns[BDRV_ACCT_READ], @@ -2564,7 +2565,7 @@ static int bdrv_read_em(BlockDriverState *bs, int64_t sector_num, async_ret = NOT_DONE; iov.iov_base = (void *)buf; - iov.iov_len = nb_sectors * 512; + iov.iov_len = nb_sectors * BDRV_SECTOR_SIZE; qemu_iovec_init_external(&qiov, &iov, 1); acb = bdrv_aio_readv(bs, sector_num, &qiov, nb_sectors, bdrv_rw_em_cb, &async_ret); @@ -2595,7 +2596,7 @@ static int bdrv_write_em(BlockDriverState *bs, int64_t sector_num, async_ret = NOT_DONE; iov.iov_base = (void *)buf; - iov.iov_len = nb_sectors * 512; + iov.iov_len = nb_sectors * BDRV_SECTOR_SIZE; qemu_iovec_init_external(&qiov, &iov, 1); acb = bdrv_aio_writev(bs, sector_num, &qiov, nb_sectors, bdrv_rw_em_cb, &async_ret); -- 1.7.7.5