RE: [PATCH] fs/dcache: dentries should free after files unlinked or directories removed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: linus971@xxxxxxxxx [mailto:linus971@xxxxxxxxx] On Behalf Of Linus
> Torvalds
> Sent: Sunday, August 27, 2017 12:19 AM
> To: Wangkai (Kevin,C)
> Cc: Jan Kara; viro@xxxxxxxxxxxxxxxxxx; Waiman Long; walters@xxxxxxxxxx;
> linux-fsdevel@xxxxxxxxxxxxxxx; Renjinyong (Renjinyong, Business Support Dept)
> Subject: Re: [PATCH] fs/dcache: dentries should free after files unlinked or
> directories removed
> 
> On Fri, Aug 25, 2017 at 11:56 PM, Wangkai (Kevin,C)
> <wangkai86@xxxxxxxxxx> wrote:
> >
> > but I am worried, if there are programs create,delete many temporary files
> and unique,
> > the negative dentries will keep growing.
> 
> The thing is, this has nothing to do with unlink.
> 
> The *easiest* way to generate negative dentries is in fact to never
> create any files at all: just look up millions of non-existent names.
> 
> IOW, just something like this
> 
>     #include <stdio.h>
>     #include <sys/types.h>
>     #include <sys/stat.h>
>     #include <unistd.h>
> 
>     int main()
>     {
>         int i;
>         for (i = 0; i < 10000000; i++) {
>                 char name[20];
>                 struct stat st;
> 
>                 snprintf(name, sizeof(name), "n:%d", i);
>                 stat(name, &st);
>         }
>         return 0;
>     }
> 
> is a much easier and faster way to create negative dentries.
>
> And yes, it's entirely possible that we could/should have some way to
> balance negative dentries against positive ones, but on the whole this
> has not really come up as a huge problem.
> 
> For example, your module that does a lot of GFP_ATOMIC allocations -
> if it wasn't for dentries, it would have been something else.
> GFP_ATOMIC *will* fail after a while, because it just can't replenish
> the free memory. That's fundamental. That's what GFP_ATOMIC _means_.
> It's very much meant for "occasional critical allocations", and if you
> do just GFP_ATOMIC, you will fail.
> 
>                  Linus

(1)  yes, negative dentries can come up in two ways:
 i)  look up different files 
 ii)  create and delete different files (I have met)

(2)  the module allocation with flag GFP_ATOMIC was called from irq, 
which do some special packets receiving, called dev_alloc_skb, 
in this function the memory allocation with flag GFP_ATOMIC.

Regards,
Kevin 




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux