From patchwork Mon Dec 5 14:20:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 129312 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E7A031007D4 for ; Tue, 6 Dec 2011 02:09:39 +1100 (EST) Received: from localhost ([::1]:56364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXZOQ-0002F4-SM for incoming@patchwork.ozlabs.org; Mon, 05 Dec 2011 09:19:42 -0500 Received: from eggs.gnu.org ([140.186.70.92]:46227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXZNA-00085f-NT for qemu-devel@nongnu.org; Mon, 05 Dec 2011 09:18:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RXZMy-0008QP-Rd for qemu-devel@nongnu.org; Mon, 05 Dec 2011 09:18:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45773) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXZMy-0008QK-I0 for qemu-devel@nongnu.org; Mon, 05 Dec 2011 09:18:12 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pB5EIBcw007954 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 5 Dec 2011 09:18:11 -0500 Received: from dhcp-5-188.str.redhat.com (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pB5EI5as015214; Mon, 5 Dec 2011 09:18:10 -0500 From: Kevin Wolf To: anthony@codemonkey.ws Date: Mon, 5 Dec 2011 15:20:40 +0100 Message-Id: <1323094878-7967-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1323094878-7967-1-git-send-email-kwolf@redhat.com> References: <1323094878-7967-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 03/41] qed: adjust the way to get nb_sectors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Zhi Yong Wu This patch is only to refactor some lines of codes to get better and more robust codes. As you have seen, in qed_read_table_cb() it's nice to use qiov->size because that function doesn't obviously use a single struct iovec. In other two functions, if qiov use more than one struct iovec, the existing way will get wrong nb_sectors. To make the code more robust, it will be nicer to refactor the existing way as below. Signed-off-by: Zhi Yong Wu Acked-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- block/qed-table.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/block/qed-table.c b/block/qed-table.c index f31f9ff..8ee8443 100644 --- a/block/qed-table.c +++ b/block/qed-table.c @@ -29,7 +29,7 @@ static void qed_read_table_cb(void *opaque, int ret) { QEDReadTableCB *read_table_cb = opaque; QEDTable *table = read_table_cb->table; - int noffsets = read_table_cb->iov.iov_len / sizeof(uint64_t); + int noffsets = read_table_cb->qiov.size / sizeof(uint64_t); int i; /* Handle I/O error */ @@ -65,7 +65,7 @@ static void qed_read_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, qemu_iovec_init_external(qiov, &read_table_cb->iov, 1); aiocb = bdrv_aio_readv(s->bs->file, offset / BDRV_SECTOR_SIZE, qiov, - read_table_cb->iov.iov_len / BDRV_SECTOR_SIZE, + qiov->size / BDRV_SECTOR_SIZE, qed_read_table_cb, read_table_cb); if (!aiocb) { qed_read_table_cb(read_table_cb, -EIO); @@ -160,7 +160,7 @@ static void qed_write_table(BDRVQEDState *s, uint64_t offset, QEDTable *table, aiocb = bdrv_aio_writev(s->bs->file, offset / BDRV_SECTOR_SIZE, &write_table_cb->qiov, - write_table_cb->iov.iov_len / BDRV_SECTOR_SIZE, + write_table_cb->qiov.size / BDRV_SECTOR_SIZE, qed_write_table_cb, write_table_cb); if (!aiocb) { qed_write_table_cb(write_table_cb, -EIO);