From patchwork Fri Jun 4 16:32:51 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 54659 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 95B1AB7D2E for ; Sat, 5 Jun 2010 04:20:38 +1000 (EST) Received: from localhost ([127.0.0.1]:53505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKb0f-0007Wy-9W for incoming@patchwork.ozlabs.org; Fri, 04 Jun 2010 13:48:45 -0400 Received: from [140.186.70.92] (port=45252 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKZtr-00086L-AZ for qemu-devel@nongnu.org; Fri, 04 Jun 2010 12:37:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OKZtp-0002q7-KE for qemu-devel@nongnu.org; Fri, 04 Jun 2010 12:37:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38168) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKZtp-0002pt-DL for qemu-devel@nongnu.org; Fri, 04 Jun 2010 12:37:37 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o54GbIuX026701 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 4 Jun 2010 12:37:23 -0400 Received: from localhost.localdomain (vpn2-9-144.ams2.redhat.com [10.36.9.144]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o54GXWSk032074; Fri, 4 Jun 2010 12:34:08 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Fri, 4 Jun 2010 18:32:51 +0200 Message-Id: <1275669195-28312-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1275669195-28312-1-git-send-email-kwolf@redhat.com> References: <1275669195-28312-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 03/27] 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 Signed-off-by: Kevin Wolf --- 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);