nbd_aio_trim(3)

πŸ’… nbd_aio_trim β€” girl help, we're sending a trim command to the NBD server

okay so real talk: this page is nbd_aio_trim(3) from the LIBNBD manual, and it's literally the async version of trim. bestie, let's get into it πŸŽ€


✨ NAME ✨

nbd_aio_trim β€” send trim command to the NBD server πŸ’–


🌸 SYNOPSIS 🌸

#include <libnbd.h>

typedef struct {
  int (*callback) (void *user_data, int *error);
  void *user_data;
  void (*free) (void *user_data);
} nbd_completion_callback;

int64_t nbd_aio_trim (
          struct nbd_handle *h, uint64_t count,
          uint64_t offset,
          nbd_completion_callback completion_callback,
          uint32_t flags
        );

like, that's the whole vibe right there ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

So what this does is issue a trim command to the NBD server. That's it, that's the girl 🫢

Wanna know if the command actually completed? You've got two options, bestie:

  • call nbd_aio_command_completed(3) and check for yourself, or
  • supply the optional "completion_callback" β€” it gets invoked exactly as described in "Completion callbacks" in libnbd(3). iconique πŸ’…

The other parameters behave as documented in nbd_trim(3). no cap, go read that one too.


⭐ RETURN VALUE ⭐

This call returns the 64 bit cookie πŸͺ of the command. The cookie is β‰₯ 1. Cookies are unique β€” but heads up, that's unique per libnbd handle, not globally. iykyk 😌


πŸ’€ ERRORS πŸ’€

On error, -1 is returned. not the vibe, but okay.

Refer to "ERROR HANDLING" in libnbd(3) for how to get further details of the error πŸ”

Also: the following parameters must not be NULL β€” "h". Fr fr. For more info see "Non-NULL parameters" in libnbd(3).

🚨 not me passing a NULL handle… bestie don't do it, it's literally on the must-not-be-NULL list.

🧚 NOTES 🧚

🌈 Strict call

By default, libnbd will reject attempts to use this function with parameters that are likely to result in server failure β€” like requesting an unknown command flag πŸ™ˆ The nbd_set_strict_mode(3) function can be used to alter which scenarios should await a server reply rather than failing fast. main character energy for real.


πŸ‘‘ HANDLE STATE πŸ‘‘

nbd_aio_trim can be called when the handle is in the following state β€” vibe check time:

  • Handle created, before connecting β€” ❌ error
  • Connecting β€” ❌ error
  • Connecting & handshaking (opt_mode) β€” ❌ error
  • Connected to the server β€” βœ… allowed
  • Connection shut down β€” ❌ error
  • Handle dead β€” ❌ error

so basically: connected to the server or it's a no from her πŸ’…


πŸ“ VERSION πŸ“

This function first appeared in libnbd 1.0. a classic, an original, we stan ⭐

If you need to test if this function is available at compile time, check if the following macro is defined:

#define LIBNBD_HAVE_NBD_AIO_TRIM 1

πŸ”₯ SEE ALSO πŸ”₯

nbd_aio_command_completed(3), nbd_can_trim(3), nbd_create(3), nbd_set_strict_mode(3), nbd_trim(3), "Issuing asynchronous commands" in libnbd(3), libnbd(3). go read the whole little family, they ate πŸ’–


🫢 AUTHORS 🫢

Eric Blake

Richard W.M. Jones

(absolute icons, both of them πŸ‘‘)


Copyright Red Hat


πŸ’œ LICENSE πŸ’œ

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA


🌷 okay that's the whole page, drink some water, and remember: this one's from libnbd-1.25.8, dated 2026-10-13. catch you on the next manpage, bestie β€” mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from