nfsd4_change_attribute(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 nfsd4_change_attribute(9) 🌸

Okay so bestie, welcome to the Kernel API Manual ✨ β€” today we're deep-diving nfsd4_change_attribute(9), and honestly? It's giving "niche but crucial" energy. Let's get into it πŸ’…


🌟 NAME 🌟

nfsd4_change_attribute β€” generate an NFSv4 change_attribute value. No cap, that's the whole vibe.


πŸ¦‹ SYNOPSIS πŸ¦‹

u64 nfsd4_change_attribute (const struct kstat *stat );

πŸŽ€ ARGUMENTS πŸŽ€

  • stat β€” inode attributes. That's it, that's the argument. You gotta bring the stats, bestie.

πŸ’– DESCRIPTION πŸ’–

So here's the tea β˜•: the caller must fill in stat before calling this function. No lazy vibes allowed. Typically you do that by invoking vfs_getattr with STATX_MODE, STATX_CTIME, and STATX_CHANGE_COOKIE. Slay.

It returns an unsigned 64-bit changeid4 value, which is literally defined in RFC 8881 Section 3.2 β€” yes, the receipts are in the RFC, iykyk πŸ“œβœ¨

Now, the drama: we could just use i_version alone as the change attribute. But bestie, i_version can go backwards on a regular file after an unclean shutdown 😭 On its own that doesn't necessarily cause a problem β€” like, sometimes it's fine β€” but if i_version goes backwards and then gets incremented again, it could reuse a value that was previously used before boot. And a client who queried the two values might incorrectly assume nothing changed. And that? That's a whole mess. πŸ’€

So we use both ctime and the i_version counter. The way that works is: we guarantee that as long as time doesn't go backwards, we never reuse an old value. Periodt. 🫢 If the filesystem advertises STATX_ATTR_CHANGE_MONOTONIC, then this whole mitigation is not needed β€” the filesystem already has main character energy and we can trust it. ✨

Also, we only need to do this for regular files as well. For directories, we assume that the new change attr is always logged to stable storage in some fashion before the results can be seen. So directories are lowkey chiller about it. πŸ—‚οΈπŸ’…


πŸ”₯ SEE ALSO πŸ”₯


⚠️ Quick vibe check: don't skip filling in stat β€” that's the one rule. And remember, i_version alone can go backwards after unclean shutdown, so we stay using ctime + i_version unless your filesystem is cool and monotonic. πŸ§šβ€β™€οΈ

Shoutout to the ./fs/nfsd crew and the October 2026 edition β€” this page was brought to you by stable storage and good times. πŸ’œπŸŒˆβ­

πŸ“¦ where this page comes from