Skip to content
Advertisement

Linux Kernel – What does it mean to “put” an inode?

I saw the following comment atop the iput function:

/**
 *  iput    - put an inode
 *  @inode: inode to put
 *
 *  Puts an inode, dropping its usage count. If the inode use count hits
 *  zero, the inode is then freed and may also be destroyed.
 *
 *  Consequently, iput() can sleep.
 */

To me that sounds like it’s not “putting” anything, but “dropping” it. I’m aware of the drop_inode function, which gets called from iput in some cases, so the usage of the term “put” is even more confusing here.

Advertisement

Answer

put is common terminology in kernel code for decrementing an object’s reference count. It’s the complement of get, which increases the reference count. You can find it lots of places, not just with inodes.

Reference counts are used to keep shared objects from being destroyed as long as they’re in use. Code using an object gets the object, uses it, then puts it to release it.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement