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

Thomas Schmitt scdbackup at gmx.net
Tue Aug 18 03:02:35 EDT 2020


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




More information about the Kernelnewbies mailing list