autofs4 - fix get_next_positive_subdir()
Subsystems (2)
PATCH 1/1 autofs4 - fix get_next_positive_subdir()
From: Ian Kent <[email protected]>
The locking for the list traversal in get_next_positive_subdir() is wrong, so fix it.
---
fs/autofs4/expire.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
fs/autofs4/expire.c +6 -4
@@ -97,9 +97,9 @@ static struct dentry *get_next_positive_subdir(struct dentry *prev,struct dentry *p, *q;spin_lock (&sbi->lookup_lock); +spin_lock (&root->d_lock);if (prev ==NULL ) { -spin_lock (&root->d_lock); prev =dget_dlock (root); next = prev->d_subdirs.next; p = prev;
@@ -107,12 +107,13 @@ static struct dentry *get_next_positive_subdir(struct dentry *prev, } p = prev; -spin_lock (&p->d_lock); +spin_lock_nested (&p->d_lock,DENTRY_D_LOCK_NESTED ); again: next = p->d_u.d_child.next; start:if (next == &root->d_subdirs) {spin_unlock (&p->d_lock); +spin_unlock (&root->d_lock);spin_unlock (&sbi->lookup_lock);dput (prev);return NULL ;
@@ -121,8 +122,8 @@ start: q = list_entry(next, struct dentry, d_u.d_child);spin_lock_nested (&q->d_lock,DENTRY_D_LOCK_NESTED ); -/* Negative dentry - try next */ -if (!simple_positive (q)) { +/* Negative dentry or already gone - try next */ +if (q->d_count ==0 || !simple_positive (q)) {spin_unlock (&p->d_lock);lock_set_subclass (&q->d_lock.dep_map,0 , _RET_IP_); p = q;
@@ -131,6 +132,7 @@ start:dget_dlock (q);spin_unlock (&q->d_lock);spin_unlock (&p->d_lock); +spin_unlock (&root->d_lock);spin_unlock (&sbi->lookup_lock);dput (prev);
Quoted 3 lines · Ian Kent
The locking for the list traversal in
get_next_positive_subdir()is wrong, so fix it.
As an explanation, this kind of thing is totally useless. It doesn't actually give any information at all. It's like saying "change locking"
What happened, and why? Why is the new nested spinlock ok and won't deadlock against other nested users? Wazzup?
Linus
Quoted 8 lines · Linus Torvalds
Quoted 3 lines · Ian Kent
The locking for the list traversal in
get_next_positive_subdir()is wrong, so fix it.As an explanation, this kind of thing is totally useless. It doesn't actually give any information at all. It's like saying "change locking"
OK, I'll fix that and re-submit.
Ian
Quoted 11 lines · Linus Torvalds
Quoted 3 lines · Ian Kent
The locking for the list traversal in
get_next_positive_subdir()is wrong, so fix it.As an explanation, this kind of thing is totally useless. It doesn't actually give any information at all. It's like saying "change locking"
What happened, and why? Why is the new nested spinlock ok and won't deadlock against other nested users? Wazzup?
It's good that you questioned this Linus.
Looking again at dput() I think the traversal still isn't quite right.
For a start the test for d_count 0 or positive and hashed can never be true since the point of the change was to take the d_lock of the d_subdirs dentry for the traversal.
I'll need to work on this some more, thanks.
Ian
Quoted 10 lines · Ian Kent
Quoted 9 lines · Linus Torvalds
Quoted 3 lines · Ian Kent
The locking for the list traversal in
get_next_positive_subdir()is wrong, so fix it.As an explanation, this kind of thing is totally useless. It doesn't actually give any information at all. It's like saying "change locking"
Quoted 8 lines
Quoted 2 lines
What happened, and why? Why is the new nested spinlock ok and won't deadlock against other nested users? Wazzup?
It's good that you questioned this Linus.
Looking again at
dput()I think the traversal still isn't quite right.For a start the test for
d_count0 or positive and hashed can never be
Correction, that second check is actually !(positive and hashed) in the code.
Quoted 5 lines
true since the point of the change was to take the
d_lockof thed_subdirsdentry for the traversal.I'll need to work on this some more, thanks.
Ian
Quoted 14 lines · Ian Kent
Quoted 13 lines · Ian Kent
Quoted 11 lines · Linus Torvalds
Quoted 3 lines · Ian Kent
The locking for the list traversal in
get_next_positive_subdir()is wrong, so fix it.As an explanation, this kind of thing is totally useless. It doesn't actually give any information at all. It's like saying "change locking"
What happened, and why? Why is the new nested spinlock ok and won't deadlock against other nested users? Wazzup?
Quoted 11 lines
Quoted 5 lines
It's good that you questioned this Linus.
Looking again at
dput()I think the traversal still isn't quite right.For a start the test for
d_count0 or positive and hashed can never beCorrection, that second check is actually !(positive and hashed) in the code.
Quoted 2 lines
true since the point of the change was to take the
d_lockof thed_subdirsdentry for the traversal.
That's not right, ignore this.
Quoted 4 lines
Quoted 3 lines
I'll need to work on this some more, thanks.
Ian