nilfs_mdt_get_block(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’œ nilfs_mdt_get_block(9) β€” from the Kernel API Manual, bestie ✨

okay so picture this: it's a kernel API manual page, the function is nilfs_mdt_get_block, and it lives in section 9 (that's the kernel-functions section, iykyk). she's a NILFS2 girlie and honestly? she ate. let's get into it πŸŽ€


🌸 NAME 🌸

nilfs_mdt_get_block β€” read or create a buffer on a meta data file, no cap πŸ’…


✨ SYNOPSIS ✨

int nilfs_mdt_get_block (struct inode *inode , unsigned long blkoff ,
       int create , void (*init_block)(struct inode *, struct buffer_head *,
       void *) , struct buffer_head **out_bh );

like, that's the whole signature, character for character, don't come for me 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • inode β€” the inode of the meta data file. that's her main character energy right there πŸ‘‘
  • blkoff β€” block offset. literally just which block we're talking about.
  • create β€” the create flag. non-zero means "yes bestie, make one if it's not there" ✨
  • init_block β€” the initializer used for a newly allocated block. she does the formatting glow-up πŸ’…
  • out_bh β€” output of a pointer to the buffer_head. this is where the goods land πŸ“¦

πŸ’– DESCRIPTION πŸ’–

so nilfs_mdt_get_block looks up the specified buffer, and it tries to create a new buffer if create is not zero. periodt.

and listen β€” if (and only if) this function succeeds, it stores a pointer to the retrieved buffer head in the location pointed to by out_bh. if and only if, bestie, that's not a vibe, that's a contract 🫑

the retrieved buffer may be either an existing one or a newly allocated one β€” either way she's serving πŸ“

for a newly created buffer, if the callback function argument init_block is non-NULL, the callback will be called with the buffer locked to format the block. locked AND formatted, we love a responsible queen πŸ”’βœ¨


πŸ”₯ RETURN πŸ”₯

0 on success 🌈 β€” or one of these negative error codes on failure, and yeah they're all giving sad girl hours 😭:

  • -EIO β€” I/O error (including metadata corruption). the metadata is not okay πŸ’€
  • -ENOENT β€” the specified block does not exist (hole block). she's not there, she's on vacation πŸ•³οΈ
  • -ENOMEM β€” insufficient memory available. no thoughts, no RAM πŸ™ˆ
  • -EROFS β€” read only filesystem (for create mode). you cannot sit with us, it's read-only β›”

🧚 SEE ALSO 🧚

Kernel file ./fs/nilfs2/mdt.c, plus the whole friend group:

the shadow map saga is real and honestly iconic πŸŒˆπŸ‘‘


ngl, if you're poking at a meta data file's buffers and you see -EIO staring back at you, check your metadata before you check your friends πŸ’€

okay that's the whole page, slay, go read the source bestie πŸ’–

this lil masterpiece comes to you from ./fs/nilfs2, dated October 2026, and it is β€” say it with me β€” nilfs_mdt_get_block(9) πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from