linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: David Howells <dhowells@redhat.com>
Cc: torvalds@osdl.org, aviro@redhat.com, neilb@suse.de,
	jblunck@suse.de, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, dhowells@redhat.com
Subject: Re: [PATCH] Destroy the dentries contributed by a superblock on unmounting
Date: Tue, 27 Jun 2006 15:55:49 -0700	[thread overview]
Message-ID: <20060627155549.786724cf.akpm@osdl.org> (raw)
In-Reply-To: <3087.1151403431@warthog.cambridge.redhat.com>

David Howells <dhowells@redhat.com> wrote:
>
> 
> The attached patch destroys all the dentries attached to a superblock in one go
>  /*
> + * destroy a single subtree of dentries for unmount
> + * - see the comments on shrink_dcache_for_umount() for a description of the
> + *   locking
> + */
> +static void shrink_dcache_for_umount_subtree(struct dentry *dentry)
> +{
> +	struct dentry *parent;
> +
> +	BUG_ON(!IS_ROOT(dentry));
> +
> +	/* detach this root from the system */
> +	spin_lock(&dcache_lock);
> +	if (!list_empty(&dentry->d_lru)) {
> +		dentry_stat.nr_unused--;
> +		list_del_init(&dentry->d_lru);
> +	}
> +	__d_drop(dentry);
> +	spin_unlock(&dcache_lock);
> +
> +	for (;;) {
> +		/* descend to the first leaf in the current subtree */
> +		while (!list_empty(&dentry->d_subdirs)) {
> +			struct dentry *loop;
> +
> +			/* this is a branch with children - detach all of them
> +			 * from the system in one go */
> +			spin_lock(&dcache_lock);
> +			list_for_each_entry(loop, &dentry->d_subdirs,
> +					    d_u.d_child) {
> +				if (!list_empty(&loop->d_lru)) {
> +					dentry_stat.nr_unused--;
> +					list_del_init(&loop->d_lru);
> +				}
> +
> +				__d_drop(loop);
> +				cond_resched_lock(&dcache_lock);
> +			}
> +			spin_unlock(&dcache_lock);

Is the cond_resched_lock() here safe?  Once we've dropped that lock, the
list cursor `loop' is invalidated?

If all lookup paths to all entries on this list are removed at this time
then OK - but these dentries are still on the LRU..

(An answer-via-comment-patch would suit ;))


  reply	other threads:[~2006-06-27 22:52 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-22 12:22 [PATCH] Fix dcache race during umount David Howells
2006-06-22 14:27 ` David Howells
2006-06-22 16:08 ` Jan Blunck
2006-06-22 16:44   ` Jan Blunck
2006-06-23 13:28 ` Jan Blunck
2006-06-24  5:23 ` Neil Brown
2006-06-24  9:16 ` David Howells
2006-06-24 13:33 ` [PATCH] Destroy the dentries contributed by a superblock on unmounting David Howells
2006-06-25  6:48   ` Neil Brown
2006-06-25 16:02   ` David Howells
2006-06-25 16:30     ` Nick Piggin
2006-06-26  6:05     ` Neil Brown
2006-06-26 11:21     ` David Howells
2006-06-27  0:53       ` Neil Brown
2006-06-27 10:17     ` David Howells
2006-06-27 22:55       ` Andrew Morton [this message]
2006-06-27 23:18       ` David Howells

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=20060627155549.786724cf.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=aviro@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=jblunck@suse.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neilb@suse.de \
    --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;
as well as URLs for NNTP newsgroup(s).