From nobody Wed Feb 11 09:04:10 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1668475728; cv=none; d=zohomail.com; s=zohoarc; b=NdrFalpxZ0erYw0AdbJx9AlO26o6aj8zhH83YlC6WrWfBpE+RT+q3TiUPntzA9kd4+GAt68dCizoKQ/vBgt8c160tJ5tlmKXeytyL7ffcxE8duL+7sHzfSDCMkEpXrFRn9YVuagK0U/vY0Dk4b5/jPIAiAHADdAfrkQLxTov7bw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668475728; 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=5xwarWq7IS97eQgNFs7g0Lw+/taGHjpDs4Ete5qDg2U=; b=oEJeRoPIj7SnRCXfOxJjLEPuBBe0vciToAvPEAoWKJOUgLPo6BWNDp1oSbIlbsQNruPWHGN7eM+2NGMR/kMG1e6tqKFjL4zVGiY0n+gbaEt6cP8e6k5iEWZCByOhDbesmKCq78yw6tt3zZ4Q1/u+gMt5KWXzgc/RRsvchEQUfzY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1668475728353676.8264690815435; Mon, 14 Nov 2022 17:28:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouido-0001lr-HG; Mon, 14 Nov 2022 18:13:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouidl-0001X6-Oh for qemu-devel@nongnu.org; Mon, 14 Nov 2022 18:13:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ouiJP-00036i-E0 for qemu-devel@nongnu.org; Mon, 14 Nov 2022 17:52:30 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-300-RlTzK5bCNRemScTiMHoUDw-1; Mon, 14 Nov 2022 17:52:11 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1216F857D0E; Mon, 14 Nov 2022 22:52:11 +0000 (UTC) Received: from green.redhat.com (unknown [10.2.16.240]) by smtp.corp.redhat.com (Postfix) with ESMTP id A259940E9786; Mon, 14 Nov 2022 22:52:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668466334; 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=5xwarWq7IS97eQgNFs7g0Lw+/taGHjpDs4Ete5qDg2U=; b=QEMnzOSrNnDXTyylgMiWUilA9Tzy1CMsFzogC9U9n2GhlXor0K/yX5/jnn63dv/Zau2HmR h1zTYvFmNHRqMxQ/on9ZTAHrAMvlQqua4DAaR885f/9PytYOxEfElRRVFvc/Bkyfd88o+K rli9FC3mVWglRgY1FfNVOmQ2Wx2p1L0= X-MC-Unique: RlTzK5bCNRemScTiMHoUDw-1 From: Eric Blake To: libguestfs@redhat.com Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, nbd@other.debian.org Subject: [libnbd PATCH v2 16/23] examples: Update copy-libev to use 64-bit block status Date: Mon, 14 Nov 2022 16:51:51 -0600 Message-Id: <20221114225158.2186742-17-eblake@redhat.com> In-Reply-To: <20221114225158.2186742-1-eblake@redhat.com> References: <20221114224141.cm5jgyxfmvie5xb5@redhat.com> <20221114225158.2186742-1-eblake@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=170.10.133.124; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-124.mimecast.com 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1668475729942100008 Content-Type: text/plain; charset="utf-8" Although our use of "base:allocation" doesn't require the use of the 64-bit API for flags, we might perform slightly faster for a server that does give us 64-bit extent lengths and honors larger nbd_zero lengths. --- examples/copy-libev.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/examples/copy-libev.c b/examples/copy-libev.c index 418d99f1..d8b45d87 100644 --- a/examples/copy-libev.c +++ b/examples/copy-libev.c @@ -94,7 +94,7 @@ struct request { }; struct extent { - uint32_t length; + uint64_t length; bool zero; }; @@ -182,7 +182,7 @@ get_events(struct connection *c) static int extent_callback (void *user_data, const char *metacontext, uint64_t offset, - uint32_t *entries, size_t nr_entries, int *error) + nbd_extent *entries, size_t nr_entries, int *error) { struct request *r =3D user_data; @@ -197,22 +197,21 @@ extent_callback (void *user_data, const char *metacon= text, uint64_t offset, return 1; } - /* Libnbd returns uint32_t pair (length, flags) for each extent. */ - extents_len =3D nr_entries / 2; + extents_len =3D nr_entries; extents =3D malloc (extents_len * sizeof *extents); if (extents =3D=3D NULL) FAIL ("Cannot allocated extents: %s", strerror (errno)); /* Copy libnbd entries to extents array. */ - for (int i =3D 0, j =3D 0; i < extents_len; i++, j=3Di*2) { - extents[i].length =3D entries[j]; + for (int i =3D 0; i < extents_len; i++) { + extents[i].length =3D entries[i].length; /* Libnbd exposes both ZERO and HOLE flags. We care only about * ZERO status, meaning we can copy this extent using efficinet * zero method. */ - extents[i].zero =3D (entries[j + 1] & LIBNBD_STATE_ZERO) !=3D 0; + extents[i].zero =3D (entries[i].flags & LIBNBD_STATE_ZERO) !=3D 0; } DEBUG ("r%zu: received %zu extents for %s", @@ -284,10 +283,10 @@ start_extents (struct request *r) DEBUG ("r%zu: start extents offset=3D%" PRIi64 " count=3D%zu", r->index, offset, count); - cookie =3D nbd_aio_block_status ( + cookie =3D nbd_aio_block_status_64 ( src.nbd, count, offset, - (nbd_extent_callback) { .callback=3Dextent_callback, - .user_data=3Dr }, + (nbd_extent64_callback) { .callback=3Dextent_callback, + .user_data=3Dr }, (nbd_completion_callback) { .callback=3Dextents_completed, .user_data=3Dr }, 0); @@ -322,7 +321,7 @@ next_extent (struct request *r) limit =3D MIN (REQUEST_SIZE, size - offset); while (length < limit) { - DEBUG ("e%zu: offset=3D%" PRIi64 " len=3D%" PRIu32 " zero=3D%d", + DEBUG ("e%zu: offset=3D%" PRIi64 " len=3D%" PRIu64 " zero=3D%d", extents_pos, offset, extents[extents_pos].length, is_zero); /* If this extent is too large, steal some data from it to --=20 2.38.1