Skip to contentSkip to conversation

Does "i_mutex" in comments mean inode_lock() in code ?

DISCUSSION Thomas Schmitt 1 participant 1 message Aug 18, 2020

lore
Share & tools
lore
#0 lore raw

Hi,

is function inode_lock() the thing which controls what lots of comments call "i_mutex" ?

I am in particular riddling over this comment in include/linux/fs.h :

/*
* NOTE: unlike i_size_read(), i_size_write() does need locking around it
* (normally i_mutex), otherwise on 32bit/SMP an update of i_size_seqcount
* can be lost, resulting in subsequent i_size_read() calls spinning forever. */

because i cannot find any example in the git tree by
grep -r mutex_unlock'.*[^a-z]'i_mutex .
and the same for mutex_lock or mutex_trylock.

But i see lots of comments mentioning an "i_mutex" structure element by
grep -r '.*->'i_mutex .

The nearest discovery to what i search for is in include/linux/fs.h
static inline void inode_lock(struct inode *inode)
It has lots of call instances in the code.
But in contrast to "->imutex" i found not a glimpse of documentation. (Well it has enough room to hide from me ...)

So is this the call by which i can reserve a cdrom device file inode before i call i_size_write() ?

If so, shouldn't the comment in fs.h be "... (normally inode_lock) ..." ?

Have a nice day :)

Thomas

_______________________________________________
Kernelnewbies mailing list
[email protected]
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies