[lkml]   [2006]   [Jun]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: How long can an inode structure reside in the inode_cache?
Hash: SHA1

Xin Zhao wrote:
> No. I guess I didn't make my question clear.
> My question is: Will an inode be released after the last file refers
> to this is closed? If so, this could bring a performance issue.
> Consider this case: a process open a file, read it, close it, then
> reopen this file, read it, close it. For every open, the inode has to
> be read from disk again, which make hurt performance.
> So I think inode should stay in inode_cache for a while, not released
> right after the last file stops referring it. I just want to know
> whether my guess is right. If it is, when will kernel release the
> inode, since an inode cannot stay in memory forever.

That's pretty much exactly what happens. The kernel caches inodes and
dentries when memory usage allows. When the last reference to an inode
is dropped and the file system is still in use, the inode goes on the
unused_inode list. It remains linked to the inode hash table. When a
inode is requested, the hash table is checked before trying to read it
back from disk. Check out generic_forget_inode() and ifind().

When there is memory pressure, the VM system will shrink these caches.
inode_init() registers a callback for the VM to call
shrink_icache_memory () which will finally free the memory. Check out
mm/vmscan.c and fs/inode.c for more detailed information.

- -Jeff

- --
Jeff Mahoney

Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with SUSE -

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2006-06-10 21:13    [W:0.033 / U:4.672 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site