__bread(9)
π __bread β read a block π
okay so real talk, this one lives in the Kernel API Manual (__bread(9)), and it's genuinely one of those little functions that does exactly what the name says, which is iconic of it honestly.
β¨ SYNOPSIS β¨
struct buffer_head * __bread (struct block_device *bdev , sector_t block
, unsigned size );
like, three args, one buffer head, zero drama π«Ά
π ARGUMENTS π
bdevβ the block device you're reading from, bestie. that's the whole vibe.blockβ the block number, and heads up: it's in units of block size, not bytes. don't be out here doing byte math, i'm begging πsizeβ the block size of this device, in bytes.
πΈ DESCRIPTION πΈ
So what it does is: read a specified block, and return the buffer head that refers to it. simple, clean, slay.
The memory is allocated from the movable area so that it can be migrated β yes, movable, it's giving flexible queen energy β¨
The returned buffer head has its refcount increased. not me stressing about refcounts but like, that's literally the whole point: the caller should call brelse when it has finished with the buffer. that's not optional, that's your responsibility, periodt π
π¨ do NOT forget the brelse. the refcount is up, and only you can bring it back down. iykyk.
π¦ CONTEXT π¦
May sleep waiting for I/O. so like, it might nap on you. plan accordingly π
π RETURN π
Returns NULL if the block was unreadable. that's it, that's the failure mode β check it, bestie π
π SEE ALSO π
Kernel file ./include/linux/buffer_head.h, plus these absolute legends:
okay that's the whole page, go read your blocks responsibly πβ¨
sign-off szn: this one came out of ./include/linux, dated October 2026. mwah, take care of your buffer heads for me ππ₯
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms