autofs_clear_leaf_automount_flags(): use ino->count instead of ->d_subdirs
We want to find out if the parent will become empty after we remove the victim of rmdir(). Checking if the victim is the only element of parent's ->d_subdirs is completely wrong - e.g. opening the parent will end up with a cursor added to its ->d_parent and fooling the check. We do maintain ino->count - 0 for anything removed, 1 + number of children for anything live. Which gives us precisely what we need for that check... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
5f68056ca5
commit
e509d6e9c1
@ -660,7 +660,6 @@ static void autofs_set_leaf_automount_flags(struct dentry *dentry)
|
|||||||
|
|
||||||
static void autofs_clear_leaf_automount_flags(struct dentry *dentry)
|
static void autofs_clear_leaf_automount_flags(struct dentry *dentry)
|
||||||
{
|
{
|
||||||
struct list_head *d_child;
|
|
||||||
struct dentry *parent;
|
struct dentry *parent;
|
||||||
|
|
||||||
/* flags for dentrys in the root are handled elsewhere */
|
/* flags for dentrys in the root are handled elsewhere */
|
||||||
@ -673,10 +672,7 @@ static void autofs_clear_leaf_automount_flags(struct dentry *dentry)
|
|||||||
/* only consider parents below dentrys in the root */
|
/* only consider parents below dentrys in the root */
|
||||||
if (IS_ROOT(parent->d_parent))
|
if (IS_ROOT(parent->d_parent))
|
||||||
return;
|
return;
|
||||||
d_child = &dentry->d_child;
|
if (atomic_read(&autofs_dentry_ino(parent)->count) == 2)
|
||||||
/* 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);
|
managed_dentry_set_managed(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user