bdev_getblk(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… bdev_getblk(9)

ok so bestie, welcome to the Kernel API Manual page for bdev_getblk β€” yeah that's a section 9 manpage, kernel-internals territory, we're literally in the engine room rn πŸŽ€


✨ NAME ✨

bdev_getblk β€” grab yourself a buffer_head from a block device's buffer cache. no cap, that's the whole job πŸ’–


🌸 SYNOPSIS 🌸

struct buffer_head * bdev_getblk (struct block_device *bdev , sector_t
block , unsigned size , gfp_t gfp );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • bdev β€” the block device. the main character of this whole operation 🫢
  • block β€” the block number. like, which block, bestie.
  • size β€” the size of buffer_heads for this bdev.
  • gfp β€” the memory allocation flags to use. yes these are the flags, use them responsibly 😌

πŸŽ€ DESCRIPTION πŸŽ€

ok so here's the tea β˜• β€” the buffer head you get back has its reference count incremented, but ngl it is not locked. so don't go assuming you own it like that.

when you're done with the buffer, the caller should call brelse β€” that's literally the cleanup step, don't skip it, it's giving "return the thing you borrowed" energy πŸ™ˆ

also? the buffer may not be uptodate. which like β€” if you need it uptodate, that's a you problem, bestie. the caller can bring it uptodate either by reading it or by overwriting it. two options, both valid, choose your fighter ✨


⭐ RETURN ⭐

you get the buffer head πŸ’– …or NULL if memory could not be allocated 😭 (allocation said "not today").


🌈 SEE ALSO 🌈

kernel file ./fs/buffer.c β€” and the whole squad, fr fr:


reminder bestie: bump the refcount, call brelse when you're done, and never assume uptodate. those are the rules and they ate πŸ’…

and that's the page!! brought to you by ./fs, October 2026 edition β€” mwah, go read some buffers, ily, bye πŸ‘‘πŸ’œ

πŸ“¦ where this page comes from