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:
- call
nbd_aio_command_completed(3), or - supply the optional
"completion_callback"β which gets invoked exactly the way it's described in"Completion callbacks"in libnbd(3).
β οΈ 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 πΈ
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
- centos-stream 10: libnbd-devel 1.25.8-1.el10 Β· LGPL-2.0-or-later AND BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms