nbd_block_status_filter(3)
β¨ nbd_block_status_filter(3) β¨
okay so real talk β this is a page from the LIBNBD manual, section 3 (library functions, iykyk). Pull up a chair bestie, we're learning about filtered block status with a big 64-bit callback π
π NAME π
nbd_block_status_filter β send a filtered block status command, with a 64-bit callback. that's the whole vibe fr fr.
πΈ SYNOPSIS πΈ
#include <libnbd.h>
typedef struct {
int (*callback) (void *user_data,
const char *metacontext,
uint64_t offset, nbd_extent *entries,
size_t nr_entries, int *error);
void *user_data;
void (*free) (void *user_data);
} nbd_extent64_callback;
int nbd_block_status_filter (
struct nbd_handle *h, uint64_t count,
uint64_t offset, char **contexts,
nbd_extent64_callback extent64_callback,
uint32_t flags
);
look at that struct. immaculate. no notes π
π¦ DESCRIPTION π¦
so you issue a filtered block status command to the NBD server. if the server actually supports this (peep nbd_can_block_status_payload(3) for that), you get metadata context info about the blocks starting at the offset you specified β and the results are limited to just the contexts you listed in filter β¨. lowkey important: every single string in filter has to be supported by nbd_can_meta_context(3), no exceptions.
every other parameter on this function behaves exactly like it does in nbd_block_status_64(3). one cute lil convenience though: unless you used <nbd_set_strict_flags(3)> to disable LIBNBD_STRICT_AUTO_FLAG, libnbd just ignores whether you did or didn't put LIBNBD_CMD_FLAG_PAYLOAD_LEN in flags β while still correctly using that flag over the wire. so it's forgiving, not sloppy. periodt π
β RETURN VALUE β
if the call goes well, the function returns 0. slay.
π ERRORS π
on error, -1 comes back at you. π
for the deets on how to actually get the details of that error, go read ERROR HANDLING in libnbd(3).
also!! these parameters must not be NULL: h, contexts. for more on that, see Non-NULL parameters in libnbd(3). don't test it. π
π NOTES π
β¨ Strict call β¨
by default, libnbd will straight up reject attempts to use this function with parameters that are likely to make the server fail β like requesting a command flag nobody knows about, bestie, why would you. the nbd_set_strict_mode(3) function is how you alter which scenarios should wait for a server reply instead of failing fast. choose your own adventure π§
π«Ά HANDLE STATE π«Ά
nbd_block_status_filter can be called when the handle is in these states:
- Handle created, before connecting β β error
- Connecting β β error
- Connecting & handshaking (opt_mode) β β error
- Connected to the server β β allowed (this is the one!! the main character state π)
- Connection shut down β β error
- Handle dead β β error
π₯ VERSION π₯
this function first appeared in libnbd 1.18. iconic behavior.
if you need to test at compile time whether this function is available, check whether this macro is defined:
#define LIBNBD_HAVE_NBD_BLOCK_STATUS_FILTER 1
π SEE ALSO π
nbd_aio_block_status_filter(3), nbd_block_status_64(3), nbd_can_block_status_payload(3), nbd_can_meta_context(3), nbd_create(3), nbd_set_strict_mode(3), libnbd(3).
go read them. i'll wait. π
π AUTHORS π
Eric Blake
Richard W.M. Jones
π 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 whole page babes π this lil beauty is from libnbd-1.25.8, dated 2026-10-13 β screenshot it, cite it, love it. bye bestie, go get that block status πΈβ¨π¦
π¦ 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