From nobody Sat Feb 7 09:46:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487645163086902.1482835329148; Mon, 20 Feb 2017 18:46:03 -0800 (PST) Received: from localhost ([::1]:41896 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cg0Sn-0007GC-Ok for importer@patchew.org; Mon, 20 Feb 2017 21:46:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cg0Q0-0005Xp-0x for qemu-devel@nongnu.org; Mon, 20 Feb 2017 21:43:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cg0Pz-0003VU-4W for qemu-devel@nongnu.org; Mon, 20 Feb 2017 21:43:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41778) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cg0Pt-0003Qa-46; Mon, 20 Feb 2017 21:43:01 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 33728C054C59; Tue, 21 Feb 2017 02:43:01 +0000 (UTC) Received: from red.redhat.com (ovpn-123-67.rdu2.redhat.com [10.10.123.67] (may be forged)) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1L2gnuC023090; Mon, 20 Feb 2017 21:42:59 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Mon, 20 Feb 2017 20:42:43 -0600 Message-Id: <20170221024248.11027-4-eblake@redhat.com> In-Reply-To: <20170221024248.11027-1-eblake@redhat.com> References: <20170221024248.11027-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 21 Feb 2017 02:43:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 3/8] block: Add blk_get_opt_transfer() 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 , vsementsov@virtuozzo.com, den@virtuozzo.com, qemu-block@nongnu.org, Max Reitz , pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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. This copies the existing blk_get_max_transfer() in reading a value from the top BDS; where that value was picked via bdrv_refresh_limits() to reflect the overall constraints of the entire BDS chain. Signed-off-by: Eric Blake Reviewed-by: Marc-Andr=C3=A9 Lureau --- v4: retitle, as part of rebasing to byte limits v3: new patch --- include/sysemu/block-backend.h | 1 + block/block-backend.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 6444e41..882480a 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -174,6 +174,7 @@ void blk_lock_medium(BlockBackend *blk, bool locked); void blk_eject(BlockBackend *blk, bool eject_flag); int blk_get_flags(BlockBackend *blk); uint32_t blk_get_max_transfer(BlockBackend *blk); +uint32_t blk_get_opt_transfer(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 efbf398..4d91ff8 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1426,6 +1426,18 @@ uint32_t blk_get_max_transfer(BlockBackend *blk) return MIN_NON_ZERO(max, INT_MAX); } +/* Returns the optimum transfer length, in bytes; may be 0 if no optimum */ +uint32_t blk_get_opt_transfer(BlockBackend *blk) +{ + BlockDriverState *bs =3D blk_bs(blk); + + if (bs) { + return bs->bl.opt_transfer; + } else { + return 0; + } +} + int blk_get_max_iov(BlockBackend *blk) { return blk->root->bs->bl.max_iov; --=20 2.9.3