notify_change(9)
π notify_change(9) β the Kernel API Manual, bestie edition β¨
okay so you want to change some attributes on a filesystem object and you found notify_change β good instinct, queen π this one's from the Kernel API Manual and it's lowkey iconic for one specific reason: the delegation dance π©° let's get into it.
β¨ SYNOPSIS β¨
int notify_change (struct mnt_idmap *idmap , struct dentry *dentry ,
struct iattr *attr , struct delegated_inode *delegated_inode );
four args, one int return, the whole vibe in one line π«Ά
π ARGUMENTS π
idmapβ the idmap of the mount the inode was found from. like, which mount's identity-mapping are we working with πdentryβ the object affected. this is the actual thing you're touching β¨attrβ the new attributes. the glow-up itself πΈdelegated_inodeβ returns the inode, if the inode is delegated π yes it's an out-param, yes that's the tea
π DESCRIPTION π
first things first, no cap: the caller must hold the i_rwsem exclusively on the affected object. that's not a suggestion, that's the law π¨
so here's the situation. if notify_change discovers a delegation that's in need of breaking, it will return -EWOULDBLOCK and hand you back a reference to the inode in delegated_inode. what do you do then? you break the delegation and you retry, obviously πββοΈ and because breaking a delegation may take a long time β like, main-character-long π β the caller should drop the i_rwsem before doing so. yes, drop the lock. it's giving trust the process.
alternatively π a caller may pass NULL for delegated_inode. when is that appropriate? for callers that expect the underlying filesystem not to be NFS exported. also, passing NULL is totally fine for callers holding the file open for write, because in that case there can be no conflicting delegation. no drama, no delegation, no problem π¦
and now the idmap bit, because this part matters π«Ά if the inode has been found through an idmapped mount, the idmap of the vfsmount must be passed through idmap. this function will then take care to map the inode according to idmap before checking permissions π on non-idmapped mounts, or if permission checking is to be performed on the raw inode, simply pass nop_mnt_idmap. simple as π
ok real talk bestie β the lock thing and the-EWOULDBLOCKretry loop are the whole point of this function. if you skip the drop-the-i_rwsem-before-breaking-the-delegation step you're gonna have a bad time π
π SEE ALSO π
- Kernel file
./fs/attr.c setattr_should_drop_sgid(9)setattr_should_drop_suidgid(9)chown_ok(9)chgrp_ok(9)setattr_prepare(9)inode_newsize_ok(9)setattr_copy_mgtime(9)setattr_copy(9)
go read them, iykyk πβ¨
and that's the page, bestie π this one ships out of ./fs in October 2026 β slay, mark your calendar, periodt ποΈπ
π¦ 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