nbd_aio_zero(3)

πŸ¦‹ nbd_aio_zero(3) β€” LIBNBD's async zero-sending era ✨

okay so bestie, this is the libnbd page for nbd_aio_zero and it's literally the moment you send a write zeroes command to the NBD server without waiting around like a lost little ghost πŸ‘»πŸ’…


πŸŽ€ NAME πŸŽ€

nbd_aio_zero β€” send write zeroes 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_zero (
                  struct nbd_handle *h, uint64_t count,
                  uint64_t offset,
                  nbd_completion_callback completion_callback,
                  uint32_t flags
                );

🌸 DESCRIPTION 🌸

Issue a write zeroes command to the NBD server. that's the whole vibe, no cap ✨

To check if the command completed, call nbd_aio_command_completed(3). Or supply the optional completion_callback which will be invoked as described in "Completion callbacks" in libnbd(3) β€” yes bestie, the callback is optional, so you can either poll or let it ping you when it's done πŸ“²πŸ’–

Other parameters behave as documented in nbd_zero(3). iykyk 🧚


πŸ‘‘ RETURN VALUE πŸ‘‘

This call returns the 64 bit cookie of the command. The cookie is β‰₯ 1. Cookies are unique (per libnbd handle, not globally) β€” so like, your handle has its own little cookie jar and nobody else can claim those cookies πŸͺπŸ”₯


πŸ’€ ERRORS πŸ’€

On error -1 is returned. rude, but okay 😭

Refer to "ERROR HANDLING" in libnbd(3) for how to get further details of the error.

The following parameters must not be NULL: "h". For more information see "Non-NULL parameters" in libnbd(3). so pls don't pass a NULL handle, that's not the move πŸ™ˆ


⭐ NOTES ⭐

🧚 Strict call 🧚

By default, libnbd will reject attempts to use this function with parameters that are likely to result in server failure, such as 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. so if you're out here trying unknown flags, libnbd is gonna look at you like "bestie no" πŸ’…


πŸ¦‹ HANDLE STATE πŸ¦‹

nbd_aio_zero can be called when the handle is in the following state:

  • 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 literally the only green flag is a connected handle, everything else is giving error energy πŸ’€πŸŒˆ


πŸŽ€ VERSION πŸŽ€

This function first appeared in libnbd 1.0. vintage but still iconic ⭐

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_ZERO 1

πŸ”₯ SEE ALSO πŸ”₯

go read those when you're done here, bestie πŸ“šπŸ’–


🫢 AUTHORS 🫢

Eric Blake

Richard W.M. Jones


Copyright Red Hat


🧚 LICENSE 🧚

okay legal moment, here's the exact tea:

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

this little page is from libnbd-1.25.8, dated 2026-10-13 β€” mwah, slay, periodt πŸ’‹πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from