From patchwork Mon Jul 15 10:49:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 258995 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 2656C2C00E7 for ; Mon, 15 Jul 2013 20:52:38 +1000 (EST) Received: from localhost ([::1]:57099 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UygOR-0006HA-Sq for incoming@patchwork.ozlabs.org; Mon, 15 Jul 2013 06:52:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UygMZ-0003aP-OD for qemu-devel@nongnu.org; Mon, 15 Jul 2013 06:50:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UygMV-0002DR-0b for qemu-devel@nongnu.org; Mon, 15 Jul 2013 06:50:39 -0400 Received: from mx.ipv6.kamp.de ([2a02:248:0:51::16]:48670 helo=mx01.kamp.de) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1UygMU-0002D3-M0 for qemu-devel@nongnu.org; Mon, 15 Jul 2013 06:50:34 -0400 Received: (qmail 21514 invoked by uid 89); 15 Jul 2013 10:50:33 -0000 Received: from [82.141.1.145] by client-16-kamp (envelope-from , uid 89) with qmail-scanner-2.01 (clamdscan: 0.97.8/17510. hbedv: 8.2.12.78/7.11.90.136. spamassassin: 3.3.1. Clear:RC:1(82.141.1.145):SA:0(-1.2/5.0):. Processed in 10.327398 secs); 15 Jul 2013 10:50:33 -0000 Received: from ns.kamp-intra.net (HELO dns.kamp-intra.net) ([82.141.1.145]) by mx01.kamp.de with SMTP; 15 Jul 2013 10:50:23 -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 14D9D206A6; Mon, 15 Jul 2013 12:49:43 +0200 (CEST) Received: by lieven-pc.kamp-intra.net (Postfix, from userid 1000) id 509B35FA15; Mon, 15 Jul 2013 12:49:43 +0200 (CEST) From: Peter Lieven To: qemu-devel@nongnu.org Date: Mon, 15 Jul 2013 12:49:33 +0200 Message-Id: <1373885375-13601-3-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1373885375-13601-1-git-send-email-pl@kamp.de> References: <1373885375-13601-1-git-send-email-pl@kamp.de> 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, pbonzini@redhat.com, Peter Lieven , ronniesahlberg@gmail.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH 2/4] iscsi: add .bdrv_get_info 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 this is used to reveal max_unmap and discard_zeroes capabilities. Signed-off-by: Peter Lieven --- block/iscsi.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index 2b8fab9..74a35b9 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -927,6 +927,11 @@ retry: return 0; } +static bool iscsi_discard_zeroes(IscsiLun *iscsilun) +{ + return iscsilun->lbprz && iscsilun->lbpu; +} + static int coroutine_fn iscsi_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, int nb_sectors) @@ -937,8 +942,7 @@ coroutine_fn iscsi_co_write_zeroes(BlockDriverState *bs, int64_t sector_num, return -EINVAL; } - if (!iscsilun->lbprz || !iscsilun->lbpu || - !(bs->open_flags & BDRV_O_UNMAP)) { + if (!iscsi_discard_zeroes(iscsilun) || !(bs->open_flags & BDRV_O_UNMAP)) { /* fall back to writev */ return -ENOTSUP; } @@ -1468,6 +1472,16 @@ out: return ret; } +static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) +{ + IscsiLun *iscsilun = bs->opaque; + + bdi->max_unmap = sector_lun2qemu(iscsilun->max_unmap, iscsilun); + bdi->discard_zeroes = iscsi_discard_zeroes(iscsilun); + + return 0; +} + static QEMUOptionParameter iscsi_create_options[] = { { .name = BLOCK_OPT_SIZE, @@ -1488,6 +1502,7 @@ static BlockDriver bdrv_iscsi = { .create_options = iscsi_create_options, .bdrv_getlength = iscsi_getlength, + .bdrv_get_info = iscsi_get_info, .bdrv_truncate = iscsi_truncate, .bdrv_co_is_allocated = iscsi_co_is_allocated,