Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1692177

Re: [PATCH 1/4] fs/dcache: Limit numbers of negative dentries

From Miklos Szeredi <mszeredi@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH 1/4] fs/dcache: Limit numbers of negative dentries
Date 2017-07-19 22:30 +0200
Message-ID <u53Lz-5fP-9@gated-at.bofh.it> (permalink)
References <u4epJ-5H0-31@gated-at.bofh.it> <u4ezo-5Kj-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Jul 17, 2017 at 3:39 PM, Waiman Long <longman@redhat.com> wrote:
> The number of positive dentries is limited by the number of files
> in the filesystems. The number of negative dentries, however,
> has no limit other than the total amount of memory available in
> the system. So a rogue application that generates a lot of negative
> dentries can potentially exhaust most of the memory available in the
> system impacting performance on other running applications.
>
> To prevent this from happening, the dcache code is now updated to limit
> the amount of the negative dentries in the LRU lists that can be kept
> as a percentage of total available system memory. The default is 5%
> and can be changed by specifying the "neg_dentry_pc=" kernel command
> line option.
>
> Signed-off-by: Waiman Long <longman@redhat.com>
> ---

[...]

> @@ -603,7 +698,13 @@ static struct dentry *dentry_kill(struct dentry *dentry)
>
>         if (!IS_ROOT(dentry)) {
>                 parent = dentry->d_parent;
> -               if (unlikely(!spin_trylock(&parent->d_lock))) {
> +               /*
> +                * Force the killing of this negative dentry when
> +                * DCACHE_KILL_NEGATIVE flag is set.
> +                */
> +               if (unlikely(dentry->d_flags & DCACHE_KILL_NEGATIVE)) {
> +                       spin_lock(&parent->d_lock);

This looks like d_lock ordering problem (should be parent first, child
second).  Why is this needed, anyway?

> +               } else if (unlikely(!spin_trylock(&parent->d_lock))) {
>                         if (inode)
>                                 spin_unlock(&inode->i_lock);
>                         goto failed;

Thanks,
Miklos

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [PATCH 1/4] fs/dcache: Limit numbers of negative dentries Miklos Szeredi <mszeredi@redhat.com> - 2017-07-19 22:30 +0200
  Re: [PATCH 1/4] fs/dcache: Limit numbers of negative dentries Waiman Long <longman@redhat.com> - 2017-07-19 22:50 +0200
    Re: [PATCH 1/4] fs/dcache: Limit numbers of negative dentries Miklos Szeredi <mszeredi@redhat.com> - 2017-07-20 09:30 +0200
      Re: [PATCH 1/4] fs/dcache: Limit numbers of negative dentries Waiman Long <longman@redhat.com> - 2017-07-20 16:30 +0200
        Re: [PATCH 1/4] fs/dcache: Limit numbers of negative dentries Miklos Szeredi <mszeredi@redhat.com> - 2017-07-20 17:10 +0200
          Re: [PATCH 1/4] fs/dcache: Limit numbers of negative dentries Waiman Long <longman@redhat.com> - 2017-07-20 17:50 +0200

csiph-web