1nbd_zero(3)                         LIBNBD                         nbd_zero(3)
2
3
4

NAME

6       nbd_zero - send write zeroes command to the NBD server
7

SYNOPSIS

9        #include <libnbd.h>
10
11        int nbd_zero (
12              struct nbd_handle *h, uint64_t count,
13              uint64_t offset, uint32_t flags
14            );
15

DESCRIPTION

17       Issue a write zeroes command to the NBD server, which if supported by
18       the server causes a zeroes to be written efficiently starting at
19       "offset" and ending at "offset" + "count" - 1.  The call returns when
20       the command has been acknowledged by the server, or there is an error.
21       Note this will generally return an error if nbd_can_zero(3) is false or
22       nbd_is_read_only(3) is true.
23
24       Note that not all servers can support a "count" of 4GiB or larger;
25       nbd_get_extended_headers_negotiated(3) indicates which servers will
26       parse a request larger than 32 bits.  The NBD protocol does not yet
27       have a way for a client to learn if the server will enforce an even
28       smaller maximum zero size, although a future extension may add a
29       constraint visible in nbd_get_block_size(3).  Also, some servers may
30       permit a larger zero request only when the "LIBNBD_CMD_FLAG_FAST_ZERO"
31       is in use.
32
33       The "flags" parameter may be 0 for no flags, or may contain
34       "LIBNBD_CMD_FLAG_FUA" meaning that the server should not return until
35       the data has been committed to permanent storage (if that is supported
36       - some servers cannot do this, see nbd_can_fua(3)),
37       "LIBNBD_CMD_FLAG_NO_HOLE" meaning that the server should favor writing
38       actual allocated zeroes over punching a hole, and/or
39       "LIBNBD_CMD_FLAG_FAST_ZERO" meaning that the server must fail quickly
40       if writing zeroes is no faster than a normal write (if that is
41       supported - some servers cannot do this, see nbd_can_fast_zero(3)).
42
43       By default, libnbd will reject attempts to use this function with
44       parameters that are likely to result in server failure, such as
45       requesting an unknown command flag.  The nbd_set_strict_mode(3)
46       function can be used to alter which scenarios should await a server
47       reply rather than failing fast.
48

RETURN VALUE

50       If the call is successful the function returns 0.
51

ERRORS

53       On error -1 is returned.
54
55       Refer to "ERROR HANDLING" in libnbd(3) for how to get further details
56       of the error.
57
58       The following parameters must not be NULL: "h".  For more information
59       see "Non-NULL parameters" in libnbd(3).
60

HANDLE STATE

62       The handle must be connected with the server, otherwise this call will
63       return an error.
64

VERSION

66       This function first appeared in libnbd 1.0.
67
68       If you need to test if this function is available at compile time check
69       if the following macro is defined:
70
71        #define LIBNBD_HAVE_NBD_ZERO 1
72

SEE ALSO

74       nbd_aio_zero(3), nbd_can_fast_zero(3), nbd_can_fua(3), nbd_can_zero(3),
75       nbd_create(3), nbd_get_block_size(3),
76       nbd_get_extended_headers_negotiated(3), nbd_is_read_only(3),
77       nbd_set_strict_mode(3), libnbd(3).
78

AUTHORS

80       Eric Blake
81
82       Richard W.M. Jones
83
85       Copyright Red Hat
86

LICENSE

88       This library is free software; you can redistribute it and/or modify it
89       under the terms of the GNU Lesser General Public License as published
90       by the Free Software Foundation; either version 2 of the License, or
91       (at your option) any later version.
92
93       This library is distributed in the hope that it will be useful, but
94       WITHOUT ANY WARRANTY; without even the implied warranty of
95       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
96       Lesser General Public License for more details.
97
98       You should have received a copy of the GNU Lesser General Public
99       License along with this library; if not, write to the Free Software
100       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
101       02110-1301 USA
102
103
104
105libnbd-1.18.1                     2023-10-31                       nbd_zero(3)
Impressum