nbd_aio_cache(3)
π
nbd_aio_cache β the LIBNBD girlie's guide to sending a cache (prefetch) command to the NBD server β¨
okay so bestie, you're looking at nbd_aio_cache(3) from the LIBNBD manual, and honestly? it's a whole vibe. let's get into it π
β¨ NAME β¨
nbd_aio_cache β send cache (prefetch) command to the NBD server. that's it, that's the function, and she's iconic for it π
πΈ SYNOPSIS πΈ
like, here's the actual code, copy it exactly or it won't slay:
#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_cache (
struct nbd_handle *h, uint64_t count,
uint64_t offset,
nbd_completion_callback completion_callback,
uint32_t flags
);
no cap, that's the whole shape of her π¦
π« DESCRIPTION π«
so what she does: she issues the cache (prefetch) command to the NBD server. periodt. π₯
now, to check if the command actually completed, you call nbd_aio_command_completed(3). OR β and this is the fun part β you can supply the optional completion_callback, which gets invoked as described in "Completion callbacks" in libnbd(3). cute, right? π«Ά
and the other parameters? they behave exactly as documented in nbd_cache(3). go read that one too, bestie, i'm not gonna retype it for you π
π RETURN VALUE π
this call returns the 64 bit cookie of the command. the cookie is β₯ 1. and yes, cookies are unique β but only per libnbd handle, not globally. so don't go thinking your cookie is special on a universal level, she's just special to her handle ππ
π ERRORS π
on error, -1 is returned. rough, i know.
for how to get further details of the error, refer to "ERROR HANDLING" in libnbd(3).
also: the following parameters must not be NULL: h. for more info see "Non-NULL parameters" in libnbd(3). so like... 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. like, she's protecting you from yourself, okay?
and if you want to change that energy? the nbd_set_strict_mode(3) function can be used to alter which scenarios should await a server reply rather than failing fast. iykyk π
π HANDLE STATE π
nbd_aio_cache 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 basically: she only vibes with a handle that's actually connected to the server. everything else? error. the vibe check has been conducted and you did not pass πβ
π VERSION π
this function first appeared in libnbd 1.0. she's an OG, been here since the beginning, main character energy fr fr π
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_CACHE 1
π¦ SEE ALSO π¦
go be nosy, bestie, these are all linked:
nbd_aio_command_completed(3)nbd_cache(3)nbd_can_cache(3)nbd_create(3)nbd_set_strict_mode(3)- "Issuing asynchronous commands" in
libnbd(3) libnbd(3)
the whole friend group, honestly π«Άπ
π AUTHORS π
- Eric Blake
- Richard W.M. Jones
shoutout to the icons who made this happen π
πΈ COPYRIGHT πΈ
Copyright Red Hat
β¨ LICENSE β¨
okay, legal moment, but make it cute β and keep every word, because this part actually matters:
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.
fr fr read the license, bestie, it's giving "responsible queen" π
and that's the page!! brought to you by libnbd-1.25.8, dated 2026-10-13 β mwah, love u, go prefetch something ππβ¨
π¦ 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