From nobody Wed May 8 18:57:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=1557501783; cv=none; d=zoho.com; s=zohoarc; b=lbAPi3AmlEmZBO5vCVd4lM0Qh2vY8booFf+CHY4Bq0MML5NTmsLgVz48NoAbo5WrEoXkkZEyaJ/BefEcxZKCK1phhvaqyjnPGyYCQIaW2+Y3yPVbBUbToEhJt+W51dBnyQpT8fIcgj4bAapjgeI+mwekkP3OTjcfl9u09FRRhe4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557501783; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=YkbfSkHtVoe7fk7aG2Qb1/vr4Tfh0BASRutg4CubJQ8=; b=m3xRsmZw7v6ljO2eK+xBL71h4+j4w1ZR8tzI5rzmcBeDSY5OOCfZoUeri+qUizc/qExmP4ZgKQG1KzLVLpT6dJqHwP+dvMlmwMbFPDy3dpraP4hKxH3uQMRABPt44IaCaRFxibjZ1fV5Tl52u3ryRqL1RsboUKyCLdBMMkUTf4E= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1557501783888154.9756166194087; Fri, 10 May 2019 08:23:03 -0700 (PDT) Received: from localhost ([127.0.0.1]:45001 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP7MS-0001Oc-SH for importer@patchew.org; Fri, 10 May 2019 11:23:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hP7HK-00062k-4M for qemu-devel@nongnu.org; Fri, 10 May 2019 11:17:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hP7HJ-0006LD-3l for qemu-devel@nongnu.org; Fri, 10 May 2019 11:17:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45596) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hP7HG-0006Ik-Tc; Fri, 10 May 2019 11:17:39 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 40B5180F6D; Fri, 10 May 2019 15:17:38 +0000 (UTC) Received: from blue.redhat.com (ovpn-116-15.phx2.redhat.com [10.3.116.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id A19051001E86; Fri, 10 May 2019 15:17:37 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Fri, 10 May 2019 10:17:35 -0500 Message-Id: <20190510151735.29687-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 10 May 2019 15:17:38 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] nbd/server: Nicer spelling of max BLOCK_STATUS reply 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: vsementsov@virtuozzo.com, "open list:Network Block Dev..." Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Commit 3d068aff (3.0) introduced NBD_MAX_BITMAP_EXTENTS as a limit on how large we would allow a reply to NBD_CMD_BLOCK_STATUS to grow when it is visiting a qemu:dirty-bitmap: context. Later, commit fb7afc79 (3.1) reused the constant to limit base:allocation context replies, although the name is now less appropriate in that situation. Rename things, and improve the macro to use units.h for better legibility. Then reformat the comment to comply with checkpatch rules added in the meantime. No semantic change. Signed-off-by: Eric Blake Reviewed-by: Stefano Garzarella --- nbd/server.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nbd/server.c b/nbd/server.c index e21bd501dc6..2c49744fc43 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -21,15 +21,18 @@ #include "qapi/error.h" #include "trace.h" #include "nbd-internal.h" +#include "qemu/units.h" #define NBD_META_ID_BASE_ALLOCATION 0 #define NBD_META_ID_DIRTY_BITMAP 1 -/* NBD_MAX_BITMAP_EXTENTS: 1 mb of extents data. An empirical +/* + * NBD_MAX_BLOCK_STATUS_EXTENTS: 1 mb of extents data. An empirical * constant. If an increase is needed, note that the NBD protocol * recommends no larger than 32 mb, so that the client won't consider - * the reply as a denial of service attack. */ -#define NBD_MAX_BITMAP_EXTENTS (0x100000 / 8) + * the reply as a denial of service attack. + */ +#define NBD_MAX_BLOCK_STATUS_EXTENTS (1 * MiB / 8) static int system_errno_to_nbd_errno(int err) { @@ -1958,7 +1961,7 @@ static int nbd_co_send_block_status(NBDClient *client= , uint64_t handle, Error **errp) { int ret; - unsigned int nb_extents =3D dont_fragment ? 1 : NBD_MAX_BITMAP_EXTENTS; + unsigned int nb_extents =3D dont_fragment ? 1 : NBD_MAX_BLOCK_STATUS_E= XTENTS; NBDExtent *extents =3D g_new(NBDExtent, nb_extents); uint64_t final_length =3D length; @@ -2043,7 +2046,7 @@ static int nbd_co_send_bitmap(NBDClient *client, uint= 64_t handle, uint32_t context_id, Error **errp) { int ret; - unsigned int nb_extents =3D dont_fragment ? 1 : NBD_MAX_BITMAP_EXTENTS; + unsigned int nb_extents =3D dont_fragment ? 1 : NBD_MAX_BLOCK_STATUS_E= XTENTS; NBDExtent *extents =3D g_new(NBDExtent, nb_extents); uint64_t final_length =3D length; --=20 2.20.1