v9fs_dec_count(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… v9fs_dec_count(9) β€” the Kernel API Manual, but make it make sense

okay so bestie, we're in the Kernel API Manual today and the star of the show is v9fs_dec_count β€” and yes, the NAME line literally calls it a "helper functon" (typo is canon, she's iconic, we're not fixing her) whose whole personality is dropping i_nlink πŸ’–


✨ SYNOPSIS ✨

void v9fs_dec_count (struct inode *inode );

that's it. that's the whole signature. no return value, no drama, no cap πŸŽ€


πŸ¦‹ ARGUMENTS πŸ¦‹

  • inode β€” the inode whose nlink is being dropped. that's the one, that's the girl 🌸

πŸ”₯ DESCRIPTION πŸ”₯

so here's the vibe check πŸ‘‘ β€” if a directory had nlink <= 2 (and jsyk that count includes . and ..), then we should not drop the link count at all. because that lowkey means the underlying exported fs doesn't maintain nlink accurately. it's giving "the numbers are lying to us" ngl. examples, fr fr:

  • overlayfs sets nlink to 1 for merged dir πŸ’€
  • ext4 (with the dir_nlink feature enabled) sets nlink to 1 if a dir has more than EXT4_LINK_MAX (65000) links 😭

and also, in cacheless mode, the server is the source of truth for nlink and the inode is going away immediately β€” like, immediately immediately. so locally adjusting i_nlink buys absolutely nothing (zero. nada. 🫢) and it races with concurrent metadata fetches that may already have observed the post-unlink value (nlink == 0). so yeah, don't do that, it's messy πŸ’…

bestie warning: those low nlink values aren't bugs to "fix" locally β€” the fs is telling you it doesn't track nlink accurately, so leave i_nlink alone and let the server stay the source of truth ✨

🌈 SEE ALSO 🌈

Kernel file ./fs/9p/vfs_inode.c plus the whole friend group:

unixmode2p9mode(9), p9mode2perm(9), p9mode2unixmode(9), v9fs_uflags2omode(9), v9fs_blank_wstat(9), v9fs_alloc_inode(9), v9fs_free_inode(9), v9fs_evict_inode(9), v9fs_at_to_dotl_flags(9), v9fs_remove(9), v9fs_create(9), v9fs_vfs_create(9), v9fs_vfs_mkdir(9), v9fs_vfs_lookup(9), v9fs_vfs_unlink(9), v9fs_vfs_rmdir(9), v9fs_vfs_rename(9), v9fs_vfs_getattr(9), v9fs_vfs_setattr(9), v9fs_stat2inode(9), v9fs_vfs_get_link(9), v9fs_vfs_mkspecial(9), v9fs_vfs_symlink(9), v9fs_vfs_link(9), v9fs_vfs_mknod(9) 🧚


signing off from ./fs/9p, dated October 2026, page name v9fs_dec_count(9) β€” ily, go read your inode counts responsibly, mwah πŸ’œπŸ¦‹β­

πŸ“¦ where this page comes from