Skip to contentSkip to conversation

clean-up patch for autofs4

PATCH New NeilBrown 1 participant 6 messages Jul 18, 2014 Kernel automounter

lore
Share & tools
lore

NeilBrown

author
#0 lore raw

cover clean-up patch for autofs4

Hi Andrew,
I believe you shepherd autofs4 patches at present. The following 5 patches are some simple cleanups.
4 are trivial. One (the third) is a very simple optimization which will be more important after the next patch set, but is simple enough to be included now.

The next patch set will make autofs4 RCU-walk friendly so that in the common case a filename lookup can walk across an autofs4 filesystem without taking spinlocks or refcounts. I'll submit that once more testing and review have convinced Ian and myself that it is ready.

Thanks,
NeilBrown

---

NeilBrown (5):
autofs4: remove unused autofs4_ispending()
autofs4: remove a redundant assignment
autofs4: don't take spinlock when not needed in autofs4_lookup_expiring
autofs4: remove some unused inline functions.
autofs4: comment typo: remove a a doubled word.

 fs/autofs4/autofs_i.h |   63 -------------------------------------------------
 fs/autofs4/expire.c   |    1 -
 fs/autofs4/root.c     |   10 +++++---
 3 files changed, 7 insertions(+), 67 deletions(-)
Signature · 1 line
Signature
author
#1 lore raw

PATCH 1/5 autofs4: remove unused autofs4_ispending()

---
 fs/autofs4/autofs_i.h |   14 --------------
 1 file changed, 14 deletions(-)
fs/autofs4/autofs_i.h +0 -14
index acf32054edd8..22a280151e45 100644
@@ -143,20 +143,6 @@ static inline int autofs4_oz_mode(struct autofs_sb_info *sbi) {
 	return sbi->catatonic || task_pgrp(current) == sbi->oz_pgrp;
 }
 
-/* Does a dentry have some pending activity? */
-static inline int autofs4_ispending(struct dentry *dentry)
-{
-	struct autofs_info *inf = autofs4_dentry_ino(dentry);
-
-	if (inf->flags & AUTOFS_INF_PENDING)
-		return 1;
-
-	if (inf->flags & AUTOFS_INF_EXPIRING)
-		return 1;
-
-	return 0;
-}
-
 struct inode *autofs4_get_inode(struct super_block *, umode_t);
 void autofs4_free_ino(struct autofs_info *);
 
author
#2 lore raw

PATCH 2/5 autofs4: remove a redundant assignment

In reply to NeilBrown

The variable 'ino' already exists and already has the correct value. The d_fsdata of a dentry is never changed after the d_fsdata is instantiated, so this new assignment cannot be necessary.

It was introduced in
commit b5b801779d59165c4ecf1009009109545bd1f642
autofs4: Add d_manage() dentry operation

---
 fs/autofs4/expire.c |    1 -
 1 file changed, 1 deletion(-)
