From nobody Mon Feb 9 08:11:24 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604511382; cv=none; d=zohomail.com; s=zohoarc; b=LnvlJ27DiFqBHIdVNe+GTXHYxBQs3xoupXlbg+2BRpPTRY/MjZOlwdrT/q8Q8zQXvmyz3DNByrqbu9pCIzwAu3rQGA+w879R495pOmrjORwsf6syrLKaACuQGr16he7sbURa5rcExPIqFWX8bLmv9e8kUOFD1LXGdiLUXxsHQ7A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604511382; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2xSuC77k3yq5Xr0fSz+OMThLjn2jI/KvI5V3T68Sb1k=; b=R+Lh9MBkFJ60zJ+lY3XLYTIEH43VkTznxcWLdvjseKh8vsg8gXyFytpTFrSi6amDw40Kn5HSuJvi2rHGMGa5+RIxjzMrTBp7fNhI2ZBKHaLyHsUpuY8FyVq1tX1AhEUb9LE9tg1QDVl2i/A1Xf5k3GmpBawBaxcHaeK3MTvJncQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604511382681498.46878303893334; Wed, 4 Nov 2020 09:36:22 -0800 (PST) Received: from localhost ([::1]:52640 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaMhp-00070H-IJ for importer@patchew.org; Wed, 04 Nov 2020 12:36:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34476) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaMeK-0002qs-DU for qemu-devel@nongnu.org; Wed, 04 Nov 2020 12:32:45 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:47467) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kaMeG-0000eT-Vo for qemu-devel@nongnu.org; Wed, 04 Nov 2020 12:32:44 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-456-2a84hTLmPgmk9RixxarJjw-1; Wed, 04 Nov 2020 12:32:38 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1C4361009E23; Wed, 4 Nov 2020 17:32:37 +0000 (UTC) Received: from localhost.localdomain (unknown [10.35.207.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38FCA6266E; Wed, 4 Nov 2020 17:32:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604511160; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2xSuC77k3yq5Xr0fSz+OMThLjn2jI/KvI5V3T68Sb1k=; b=N97TZwD0fpP4j14eFoPlot2Twkm8jAZJD9MHkwxi65dBK9Ewblq+JTl84EHPA6Gsvcf8uH TvKQXgpwVwIkMOtZJGEjSTFc7pSWRZwm+Bxhr0OIRZ8z0szkviNo81A9ndyxyxkSwXoItp eYYZzTE5tOL5ldClzaeHbPfuEcV+f3I= X-MC-Unique: 2a84hTLmPgmk9RixxarJjw-1 From: Maxim Levitsky To: qemu-devel@nongnu.org Subject: [PATCH 3/5] block: add max_ioctl_transfer to BlockLimits Date: Wed, 4 Nov 2020 19:32:15 +0200 Message-Id: <20201104173217.417538-4-mlevitsk@redhat.com> In-Reply-To: <20201104173217.417538-1-mlevitsk@redhat.com> References: <20201104173217.417538-1-mlevitsk@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mlevitsk@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=mlevitsk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/03 22:09:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , Stefan Hajnoczi , qemu-block@nongnu.org, Peter Lieven , Tom Yan , Ronnie Sahlberg , Paolo Bonzini , Maxim Levitsky , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Maximum transfer size when accessing a kernel block device is only relevant when using SCSI passthrough (SG_IO ioctl) since only in this case the reque= sts are passed directly to underlying hardware with no pre-processing. Same is true when using /dev/sg* character devices (which only support SG_I= O) Therefore split the block driver's advertized max transfer size by the regular max transfer size, and the max transfer size for SCSI passthrou= gh (the new max_ioctl_transfer field) In the next patch, the qemu block drivers that support SCSI passthrough will set the max_ioctl_transfer field, and simultaneously, the block devices that implement scsi passthrough will switch to 'blk_get_max_ioctl_transfer'= to query and to pass it to the guest. Signed-off-by: Maxim Levitsky --- block/block-backend.c | 12 ++++++++++++ block/io.c | 2 ++ include/block/block_int.h | 4 ++++ include/sysemu/block-backend.h | 1 + 4 files changed, 19 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index ce78d30794..c1d149a755 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1938,6 +1938,18 @@ uint32_t blk_get_max_transfer(BlockBackend *blk) return MIN_NON_ZERO(max, INT_MAX); } =20 +/* Returns the maximum transfer length, for SCSI passthrough */ +uint32_t blk_get_max_ioctl_transfer(BlockBackend *blk) +{ + BlockDriverState *bs =3D blk_bs(blk); + uint32_t max =3D 0; + + if (bs) { + max =3D bs->bl.max_ioctl_transfer; + } + return MIN_NON_ZERO(max, INT_MAX); +} + int blk_get_max_iov(BlockBackend *blk) { return blk->root->bs->bl.max_iov; diff --git a/block/io.c b/block/io.c index ec5e152bb7..3eae176992 100644 --- a/block/io.c +++ b/block/io.c @@ -126,6 +126,8 @@ static void bdrv_merge_limits(BlockLimits *dst, const B= lockLimits *src) { dst->opt_transfer =3D MAX(dst->opt_transfer, src->opt_transfer); dst->max_transfer =3D MIN_NON_ZERO(dst->max_transfer, src->max_transfe= r); + dst->max_ioctl_transfer =3D MIN_NON_ZERO(dst->max_ioctl_transfer, + src->max_ioctl_transfer); dst->opt_mem_alignment =3D MAX(dst->opt_mem_alignment, src->opt_mem_alignment); dst->min_mem_alignment =3D MAX(dst->min_mem_alignment, diff --git a/include/block/block_int.h b/include/block/block_int.h index 38cad9d15c..b198165114 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -678,6 +678,10 @@ typedef struct BlockLimits { * clamped down. */ uint32_t max_transfer; =20 + /* Maximal transfer length for SCSI passthrough (ioctl interface) */ + uint32_t max_ioctl_transfer; + + /* memory alignment, in bytes so that no bounce buffer is needed */ size_t min_mem_alignment; =20 diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 8203d7f6f9..b019a37b7a 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -203,6 +203,7 @@ void blk_eject(BlockBackend *blk, bool eject_flag); int blk_get_flags(BlockBackend *blk); uint32_t blk_get_request_alignment(BlockBackend *blk); uint32_t blk_get_max_transfer(BlockBackend *blk); +uint32_t blk_get_max_ioctl_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); --=20 2.26.2