From: David Howells <dhowells@redhat.com>
To: viro@ftp.linux.org.uk, jmoyer@redhat.com
Cc: linux-fs@vger.kernel.org, autofs@linux.kernel.org,
linux-kernel@vger.kernel.org, linux-afs@lists.infradead.org,
linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org,
Ian Kent <raven@themaw.net>, David Howells <dhowells@redhat.com>
Subject: [PATCH 16/17] autofs4 - add v4 pseudo direct mount support
Date: Thu, 30 Sep 2010 19:16:17 +0100 [thread overview]
Message-ID: <20100930181617.30939.37248.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20100930181455.30939.53914.stgit@warthog.procyon.org.uk>
From: Ian Kent <raven@themaw.net>
Version 4 of autofs provides a pseudo direct mount implementation
that relies on directories at the leaves of a directory tree under
an indirect mount to trigger mounts.
This patch adds support for that functionality.
Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/autofs4/root.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/fs/autofs4/root.c b/fs/autofs4/root.c
index 3b38794..135d713 100644
--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -629,6 +629,60 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)
return 0;
}
+/*
+ * Version 4 of autofs provides a pseudo direct mount implementation
+ * that relies on directories at the leaves of a directory tree under
+ * an indirect mount to trigger mounts. To allow for this we need to
+ * set the DMANAGED_AUTOMOUNT and DMANAGED_TRANSIT flags on the leaves
+ * of the directory tree. There is no need to clear the automount flag
+ * following a mount or restore it after an expire because these mounts
+ * are always covered. However, it is neccessary to ensure that these
+ * flags are clear on non-empty directories to avoid unnecessary calls
+ * during path walks.
+ */
+static void autofs_set_leaf_automount_flags(struct dentry *dentry)
+{
+ struct dentry *parent;
+
+ /* root and dentrys in the root are already handled */
+ if (IS_ROOT(dentry->d_parent))
+ return;
+
+ managed_dentry_set_managed(dentry);
+
+ parent = dentry->d_parent;
+ /* only consider parents below dentrys in the root */
+ if (IS_ROOT(parent->d_parent))
+ return;
+ managed_dentry_clear_managed(parent);
+ return;
+}
+
+static void autofs_clear_leaf_automount_flags(struct dentry *dentry)
+{
+ struct list_head *d_child;
+ struct dentry *parent;
+
+ /* flags for dentrys in the root are handled elsewhere */
+ if (IS_ROOT(dentry->d_parent))
+ return;
+
+ managed_dentry_clear_managed(dentry);
+
+ parent = dentry->d_parent;
+ /* only consider parents below dentrys in the root */
+ if (IS_ROOT(parent->d_parent))
+ return;
+ d_child = &dentry->d_u.d_child;
+ spin_lock(&dcache_lock);
+ /* Set parent managed if it's becoming empty */
+ if (d_child->next == &parent->d_subdirs &&
+ d_child->prev == &parent->d_subdirs)
+ managed_dentry_set_managed(parent);
+ spin_unlock(&dcache_lock);
+ return;
+}
+
static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry)
{
struct autofs_sb_info *sbi = autofs4_sbi(dir->i_sb);
@@ -652,6 +706,9 @@ static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry)
spin_unlock(&dentry->d_lock);
spin_unlock(&dcache_lock);
+ if (sbi->version < 5)
+ autofs_clear_leaf_automount_flags(dentry);
+
if (atomic_dec_and_test(&ino->count)) {
p_ino = autofs4_dentry_ino(dentry->d_parent);
if (p_ino && dentry->d_parent != dentry)
@@ -694,6 +751,9 @@ static int autofs4_dir_mkdir(struct inode *dir, struct dentry *dentry, int mode)
}
d_add(dentry, inode);
+ if (sbi->version < 5)
+ autofs_set_leaf_automount_flags(dentry);
+
dentry->d_fsdata = ino;
ino->dentry = dget(dentry);
atomic_inc(&ino->count);
next prev parent reply other threads:[~2010-09-30 18:16 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-30 18:14 [PATCH 00/17] Introduce automounter dentry ops David Howells
2010-09-30 18:15 ` [PATCH 01/17] Add a dentry op to handle automounting rather than abusing follow_link() David Howells
2010-09-30 18:15 ` [PATCH 02/17] AFS: Use d_automount() " David Howells
2010-09-30 18:15 ` [PATCH 03/17] NFS: " David Howells
2010-09-30 18:15 ` [PATCH 04/17] CIFS: " David Howells
2010-09-30 18:15 ` [PATCH 05/17] Remove the automount through follow_link() kludge code from pathwalk David Howells
2010-10-08 23:41 ` Valerie Aurora
2010-10-10 1:16 ` Ian Kent
2010-09-30 18:15 ` [PATCH 06/17] Add an AT_NO_AUTOMOUNT flag to suppress terminal automount David Howells
2010-10-01 8:55 ` Ian Kent
2010-09-30 18:15 ` [PATCH 07/17] Make dentry::d_mounted into a more general field for special function dirs David Howells
2010-10-08 23:57 ` Valerie Aurora
2010-09-30 18:15 ` [PATCH 08/17] Make follow_down() handle d_manage() David Howells
[not found] ` <20100930181536.30939.6776.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2010-10-09 0:28 ` Valerie Aurora
2010-09-30 18:15 ` [PATCH 09/17] autofs4: add d_automount() dentry operation David Howells
2010-09-30 18:15 ` [PATCH 10/17] autofs4: add d_manage() " David Howells
2010-09-30 18:15 ` [PATCH 11/17] autofs4: removed unused code David Howells
2010-09-30 18:15 ` [PATCH 12/17] autofs4: cleanup inode operations David Howells
2010-09-30 18:16 ` [PATCH 13/17] autofs4: cleanup dentry operations David Howells
2010-09-30 18:16 ` [PATCH 14/17] autofs4: cleanup autofs4_free_ino() David Howells
2010-09-30 18:16 ` [PATCH 15/17] autofs4 - fix wait validation David Howells
2010-09-30 18:16 ` David Howells [this message]
2010-09-30 18:16 ` [PATCH 17/17] autofs4 - bump version 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=20100930181617.30939.37248.stgit@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=autofs@linux.kernel.org \
--cc=jmoyer@redhat.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=raven@themaw.net \
--cc=viro@ftp.linux.org.uk \
/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).