1nbd_trim(3)                         LIBNBD                         nbd_trim(3)
2
3
4

NAME

6       nbd_trim - send trim command to the NBD server
7

SYNOPSIS

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

DESCRIPTION

17       Issue a trim command to the NBD server, which if supported by the
18       server causes a hole to be punched in the backing store 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_trim(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 trim size, although a future extension may add a
29       constraint visible in nbd_get_block_size(3).
30
31       The "flags" parameter may be 0 for no flags, or may contain
32       "LIBNBD_CMD_FLAG_FUA" meaning that the server should not return until
33       the data has been committed to permanent storage (if that is supported
34       - some servers cannot do this, see nbd_can_fua(3)).
35
36       By default, libnbd will reject attempts to use this function with
37       parameters that are likely to result in server failure, such as
38       requesting an unknown command flag.  The nbd_set_strict_mode(3)
39       function can be used to alter which scenarios should await a server
40       reply rather than failing fast.
41

RETURN VALUE

43       If the call is successful the function returns 0.
44

ERRORS

46       On error -1 is returned.
47
48       Refer to "ERROR HANDLING" in libnbd(3) for how to get further details
49       of the error.
50
51       The following parameters must not be NULL: "h".  For more information
52       see "Non-NULL parameters" in libnbd(3).
53

HANDLE STATE

55       The handle must be connected with the server, otherwise this call will
56       return an error.
57

VERSION

59       This function first appeared in libnbd 1.0.
60
61       If you need to test if this function is available at compile time check
62       if the following macro is defined:
63
64        #define LIBNBD_HAVE_NBD_TRIM 1
65

SEE ALSO

67       nbd_aio_trim(3), nbd_can_fua(3), nbd_can_trim(3), nbd_create(3),
68       nbd_get_block_size(3), nbd_get_extended_headers_negotiated(3),
69       nbd_is_read_only(3), nbd_set_strict_mode(3), libnbd(3).
70

AUTHORS

72       Eric Blake
73
74       Richard W.M. Jones
75
77       Copyright Red Hat
78

LICENSE

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