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.  The
25       NBD protocol does not yet have a way for a client to learn if the
26       server will enforce an even smaller maximum trim size, although a
27       future extension may add a constraint visible in nbd_get_block_size(3).
28
29       The "flags" parameter may be 0 for no flags, or may contain
30       "LIBNBD_CMD_FLAG_FUA" meaning that the server should not return until
31       the data has been committed to permanent storage (if that is supported
32       - some servers cannot do this, see nbd_can_fua(3)).
33
34       By default, libnbd will reject attempts to use this function with
35       parameters that are likely to result in server failure, such as
36       requesting an unknown command flag.  The nbd_set_strict_mode(3)
37       function can be used to alter which scenarios should await a server
38       reply rather than failing fast.
39

RETURN VALUE

41       If the call is successful the function returns 0.
42

ERRORS

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

HANDLE STATE

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

VERSION

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

SEE ALSO

65       nbd_aio_trim(3), nbd_can_fua(3), nbd_can_trim(3), nbd_create(3),
66       nbd_get_block_size(3), nbd_is_read_only(3), nbd_set_strict_mode(3),
67       libnbd(3).
68

AUTHORS

70       Eric Blake
71
72       Richard W.M. Jones
73
75       Copyright Red Hat
76

LICENSE

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