From patchwork Mon Oct 7 05:59:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 280926 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 150712C00B6 for ; Mon, 7 Oct 2013 17:00:37 +1100 (EST) Received: from localhost ([::1]:57522 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VT3rt-0000pO-Ma for incoming@patchwork.ozlabs.org; Mon, 07 Oct 2013 02:00:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VT3rU-0000pI-Ke for qemu-devel@nongnu.org; Mon, 07 Oct 2013 02:00:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VT3rK-0005oU-A5 for qemu-devel@nongnu.org; Mon, 07 Oct 2013 02:00:08 -0400 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:34339 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VT3rJ-0005nx-Vb for qemu-devel@nongnu.org; Mon, 07 Oct 2013 01:59:58 -0400 Received: (qmail 14967 invoked by uid 89); 7 Oct 2013 05:59:54 -0000 Received: from [82.141.1.145] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2010/03/19-MF (clamdscan: 0.98/17945. hbedv: 8.2.12.126/7.11.106.18. spamassassin: 3.3.1. Clear:RC:1(82.141.1.145):SA:0(-1.2/5.0):. Processed in 1.157689 secs); 07 Oct 2013 05:59:54 -0000 Received: from ns.kamp-intra.net (HELO dns.kamp-intra.net) ([82.141.1.145]) by mx01.kamp.de with SMTP; 7 Oct 2013 05:59:53 -0000 X-GL_Whitelist: yes Received: from lieven-pc.kamp-intra.net (lieven-pc.kamp-intra.net [172.21.12.60]) by dns.kamp-intra.net (Postfix) with ESMTP id 78DE620688; Mon, 7 Oct 2013 07:58:53 +0200 (CEST) Received: by lieven-pc.kamp-intra.net (Postfix, from userid 1000) id CC79D5FE33; Mon, 7 Oct 2013 07:59:12 +0200 (CEST) From: Peter Lieven To: qemu-devel@nongnu.org Date: Mon, 7 Oct 2013 07:59:11 +0200 Message-Id: <1381125551-24354-1-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.7.9.5 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a02:248:0:51::16 Cc: kwolf@redhat.com, ronniesahlberg@gmail.com, Peter Lieven , stefanha@redhat.com, anthony@codemonkey.ws, pbonzini@redhat.com Subject: [Qemu-devel] [PATCHv5] block/get_block_status: avoid redundant callouts on raw devices 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 if a raw device like an iscsi target or host device is used the current implementation makes a second call out to get the block status of bs->file. Signed-off-by: Peter Lieven --- v5: add a generic get_lba_status function in the raw driver which adds the BDRV_BLOCK_RAW flag. bdrv_co_get_block_status will handle the callout to bs->file then. v4: use a flag to detect the raw driver instead of the strncmp hack block.c | 4 ++++ block/raw_bsd.c | 3 ++- include/block/block.h | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 93e113a..38a589e 100644 --- a/block.c +++ b/block.c @@ -3147,6 +3147,10 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, return ret; } + if (ret & BDRV_BLOCK_RAW) { + return bdrv_get_block_status(bs->file, sector_num, nb_sectors, pnum); + } + if (!(ret & BDRV_BLOCK_DATA)) { if (bdrv_has_zero_init(bs)) { ret |= BDRV_BLOCK_ZERO; diff --git a/block/raw_bsd.c b/block/raw_bsd.c index d4ace60..308d605 100644 --- a/block/raw_bsd.c +++ b/block/raw_bsd.c @@ -62,7 +62,8 @@ static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { - return bdrv_get_block_status(bs->file, sector_num, nb_sectors, pnum); + return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID | + (sector_num << BDRV_SECTOR_BITS); } static int coroutine_fn raw_co_write_zeroes(BlockDriverState *bs, diff --git a/include/block/block.h b/include/block/block.h index f808550..003699e 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -84,6 +84,9 @@ typedef struct BlockDevOps { /* BDRV_BLOCK_DATA: data is read from bs->file or another file * BDRV_BLOCK_ZERO: sectors read as zero * BDRV_BLOCK_OFFSET_VALID: sector stored in bs->file as raw data + * BDRV_BLOCK_RAW: used internally to indicate that the request + * was answered by the raw driver and that one + * should look in bs->file directly. * * If BDRV_BLOCK_OFFSET_VALID is set, bits 9-62 represent the offset in * bs->file where sector data can be read from as raw data. @@ -105,6 +108,7 @@ typedef struct BlockDevOps { #define BDRV_BLOCK_DATA 1 #define BDRV_BLOCK_ZERO 2 #define BDRV_BLOCK_OFFSET_VALID 4 +#define BDRV_BLOCK_RAW 8 #define BDRV_BLOCK_OFFSET_MASK BDRV_SECTOR_MASK typedef enum {