Skip to content

Commit

Permalink
autofs4: don't take spinlock when not needed in autofs4_lookup_expiring
Browse files Browse the repository at this point in the history
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).

Signed-off-by: NeilBrown <neilb@suse.de>
Reviewed-by: Ian Kent <raven@themaw.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
NeilBrown authored and Linus Torvalds committed Aug 8, 2014
1 parent c312442 commit 668128e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fs/autofs4/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 668128e

Please sign in to comment.