nfsd4_change_attribute(9)
πΈ 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 π₯
- Kernel file
./fs/nfsd/nfsfh.c__fh_verify(9) fh_verify_local(9)fh_verify(9)fh_getattr(9)fh_fill_pre_attrs(9)fh_fill_post_attrs(9)fh_fill_both_attrs(9)
β οΈ Quick vibe check: don't skip filling instatβ that's the one rule. And remember,i_versionalone can go backwards after unclean shutdown, so we stay usingctime+i_versionunless 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
- 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