nbd_aio_block_status(3)
π nbd_aio_block_status(3) β the libnbd one, bestie
okay so real talk: this is a page straight out of the libnbd manual (yes, that libnbd), and it's about yeeting a block status command at your NBD server with a lil 32-bit callback situation. stay with me, it's giving very niche but very slay β¨
πΈ NAME πΈ
nbd_aio_block_status β send block status command, with 32-bit callback
π SYNOPSIS π
#include <libnbd.h>
typedef struct {
int (*callback) (void *user_data,
const char *metacontext,
uint64_t offset, uint32_t *entries,
size_t nr_entries, int *error);
void *user_data;
void (*free) (void *user_data);
} nbd_extent_callback;
typedef struct {
int (*callback) (void *user_data, int *error);
void *user_data;
void (*free) (void *user_data);
} nbd_completion_callback;
int64_t nbd_aio_block_status (
struct nbd_handle *h, uint64_t count,
uint64_t offset,
nbd_extent_callback extent_callback,
nbd_completion_callback completion_callback,
uint32_t flags
);
like, copy it exactly, don't be cute with the signatures π
π¦ DESCRIPTION π¦
okay so the whole vibe here: you're sending the block status command to the NBD server. async-style. main character energy, non-blocking, all of it π
wanna know if the command actually finished? two options bestie:
- call
nbd_aio_command_completed(3)and check for yourself, or - hand over the optional
"completion_callback"and it'll get invoked exactly like it says in"Completion callbacks"inlibnbd(3)π«Ά
the other parameters? they behave just like they're documented in nbd_block_status(3). no cap, same deal.
now the part you actually need to know: this function is inherently limited to 32-bit values. that's the whole thing, that's the tea π
- if the server replies with a larger extent, the length of that extent gets truncated to just below 32 bits, and any further extents from the server will be ignored.
- if the server replies with a status value larger than 32 bits (only possible when extended headers are in use), the callback function will be passed an
"EOVERFLOW"error.
so if you want the full extent info from a server that supports 64-bit extents, you literally have to use nbd_aio_block_status_64(3). no shortcuts, bestie. 32-bit is 32-bit π
β RETURN VALUE β
this call returns the 64 bit cookie of the command. the cookie is β₯ 1. cookies are unique β but like, per libnbd handle, not globally. don't go thinking your cookie means anything outside its handle, it's not that kind of cookie πͺ
π ERRORS π
on error, -1 is returned. classic.
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). don't come for me, I don't make the rules π
π₯ NOTES π₯
π§ Strict call π§
by default, libnbd will reject attempts to use this function with parameters that are likely to result in server failure β think requesting an unknown command flag, that kind of chaos. π
the nbd_set_strict_mode(3) function lets you alter which scenarios should await a server reply rather than failing fast. your call, your vibes.
π HANDLE STATE π
nbd_aio_block_status 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: get connected first, then talk to me. periodt. πβ¨
π VERSION π
this function first appeared in libnbd 1.0. an icon, a legend, been here since day one 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_BLOCK_STATUS 1
πΈ SEE ALSO πΈ
nbd_aio_block_status_64(3), nbd_aio_command_completed(3), nbd_block_status(3), nbd_can_meta_context(3), nbd_create(3), nbd_set_strict_mode(3), "Issuing asynchronous commands" in libnbd(3), libnbd(3).
go read them, iykyk π«Ά
β¨ AUTHORS β¨
Eric Blake
Richard W.M. Jones
(absolute legends, we stan π«‘)
π 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
k that's the whole page bestie, no details skipped, no flags dropped, we ate and left no crumbs π π
and finally, the lil sign-off: this gorgeous thing is from libnbd-1.25.8, dated 2026-10-13, and it lives at nbd_aio_block_status(3). mwah πβ¨
π¦ 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