fs/autofs4/expire.c +0 -1
index 394e90b02c5e..a7be57e39be7 100644
@@ -333,7 +333,6 @@ struct dentry *autofs4_expire_direct(struct super_block *sb,
 	if (ino->flags & AUTOFS_INF_PENDING)
 		goto out;
 	if (!autofs4_direct_busy(mnt, root, timeout, do_now)) {
-		struct autofs_info *ino = autofs4_dentry_ino(root);
 		ino->flags |= AUTOFS_INF_EXPIRING;
 		init_completion(&ino->expire_complete);
 		spin_unlock(&sbi->fs_lock);
author
#3 lore raw

PATCH 3/5 autofs4: don't take spinlock when not needed in autofs4_lookup_expiring

In reply to NeilBrown

If the expiring_list is empty, we can avoid a costly spinlock in the rcu-walk path through autofs4_d_manage (once the rest of the path becomes rcu-walk friendly).

---
 fs/autofs4/root.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
fs/autofs4/root.c +6 -2
index cc87c1abac97..fb202cadd4b3 100644
@@ -166,8 +166,10 @@ static struct dentry *autofs4_lookup_active(struct dentry *dentry)
 	const unsigned char *str = name->name;
 	struct list_head *p, *head;
 
-	spin_lock(&sbi->lookup_lock);
 	head = &sbi->active_list;
+	if (list_empty(head))
+		return NULL;
+	spin_lock(&sbi->lookup_lock);
 	list_for_each(p, head) {
 		struct autofs_info *ino;
 		struct dentry *active;
@@ -218,8 +220,10 @@ static struct dentry *autofs4_lookup_expiring(struct dentry *dentry)
 	const unsigned char *str = name->name;
 	struct list_head *p, *head;
 
-	spin_lock(&sbi->lookup_lock);
 	head = &sbi->expiring_list;
+	if (list_empty(head))
+		return NULL;
+	spin_lock(&sbi->lookup_lock);
 	list_for_each(p, head) {
 		struct autofs_info *ino;
 		struct dentry *expiring;
author
#4 lore raw

PATCH 4/5 autofs4: remove some unused inline functions.

In reply to NeilBrown

{__,}manage_dentry_{set,clear}_{automount,transit}

are 4 unused inline functions. Discard them.

---
 fs/autofs4/autofs_i.h |   49 -------------------------------------------------
 1 file changed, 49 deletions(-)
fs/autofs4/autofs_i.h +0 -49
index 22a280151e45..9e359fb20c0a 100644
@@ -177,55 +177,6 @@ extern const struct file_operations autofs4_root_operations;
 extern const struct dentry_operations autofs4_dentry_operations;
 
 /* VFS automount flags management functions */
-
-static inline void __managed_dentry_set_automount(struct dentry *dentry)
-{
-	dentry->d_flags |= DCACHE_NEED_AUTOMOUNT;
-}
-
-static inline void managed_dentry_set_automount(struct dentry *dentry)
-{
-	spin_lock(&dentry->d_lock);
-	__managed_dentry_set_automount(dentry);
-	spin_unlock(&dentry->d_lock);
-}
-
-static inline void __managed_dentry_clear_automount(struct dentry *dentry)
-{
-	dentry->d_flags &= ~DCACHE_NEED_AUTOMOUNT;
-}
-
-static inline void managed_dentry_clear_automount(struct dentry *dentry)
-{
-	spin_lock(&dentry->d_lock);
-	__managed_dentry_clear_automount(dentry);
-	spin_unlock(&dentry->d_lock);
-}
-
-static inline void __managed_dentry_set_transit(struct dentry *dentry)
-{
-	dentry->d_flags |= DCACHE_MANAGE_TRANSIT;
-}
-
-static inline void managed_dentry_set_transit(struct dentry *dentry)
-{
-	spin_lock(&dentry->d_lock);
-	__managed_dentry_set_transit(dentry);
-	spin_unlock(&dentry->d_lock);
-}
-
-static inline void __managed_dentry_clear_transit(struct dentry *dentry)
-{
-	dentry->d_flags &= ~DCACHE_MANAGE_TRANSIT;
-}
-
-static inline void managed_dentry_clear_transit(struct dentry *dentry)
-{
-	spin_lock(&dentry->d_lock);
-	__managed_dentry_clear_transit(dentry);
-	spin_unlock(&dentry->d_lock);
-}
-
 static inline void __managed_dentry_set_managed(struct dentry *dentry)
 {
 	dentry->d_flags |= (DCACHE_NEED_AUTOMOUNT|DCACHE_MANAGE_TRANSIT);
author
#5 lore raw

PATCH 5/5 autofs4: comment typo: remove a a doubled word.

In reply to NeilBrown
---
 fs/autofs4/root.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/autofs4/root.c +1 -1
index fb202cadd4b3..cdb25ebccc4c 100644
@@ -377,7 +377,7 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
 		 * this because the leaves of the directory tree under the
 		 * mount never trigger mounts themselves (they have an autofs
 		 * trigger mount mounted on them). But v4 pseudo direct mounts
-		 * do need the leaves to to trigger mounts. In this case we
+		 * do need the leaves to trigger mounts. In this case we
 		 * have no choice but to use the list_empty() check and
 		 * require user space behave.
 		 */