1nbd_trim(3) LIBNBD nbd_trim(3)
2
3
4
6 nbd_trim - send trim command to the NBD server
7
9 #include <libnbd.h>
10
11 int nbd_trim (struct nbd_handle *h, uint64_t count,
12 uint64_t offset, uint32_t flags);
13
15 Issue a trim command to the NBD server, which if supported by the
16 server causes a hole to be punched in the backing store starting at
17 "offset" and ending at "offset" + "count" - 1. The call returns when
18 the command has been acknowledged by the server, or there is an error.
19 Note this will generally return an error if nbd_can_trim(3) is false or
20 nbd_is_read_only(3) is true.
21
22 The "flags" parameter may be 0 for no flags, or may contain
23 "LIBNBD_CMD_FLAG_FUA" meaning that the server should not return until
24 the data has been committed to permanent storage (if that is supported
25 - some servers cannot do this, see nbd_can_fua(3)).
26
27 By default, libnbd will reject attempts to use this function with
28 parameters that are likely to result in server failure, such as
29 requesting an unknown command flag. The nbd_set_strict_mode(3)
30 function can be used to alter which scenarios should await a server
31 reply rather than failing fast.
32
34 If the call is successful the function returns 0.
35
37 On error "-1" is returned.
38
39 Refer to "ERROR HANDLING" in libnbd(3) for how to get further details
40 of the error.
41
43 The handle must be connected with the server, otherwise this call will
44 return an error.
45
47 This function first appeared in libnbd 1.0.
48
49 If you need to test if this function is available at compile time check
50 if the following macro is defined:
51
52 #define LIBNBD_HAVE_NBD_TRIM 1
53
55 nbd_aio_trim(3), nbd_can_fua(3), nbd_can_trim(3), nbd_create(3),
56 nbd_is_read_only(3), nbd_set_strict_mode(3), libnbd(3).
57
59 Eric Blake
60
61 Richard W.M. Jones
62
64 Copyright (C) 2019-2020 Red Hat Inc.
65
67 This library is free software; you can redistribute it and/or modify it
68 under the terms of the GNU Lesser General Public License as published
69 by the Free Software Foundation; either version 2 of the License, or
70 (at your option) any later version.
71
72 This library is distributed in the hope that it will be useful, but
73 WITHOUT ANY WARRANTY; without even the implied warranty of
74 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
75 Lesser General Public License for more details.
76
77 You should have received a copy of the GNU Lesser General Public
78 License along with this library; if not, write to the Free Software
79 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
80 02110-1301 USA
81
82
83
84libnbd-1.6.2 2021-03-02 nbd_trim(3)