[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libnbd PATCH v3 13/22] dump: Update nbddump to use 64-bit block status
From: |
Eric Blake |
Subject: |
[libnbd PATCH v3 13/22] dump: Update nbddump to use 64-bit block status |
Date: |
Thu, 25 May 2023 08:00:59 -0500 |
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.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
dump/dump.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/dump/dump.c b/dump/dump.c
index b4aebe84..71053277 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -38,7 +38,7 @@
#include "version.h"
#include "vector.h"
-DEFINE_VECTOR_TYPE (uint32_vector, uint32_t);
+DEFINE_VECTOR_TYPE (uint64_vector, uint64_t);
static const char *progname;
static struct nbd_handle *nbd;
@@ -262,10 +262,10 @@ catch_signal (int sig)
static int
extent_callback (void *user_data, const char *metacontext,
uint64_t offset,
- uint32_t *entries, size_t nr_entries,
+ nbd_extent *entries, size_t nr_entries,
int *error)
{
- uint32_vector *list = user_data;
+ uint64_vector *list = user_data;
size_t i;
if (strcmp (metacontext, LIBNBD_CONTEXT_BASE_ALLOCATION) != 0)
@@ -273,7 +273,8 @@ extent_callback (void *user_data, const char *metacontext,
/* Just append the entries we got to the list. */
for (i = 0; i < nr_entries; ++i) {
- if (uint32_vector_append (list, entries[i]) == -1) {
+ if (uint64_vector_append (list, entries[i].length) == -1 ||
+ uint64_vector_append (list, entries[i].flags) == -1) {
perror ("realloc");
exit (EXIT_FAILURE);
}
@@ -284,7 +285,7 @@ extent_callback (void *user_data, const char *metacontext,
static bool
test_all_zeroes (uint64_t offset, size_t count)
{
- uint32_vector entries = empty_vector;
+ uint64_vector entries = empty_vector;
size_t i;
uint64_t count_read;
@@ -296,22 +297,22 @@ test_all_zeroes (uint64_t offset, size_t count)
* false, causing the main code to do a full read. We could be
* smarter and keep asking the server (XXX).
*/
- if (nbd_block_status (nbd, count, offset,
- (nbd_extent_callback) {
- .callback = extent_callback,
- .user_data = &entries },
- 0) == -1) {
+ if (nbd_block_status_64 (nbd, count, offset,
+ (nbd_extent64_callback) {
+ .callback = extent_callback,
+ .user_data = &entries },
+ 0) == -1) {
fprintf (stderr, "%s: %s\n", progname, nbd_get_error ());
exit (EXIT_FAILURE);
}
count_read = 0;
for (i = 0; i < entries.len; i += 2) {
- uint32_t len = entries.ptr[i];
- uint32_t type = entries.ptr[i+1];
+ uint64_t len = entries.ptr[i];
+ uint64_t type = entries.ptr[i+1];
count_read += len;
- if (!(type & 2)) /* not zero */
+ if (!(type & LIBNBD_STATE_ZERO)) /* not zero */
return false;
}
--
2.40.1
- [libnbd PATCH v3 12/22] copy: Update nbdcopy to use 64-bit block status, (continued)
- [libnbd PATCH v3 12/22] copy: Update nbdcopy to use 64-bit block status, Eric Blake, 2023/05/25
- [libnbd PATCH v3 03/22] protocol: Add definitions for extended headers, Eric Blake, 2023/05/25
- [libnbd PATCH v3 04/22] states: Prepare to send 64-bit requests, Eric Blake, 2023/05/25
- [libnbd PATCH v3 22/22] api: Add nbd_[aio_]block_status_filter(), Eric Blake, 2023/05/25
- [libnbd PATCH v3 11/22] api: Add several functions for controlling extended headers, Eric Blake, 2023/05/25
- [libnbd PATCH v3 20/22] interop: Add test of 64-bit block status, Eric Blake, 2023/05/25
- [libnbd PATCH v3 08/22] block_status: Track 64-bit extents internally, Eric Blake, 2023/05/25
- [libnbd PATCH v3 17/22] ocaml: Add example for 64-bit extents, Eric Blake, 2023/05/25
- [libnbd PATCH v3 15/22] info: Update nbdinfo --map to use 64-bit block status, Eric Blake, 2023/05/25
- [libnbd PATCH v3 07/22] generator: Add struct nbd_extent in prep for 64-bit extents, Eric Blake, 2023/05/25
- [libnbd PATCH v3 13/22] dump: Update nbddump to use 64-bit block status,
Eric Blake <=
- [libnbd PATCH v3 01/22] block_status: Refactor array storage, Eric Blake, 2023/05/25
- [libnbd PATCH v3 16/22] examples: Update copy-libev to use 64-bit block status, Eric Blake, 2023/05/25
- [libnbd PATCH v3 06/22] states: Break deadlock if server goofs on extended replies, Eric Blake, 2023/05/25
- [libnbd PATCH v3 10/22] api: Add [aio_]nbd_block_status_64, Eric Blake, 2023/05/25
- [libnbd PATCH v3 02/22] internal: Refactor layout of replies in sbuf, Eric Blake, 2023/05/25