From patchwork Fri Apr 22 23:40:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 8916611 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 070EC9F1C1 for ; Sat, 23 Apr 2016 00:04:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 71A82201C7 for ; Sat, 23 Apr 2016 00:04:56 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 972C2200E9 for ; Sat, 23 Apr 2016 00:04:55 +0000 (UTC) Received: from localhost ([::1]:42032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atl4A-0003QD-UY for patchwork-qemu-devel@patchwork.kernel.org; Fri, 22 Apr 2016 20:04:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atkhs-0004O2-9A for qemu-devel@nongnu.org; Fri, 22 Apr 2016 19:41:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1atkhr-0005fr-A0 for qemu-devel@nongnu.org; Fri, 22 Apr 2016 19:41:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34698) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1atkhn-0005YC-IK; Fri, 22 Apr 2016 19:41:47 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3295C7822B; Fri, 22 Apr 2016 23:41:47 +0000 (UTC) Received: from red.redhat.com (ovpn-113-21.phx2.redhat.com [10.3.113.21]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3MNfHXR028475; Fri, 22 Apr 2016 19:41:46 -0400 From: Eric Blake To: qemu-devel@nongnu.org Date: Fri, 22 Apr 2016 17:40:46 -0600 Message-Id: <1461368452-10389-39-git-send-email-eblake@redhat.com> In-Reply-To: <1461368452-10389-1-git-send-email-eblake@redhat.com> References: <1461368452-10389-1-git-send-email-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 38/44] block: Add blk_get_opt_transfer_length() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , alex@alex.org.uk, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The NBD protocol would like to advertise the optimal I/O size to the client; but it would be a layering violation to peek into blk_bs(blk)->bl, when we only have a BB. I just copied the existing blk_get_max_transfer_length() in reading a value from the top BDS; I have no idea if bdrv_refresh_limits() properly picks a size valid over the entire BDS chain as part of its recursion, but if not, it would be audit of existing code in addition to the new accessor function added here. Signed-off-by: Eric Blake --- include/sysemu/block-backend.h | 1 + block/block-backend.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index bf04086..76b3647 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -145,6 +145,7 @@ void blk_lock_medium(BlockBackend *blk, bool locked); void blk_eject(BlockBackend *blk, bool eject_flag); int blk_get_flags(BlockBackend *blk); int blk_get_max_transfer_length(BlockBackend *blk); +int blk_get_opt_transfer_length(BlockBackend *blk); int blk_get_max_iov(BlockBackend *blk); void blk_set_guest_block_size(BlockBackend *blk, int align); void *blk_try_blockalign(BlockBackend *blk, size_t size); diff --git a/block/block-backend.c b/block/block-backend.c index 1c3b495..e76e61d 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1272,6 +1272,17 @@ int blk_get_max_transfer_length(BlockBackend *blk) } } +int blk_get_opt_transfer_length(BlockBackend *blk) +{ + BlockDriverState *bs = blk_bs(blk); + + if (bs) { + return bs->bl.opt_transfer_length; + } else { + return 0; + } +} + int blk_get_max_iov(BlockBackend *blk) { return blk->root->bs->bl.max_iov;