From patchwork Thu May 27 14:20:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 53765 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4FE94B7D1C for ; Fri, 28 May 2010 00:46:36 +1000 (EST) Received: from localhost ([127.0.0.1]:54627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHeLx-0005BX-4o for incoming@patchwork.ozlabs.org; Thu, 27 May 2010 10:46:33 -0400 Received: from [140.186.70.92] (port=58840 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHdxK-0007uA-RT for qemu-devel@nongnu.org; Thu, 27 May 2010 10:21:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OHdxG-0008PH-DK for qemu-devel@nongnu.org; Thu, 27 May 2010 10:21:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4450) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OHdxG-0008P7-6Z for qemu-devel@nongnu.org; Thu, 27 May 2010 10:21:02 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o4REKteY027523 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 27 May 2010 10:20:55 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o4REKiaM009096; Thu, 27 May 2010 10:20:51 -0400 From: Jes.Sorensen@redhat.com To: anthony@codemonkey.ws Date: Thu, 27 May 2010 16:20:32 +0200 Message-Id: <1274970033-24093-4-git-send-email-Jes.Sorensen@redhat.com> In-Reply-To: <1274970033-24093-1-git-send-email-Jes.Sorensen@redhat.com> References: <1274970033-24093-1-git-send-email-Jes.Sorensen@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Jes Sorensen , qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 3/4] Cleanup: raw-posix.c: Be more consistent using BDRV_SECTOR_SIZE instead of 512 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jes Sorensen Clean up raw-posix.c to be more consistent using BDRV_SECTOR_SIZE instead of hard coded 512 values. Signed-off-by: Jes Sorensen --- block/raw-posix.c | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index 7541ed2..3f0701b 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -392,8 +392,9 @@ static int raw_read(BlockDriverState *bs, int64_t sector_num, { int ret; - ret = raw_pread(bs, sector_num * 512, buf, nb_sectors * 512); - if (ret == (nb_sectors * 512)) + ret = raw_pread(bs, sector_num * BDRV_SECTOR_SIZE, buf, + nb_sectors * BDRV_SECTOR_SIZE); + if (ret == (nb_sectors * BDRV_SECTOR_SIZE)) ret = 0; return ret; } @@ -480,8 +481,9 @@ static int raw_write(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors) { int ret; - ret = raw_pwrite(bs, sector_num * 512, buf, nb_sectors * 512); - if (ret == (nb_sectors * 512)) + ret = raw_pwrite(bs, sector_num * BDRV_SECTOR_SIZE, buf, + nb_sectors * BDRV_SECTOR_SIZE); + if (ret == (nb_sectors * BDRV_SECTOR_SIZE)) ret = 0; return ret; } @@ -494,7 +496,7 @@ static int qiov_is_aligned(QEMUIOVector *qiov) int i; for (i = 0; i < qiov->niov; i++) { - if ((uintptr_t) qiov->iov[i].iov_base % 512) { + if ((uintptr_t) qiov->iov[i].iov_base % BDRV_SECTOR_SIZE) { return 0; } } @@ -703,7 +705,7 @@ static int raw_create(const char *filename, QEMUOptionParameter *options) /* Read out options */ while (options && options->name) { if (!strcmp(options->name, BLOCK_OPT_SIZE)) { - total_size = options->value.n / 512; + total_size = options->value.n / BDRV_SECTOR_SIZE; } options++; } @@ -713,7 +715,7 @@ static int raw_create(const char *filename, QEMUOptionParameter *options) if (fd < 0) { result = -errno; } else { - if (ftruncate(fd, total_size * 512) != 0) { + if (ftruncate(fd, total_size * BDRV_SECTOR_SIZE) != 0) { result = -errno; } if (close(fd) != 0) { @@ -976,7 +978,7 @@ static int hdev_create(const char *filename, QEMUOptionParameter *options) /* Read out options */ while (options && options->name) { if (!strcmp(options->name, "size")) { - total_size = options->value.n / 512; + total_size = options->value.n / BDRV_SECTOR_SIZE; } options++; } @@ -989,7 +991,7 @@ static int hdev_create(const char *filename, QEMUOptionParameter *options) ret = -errno; else if (!S_ISBLK(stat_buf.st_mode) && !S_ISCHR(stat_buf.st_mode)) ret = -ENODEV; - else if (lseek(fd, 0, SEEK_END) < total_size * 512) + else if (lseek(fd, 0, SEEK_END) < total_size * BDRV_SECTOR_SIZE) ret = -ENOSPC; close(fd);