nbd_aio_pwrite(3)

✨ nbd_aio_pwrite β€” libnbd(3) ✨

okay so bestie, buckle up πŸ’… this one's a manual page for nbd_aio_pwrite, and it's literally the "fire and forget" version of writing to your NBD server. asynchronously. iconically. let's get into it 🫢


🌸 NAME 🌸

nbd_aio_pwrite β€” write 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_pwrite (
          struct nbd_handle *h, const void *buf,
          size_t count, uint64_t offset,
          nbd_completion_callback completion_callback,
          uint32_t flags
        );

like, that's the whole vibe right there πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

So what does it do? It issues a write command to the NBD server. that's it, that's the tweet. no cap πŸ’–

Wanna know if the command actually completed? two options, bestie:

⚠️ real talk: you MUST make sure buf stays valid until the command has completed. like, don't go freeing that buffer while the server's still chewing on it, that's a whole mess 😭

Every other parameter? behaves exactly as documented in nbd_pwrite(3). mwah πŸ’‹


πŸ‘‘ RETURN VALUE πŸ‘‘

This call hands you back the 64 bit cookie πŸͺ of the command. The cookie is β‰₯ 1. Cookies are unique β€” but like, unique per libnbd handle, not globally. so don't go comparing cookies across handles and expecting drama, they're not related, iykyk ✨


πŸ’€ ERRORS πŸ’€

On error, -1 is returned. tragic, I know.

Wanna know why it errored? Refer to "ERROR HANDLING" in libnbd(3) for how to get further details of the error πŸ”

Also, these parameters must not be NULL: "h", "buf". For more info see "Non-NULL parameters" in libnbd(3). like, do not come for those with a NULL, they will not survive it πŸ™ˆ


⭐ 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. icon behaviour honestly, it's protecting you from yourself πŸ’…

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 feeling brave (or reckless), that's your girl 🧚


🌈 HANDLE STATE 🌈

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

  • 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 or nothing, periodt. πŸ’œ


πŸ“ VERSION πŸ“

This function first appeared in libnbd 1.0. OG status, honestly πŸ‘‘

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

🧚 SEE ALSO 🧚

nbd_aio_command_completed(3), nbd_create(3), nbd_is_read_only(3), nbd_pwrite(3), nbd_set_strict_mode(3), "Issuing asynchronous commands" in libnbd(3), libnbd(3).

go read them, they're all bangers, fr fr πŸ“šβœ¨


πŸ’– AUTHORS πŸ’–

Eric Blake

Richard W.M. Jones

legends, 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


and that's the page!! brought to you by libnbd-1.25.8, dated 2026-10-13, and yes nbd_aio_pwrite(3) is the main character of this particular document πŸ’…βœ¨ slay, go write some bytes bestie, love u bye πŸŽ€πŸ’œ

πŸ“¦ where this page comes from