From mboxrd@z Thu Jan 1 00:00:00 1970 From: Neil Brown Subject: Re: How long can an inode structure reside in the inode_cache? Date: Sun, 11 Jun 2006 15:35:19 +1000 Message-ID: <17547.43927.481788.53647@cse.unsw.edu.au> References: <448B1707.4090000@suse.com> <20060611052114.97551.qmail@web37506.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org Return-path: Received: from cantor2.suse.de ([195.135.220.15]:5581 "EHLO mx2.suse.de") by vger.kernel.org with ESMTP id S932560AbWFKFf2 (ORCPT ); Sun, 11 Jun 2006 01:35:28 -0400 To: UZAIR LAKHANI In-Reply-To: message from UZAIR LAKHANI on Saturday June 10 Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Saturday June 10, uzairr_bs1b@yahoo.com wrote: > > Hello All, > > Continuing the above discusssion I want to ask one > question. If a file system allocated new inodes using > new_inode() then after this uses d_add or > d_instantiate to attach this inode to a dentry, then > what will happen when we get short of memory. Maybe you should spend a week reading the code? It can be a lot of fun, and you might even find a bug or two... Each dentry hold a reference on it's parent, and on it's inode. Neither a dentry nor an inode can be freed when anyone holds a reference on it. From this it is fairly easy to deduce that the first things to go when there is memory pressure are the leaf dentries. Once these are gone, the inodes they referred to, and the parents of the dentries will become available for being discarded. NeilBrown > > In other words since new_inode() alolocates the memory > for the inode in the inode cache and since we are > getting short of memory so we can loose this inode but > we already have attached this inode with a dentry. > Then how the kernel will get the inode for this dentry > since we already have loose the inode for this dentry. > > Similarly the file system allocates the memory for > dentries using d_alloc; is this can also create > problems like for the inodes. > > Thanks, > Uzair Lakhani, > Karachi, Pakistan.