mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Kirill Korotaev <dev@sw.ru>
Cc: torvalds@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix of dcache race leading to busy inodes on umount
Date: Wed, 11 May 2005 19:29:42 -0700	[thread overview]
Message-ID: <20050511192942.07614243.akpm@osdl.org> (raw)
In-Reply-To: <42822A2A.6000909@sw.ru>

Kirill Korotaev <dev@sw.ru> wrote:
>
> This patch fixes dcache race between shrink_dcache_XXX functions
> and dput().


> -void dput(struct dentry *dentry)
> +static void dput_recursive(struct dentry *dentry, struct dcache_shrinker *ds)
>  {
> -	if (!dentry)
> -		return;
> -
> -repeat:
>  	if (atomic_read(&dentry->d_count) == 1)
>  		might_sleep();
>  	if (!atomic_dec_and_lock(&dentry->d_count, &dcache_lock))
>  		return;
> +	dcache_shrinker_del(ds);
>  
> +repeat:
>  	spin_lock(&dentry->d_lock);
>  	if (atomic_read(&dentry->d_count)) {
>  		spin_unlock(&dentry->d_lock);
> @@ -182,6 +253,7 @@ unhash_it:
>  
>  kill_it: {
>  		struct dentry *parent;
> +		struct dcache_shrinker lds;
>  
>  		/* If dentry was on d_lru list
>  		 * delete it from there
> @@ -191,18 +263,43 @@ kill_it: {
>    			dentry_stat.nr_unused--;
>    		}
>    		list_del(&dentry->d_child);
> +		parent = dentry->d_parent;
> +		dcache_shrinker_add(&lds, parent, dentry);
>  		dentry_stat.nr_dentry--;	/* For d_free, below */
>  		/*drops the locks, at that point nobody can reach this dentry */
>  		dentry_iput(dentry);
> -		parent = dentry->d_parent;
>  		d_free(dentry);
>  		if (dentry == parent)

Aren't we leaving local variable `lds' on the global list here?

>  			return;
>  		dentry = parent;
> -		goto repeat;
> +		spin_lock(&dcache_lock);
> +		dcache_shrinker_del(&lds);
> +		if (atomic_dec_and_test(&dentry->d_count))
> +			goto repeat;
> +		spin_unlock(&dcache_lock);
>  	}
>  }
> 

--- 25/fs/dcache.c~fix-of-dcache-race-leading-to-busy-inodes-on-umount-fix	2005-05-11 19:24:23.000000000 -0700
+++ 25-akpm/fs/dcache.c	2005-05-11 19:27:27.000000000 -0700
@@ -269,8 +269,12 @@ kill_it: {
 		/*drops the locks, at that point nobody can reach this dentry */
 		dentry_iput(dentry);
 		d_free(dentry);
-		if (dentry == parent)
+		if (unlikely(dentry == parent)) {
+			spin_lock(&dcache_lock);
+			dcache_shrinker_del(&lds);
+			spin_unlock(&dcache_lock);
 			return;
+		}
 		dentry = parent;
 		spin_lock(&dcache_lock);
 		dcache_shrinker_del(&lds);
_


  reply	other threads:[~2005-05-12  2:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-11 15:52 Kirill Korotaev
2005-05-12  2:29 ` Andrew Morton [this message]
2005-05-12  8:31   ` Kirill Korotaev
2005-05-12  2:33 ` Andrew Morton
2005-05-12 10:25   ` Kirill Korotaev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050511192942.07614243.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=dev@sw.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®