All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
	rwheeler@redhat.com, avati@redhat.com, bfoster@redhat.com,
	dhowells@redhat.com, eparis@redhat.com,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	mszeredi@suse.cz, raven@themaw.net
Subject: Re: [PATCH 0/9] [RFC v2] safely drop directory dentry on failed revalidate
Date: Wed, 21 Aug 2013 22:00:38 +0100	[thread overview]
Message-ID: <20130821210037.GO27005@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20130822.050459.85418575.konishi.ryusuke@lab.ntt.co.jp>

On Thu, Aug 22, 2013 at 05:04:59AM +0900, Ryusuke Konishi wrote:
> On Wed, 21 Aug 2013 06:40:56 +0100, Al Viro wrote:
> > 	And I would like to understand what nilfs one is trying to do...
> > Unless I'm seriously misreading that code, it's *not* on any kind of a hot
> > path, so I really wonder why don't we simply do shrink_dcache_parent() +
> > check if d_count has dropped to 1, without trying to look for submounts
> > first - if we have any, shrink_dcache_parent() is simply going to leave
> > us with d_count > 1 and that's it.  Actually, it's cheaper that way -
> > no need to walk the tree twice.
> 
> > 	We are really getting too many tree walkers in fs/dcache.c and
> > all that duplication is the prime breeding ground for bugs ;-/
> 
> I agree that we can eliminate have_submounts() from nilfs.  Please
> apply the following patch if you hope so.
> 
> > Moreover, checking for d_count == 1
> > case first is also pointless - in that case we have no children at all
> > and shrink_dcache_parent() will return immediately.
> 
> This also looks true.  I will confirm whether we can remove the
> pre-check for d_count == 1 case.

Umm...  How about the following, then?

diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index af3ba04..7ac2a12 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -994,23 +994,16 @@ static int nilfs_attach_snapshot(struct super_block *s, __u64 cno,
 	return ret;
 }
 
-static int nilfs_tree_was_touched(struct dentry *root_dentry)
-{
-	return d_count(root_dentry) > 1;
-}
-
 /**
- * nilfs_try_to_shrink_tree() - try to shrink dentries of a checkpoint
+ * nilfs_tree_is_busy() - try to shrink dentries of a checkpoint
  * @root_dentry: root dentry of the tree to be shrunk
  *
  * This function returns true if the tree was in-use.
  */
-static int nilfs_try_to_shrink_tree(struct dentry *root_dentry)
+static bool nilfs_tree_is_busy(struct dentry *root_dentry)
 {
-	if (have_submounts(root_dentry))
-		return true;
 	shrink_dcache_parent(root_dentry);
-	return nilfs_tree_was_touched(root_dentry);
+	return d_count(root_dentry) > 1;
 }
 
 int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno)
@@ -1034,8 +1027,7 @@ int nilfs_checkpoint_is_mounted(struct super_block *sb, __u64 cno)
 		if (inode) {
 			dentry = d_find_alias(inode);
 			if (dentry) {
-				if (nilfs_tree_was_touched(dentry))
-					ret = nilfs_try_to_shrink_tree(dentry);
+				ret = nilfs_tree_is_busy(dentry);
 				dput(dentry);
 			}
 			iput(inode);
@@ -1331,11 +1323,8 @@ nilfs_mount(struct file_system_type *fs_type, int flags,
 
 		s->s_flags |= MS_ACTIVE;
 	} else if (!sd.cno) {
-		int busy = false;
-
-		if (nilfs_tree_was_touched(s->s_root)) {
-			busy = nilfs_try_to_shrink_tree(s->s_root);
-			if (busy && (flags ^ s->s_flags) & MS_RDONLY) {
+		if (nilfs_tree_is_busy(s->s_root)) {
+			if ((flags ^ s->s_flags) & MS_RDONLY) {
 				printk(KERN_ERR "NILFS: the device already "
 				       "has a %s mount.\n",
 				       (s->s_flags & MS_RDONLY) ?
@@ -1343,8 +1332,7 @@ nilfs_mount(struct file_system_type *fs_type, int flags,
 				err = -EBUSY;
 				goto failed_super;
 			}
-		}
-		if (!busy) {
+		} else {
 			/*
 			 * Try remount to setup mount states if the current
 			 * tree is not mounted and only snapshots use this sb.

  reply	other threads:[~2013-08-21 21:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-08 15:24 [PATCH 0/9] [RFC v2] safely drop directory dentry on failed revalidate Miklos Szeredi
2013-08-08 15:24 ` [PATCH 1/9] vfs: check submounts and drop atomically Miklos Szeredi
2013-08-12 13:27   ` Jeff Layton
2013-08-08 15:24 ` [PATCH 2/9] vfs: check unlinked ancestors before mount Miklos Szeredi
2013-08-12 13:33   ` Jeff Layton
2013-08-08 15:24 ` [PATCH 3/9] afs: use check_submounts_and_drop() Miklos Szeredi
2013-08-08 15:24 ` [PATCH 4/9] gfs2: " Miklos Szeredi
2013-08-08 15:24 ` [PATCH 5/9] nfs: " Miklos Szeredi
2013-08-12 13:34   ` Jeff Layton
2013-08-08 15:24 ` [PATCH 6/9] sysfs: " Miklos Szeredi
2013-08-08 15:24 ` [PATCH 7/9] fuse: use d_materialise_unique() Miklos Szeredi
2013-08-08 15:24 ` [PATCH 8/9] fuse: clean up return in fuse_dentry_revalidate() Miklos Szeredi
2013-08-08 15:24 ` [PATCH 9/9] fuse: drop dentry on failed revalidate Miklos Szeredi
2013-08-21  5:40 ` [PATCH 0/9] [RFC v2] safely drop directory " Al Viro
2013-08-21 20:04   ` Ryusuke Konishi
2013-08-21 21:00     ` Al Viro [this message]
2013-08-21 23:47       ` Ryusuke Konishi
2013-08-29  3:51   ` Miklos Szeredi
2013-08-29 23:24     ` Ian Kent
2013-08-29 23:44       ` Ian Kent
2013-08-30  8:59         ` Miklos Szeredi
2013-09-01  0:56           ` Ian Kent
2013-09-01  1:00             ` Ian Kent

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=20130821210037.GO27005@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=avati@redhat.com \
    --cc=bfoster@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=eparis@redhat.com \
    --cc=konishi.ryusuke@lab.ntt.co.jp \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=mszeredi@suse.cz \
    --cc=raven@themaw.net \
    --cc=rwheeler@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.