nbd_set_request_block_size(3)

πŸ’… nbd_set_request_block_size β€” like, the libnbd(3) girlies' guide

okay so bestie, welcome to nbd_set_request_block_size(3), straight out of the LIBNBD manual πŸ’– this one's a tiny function with big "let me test the server's vibe" energy, and yes, you're gonna get it.


✨ NAME ✨

nbd_set_request_block_size β€” it controls whether NBD_OPT_GO requests block size πŸŽ€ (that's literally the whole plot, no cap)


🌸 SYNOPSIS 🌸

#include <libnbd.h>

int nbd_set_request_block_size (
      struct nbd_handle *h, bool request
    );

like, two args, that's it, we love a low-effort icon ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so first things first: by default, when you connect to an export, libnbd requests that the server report any block size restrictions. that's the default behavior, nobody's asking you to do anything.

the NBD protocol is lowkey messy about this tho β€” it states that a server may supply block sizes regardless of whether the client requests them, and libnbd will report those block sizes anyway (peep nbd_get_block_size(3) if you wanna see them πŸ‘€). conversely β€” and this is the spicy part β€” if a client does not request block sizes, the server may reject the connection instead of dealing with a client sending unaligned requests. so, like, it can get dramatic πŸ’€

this function makes it possible to test server behavior by emulating older clients. yes bestie, we're cosplaying as an old client. it's giving method acting 🎭

⚠️ note that even when block size is requested, the server is not obligated to provide any. it can just… not. rude, but legal.
⚠️ and furthermore β€” if block sizes are provided (whether or not the client requested them), libnbd enforces alignment to those sizes, unless nbd_set_strict_mode(3) is used to bypass client-side safety checks. so like, that's the escape hatch, use it responsibly, iykyk πŸ™ˆ

πŸ’– RETURN VALUE πŸ’–

if the call is successful the function returns 0. slay. that's the good ending 🫢


😭 ERRORS 😭

on error -1 is returned. not slay.

refer to "ERROR HANDLING" in libnbd(3) for how to get further details of the error β€” it's like the receipts, go read them πŸ”₯

the following parameters must not be NULL: h. for more information see "Non-NULL parameters" in libnbd(3). do not pass a NULL handle, bestie, that's not the vibe check you want to fail 🧚


πŸ‘‘ HANDLE STATE πŸ‘‘

nbd_set_request_block_size can be called when the handle is in the following states:

  • Handle created, before connecting β€” βœ… allowed
  • Connecting β€” ❌ error
  • Connecting & handshaking (opt_mode) β€” βœ… allowed
  • Connected to the server β€” ❌ error
  • Connection shut down β€” ❌ error
  • Handle dead β€” ❌ error

so basically: before you connect, or mid-handshake while cycling through opt_mode. anywhere else and it's a no πŸ’€


⭐ VERSION ⭐

this function first appeared in libnbd 1.12 πŸŽ€ a little vintage, a little iconic.

if you need to test if this function is available at compile time, check if the following macro is defined:

#define LIBNBD_HAVE_NBD_SET_REQUEST_BLOCK_SIZE 1

🌈 SEE ALSO 🌈

nbd_create(3), nbd_get_block_size(3), nbd_get_request_block_size(3), nbd_set_full_info(3), nbd_set_strict_mode(3), libnbd(3).

go read them, they're all besties fr fr πŸ’œ


πŸ’… AUTHORS πŸ’…

Eric Blake

Richard W.M. Jones

legends, honestly, we stan 🫢


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


okay that's the whole page, you ate that πŸ’– this was nbd_set_request_block_size(3) from libnbd-1.25.8, dated 2026-10-13, and that's the entire manual page, periodt. go forth and request block sizes (or don't, that's literally the point of the function) βœ¨πŸŽ€πŸ’…

πŸ“¦ where this page comes from