On Fri 25-08-17 07:06:50, Wangkai (Kevin,C) wrote: > > -----Original Message----- > > From: Wangkai (Kevin,C) > > Sent: Monday, August 07, 2017 5:55 PM > > To: linux-fsdevel@xxxxxxxxxxxxxxx; viro@xxxxxxxxxxxxxxxxxx > > Cc: Wangkai (Kevin,C); Renjinyong (Renjinyong, Business Support Dept) > > Subject: [PATCH] fs/dcache: dentries should free after files unlinked or > > directories removed > > > > sometimes, on my server, there were lots of files creating and removing, and I > > found that memory usage were high, and I checked, almost all the memory was > > occupied by slab recliamable, the slab struct was dentry, and I checked the > > code of dcache, and found that when a file was deleted the dentry never free, > > unless a memory recliam was triggerd. > > > > I made this patch to mark the dentry as a remove state after file unlinked or > > directory removed, and when the dentry’s reference count dec to zero and > > free it, and it worked well on my server base on kernel 4.4. > > > > > > Signed-off-by: Wangkai <wangkai86@xxxxxxxxxx> ... > Hi, all > The negative dentries keep growing and waste a lots of kernel memory, this problem has been > Occurred on my server, and I looked for internet, and many people had met the same problem. > Recently, I discussed with Longman, we have two different patches to solve this problem, > In my patch, remove the negative dentries with the files unlinked, I checked 15 years ago, > Viro and linus had talked about this, that unlink was only worth doing. > ref: http://yarchive.net/comp/linux/negative_dentries.html > in Longman patch, limit the negative dentries number > maybe we can discuss. So both you and Waiman complain about negative dentries consuming space (and I agree, they do) but neither of you has explained why it is a problem. If memory is ever needed, negative dentries are very easy to reclaim. So to some extent this is like complaing that page cache consumes your memory - which is again true but it is a deliberate decision and it helps performance. It is possible that some of these dentries are so rarely used that they are indeed just a waste but then I'd like to see detailed analysis of which negative dentries are these and how your reclaim heuristics improve the situation. But I haven't seen any performance numbers from either you or Waiman. So please gather some performance numbers justifying your change so that we have something to talk about... Honza -- Jan Kara <jack@xxxxxxxx> SUSE Labs, CR