From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A909C2B9F4 for ; Fri, 25 Jun 2021 14:42:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DB6AF61965 for ; Fri, 25 Jun 2021 14:42:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB6AF61965 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:35690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lwn22-0006Ga-Uq for qemu-devel@archiver.kernel.org; Fri, 25 Jun 2021 10:42:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60794) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lwmfK-0003LW-QW for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:42 -0400 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]:33714) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lwmfJ-0003F2-84 for qemu-devel@nongnu.org; Fri, 25 Jun 2021 10:18:42 -0400 Received: by mail-ed1-x529.google.com with SMTP id w13so7641048edc.0 for ; Fri, 25 Jun 2021 07:18:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qpjBRyyTP4cjVVNX0Br2C9CiFX8IHvmV4kWlXQxiCsA=; b=jCGCwDW6AqI+9Krkho8arWdBi0a0ZVQaQVi5zJn3yLKOsnLPaYaZKV/10GH1rO5PrW WFDEKv3BLJzmDnQCITlKRWjgadCCSwADF69EV/SNdZcO3t7kN5naLMIKt5gYL42+uCwd mzQJ7PN7kb4jMz6eIIBEsc0zPfcwuoAslbiyvnRi7gKzu2d9so4AAnbszGnt91VTlbue 4ZF668IHm/k46erNkzAORbimRkUYERoiiEhY5jY1JEfbtNslrw/FqrXWmlSQrZ4Kok+/ lJNDtQMZopfdCGZDHMz4UWzP+PCdl+vI9LcP84jZ9kkTsPtJB5hIsf5IHzbtn3aO/yBx KXzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=qpjBRyyTP4cjVVNX0Br2C9CiFX8IHvmV4kWlXQxiCsA=; b=VONhXnxflgqyjudykLYmweRvggG59WnBSWz7kfIphR6h4BH2/3uMHnomtzE51d8Ov3 dxVmsVSNbdW8vOpzeFmZJYTyYpLIxjq4nu1zUbyH6PC2LjvLthfL/B3nj31by5eQfN8P 5LO2HiL7IIxeaOG0Sn7vzRjx0A0oWLCoG5uVHGKEeXe61z/KD8YOLSjC/A8eERK1x8E2 Tu7qJCqlnxyQXQ7LJV+iOmh6VeD5fvluiCS3/Ix/C1Ddvou1p8u1lh+kjpO0KKBG9+8N Q0rMt3dvGh3QmWtmVMDF3EE/vg/9sbYWA4X9wRtEZxOcST/YZztJRtxi6h+wK8IgubDj xnVA== X-Gm-Message-State: AOAM533xP02VjBYlFdh0cqSbISHoXPRdB5dD1Jl0jt2HfJsXhIlJ9+c0 KX+m1wDNg2w2F1T14vYN9ceRlDoYH9s= X-Google-Smtp-Source: ABdhPJy9AWr9bXKKdgKVDoxDOshryv2Y7dxjVQHezoR8e4J7PSyskMi0QOKjHeBecVZX0Mspguct9Q== X-Received: by 2002:a50:bf0f:: with SMTP id f15mr14705436edk.205.1624630719902; Fri, 25 Jun 2021 07:18:39 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id c28sm326579ejc.102.2021.06.25.07.18.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 07:18:39 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 16/28] block-backend: align max_transfer to request alignment Date: Fri, 25 Jun 2021 16:18:10 +0200 Message-Id: <20210625141822.1368639-17-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625141822.1368639-1-pbonzini@redhat.com> References: <20210625141822.1368639-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=paolo.bonzini@gmail.com; helo=mail-ed1-x529.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Block device requests must be aligned to bs->bl.request_alignment. It makes sense for drivers to align bs->bl.max_transfer the same way; however when there is no specified limit, blk_get_max_transfer just returns INT_MAX. Since the contract of the function does not specify that INT_MAX means "no maximum", just align the outcome of the function (whether INT_MAX or bs->bl.max_transfer) before returning it. Signed-off-by: Paolo Bonzini --- block/block-backend.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/block-backend.c b/block/block-backend.c index 15f1ea4288..6e37582740 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1957,12 +1957,12 @@ uint32_t blk_get_request_alignment(BlockBackend *blk) uint32_t blk_get_max_transfer(BlockBackend *blk) { BlockDriverState *bs = blk_bs(blk); - uint32_t max = 0; + uint32_t max = INT_MAX; if (bs) { - max = bs->bl.max_transfer; + max = MIN_NON_ZERO(max, bs->bl.max_transfer); } - return MIN_NON_ZERO(max, INT_MAX); + return ROUND_DOWN(max, blk_get_request_alignment(blk)); } int blk_get_max_iov(BlockBackend *blk) -- 2.31.1