1nbd_block_status_64(3)              LIBNBD              nbd_block_status_64(3)
2
3
4

NAME

6       nbd_block_status_64 - send block status command, with 64-bit callback
7

SYNOPSIS

9        #include <libnbd.h>
10
11        typedef struct {
12          int (*callback) (void *user_data,
13                           const char *metacontext,
14                           uint64_t offset, nbd_extent *entries,
15                           size_t nr_entries, int *error);
16          void *user_data;
17          void (*free) (void *user_data);
18        } nbd_extent64_callback;
19
20        int nbd_block_status_64 (
21              struct nbd_handle *h, uint64_t count,
22              uint64_t offset,
23              nbd_extent64_callback extent64_callback,
24              uint32_t flags
25            );
26

DESCRIPTION

28       Issue the block status command to the NBD server.  If supported by the
29       server, this causes metadata context information about blocks beginning
30       from the specified offset to be returned. The "count" parameter is a
31       hint: the server may choose to return less status, or the final block
32       may extend beyond the requested range. When multiple contexts are
33       supported, the number of blocks and cumulative length of those blocks
34       need not be identical between contexts; this command generally returns
35       the status of all negotiated contexts, while some servers also support
36       a filtered request (see nbd_can_block_status_payload(3),
37       nbd_block_status_filter(3)).
38
39       Note that not all servers can support a "count" of 4GiB or larger;
40       nbd_get_extended_headers_negotiated(3) indicates which servers will
41       parse a request larger than 32 bits.  The NBD protocol does not yet
42       have a way for a client to learn if the server will enforce an even
43       smaller maximum block status size, although a future extension may add
44       a constraint visible in nbd_get_block_size(3).
45
46       Depending on which metadata contexts were enabled before connecting
47       (see nbd_add_meta_context(3)) and which are supported by the server
48       (see nbd_can_meta_context(3)) this call returns information about
49       extents by calling back to the "extent64" function.  The callback
50       cannot call "nbd_*" APIs on the same handle since it holds the handle
51       lock and will cause a deadlock.  If the callback returns -1, and no
52       earlier error has been detected, then the overall block status command
53       will fail with any non-zero value stored into the callback's "error"
54       parameter (with a default of "EPROTO"); but any further contexts will
55       still invoke the callback.
56
57       The "extent64" function is called once per type of metadata available,
58       with the "user_data" passed to this function.  The "metacontext"
59       parameter is a string such as "base:allocation".  The "entries" array
60       is an array of nbd_extent structs, containing length (in bytes) of the
61       block and a status/flags field which is specific to the metadata
62       context.  The number of array entries passed to the function is
63       "nr_entries".  The NBD protocol document in the section about
64       "NBD_REPLY_TYPE_BLOCK_STATUS" describes the meaning of this array; for
65       contexts known to libnbd, <libnbd.h> contains constants beginning with
66       "LIBNBD_STATE_" that may help decipher the values.  On entry to the
67       callback, the "error" parameter contains the errno value of any
68       previously detected error.
69
70       It is possible for the extent function to be called more times than you
71       expect (if the server is buggy), so always check the "metacontext"
72       field to ensure you are receiving the data you expect.  It is also
73       possible that the extent function is not called at all, even for
74       metadata contexts that you requested.  This indicates either that the
75       server doesn't support the context or for some other reason cannot
76       return the data.
77
78       The "flags" parameter may be 0 for no flags, or may contain
79       "LIBNBD_CMD_FLAG_REQ_ONE" meaning that the server should return only
80       one extent per metadata context where that extent does not exceed
81       "count" bytes; however, libnbd does not validate that the server obeyed
82       the flag.
83
84       By default, libnbd will reject attempts to use this function with
85       parameters that are likely to result in server failure, such as
86       requesting an unknown command flag.  The nbd_set_strict_mode(3)
87       function can be used to alter which scenarios should await a server
88       reply rather than failing fast.
89

RETURN VALUE

91       If the call is successful the function returns 0.
92

ERRORS

94       On error -1 is returned.
95
96       Refer to "ERROR HANDLING" in libnbd(3) for how to get further details
97       of the error.
98
99       The following parameters must not be NULL: "h".  For more information
100       see "Non-NULL parameters" in libnbd(3).
101

HANDLE STATE

103       The handle must be connected with the server, otherwise this call will
104       return an error.
105

VERSION

107       This function first appeared in libnbd 1.18.
108
109       If you need to test if this function is available at compile time check
110       if the following macro is defined:
111
112        #define LIBNBD_HAVE_NBD_BLOCK_STATUS_64 1
113

SEE ALSO

115       nbd_add_meta_context(3), nbd_aio_block_status_64(3),
116       nbd_block_status(3), nbd_block_status_filter(3),
117       nbd_can_block_status_payload(3), nbd_can_meta_context(3),
118       nbd_create(3), nbd_get_block_size(3),
119       nbd_get_extended_headers_negotiated(3), nbd_set_strict_mode(3),
120       libnbd(3).
121

AUTHORS

123       Eric Blake
124
125       Richard W.M. Jones
126
128       Copyright Red Hat
129

LICENSE

131       This library is free software; you can redistribute it and/or modify it
132       under the terms of the GNU Lesser General Public License as published
133       by the Free Software Foundation; either version 2 of the License, or
134       (at your option) any later version.
135
136       This library is distributed in the hope that it will be useful, but
137       WITHOUT ANY WARRANTY; without even the implied warranty of
138       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
139       Lesser General Public License for more details.
140
141       You should have received a copy of the GNU Lesser General Public
142       License along with this library; if not, write to the Free Software
143       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
144       02110-1301 USA
145
146
147
148libnbd-1.18.1                     2023-10-31            nbd_block_status_64(3)
Impressum